Returned batches drop their saved compile and merged files
Only a merge uses them and a returned batch never merges; verification returns left them behind (32 GB of saved checks, 9.5 GB of results on the live database). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
22b5975ffc
commit
e45711aa74
1 changed files with 10 additions and 2 deletions
|
|
@ -21,10 +21,17 @@ export function returnBatch(store, batchId, reason) {
|
|||
);
|
||||
}
|
||||
store.run(`UPDATE batches SET state = 'returned', result_json = json_set(COALESCE(result_json, '{}'), '$.returned', ?) WHERE id = ?`, reason, batchId);
|
||||
store.run('DELETE FROM batch_checks WHERE batch_id = ?', batchId);
|
||||
dropMergeData(store, batchId);
|
||||
store.event('batch_returned', b.user_id, { batch: batchId, reason });
|
||||
}
|
||||
|
||||
// What only a merge needs (the verification's compile, the merged files): a returned batch never
|
||||
// merges, and with a header change it can be hundreds of megabytes.
|
||||
export function dropMergeData(store, batchId) {
|
||||
store.run('DELETE FROM batch_checks WHERE batch_id = ?', batchId);
|
||||
store.run(`UPDATE batches SET result_json = json_remove(result_json, '$.check', '$.mergedFiles') WHERE id = ? AND json_valid(result_json)`, batchId);
|
||||
}
|
||||
|
||||
// Attempts still on their way to main; the others were sent back or rejected.
|
||||
export const LIVE_STATES = ['queued', 'verifying', 'peer_review', 'in_review', 'approved', 'merging'];
|
||||
|
||||
|
|
@ -33,7 +40,8 @@ export function settleBatch(store, batchId, reason) {
|
|||
if (!batchId) return;
|
||||
const ph = LIVE_STATES.map(() => '?').join(',');
|
||||
if (store.get(`SELECT 1 FROM attempts WHERE batch_id = ? AND state IN (${ph})`, batchId, ...LIVE_STATES)) return;
|
||||
store.run(`UPDATE batches SET state = 'returned', result_json = json_set(COALESCE(result_json, '{}'), '$.returned', ?) WHERE id = ? AND state = 'open'`, reason, batchId);
|
||||
const r = store.run(`UPDATE batches SET state = 'returned', result_json = json_set(COALESCE(result_json, '{}'), '$.returned', ?) WHERE id = ? AND state = 'open'`, reason, batchId);
|
||||
if (r.changes) dropMergeData(store, batchId);
|
||||
}
|
||||
|
||||
/** Attempts of a batch with their task's symbol. */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue