Commit dbe70e3
Fix cancellation safety of LruCachingStore::write_batch
The previous implementation wrote to the DB first, then updated the LRU
cache. If the future was cancelled between the two (e.g. by the
RollbackGuard introduced in linera-io#5790), the DB would have the new data but
the cache would retain stale entries. Subsequent reads would hit the
stale cache, and the next save would overwrite the DB with old data,
causing silent data loss.
Fix: invalidate cache entries BEFORE writing to the DB, then repopulate
after success. If cancelled at any point after invalidation, subsequent
reads go directly to the DB and see the correct state.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent bd52363 commit dbe70e3
2 files changed
Lines changed: 44 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
353 | 353 | | |
354 | 354 | | |
355 | 355 | | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
356 | 375 | | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
357 | 379 | | |
358 | 380 | | |
359 | 381 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
555 | 555 | | |
556 | 556 | | |
557 | 557 | | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
558 | 565 | | |
559 | 566 | | |
560 | 567 | | |
| |||
731 | 738 | | |
732 | 739 | | |
733 | 740 | | |
734 | | - | |
735 | | - | |
736 | | - | |
737 | | - | |
738 | | - | |
739 | | - | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
740 | 744 | | |
741 | 745 | | |
742 | 746 | | |
| |||
792 | 796 | | |
793 | 797 | | |
794 | 798 | | |
795 | | - | |
| 799 | + | |
796 | 800 | | |
797 | 801 | | |
798 | 802 | | |
| |||
807 | 811 | | |
808 | 812 | | |
809 | 813 | | |
810 | | - | |
811 | | - | |
812 | | - | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
| 820 | + | |
| 821 | + | |
| 822 | + | |
| 823 | + | |
| 824 | + | |
813 | 825 | | |
814 | 826 | | |
815 | 827 | | |
| |||
0 commit comments