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

Leak of HS cursor and flags in eviction server

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Priority: Minor - P4
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: 4.5 Required
    • Component/s: None
    • Labels:
      None
    • Story Points:
      5

      Description

      We typically open and close a history store cursor through a matching pair of calls:

       

      __wt_hs_cursor(session, &session_flags, &is_owner);
      ...
      __wt_hs_cursor_close(session, session_flags, is_owner);
      

      These pairs can be nested and wt_hs_cursor() will only call wt_hs_cursor_open() to open a cursor if the session doesn't already have one (i.e., the first time it is called).

      The problem is that we don't follow this paradigm in thread_group_resize(), where we directly call wt_hs_cursor_open() to open a HS cursor for new threads.  I couldn't find a corresponding place where this cursor would be closed. In practice, this only happens when we start the eviction server threads. MongoDB never changes the number of eviction servers so this leak would only show up at shutdown, where it should be harmless.  

      This has another side effect in the eviction server code.  Shortly after opening the HS cursor, the new eviction server threads enter wt_evict_thread_run() and execute:

          /*
           * Cache a history store cursor to avoid deadlock: if an eviction thread thread marks a file
           * busy and then opens a different file (in this case, the HS file), it can deadlock with a
           * thread waiting for the first file to drain from the eviction queue. See WT-5946 for details.
           */
          if (!F_ISSET(conn, WT_CONN_IN_MEMORY)) {
              session_flags = 0; /* [-Werror=maybe-uninitialized] */
              WT_RET(__wt_hs_cursor(session, &session_flags, &is_owner));
              WT_RET(__wt_hs_cursor_close(session, session_flags, is_owner));
          }

      A side effect here is that WT_SESSION_IGNORE_CACHE_SIZE will be added to the session flags and never cleared.  Normally that flag is cleared on the last call to  wt_hs_cursor_close(). But that won't happen here because the open HS cursor will make these calls think they are nested inside another set of calls to the same functions.

      The obvious caveat is that I may be missing something in the code. But this seems odd, and I wanted to document it before I forget it.

       

        Attachments

          Activity

            People

            Assignee:
            backlog-server-storage-engines Backlog - Storage Engines Team
            Reporter:
            keith.smith Keith Smith
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated: