Commit e9d1617
feat: unify WalAppender into ShardWriter via enable_memtable mode (#6675)
## Summary
- Add `ShardWriterConfig::enable_memtable` (default `true`); when
`false`, `ShardWriter` runs in a new WAL-only mode that keeps the async
batched WAL pipeline but skips MemTable allocation, in-memory indexes,
MemTable freezing, and MemTable-bytes backpressure (a separate WAL-only
backpressure budget reuses `max_unflushed_memtable_bytes`).
- `WalAppender` becomes the WAL write primitive used by both modes
inside `WalFlusher`, replacing the prior duplicate plain-`put` path.
MemTable mode now also gets atomic put-if-not-exists, conflict retry,
and fence-on-write.
- `WalAppender` stays public as the lowest-level synchronous-atomic
appender. New `pub(crate) WalAppender::with_claimed_epoch` lets
`ShardWriter::open` claim the epoch once and inject it.
- WAL-only mode uses a drainable `WalOnlyState` queue with
snapshot/commit semantics so a failed append leaves batches in the queue
for retry instead of dropping them silently.
- `memtable_stats()`, `scan()`, `active_memtable_ref()` now return
`Result<...>` and produce a clear `invalid_input` error in WAL-only
mode.
Behavior change to call out: first WAL entry on a fresh shard is now
position 0 instead of 1, matching the 0-based positions documented in
the [MemTable & WAL
spec](https://github.com/lance-format/lance/blob/main/docs/src/format/table/mem_wal.md).
The previous flusher seeded its counter from
`wal_entry_position_last_seen + 1` and so always skipped position 0.
Context: this realizes the layering discussed in
#6669 (comment) —
keep `WalAppender` as the low-level primitive and let users always use
`ShardWriter`, with a config switch to turn the MemTable on or off.
cc @jackye1995
---------
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 84b5d25 commit e9d1617
7 files changed
Lines changed: 2198 additions & 421 deletions
File tree
- python/src
- rust/lance
- benches
- src/dataset/mem_wal
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
201 | 201 | | |
202 | 202 | | |
203 | 203 | | |
204 | | - | |
| 204 | + | |
205 | 205 | | |
206 | 206 | | |
207 | 207 | | |
| |||
255 | 255 | | |
256 | 256 | | |
257 | 257 | | |
258 | | - | |
| 258 | + | |
259 | 259 | | |
260 | 260 | | |
261 | 261 | | |
| |||
267 | 267 | | |
268 | 268 | | |
269 | 269 | | |
270 | | - | |
| 270 | + | |
271 | 271 | | |
272 | 272 | | |
273 | 273 | | |
| |||
296 | 296 | | |
297 | 297 | | |
298 | 298 | | |
299 | | - | |
| 299 | + | |
300 | 300 | | |
301 | 301 | | |
302 | 302 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
210 | 210 | | |
211 | 211 | | |
212 | 212 | | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
213 | 217 | | |
214 | 218 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
307 | 307 | | |
308 | 308 | | |
309 | 309 | | |
310 | | - | |
| 310 | + | |
311 | 311 | | |
312 | 312 | | |
313 | 313 | | |
| |||
906 | 906 | | |
907 | 907 | | |
908 | 908 | | |
909 | | - | |
| 909 | + | |
910 | 910 | | |
911 | 911 | | |
912 | 912 | | |
| |||
0 commit comments