From 2513b20387418757253ef86eda3e1fede9daa1cc Mon Sep 17 00:00:00 2001 From: Ted Hart <15467143+TedHartMS@users.noreply.github.com> Date: Sun, 24 Mar 2024 23:17:01 -0700 Subject: [PATCH] Ensure that all in-memory records are checkpointed when not using --storage-tier (#117) Co-authored-by: Badrish Chandramouli --- .../core/Index/Synchronization/HybridLogCheckpointTask.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/libs/storage/Tsavorite/cs/src/core/Index/Synchronization/HybridLogCheckpointTask.cs b/libs/storage/Tsavorite/cs/src/core/Index/Synchronization/HybridLogCheckpointTask.cs index 5b46d072b4..5afb2353a9 100644 --- a/libs/storage/Tsavorite/cs/src/core/Index/Synchronization/HybridLogCheckpointTask.cs +++ b/libs/storage/Tsavorite/cs/src/core/Index/Synchronization/HybridLogCheckpointTask.cs @@ -226,7 +226,9 @@ public override void GlobalBeforeEnteringState(SystemState next, Tsa store._hybridLogCheckpoint.snapshotFileDevice.Initialize(store.hlog.GetSegmentSize()); store._hybridLogCheckpoint.snapshotFileObjectLogDevice.Initialize(-1); - store._hybridLogCheckpoint.info.snapshotStartFlushedLogicalAddress = store.hlog.FlushedUntilAddress; + // If we are using a NullDevice then storage tier is not enabled and FlushedUntilAddress may be ReadOnlyAddress; get all records in memory. + store._hybridLogCheckpoint.info.snapshotStartFlushedLogicalAddress = store.hlog.IsNullDevice ? store.hlog.HeadAddress : store.hlog.FlushedUntilAddress; + long startPage = store.hlog.GetPage(store._hybridLogCheckpoint.info.snapshotStartFlushedLogicalAddress); long endPage = store.hlog.GetPage(store._hybridLogCheckpoint.info.finalLogicalAddress); if (store._hybridLogCheckpoint.info.finalLogicalAddress > @@ -251,7 +253,8 @@ public override void GlobalBeforeEnteringState(SystemState next, Tsa break; case Phase.PERSISTENCE_CALLBACK: // Set actual FlushedUntil to the latest possible data in main log that is on disk - store._hybridLogCheckpoint.info.flushedLogicalAddress = store.hlog.FlushedUntilAddress; + // If we are using a NullDevice then storage tier is not enabled and FlushedUntilAddress may be ReadOnlyAddress; get all records in memory. + store._hybridLogCheckpoint.info.flushedLogicalAddress = store.hlog.IsNullDevice ? store.hlog.HeadAddress : store.hlog.FlushedUntilAddress; base.GlobalBeforeEnteringState(next, store); store._lastSnapshotCheckpoint = store._hybridLogCheckpoint.Transfer(); break;