Skip to content

Commit

Permalink
fix(swing-store): Delete transcript spans in stopUsingTranscript as i…
Browse files Browse the repository at this point in the history
…n rollover

Fixes #10054
  • Loading branch information
gibson042 committed Sep 11, 2024
1 parent 5eb08e2 commit 2d1e478
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
21 changes: 11 additions & 10 deletions packages/swing-store/src/transcriptStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -277,12 +277,22 @@ export function makeTranscriptStore(

// and change its DB row to isCurrent=null
sqlEndCurrentSpan.run(vatID);

if (!keepTranscripts) {
// Delete items of the previously-current span.
// There may still be items associated with even older spans, but we leave
// those, to avoid excessive DB churn (for details, see #9387 and #9174).
// Recovery of space claimed by such ancient items is expected to use an
// external mechanism such as restoration from an operational snapshot
// that doesn't include them.
sqlDeleteOldItems.run(vatID, startPos, endPos);
}
}

function doSpanRollover(vatID, isNewIncarnation) {
ensureTxn();
const bounds = getCurrentSpanBounds(vatID);
const { startPos, endPos, incarnation } = bounds;
const { endPos, incarnation } = bounds;

// deal with the now-old span
closeSpan(vatID, bounds);
Expand All @@ -302,15 +312,6 @@ export function makeTranscriptStore(
);
noteExport(spanMetadataKey(rec), JSON.stringify(rec));

if (!keepTranscripts) {
// Delete items of the previously-current span.
// There may still be items associated with even older spans, but we leave
// those, to avoid excessive DB churn (for details, see #9387 and #9174).
// Recovery of space claimed by such ancient items is expected to use an
// external mechanism such as restoration from an operational snapshot
// that doesn't include them.
sqlDeleteOldItems.run(vatID, startPos, endPos);
}
return newSpanIncarnation;
}

Expand Down
2 changes: 1 addition & 1 deletion packages/swing-store/test/deletion.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ const testSlowTranscriptDeletion = test.macro({
exec: execSlowTranscriptDeletion,
});
test(testSlowTranscriptDeletion, { keepTranscripts: true });
test.failing(testSlowTranscriptDeletion, { keepTranscripts: false });
test(testSlowTranscriptDeletion, { keepTranscripts: false });

test('slow deletion without stopUsingTranscript', async t => {
// slow deletion should work even without stopUsingTranscript
Expand Down

0 comments on commit 2d1e478

Please sign in to comment.