Skip to content

Fix intermittent key loss in SeSaveRecoverMultipleKeysTest("25k","18k")#1957

Open
TedHartMS wants to merge 10 commits into
mainfrom
sesr-mkt2
Open

Fix intermittent key loss in SeSaveRecoverMultipleKeysTest("25k","18k")#1957
TedHartMS wants to merge 10 commits into
mainfrom
sesr-mkt2

Conversation

@TedHartMS

Copy link
Copy Markdown
Contributor

This pull request addresses a regression in snapshot recovery under memory budget constraints, ensuring that all pages are properly flushed and no data is lost during recovery. It also improves resource management and clarifies code paths for different store configurations. The most important changes are:

Bug Fixes and Recovery Logic Improvements:

  • Modified RecoverSnapshotPages in Recovery.cs to always flush every page when a LogSizeTracker is attached, regardless of whether the store is an object allocator or not. This prevents data loss when recovering into a smaller memory budget, fixing a scenario where pages could be evicted before being flushed, resulting in lost records.
  • Simplified the call to RecoverSnapshotPages by removing unused parameters related to page ranges, reflecting the new logic that flushes all pages under a memory budget. [1] [2]

Resource Management:

  • Updated disposal logic to safely handle cases where objectLogRecoveryDevice may be null, preventing potential null reference exceptions.
  • Improved initialization of objectLogRecoveryDevice to only occur when the store has an object log, and made its initialization call null-safe.

Testing and Documentation:

  • Added a comprehensive regression test SpanByteRecoverySnapshotEvictionTests to verify that all records are correctly recovered when restoring from a snapshot under a tighter memory budget, and that no records are lost due to premature eviction.
  • Added clarifying comments in ContinuePending.cs to document status handling during read operations.

… to smaller memory in SeSaveRecoverMultipleKeysTest("25k","18k")

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes an intermittent snapshot-recovery data-loss regression under tight memory budgets by ensuring snapshot pages are made durable (flushed) before recovery-time eviction can free them. It also adds a regression test covering the failure mode and tightens a couple of recovery/resource-management code paths.

Changes:

  • Update Tsavorite snapshot recovery to flush every snapshot page when a LogSizeTracker is attached (so recovery-time eviction cannot drop unflushed pages).
  • Make snapshot object-log recovery device initialization/disposal null-safe when the store has no object log.
  • Add a regression test that recovers a SpanByte snapshot into a smaller budget (with optional concurrent resizer) and verifies all records read back correctly; add a clarifying comment in ContinuePendingRead.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
libs/storage/Tsavorite/cs/src/core/Index/Recovery/Recovery.cs Flush all snapshot pages under LogSizeTracker; null-safe object-log recovery device setup/teardown.
libs/storage/Tsavorite/cs/test/test.recovery/SpanByteRecoverySnapshotEvictionTests.cs New regression test for snapshot recovery under budget-driven eviction (SpanByte/inline store).
libs/storage/Tsavorite/cs/src/core/Index/Tsavorite/Implementation/ContinuePending.cs Comment clarifying why status is already SUCCESS at the copy-to-tail/readcache decision point.

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@TedHartMS
TedHartMS marked this pull request as draft July 21, 2026 01:53
…flush pages from the snapshot region unless the recovery memory budget is so much smaller that it has to; fix the pass2 object loading sequence when snapshot is present.
@TedHartMS
TedHartMS marked this pull request as ready for review July 22, 2026 00:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants