You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
In some circumstances files can be created in the database pointing to a non-existent entity, this can happen because its possible to delete an entity while the file is still being processed, an entity deletion also deletes its files, but at the same time we have the file still in memory and being processed, when the processing ends we save the already deleted file again using upsert instead of update.
To Reproduce
Steps to reproduce the behavior:
Start a blank state Uwazi
Create an entity by uploading a PDF
Delete the entity before the file processing ends (you can achieve this by uploading a big pdf or by explicitly hard coding a time out)
Look at the DB files collection, you should see the file there but not the entity.
Expected behavior
File exists because we use upsert instead of explicit update, a file should not be updated if the file itself does not exists on the db anymore.
Additional context
This issue can produce different scenarios depending on where in the processing process the entity is deleted
Delete entity before the file is saved to the db with processing status
This produces 2 files without entity (document and thumbnail) but NO missing in storage situation (file exists in the DB but not in storage)
Delete after file has been set to processing but before the actual processing starts
This produces 2 files without entity (document and thumbnail) and the pdf will be missing in storage (file exists in the DB but not in storage) but not the thumbnail
There are more scenarios with different outputs, but everything points to the same root cause, deleting a file via deleting its entity while the docuement processing is not yet finished
The text was updated successfully, but these errors were encountered:
daneryl
changed the title
Entity creation flow can produce orphan files (files pointing to non-existent entities)
Entity creation flow can produce orphan files (files pointing to non-existent entities) and db files without the S3 file
Dec 3, 2024
Describe the bug
In some circumstances files can be created in the database pointing to a non-existent entity, this can happen because its possible to delete an entity while the file is still being processed, an entity deletion also deletes its files, but at the same time we have the file still in memory and being processed, when the processing ends we save the already deleted file again using upsert instead of update.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
File exists because we use upsert instead of explicit update, a file should not be updated if the file itself does not exists on the db anymore.
Additional context
This issue can produce different scenarios depending on where in the processing process the entity is deleted
Delete entity before the file is saved to the db with processing status
This produces 2 files without entity (document and thumbnail) but NO missing in storage situation (file exists in the DB but not in storage)
Delete after file has been set to processing but before the actual processing starts
This produces 2 files without entity (document and thumbnail) and the pdf will be missing in storage (file exists in the DB but not in storage) but not the thumbnail
There are more scenarios with different outputs, but everything points to the same root cause, deleting a file via deleting its entity while the docuement processing is not yet finished
The text was updated successfully, but these errors were encountered: