The par2 prune's cursor is (created_at to the microsecond, set_id): 20k sets of one flush share a created_at
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
f2c5607ec3
commit
a5e0399ee6
3 files changed
+54
-8
No files matched your search
@@ -68,4 +68,26 @@ test.group('Par2Pruner', (group) => {
|
||||
// Again: the cursor is past them, nothing more.
|
||||
assert.deepEqual(await new Par2Pruner().round(), { complete: 0, judged: 0, rows: 0 })
|
||||
})
|
||||
|
||||
test('more sets of one created_at than a batch holds: each batch goes on past the last one', async ({ assert }) => {
|
||||
// One prober flush gives thousands of sets the same created_at (to the microsecond).
|
||||
const flush = new Date('2026-10-15T14:38:39.883Z')
|
||||
let candidate = 7000
|
||||
for (const letter of ['p', 'q', 'r']) {
|
||||
const key = `pr${letter}`.padEnd(40, '0')
|
||||
const [row] = await db.table('releases').insert({ release_key: key, identity_key: key, name: key, source: 'stem', groups: '[]', group_id: 1, files: 1, readable: false }).returning('id')
|
||||
const id = Number(row.id)
|
||||
const setId = letter.repeat(32)
|
||||
const h = `${letter}0`.padEnd(32, '0')
|
||||
await db.table('par2_files').insert({ set_id: setId, file_id: h, hash16k: h, length: 1000, name: 'f.rar' })
|
||||
candidate++
|
||||
await db.table('probe_candidates').insert({ id: candidate, release_id: id, kind: 'lone', message_id: `<${candidate}@x>`, file: 'x', status: 'done' })
|
||||
await db.table('file_hashes').insert({ candidate_id: candidate, release_id: id, hash16k: h, size: 1000 })
|
||||
await db.rawQuery(`INSERT INTO par2_sets (set_id, release_id, files, created_at) VALUES (?, ?, 1, ?::timestamptz + interval '984 microseconds')`, [setId, id, flush])
|
||||
}
|
||||
const round = await new Par2Pruner(1).round()
|
||||
assert.equal(round.complete, 3)
|
||||
assert.equal((await db.from('par2_files').whereIn('set_id', ['p'.repeat(32), 'q'.repeat(32), 'r'.repeat(32)]).count('* as n'))[0].n, '0')
|
||||
assert.equal((await db.from('worker_cursors').where('name', 'par2-prune').firstOrFail()).key, 'r'.repeat(32))
|
||||
})
|
||||
})
|
||||
Reference in new issue
Block a user