-
Type:
Task
-
Resolution: Fixed
-
Priority:
Major - P3
-
Affects Version/s: None
-
Component/s: Layered Tables
-
None
-
Storage Engines - Foundations
-
226.145
-
SE Foundations - 2026-07-07
-
13
cur_layered.c re-derives its per-operation state - role, constituent cursors, table, collator, snapshot/read-timestamp witnesses - throughout the file by reaching into the connection, dhandle, btree, and txn structures (e.g. ~14 live layered_table_manager.leader reads, ~12 (WT_LAYERED_TABLE *)dhandle casts). This scatters the contract and makes the helpers hard to unit-test.
Introduce WT_CLAYERED_OP, a stack-allocated per-operation context that __clayered_enter populates once and threads to the helpers, which then read op->... instead of re-reaching. Replace the opaque (reset, need_read_stable, iteration) enter bools with a single mode enum, drop the WT_CLAYERED_READ_STABLE flag (→ op->need_stable), and turn clayered->leader into a last_role change-detection sentinel.
Behavior-preserving, with one deliberate refinement: consumers read the role snapshot op->role (resolved once per op) instead of re-reading the live role mid-operation. This is the first stage of the layered-cursor cleanup - collapsing the forked leader/follower helpers and the ingest/}}stable}} → primary/}}secondary}} renames are follow-ups.
- related to
-
WT-17755 Make layered cursors APIs body functions role agnostic
-
- In Code Review
-