Skip to content

fix: replay unflushed WAL entries into memtable on restart#6532

Closed
hamersaw wants to merge 2 commits intolance-format:mainfrom
hamersaw:bug/wal-entry-replay
Closed

fix: replay unflushed WAL entries into memtable on restart#6532
hamersaw wants to merge 2 commits intolance-format:mainfrom
hamersaw:bug/wal-entry-replay

Conversation

@hamersaw
Copy link
Copy Markdown
Contributor

Summary

  • On crash/restart, WAL entries written but not yet flushed to a generation were silently lost — the memtable started empty, dropping durably written data
  • Adds WalFlusher::replay_wal_entries() that scans from replay_after_wal_entry_position + 1 forward, re-inserting non-empty WAL entries into the memtable
  • Called during ShardWriter::open() before accepting new writes, with next_wal_entry_position advanced past replayed entries

Test plan

  • test_replay_wal_entries — writes 3 WAL entries, simulates restart, verifies all 3 replayed into memtable with correct row counts
  • test_replay_wal_entries_skips_already_flushed — verifies entries covered by replay_after_wal_entry_position are not replayed
  • test_replay_wal_entries_nothing_to_replay — verifies no-op when no WAL entries exist
  • All 217 existing mem_wal tests pass with no regressions

🤖 Generated with Claude Code

On crash/restart, WAL entries that were written but not yet flushed to a
generation were silently lost. The memtable started empty, dropping any
data durably written to the WAL. This adds replay logic in
ShardWriter::open() that scans WAL entries from
replay_after_wal_entry_position + 1 forward, inserting them back into
the memtable before accepting new writes.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@github-actions github-actions Bot added the bug Something isn't working label Apr 15, 2026
@hamersaw hamersaw marked this pull request as draft April 15, 2026 20:21
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 15, 2026

Codecov Report

❌ Patch coverage is 90.74074% with 10 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
rust/lance/src/dataset/mem_wal/wal.rs 90.74% 6 Missing and 4 partials ⚠️

📢 Thoughts on this report? Let us know!

@hamersaw hamersaw closed this Apr 22, 2026
@hamersaw hamersaw reopened this May 5, 2026
# Conflicts:
#	rust/lance/src/dataset/mem_wal/wal.rs
@hamersaw hamersaw marked this pull request as ready for review May 5, 2026 01:07
Copy link
Copy Markdown

@claude claude Bot left a comment

Choose a reason for hiding this comment

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

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

@jackye1995
Copy link
Copy Markdown
Contributor

I think this one is fixed in #6675 now

@jackye1995 jackye1995 closed this May 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants