Commit 2f456ff
committed
Fix regression in DB write atomicity (#3931)
## Issue Addressed
Fix a bug introduced by #3696. The bug is not expected to occur frequently, so releasing this PR is non-urgent.
## Proposed Changes
* Add a variant to `StoreOp` that allows a raw KV operation to be passed around.
* Return to using `self.store.do_atomically` rather than `self.store.hot_db.do_atomically`. This streamlines the write back into a single call and makes our auto-revert work again.
* Prevent `import_block_update_shuffling_cache` from failing block import. This is an outstanding bug from before v3.4.0 which may have contributed to some random unexplained database corruption.
## Additional Info
In #3696 I split the database write into two calls, one to convert the `StoreOp`s to `KeyValueStoreOp`s and one to write them. This had the unfortunate side-effect of damaging our atomicity guarantees in case of a write error. If the first call failed, we would be left with the block in fork choice but not on-disk (or the snapshot cache), which would prevent us from processing any descendant blocks. On `unstable` the first call is very unlikely to fail unless the disk is full, but on `tree-states` the conversion is more involved and a user reported database corruption after it failed in a way that should have been recoverable.
Additionally, as @emhane observed, #3696 also inadvertently removed the import of the new block into the block cache. Although this seems like it could have negatively impacted performance, there are several mitigating factors:
- For regular block processing we should almost always load the parent block (and state) from the snapshot cache.
- We often load blinded blocks, which bypass the block cache anyway.
- Metrics show no noticeable increase in the block cache miss rate with v3.4.0.
However, I expect the block cache _will_ be useful again in `tree-states`, so it is restored to use by this PR.1 parent 84843d6 commit 2f456ff
File tree
4 files changed
+47
-17
lines changed- beacon_node
- beacon_chain/src
- store/src
4 files changed
+47
-17
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2714 | 2714 | | |
2715 | 2715 | | |
2716 | 2716 | | |
2717 | | - | |
| 2717 | + | |
2718 | 2718 | | |
2719 | 2719 | | |
2720 | 2720 | | |
| |||
2816 | 2816 | | |
2817 | 2817 | | |
2818 | 2818 | | |
| 2819 | + | |
| 2820 | + | |
| 2821 | + | |
| 2822 | + | |
| 2823 | + | |
2819 | 2824 | | |
2820 | 2825 | | |
2821 | | - | |
| 2826 | + | |
2822 | 2827 | | |
2823 | 2828 | | |
2824 | 2829 | | |
| |||
2841 | 2846 | | |
2842 | 2847 | | |
2843 | 2848 | | |
2844 | | - | |
2845 | | - | |
2846 | | - | |
2847 | | - | |
| 2849 | + | |
| 2850 | + | |
| 2851 | + | |
| 2852 | + | |
| 2853 | + | |
2848 | 2854 | | |
2849 | 2855 | | |
2850 | 2856 | | |
2851 | 2857 | | |
2852 | | - | |
2853 | | - | |
2854 | | - | |
| 2858 | + | |
2855 | 2859 | | |
2856 | 2860 | | |
2857 | 2861 | | |
| |||
3280 | 3284 | | |
3281 | 3285 | | |
3282 | 3286 | | |
| 3287 | + | |
| 3288 | + | |
3283 | 3289 | | |
3284 | 3290 | | |
3285 | 3291 | | |
3286 | 3292 | | |
| 3293 | + | |
| 3294 | + | |
| 3295 | + | |
| 3296 | + | |
| 3297 | + | |
| 3298 | + | |
| 3299 | + | |
| 3300 | + | |
| 3301 | + | |
| 3302 | + | |
| 3303 | + | |
| 3304 | + | |
| 3305 | + | |
| 3306 | + | |
3287 | 3307 | | |
3288 | | - | |
3289 | | - | |
3290 | 3308 | | |
3291 | 3309 | | |
3292 | 3310 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
41 | | - | |
| 41 | + | |
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
| |||
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
82 | | - | |
| 82 | + | |
83 | 83 | | |
84 | 84 | | |
85 | 85 | | |
| |||
92 | 92 | | |
93 | 93 | | |
94 | 94 | | |
95 | | - | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
96 | 99 | | |
97 | 100 | | |
98 | 101 | | |
| |||
112 | 115 | | |
113 | 116 | | |
114 | 117 | | |
115 | | - | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
116 | 121 | | |
117 | 122 | | |
118 | 123 | | |
| |||
294 | 299 | | |
295 | 300 | | |
296 | 301 | | |
297 | | - | |
| 302 | + | |
298 | 303 | | |
299 | 304 | | |
300 | 305 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
727 | 727 | | |
728 | 728 | | |
729 | 729 | | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
730 | 734 | | |
731 | 735 | | |
732 | 736 | | |
| |||
758 | 762 | | |
759 | 763 | | |
760 | 764 | | |
| 765 | + | |
| 766 | + | |
761 | 767 | | |
762 | 768 | | |
763 | 769 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
161 | 161 | | |
162 | 162 | | |
163 | 163 | | |
| 164 | + | |
164 | 165 | | |
165 | 166 | | |
166 | 167 | | |
| |||
0 commit comments