Atlassian uses cookies to improve your browsing experience, perform analytics and research, and conduct advertising. Accept all cookies to indicate that you agree to our use of cookies on your device. Atlassian cookies and tracking notice, (opens new window)
iDempiere JIRA
NON-DB attachments are disappearing when a DB deletion fails
Description
Test case:
log in as System
create a storage provider for file system
migrate GardenWorld attachments to the file system storage provider
log in as GardenAdmin
Open Business Partner C&W
Attach a file
Try to delete the Business Partner - it will fail with error “Record not deleted - there are dependent records in the table Accounting Fact for the column Business Partner”
DATA CORRUPTION ERROR: The attachment is gone
The same happens with Archives associated to the record
NOTE: Not tested, but the same must be happening with other attachment plugins, like Alfresco from @Dirk Niemeyer or S3 from @Murilo Habermann Torquato
I think the solution could be to postpone the deletion of AD_Attachment and AD_Archive until after the transaction is committed, maybe as an Trx afterCommit EventListener - but not sure if that's the best idea - or if somebody can suggest something better
Carlos Ruiz
May 18, 2024 at 11:59 AM
Two workarounds to avoid the files from being deleted can be:
migrate to Database storage provider while moving to production a solution for this ticket
The problem obviously is that the database size and backups will be increased heavily
Change the Constraint Type to Do Not Create - Ignore for the columns:
AD_Attachment.Record_ID
AD_Attachment.Record_UU
AD_Archive.Record_ID
AD_Archive.Record_UU
The problem here is that you’ll end up with orphan records in AD_Attachment and AD_Archive, as well as orphan files in the file system that would require a different process for cleanup
Test case:
log in as System
create a storage provider for file system
migrate GardenWorld attachments to the file system storage provider
log in as GardenAdmin
Open Business Partner C&W
Attach a file
Try to delete the Business Partner - it will fail with error “Record not deleted - there are dependent records in the table Accounting Fact for the column Business Partner”
DATA CORRUPTION ERROR: The attachment is gone
The same happens with Archives associated to the record
NOTE: Not tested, but the same must be happening with other attachment plugins, like Alfresco from @Dirk Niemeyer or S3 from @Murilo Habermann Torquato