Prevented deletion of one or more files that are still in use.

0
Hi Experts,I’m encountering the following error in my application logs:CRITICAL - Core: Prevented deletion of one or more files that are still in use. Please contact Mendix Support to prevent this from happening in the future. (UUIDs: [long list of IDs])Somebody contacted Mendix Support earlier mentioned in this thread and they suggested two possible approaches to resolve the issue:Delete the problematic records from System.FileDocument (for the UUIDs mentioned in the log), for example by retrieving them in a microflow and removing them. This deletion remove the unreferenced files as well. Delete the corresponding records from the system$unreferencedfile table directly in the database (after taking a full backup).Since I still need the FileDocument records, I am considering the second option (cleaning the system$unreferencedfiletable from the database).Has anyone tried this approach before?Did deleting the entries from system$unreferencedfile resolve the issue without causing side effects?Any experiences or recommendations would be appreciated.Thanks in advance.
asked
1 answers
1

Hi,


This message usually appears when the Mendix runtime cleanup task tries to delete a physical file that is still referenced somewhere in the application. Internally Mendix keeps track of files through two things:

  • System.FileDocument → the actual file entity
  • system$unreferencedfile → temporary entries created when a file becomes orphaned

During the cleanup process the runtime attempts to remove files listed in system$unreferencedfile. If Mendix detects that the file is still referenced or locked, it logs the error you are seeing:

Prevented deletion of one or more files that are still in use

So the problem is usually inconsistent metadata between the file reference and the cleanup table, not the file itself.

Regarding the two options mentioned:

Deleting System.FileDocument

This should only be done if those files are truly no longer needed. Since you mentioned you still need those documents, this is not the right approach.

Cleaning system$unreferencedfile

Yes, this is actually the safer fix in situations like this. That table only contains temporary cleanup records used by the runtime. Removing rows from system$unreferencedfile does not delete the actual files or the System.FileDocument entries.

The usual approach is:

  1. Take a full database backup.
  2. Delete the problematic entries from:
system$unreferencedfile

  1. Restart the Mendix runtime.

After that the cleanup process runs normally again and the error disappears.

Why this happens

This situation typically occurs when:

  • A file was deleted or replaced during a transaction that failed
  • A custom microflow manipulated FileDocument objects
  • A deployment restart happened during file cleanup
  • Files were created or removed through external integrations

In those cases the cleanup table keeps stale entries.

Recommendation

Your plan (option 2) is correct:

  • Backup DB
  • Clean the entries from system$unreferencedfile
  • Restart the application

This resolves the issue in most environments and does not affect existing FileDocument records or stored files.

If the issue keeps appearing frequently, it is worth checking custom file handling logic or integrations that might be creating inconsistent file references.


answered