Skip to content

Commit 2ed1d26

Browse files
allow reading v4 checkpoints with current version (#896)
1 parent 0116754 commit 2ed1d26

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

cs/src/core/Index/Common/Contexts.cs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,9 @@ public void Initialize(StreamReader reader)
437437
string value = reader.ReadLine();
438438
var cversion = int.Parse(value);
439439

440-
if (cversion != CheckpointVersion)
440+
bool translateV4toV5 = (cversion == 4 && CheckpointVersion == 5);
441+
442+
if (cversion != CheckpointVersion && !translateV4toV5)
441443
throw new FasterException($"Invalid checkpoint version {cversion} encountered, current version is {CheckpointVersion}, cannot recover with this checkpoint");
442444

443445
value = reader.ReadLine();
@@ -458,8 +460,15 @@ public void Initialize(StreamReader reader)
458460
value = reader.ReadLine();
459461
flushedLogicalAddress = long.Parse(value);
460462

461-
value = reader.ReadLine();
462-
snapshotStartFlushedLogicalAddress = long.Parse(value);
463+
if (!translateV4toV5)
464+
{
465+
value = reader.ReadLine();
466+
snapshotStartFlushedLogicalAddress = long.Parse(value);
467+
}
468+
else
469+
{
470+
snapshotStartFlushedLogicalAddress = flushedLogicalAddress;
471+
}
463472

464473
value = reader.ReadLine();
465474
startLogicalAddress = long.Parse(value);

0 commit comments

Comments
 (0)