Commit db02fc9
authored
feat: add write ahead log appender and tailer primitives (#6669)
## Summary
Surface a generic read/write surface for MemWAL shards so callers can
drive a shard directly without going through the existing flusher.
- **Shard self-description.** `ShardManifest` now records the
`(shard_spec_id, field_id -> bytes)` assignment that produced the shard,
so a manifest found on disk can be mapped back to a shard spec without
consulting the inline index. Proto adds `ShardFieldEntry`; manifest
carries `shard_field_values: HashMap<String, Vec<u8>>`.
- **Idempotent shard initialization.**
`ShardManifestStore::initialize_shard()` writes manifest v1 at writer
epoch 0 and treats `AlreadyExists` as success when the existing manifest
matches.
- **Generic WAL primitives.**
- `WalAppender::open()` claims a writer epoch via the manifest store;
`append(batches)` serializes Arrow IPC and writes with
put-if-not-exists, retrying on conflict and fencing on PUT failure.
- `WalTailer::read_entry`, `next_position`, `first_position` use
`wal_entry_position_last_seen` as a probe hint with a listing fallback.
`WalReadEntry` includes the `writer_epoch` recorded in the entry so
callers can fence-check on replay.
- **Index discovery helpers.** New `Dataset` methods
`mem_wal_index_details()` and `list_mem_wal_latest_shard_ids()`
(object-storage directory listing). The inline shard snapshot is
positioned as a stale read-optimization rather than the source of truth;
`docs/src/format/table/mem_wal.md` is updated to match.
## Tests
Added unit tests for:
- `ShardManifestStore::initialize_shard` happy path, idempotent on
match, rejects mismatched conflict.
- `WalAppender` / `WalTailer` round-trip including `writer_epoch`
propagation; position increment.
- Writer-epoch fencing: a stale appender hits the conflict path on
append and surfaces the fence error.
- Input validation: empty batch list and zero-row batches are rejected.
- `WalTailer::with_cursor_updates(true)` updates
`wal_entry_position_last_seen` asynchronously, and `next_position()`
still resolves correctly.
- `mem_wal_path()` helper.
cc @jackye1995 for review.1 parent 23003a7 commit db02fc9
8 files changed
Lines changed: 1057 additions & 128 deletions
File tree
- docs/src/format/table
- protos
- rust
- lance-index/src
- lance/src/dataset
- mem_wal
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
48 | | - | |
| 48 | + | |
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
54 | | - | |
| 54 | + | |
| 55 | + | |
55 | 56 | | |
56 | 57 | | |
57 | 58 | | |
| |||
173 | 174 | | |
174 | 175 | | |
175 | 176 | | |
| 177 | + | |
176 | 178 | | |
177 | 179 | | |
178 | 180 | | |
| |||
258 | 260 | | |
259 | 261 | | |
260 | 262 | | |
261 | | - | |
262 | | - | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
263 | 274 | | |
264 | 275 | | |
265 | 276 | | |
| |||
342 | 353 | | |
343 | 354 | | |
344 | 355 | | |
345 | | - | |
346 | | - | |
347 | | - | |
348 | | - | |
349 | | - | |
350 | | - | |
351 | | - | |
352 | | - | |
353 | | - | |
354 | | - | |
355 | | - | |
356 | | - | |
357 | | - | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
358 | 364 | | |
359 | 365 | | |
360 | 366 | | |
361 | 367 | | |
362 | 368 | | |
363 | 369 | | |
364 | | - | |
| 370 | + | |
365 | 371 | | |
366 | | - | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
367 | 375 | | |
368 | 376 | | |
369 | 377 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
537 | 537 | | |
538 | 538 | | |
539 | 539 | | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
540 | 546 | | |
541 | 547 | | |
542 | 548 | | |
| |||
559 | 565 | | |
560 | 566 | | |
561 | 567 | | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
562 | 578 | | |
563 | 579 | | |
564 | 580 | | |
| |||
596 | 612 | | |
597 | 613 | | |
598 | 614 | | |
599 | | - | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
600 | 618 | | |
601 | 619 | | |
602 | 620 | | |
603 | | - | |
604 | | - | |
605 | | - | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
606 | 624 | | |
607 | | - | |
608 | | - | |
609 | | - | |
610 | | - | |
611 | | - | |
612 | | - | |
| 625 | + | |
613 | 626 | | |
614 | 627 | | |
615 | 628 | | |
| |||
690 | 703 | | |
691 | 704 | | |
692 | 705 | | |
693 | | - | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
153 | 153 | | |
154 | 154 | | |
155 | 155 | | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
156 | 161 | | |
157 | 162 | | |
158 | 163 | | |
| |||
165 | 170 | | |
166 | 171 | | |
167 | 172 | | |
168 | | - | |
| 173 | + | |
| 174 | + | |
169 | 175 | | |
170 | 176 | | |
171 | 177 | | |
| |||
175 | 181 | | |
176 | 182 | | |
177 | 183 | | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
178 | 192 | | |
179 | 193 | | |
180 | 194 | | |
| |||
193 | 207 | | |
194 | 208 | | |
195 | 209 | | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
196 | 215 | | |
197 | 216 | | |
198 | 217 | | |
199 | 218 | | |
| 219 | + | |
200 | 220 | | |
201 | 221 | | |
202 | 222 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
44 | | - | |
| 44 | + | |
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
| 48 | + | |
48 | 49 | | |
49 | 50 | | |
0 commit comments