Mark a dhandle as outdated only when the checkpoint change

XMLWordPrintableJSON

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

      When adopting a new checkpoint, we mark all the existing btrees in the metadata as outdated no matter whether they have actually changed or not.

               if (ret == 0 && WT_PREFIX_MATCH(metadata_key, "file:")) {
                  /* Existing table: Just apply the new metadata. */
                  WT_ERR(__wt_config_getones(session, metadata_value, "checkpoint", &cval));
                  len = strlen("checkpoint=") + strlen(metadata_value) + 1 /* for NUL */;
                  if (len > metadata_value_cfg_len) {
                      metadata_value_cfg_len = len;
                      WT_ERR(
                        __wt_realloc_noclear(session, NULL, metadata_value_cfg_len, &metadata_value_cfg));
                  }
                  WT_ERR(
                    __wt_snprintf(metadata_value_cfg, len, "checkpoint=%.*s", (int)cval.len, cval.str));
      
                  /* Merge the new checkpoint metadata into the current table metadata. */
                  WT_ERR(md_cursor->get_value(md_cursor, &current_value));
                  cfg[0] = current_value;
                  cfg[1] = metadata_value_cfg;
                  cfg[2] = NULL;
                  WT_ERR(__wt_config_collapse(session, cfg, &cfg_ret));
      
                  /* FIXME-WT-14730: check that the other parts of the metadata are identical. */
      
                  /* Put our new config in */
                  md_cursor->set_value(md_cursor, cfg_ret);
                  WT_ERR_MSG_CHK(session, md_cursor->insert(md_cursor),
                    "Failed to insert metadata for key \"%s\"", metadata_key);
      
                  __wt_verbose_debug2(session, WT_VERB_DISAGGREGATED_STORAGE,
                    "Updated the local metadata for key \"%s\" to include new checkpoint: \"%.*s\"",
                    metadata_key, (int)cval.len, cval.str);
      
                  /*
                   * Mark any matching data handles to be out of date. Any new opens will get the new
                   * metadata.
                   */
                  WT_ERR_MSG_CHK(session, __wti_conn_dhandle_outdated(session, metadata_key),
                    "Marking data handles outdated failed: \"%s\"", metadata_key);
                  __wt_free(session, cfg_ret);
              }
      

      This is suboptimal as we mark the btree as outdated even the new checkpoint doesn't visit that tree and its checkpoint is the same as before.

      We should only mark a btree as outdated if its checkpoint actually has change.

            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: