Issue Summary
The WT_STAT_CONN_DSRC_INCR macro is incorrectly used in the file_skipped path within
rts_btree_walk.c:441
. When a file is skipped, the macro increments the per-datasource stat on the metadata file's dhandle, not the btree being evaluated, because session->dhandle is set to the metadata cursor's dhandle at this point. This leads to inflated stats for the metadata file and does not correctly account for the skipped btree.
Context
- The macro WT_STAT_CONN_DSRC_INCR increments both the connection-level and per-datasource stat, using session->dhandle to locate the datasource stat.
- In the file_skipped block, the session's dhandle is the metadata file's dhandle, as no btree dhandle is opened for skipped files.
- The only dhandle change in this context is inside WT_WITHOUT_DHANDLE, which temporarily nulls and restores the dhandle, but after this block, it is still the metadata dhandle.
- As a result, the per-datasource stat is incremented for the wrong file.
Proposed Solution
Replace the macro in the file_skipped block to only increment the connection-level stat:
if (file_skipped) {
- WT_STAT_CONN_DSRC_INCR(session, txn_rts_btrees_skipped);
+ WT_STAT_CONN_INCR(session, txn_rts_btrees_skipped);
(void)__wt_atomic_add_uint64_relaxed(&S2C(session)->rts->progress.btrees_skipped, 1);
}
This ensures only the correct connection-level stat is incremented, avoiding incorrect updates to the metadata file's per-datasource stat.
Original Slack thread: Slack Thread
This ticket was generated by AI from a Slack thread.