PR writeup
Version numbers that never repeat
Deleting the latest version used to free its number, so the next upload reused it and old ?v=N links pointed at new content. This change makes version numbers permanent.
The bug, step by step
Step
Before
After
Upload
v1, v2, v3
v1, v2, v3 · seq = 3
Delete v3
latest = 2
latest = 2 · seq = 3
Upload
new body saved as v3
new body saved as v4
Open old ?v=3 link
shows the wrong page
404, as it should
What changed
A counter that only goes up
A newversion_seq column records the highest number ever minted. Deletes never touch it.Reserve before writing
An upload claimsseq + 1 with a compare-and-set before storing the body. The loser of a race gets 409 version_conflict.-- reserve the next number atomically
UPDATE drops SET version_seq = ?
WHERE slug = ? AND user_id = ? AND version_seq = ?;
Risk
| Concern | Answer |
|---|---|
| Gaps in numbering | Expected and harmless; clients already read latest_version. |
| Existing drops | Migration backfills version_seq from latest_version. |
| Version cap | Now counts minted numbers, so deleting no longer buys headroom. |