Skip to content

Commit 9bb8126

Browse files
rkistnersimolus3
authored andcommitted
Clear pendingValidatedCheckpoint on new checkpoints.
1 parent ab33799 commit 9bb8126

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

packages/common/src/client/sync/stream/AbstractStreamingSyncImplementation.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -716,6 +716,8 @@ The next upload iteration will be delayed.`);
716716

717717
if (isStreamingSyncCheckpoint(line)) {
718718
targetCheckpoint = line.checkpoint;
719+
// New checkpoint - existing validated checkpoint is no longer valid
720+
pendingValidatedCheckpoint = null;
719721
const bucketsToDelete = new Set<string>(bucketMap.keys());
720722
const newBuckets = new Map<string, BucketDescription>();
721723
for (const checksum of line.checkpoint.buckets) {
@@ -737,7 +739,13 @@ The next upload iteration will be delayed.`);
737739
if (result.endIteration) {
738740
return;
739741
} else if (!result.applied) {
742+
// "Could not apply checkpoint due to local data". We need to retry after
743+
// finishing uploads.
740744
pendingValidatedCheckpoint = targetCheckpoint;
745+
} else {
746+
// Nothing to retry later. This would likely already be null from the last
747+
// checksum or checksum_diff operation, but we make sure.
748+
pendingValidatedCheckpoint = null;
741749
}
742750
} else if (isStreamingSyncCheckpointPartiallyComplete(line)) {
743751
const priority = line.partial_checkpoint_complete.priority;
@@ -773,6 +781,8 @@ The next upload iteration will be delayed.`);
773781
if (targetCheckpoint == null) {
774782
throw new Error('Checkpoint diff without previous checkpoint');
775783
}
784+
// New checkpoint - existing validated checkpoint is no longer valid
785+
pendingValidatedCheckpoint = null;
776786
const diff = line.checkpoint_diff;
777787
const newBuckets = new Map<string, BucketChecksum>();
778788
for (const checksum of targetCheckpoint.buckets) {

0 commit comments

Comments
 (0)