Problem
__random_leaf_disk crashes with SIGFPE (divide by zero) when it encounters a disk page with zero entries. The crash is at bt_random.c:241:
slot = __wt_random(&cbt->rnd) % entries;
Root Cause
_random_leaf calls random_leaf_disk when it finds an unmodified page from disk (page->dsk != NULL && page->modify == NULL), regardless of whether page->entries is zero. _random_leaf_disk reads entries from page->entries but does not guard against a zero value before the modulo.
An empty row-store leaf page on disk satisfies the dsk != NULL && modify == NULL condition. When the tree walk in _wt_btcur_next_random lands on such a page, control reaches _random_leaf_disk with entries == 0 and the modulo faults.
The fix is to return early from __random_leaf_disk when entries == 0, leaving validp false so the caller falls through to the cursor-walk path, which already handles empty trees correctly.
- related to
-
WT-18408 Data loss when a picked up checkpoint's oldest timestamp > current read timestamp
-
- Closed
-