Avoid doing the search to check existing keys for layered insert and update on leader

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

      In leader mode, the layered cursor directly operates on the stable cursor. Within the B-tree layer, checks for existing keys during insert and update operations are already performed. As a result, the following code becomes redundant for the leader mode.:

          /*
           * It isn't necessary to copy the key out after the lookup in this case because any non-failed
           * lookup results in an error, and a failed lookup leaves the original key intact.
           */
          if (!F_ISSET(cursor, WT_CURSTD_OVERWRITE) &&
            (ret = __clayered_lookup(session, clayered, &value)) != WT_NOTFOUND) {
              if (ret == 0) {
                  WT_ERR(__clayered_copy_duplicate_kv(cursor));
                  WT_ERR(__clayered_reset_cursors(clayered, false));
                  WT_ERR(WT_DUPLICATE_KEY);
              }
      
              goto err;
          }
      
          if (!F_ISSET(cursor, WT_CURSTD_OVERWRITE)) {
              WT_ERR(__clayered_lookup(session, clayered, &value));
              /*
               * Copy the key out, since the insert resets non-primary chunk cursors which our lookup may
               * have landed on.
               */
              WT_ERR(__cursor_needkey(cursor));
          }
      

            Assignee:
            [DO NOT USE] Backlog - Storage Engines Team
            Reporter:
            Chenhao Qu
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: