Uploaded image for project: 'WiredTiger'
  1. WiredTiger
  2. WT-8092

prefix enabled search_near does not return the correct key when in memory

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: In Code Review
    • Priority: Major - P3
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None
    • Story Points:
      5
    • Sprint:
      Storage - Ra 2021-09-20, Storage - Ra 2021-10-04

      Description

      Using the repro attached, when keys are not evicted, they remain in the insert list. When this is the case, the field cbt->tmp->data is not set and the condition added as part of WT-8044 does not work as expected because it is NULL. When the keys are evicted, cbt->tmp->data is updated and the field can be used.

      The field that seems to be always set whether the keys are in the inserted list or on disk is cbt->upd_value->buf. The suggested change is the following:

      diff --git a/src/btree/bt_cursor.c b/src/btree/bt_cursor.c
      index b3d879fae..d8df06486 100644
      --- a/src/btree/bt_cursor.c
      +++ b/src/btree/bt_cursor.c
      @@ -688,7 +688,7 @@ __wt_btcur_search_near(WT_CURSOR_BTREE *cbt, int *exactp)
            * key only if it is a prefix match.
            */
           if (valid && F_ISSET(cursor, WT_CURSTD_PREFIX_SEARCH) &&
      -      __wt_prefix_match(&state.key, cbt->tmp) != 0)
      +      __wt_prefix_match(&state.key, &cbt->upd_value->buf) != 0)
               valid = false; 

      With this change, the issue does not reproduce.

      EDIT: Seems that a better way to retrieve the key would be usingĀ wt_key_return

      Definition of done:

      • Check the reproducers and confirm the issue does not occur
      • Modify the existing test_search_near02 so we also do the test when keys are not evicted

        Attachments

        1. repro.py
          8 kB
        2. repro2.py
          4 kB

          Activity

            People

            Assignee:
            jie.chen Jie Chen
            Reporter:
            etienne.petrel Etienne Petrel
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated: