Fix dhandles reference counting when we find an existing one

XMLWordPrintableJSON

    • Type: Task
    • Resolution: Fixed
    • Priority: Major - P3
    • WT12.0.0, 8.3.0-rc0
    • Affects Version/s: None
    • Component/s: DHandles
    • None
    • Storage Engines, Storage Engines - Foundations
    • SE Foundations - 2025-10-10
    • 0

      Due to changes introduced by the disagg merge we now obtain 2 references instead of 1 when we find an existing dhandle in the following code:

      static int
      __session_find_shared_dhandle(WT_SESSION_IMPL *session, const char *uri, const char *checkpoint)
      {
      WT_DECL_RET;
      
      
      WT_WITH_HANDLE_LIST_READ_LOCK(session,
      if ((ret=__wt_conn_dhandle_find(session, uri, checkpoint)) ==0)
      WT_DHANDLE_ACQUIRE(session->dhandle)); // >> get first ref
      
      
      if (ret!=WT_NOTFOUND) // go to alloc since ret == 0
      return (ret);
      
      
      WT_WITH_HANDLE_LIST_WRITE_LOCK(session,
      if ((ret=__wt_conn_dhandle_alloc(session, uri, checkpoint)) ==0) // ret == 0 since dhandle already exists
      WT_DHANDLE_ACQUIRE(session->dhandle)); // >> get second reference
      
      
      return (ret);
      } 

      Since this reference is not released later, dhandles couldn't be swept until the connection close in many cases.

      Guilty commit: https://github.com/wiredtiger/wiredtiger/commit/50b05eb051ef702abbe2e07a7d5a995ffda904a7

            Assignee:
            Ivan Kochin
            Reporter:
            Ivan Kochin
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: