From 2ed1d2692952ff3822289ba3f6ecb1163612dd04 Mon Sep 17 00:00:00 2001 From: Sebastian Burckhardt Date: Thu, 29 Feb 2024 12:39:51 -0800 Subject: [PATCH] allow reading v4 checkpoints with current version (#896) --- cs/src/core/Index/Common/Contexts.cs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/cs/src/core/Index/Common/Contexts.cs b/cs/src/core/Index/Common/Contexts.cs index 350710178..8c03df6db 100644 --- a/cs/src/core/Index/Common/Contexts.cs +++ b/cs/src/core/Index/Common/Contexts.cs @@ -437,7 +437,9 @@ public void Initialize(StreamReader reader) string value = reader.ReadLine(); var cversion = int.Parse(value); - if (cversion != CheckpointVersion) + bool translateV4toV5 = (cversion == 4 && CheckpointVersion == 5); + + if (cversion != CheckpointVersion && !translateV4toV5) throw new FasterException($"Invalid checkpoint version {cversion} encountered, current version is {CheckpointVersion}, cannot recover with this checkpoint"); value = reader.ReadLine(); @@ -458,8 +460,15 @@ public void Initialize(StreamReader reader) value = reader.ReadLine(); flushedLogicalAddress = long.Parse(value); - value = reader.ReadLine(); - snapshotStartFlushedLogicalAddress = long.Parse(value); + if (!translateV4toV5) + { + value = reader.ReadLine(); + snapshotStartFlushedLogicalAddress = long.Parse(value); + } + else + { + snapshotStartFlushedLogicalAddress = flushedLogicalAddress; + } value = reader.ReadLine(); startLogicalAddress = long.Parse(value);