Repository navigation
Commit 6c6354d
authored
Treat WAL TruncateBefore below first index as a no-op (#4355)
TestConcurrentTruncateBeforeWithAsyncWrites fails with "out of range
truncate error". The test reads `FirstOffset` and then calls
`TruncateBefore(first+1)`, but background pruning runs every millisecond
and can advance the first index past that value in between.
tidwall/wal's `TruncateFront` rejects an index below the current first
index with `ErrOutOfRange`, so a request that is already satisfied comes
back as an error. In production only the pebbledb MVCC store runs a
background pruner (`KeepRecent` and `PruneInterval`) alongside its own
`PruneWALBeforeVersion`, which computes its truncation offset from an
earlier `FirstOffset` read. Losing that race logs a spurious "failed to
prune state store changelog WAL" error from the snapshot manager and
does nothing worse. memiavl opens its WAL without a pruner, and
`tryTruncateWAL` already skips indexes at or below the first index.
`handleTruncate` now treats a `TruncateBefore` whose index is below the
current first index as a successful no-op, since every entry before that
index is already gone. Both `TruncateBefore` and `TruncateAll` go
through this check, and so does `prune`, all on the main loop, so the
check and the truncation cannot race. The `TruncateBefore` godoc on
`WAL` and `GenericWAL` now states the no-op contract.
`TestTruncateBefore` and `TestTruncateAll` cover it, for both a
non-empty log and an emptied `AllowEmpty` log. The concurrent test also
waits for pruning to reach its fixed point before it reads the range, so
it no longer reads the first entry while the pruner may still move it.
Flaked in:
https://github.com/sei-protocol/sei-chain/actions/runs/35518364976/job/1060980423891 parent 1c2b3a2 commit 6c6354d
3 files changed
Lines changed: 31 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
| 14 | + | |
| 15 | + | |
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
339 | 339 | | |
340 | 340 | | |
341 | 341 | | |
342 | | - | |
343 | | - | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
344 | 345 | | |
345 | 346 | | |
346 | 347 | | |
| |||
399 | 400 | | |
400 | 401 | | |
401 | 402 | | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
402 | 408 | | |
403 | 409 | | |
404 | 410 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
249 | 249 | | |
250 | 250 | | |
251 | 251 | | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
252 | 258 | | |
253 | 259 | | |
254 | 260 | | |
| |||
588 | 594 | | |
589 | 595 | | |
590 | 596 | | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
591 | 602 | | |
592 | 603 | | |
593 | 604 | | |
594 | | - | |
| 605 | + | |
595 | 606 | | |
596 | 607 | | |
597 | 608 | | |
598 | 609 | | |
599 | | - | |
600 | | - | |
601 | | - | |
602 | | - | |
603 | 610 | | |
604 | 611 | | |
605 | 612 | | |
| |||
636 | 643 | | |
637 | 644 | | |
638 | 645 | | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
639 | 652 | | |
640 | 653 | | |
641 | 654 | | |
| |||
679 | 692 | | |
680 | 693 | | |
681 | 694 | | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
682 | 698 | | |
683 | 699 | | |
684 | 700 | | |
| |||
0 commit comments