-
Type:
Bug
-
Resolution: Fixed
-
Priority:
Major - P3
-
Affects Version/s: None
-
Component/s: Not Applicable
-
None
-
Storage Engines, Storage Engines - Persistence
-
454.513
-
SE Persistence backlog
-
None
Issue Summary
Several metadata parsing loops in src/cursor/cur_backup.c, src/meta/meta_ckpt.c, src/rollback_to_stable/rts_history.c and src/rollback_to_stable/rts_btree_walk.c call _wt_config_next() inside a while/for condition without capturing its return value. When _wt_config_next() returns an error other than WT_NOTFOUND, the loop exits but the error code is discarded, and the function later returns WT_NOTFOUND or 0. This can hide malformed configuration strings or parser failures.
In __wt_meta_checkpoint_by_name, the same pattern also means the function returns 0 when a named checkpoint is not found, instead of WT_NOTFOUND. Callers in session_dhandle.c explicitly handle WT_NOTFOUND, so the current behavior can mislead them into treating a missing checkpoint as found.
Context
Affected functions:
- src/cursor/cur_backup.c: __wt_backup_open
- src/meta/meta_ckpt.c: _wt_meta_checkpoint_has_prepare, wt_meta_checkpoint_by_name, ckpt_named, ckpt_last, wt_ckpt_last_name, _wt_meta_ckptlist_get_from_config
- src/rollback_to_stable/rts_history.c: __wti_rts_history_final_pass
- src/rollback_to_stable/rts_btree_walk.c: __wti_rts_btree_walk_btree_apply
The codebase already uses the correct pattern in many places, e.g.:
while ((ret = __wt_config_next(&parser, &key, &value)) == 0) { ... } return (ret == WT_NOTFOUND ? 0 : ret);
The listed functions should follow the same convention.
Proposed Solution
1. Capture __wt_config_next() return value in each affected loop (while ((ret = __wt_config_next(...)) == 0) / for (; (ret = __wt_config_next(...)) == 0; ...)).
2. After the loop, either:
- return the error if it is not WT_NOTFOUND, or
- use WT_ERR_NOTFOUND_OK(ret, false) when an err: cleanup path is available.
3. Preserve existing semantics: WT_NOTFOUND means the end of the configuration list and should be translated to 0 unless the caller specifically expects WT_NOTFOUND (e.g. __ckpt_named).
Definition of Done
- [ ] All listed sites propagate __wt_config_next() errors correctly.
- [ ] __wt_meta_checkpoint_by_name returns WT_NOTFOUND when the named checkpoint is absent.
- [ ] Build passes (cmake --build build) and s_all style checks pass (modulo unrelated pre-existing failures).
- [ ] Code reviewed and merged.