Commit 4e3352a
committed
Invalidate Linux page cache before mmap to prevent stale reads after ZFS rollback
After a ZFS/LVM snapshot rollback, the Linux page cache may retain
pre-rollback data for mmap'd files. When chainbase opens shared_memory.bin
via boost::interprocess::managed_mapped_file, it can read stale LIB values
from the page cache instead of the rolled-back data on disk. Meanwhile,
RocksDB uses pread() and reads correct post-rollback data, causing a
LIB mismatch assertion failure on startup.
Add posix_fadvise(POSIX_FADV_DONTNEED) before the mmap open to evict
any cached pages, ensuring fresh data is read from disk. The call has
negligible overhead (<0.01ms for a 7GB file).
Also improve the RocksDB LIB mismatch error message to explain the
likely cause and suggest remediation steps.1 parent a394359 commit 4e3352a
2 files changed
Lines changed: 25 additions & 1 deletion
Lines changed: 5 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
312 | 312 | | |
313 | 313 | | |
314 | 314 | | |
315 | | - | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
316 | 320 | | |
317 | 321 | | |
318 | 322 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
10 | 15 | | |
11 | 16 | | |
12 | 17 | | |
| |||
225 | 230 | | |
226 | 231 | | |
227 | 232 | | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
228 | 248 | | |
229 | 249 | | |
230 | 250 | | |
| |||
0 commit comments