Rebuild: a release key taken by another group's writer gets the next number
Writers lock their group only, so two groups' batches can number the same identity key at once (a spam post crossposted to 67 groups: duplicate key ...:65, HTTP 500, the batch retried). Releases are now inserted with ON CONFLICT (release_key) DO NOTHING, and those skipped take the next number (up to 20 tries). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
b87203e41a
commit
27a26c9614
2 files changed
+38
-13
No files matched your search
@@ -127,4 +127,15 @@ test.group('BatchStore', (group) => {
|
||||
assert.lengthOf(rows, 2)
|
||||
assert.equal(rows[0].identity_key, rows[1].identity_key)
|
||||
})
|
||||
|
||||
test('a release key taken meanwhile by another group\'s writer is skipped for the next number', async ({ assert }) => {
|
||||
await storeIn(GROUP, 1, upload(10, 'Some.Show.S01E01.1080p.mkv', 2, 'Some.Show.S01E01.1080p [1/1]', '2026-10-05T10:00:00Z'))
|
||||
const [first] = await releasesOf()
|
||||
// As if another group's batch numbered the key at the same moment: key:2 exists, not counted for this key.
|
||||
const [g] = await db.table('groups').insert({ name: 'alt.binaries.third', priority: 3 }).returning('id')
|
||||
await db.table('releases').insert({ release_key: `${first.identity_key}:2`, identity_key: 'someone-else', group_id: g.id, name: 'x', source: 'subject', poster: 'p', groups: JSON.stringify([]), files: 0, segments: 0, bytes: 0, chunks: 0 })
|
||||
await storeIn('alt.binaries.other', 1, upload(10, 'Some.Show.S01E01.1080p.mkv', 2, 'Some.Show.S01E01.1080p [1/1]', '2026-10-05T10:01:00Z', 'alt.binaries.other'))
|
||||
const keys = (await releasesOf()).filter((r) => r.identity_key === first.identity_key).map((r) => r.release_key)
|
||||
assert.deepEqual(keys, [first.identity_key, `${first.identity_key}:3`])
|
||||
})
|
||||
})
|
||||
Reference in new issue
Block a user