<-- Back

Error: Uploading File Failed when Uploading Concurrent Small Files

Issue

Occasionally, errors (e.g., console log errors, user-facing messages) happen when uploading multiple small files concurrently using the Mendix File Uploader widget. This issue is intermittent but tends to occur more frequently when uploading several very small files, especially during the first upload attempt after a Mendix server restart. The errors often manifest as unique constraint violations.

Environment

File Uploader (all versions)

Cause

The root cause is a race condition where multiple concurrent file upload requests attempt to auto-commit the same UploadFileContext object simultaneously. This leads to a unique constraint violation when the database tries to process these conflicting commit operations, resulting in the observed errors. The current application modeling, specifically the nanoflow responsible for creating the file object, often lacks an explicit commit activity for the file object, relying instead on auto-commit behavior, which is susceptible to this race condition.

Solution / Workaround

To prevent the race condition and resolve the unique constraint violation, explicitly commit the file object within the nanoflow that creates it.

  1. Locate the File Creation Nanoflow: Identify the nanoflow responsible for creating the file object associated with your File Uploader widget (e.g., ACT_CreateUploadedFile)

  2. Add an Explicit Commit Activity: Within this nanoflow, ensure there is an explicit Commit object(s) activity that commits the newly created file object (or the UploadFileContext object, if applicable) before the nanoflow completes. This action forces the commit to happen in a controlled manner, preventing concurrent auto-commit attempts. Example: 

If the nanoflow creates an UploadedFile object, add a Commit object(s) activity for that UploadedFile object. Committing the UploadedFile object will also auto-commit its associated UploadFileContext.
 

This explicit commit ensures proper synchronization and prevents the unique constraint violation.

For detailed guidance on configuring the File Uploader widget and associated logic, please refer to the official Mendix documentation

Internal information related

  • 260846
  • CJZ85RLTA/p1758889359229529
  • UFC-1782

Additional information

Have more questions? Submit a request

0 Comments

Article is closed for comments.

To provide feedback, please open a ticket here. Don't forget to include the article's URL along with the feedback you would like to provide.