But how can I simulate an unlink without actually deleting the file?
Could you rename the file to be deleted, then perform the DB transaction and finally only delete the file once the DB transaction is completed? If the transaction fails or rolls back, you rename the file back.
And what to do if the storage filesystem (SAN) or database server goes haywire in the middle of the transaction and drops out?
If you get a major failure of this type, you would need some kind of integrity check that scans the DB looking to match the filenames and if one is not found, it looks for the renamed version and restores (renames) it to match the DB. This would be run as part of the DB startup/recovery procedure.
In reply to Re: Atomic use of unlink() and SQL DELETE? How?
by BrowserUk
in thread Atomic use of unlink() and SQL DELETE? How?
by robins
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |