The merger keeps its place over a restart (worker_cursors), not from 1970 each deploy
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
46525f4595
commit
e627862a8d
3 files changed
+46
-1
No files matched your search
@@ -65,6 +65,19 @@ test.group('Par2Merger', (group) => {
|
||||
assert.deepEqual(await new Par2Merger().round().then((r) => r.merges), 0)
|
||||
})
|
||||
|
||||
test('a restart goes on from the last whole round, kept in worker_cursors', async ({ assert }) => {
|
||||
const hourAgo = new Date(Date.now() - 3600_000)
|
||||
await db.table('par2_sets').insert({ set_id: 'f'.repeat(32), release_id: 1, files: 2, created_at: hourAgo })
|
||||
// Never run: everything.
|
||||
assert.equal((await new Par2Merger().round()).sets, 1)
|
||||
const saved = await db.from('worker_cursors').where('name', 'merger').firstOrFail()
|
||||
assert.isAbove(new Date(saved.at).getTime(), hourAgo.getTime())
|
||||
// A new process (a deploy) reads where the last round started: the set an hour old is behind it.
|
||||
assert.equal((await new Par2Merger().round()).sets, 0)
|
||||
await db.from('worker_cursors').where('name', 'merger').update({ at: new Date(hourAgo.getTime() - 60_000) })
|
||||
assert.equal((await new Par2Merger().round()).sets, 1)
|
||||
})
|
||||
|
||||
test('a set held by two of the releases merged is held once by the target', async ({ assert }) => {
|
||||
const at = new Date('2022-07-08T03:46:00Z')
|
||||
const ids: number[] = []
|
||||
|
||||
Reference in new issue
Block a user