Technology

Engineering record

Records and dataIn use

Late delete requests and new files with the same name

We deleted a file and uploaded another under the same name, and the first delete request may only be arriving now. The name alone can't tell us which file it meant to delete.

To the user it may be the same photo, but the file that existed before the deletion and the file uploaded afterward are different files. If both use the same name and storage location, though, a late delete request can remove the new one. Would ordering requests better by arrival fix it? On a network, a request sent first can arrive last. What matters isn't the order of arrival but that what a request points to is unambiguous.

So we separated the file name the app uses from the actual storage location. A storage location is created fresh for each upload and used only once. The name the app looks up may be the same, but the file actually stored is different with every upload. An upload that finishes late becomes the current file only if the database version matches.

There was also a path that checked all of an account's files just to get the address of one. We needed a single file and looked at every one. Once what points to the current file is clear, there's no reason to search through everything.

We tested concurrent uploads, lost responses, forced kills of the server process and files up to 8 MiB on a local database and storage, then applied the change to production. We didn't use the real production storage for the tests. While we switch over, the old and new files briefly exist side by side, so it also uses more space. That's the price of creating a new file instead of overwriting.

Written from that day’s point of view, using the documents and change history of the time. Published 2026.12.01.