Skip to content

Commit b519608

Browse files
committed
Clear pendingValidatedCheckpoint on new checkpoints.
1 parent 9fb898d commit b519608

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
@@ -708,6 +708,8 @@ The next upload iteration will be delayed.`);
708708

709709
if (isStreamingSyncCheckpoint(line)) {
710710
targetCheckpoint = line.checkpoint;
711+
// New checkpoint - existing validated checkpoint is no longer valid
712+
pendingValidatedCheckpoint = null;
711713
const bucketsToDelete = new Set<string>(bucketMap.keys());
712714
const newBuckets = new Map<string, BucketDescription>();
713715
for (const checksum of line.checkpoint.buckets) {
@@ -729,7 +731,13 @@ The next upload iteration will be delayed.`);
729731
if (result.endIteration) {
730732
return;
731733
} else if (!result.applied) {
734+
// "Could not apply checkpoint due to local data". We need to retry after
735+
// finishing uploads.
732736
pendingValidatedCheckpoint = targetCheckpoint;
737+
} else {
738+
// Nothing to retry later. This would likely already be null from the last
739+
// checksum or checksum_diff operation, but we make sure.
740+
pendingValidatedCheckpoint = null;
733741
}
734742
} else if (isStreamingSyncCheckpointPartiallyComplete(line)) {
735743
const priority = line.partial_checkpoint_complete.priority;
@@ -765,6 +773,8 @@ The next upload iteration will be delayed.`);
765773
if (targetCheckpoint == null) {
766774
throw new Error('Checkpoint diff without previous checkpoint');
767775
}
776+
// New checkpoint - existing validated checkpoint is no longer valid
777+
pendingValidatedCheckpoint = null;
768778
const diff = line.checkpoint_diff;
769779
const newBuckets = new Map<string, BucketChecksum>();
770780
for (const checksum of targetCheckpoint.buckets) {

0 commit comments

Comments
 (0)