Refactor layered cursor next_random to remove file-cursor layering violation

XMLWordPrintableJSON

    • Type: Task
    • Resolution: Unresolved
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Cursors
    • None
    • Storage Engines - Foundations
    • 386.735
    • None
    • None

      The current next_random implementation in the layered cursor reaches directly into the file-cursor layer, which is an ugly layering violation:

      1. _clayered_seed_random (src/cursor/cur_layered.c) casts a constituent WT_CURSOR * to WT_CURSOR_BTREE * and pokes cbt->rnd and cbt->next_random_sample_size directly. This duplicates logic from _curfile_create instead of going through a proper file-cursor API.
      2. _clayered_next_random (src/cursor/cur_layered.c) calls _wti_curfile_next_random directly on the constituent rather than going through cursor->next dispatch.

      The reason we ended up here: configuring the constituent cursors with next_random=true would rebind their cursor->next to the random-pick implementation, which breaks _clayered_iterate's deletion-skip loop (it spins forever on an all-tombstoned ingest btree). See WT-15189 for the original spin bug. The current workaround is to open constituents _without next_random=true but seed their random state manually.

            Assignee:
            [DO NOT USE] Backlog - Storage Engines Team
            Reporter:
            Jie Chen
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: