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

Incorrect calculation for number of reserved session slots

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

      Background

      Wiredtiger calls __conn_session_size during wiredtiger_open to reserve the session slots that threads can use. Currently for eviction workers and lsm_manager workers, we use the configured max threads value, see code below.

      static int
      __conn_session_size(WT_SESSION_IMPL *session, const char *cfg[], uint32_t *vp)
      {
          WT_CONFIG_ITEM cval;
          int64_t v;
      
      /*
       * Start with 25 internal sessions to cover threads the application can't configure (for example,
       * checkpoint or statistics log server threads).
       */
      #define WT_EXTRA_INTERNAL_SESSIONS 25
          v = WT_EXTRA_INTERNAL_SESSIONS;
      
          /* Then, add in the thread counts applications can configure. */
          WT_RET(__wt_config_gets(session, cfg, "eviction.threads_max", &cval));
          v += cval.val;
      
          WT_RET(__wt_config_gets(session, cfg, "lsm_manager.worker_thread_max", &cval));
          v += cval.val;
      
          WT_RET(__wt_config_gets(session, cfg, "session_max", &cval));
          v += cval.val;
      
          *vp = (uint32_t)v;
      
          return (0);
      }
      

      Problem

      Both eviction max worker and lsm_manager max worker can be changed by WT_CONNECTION::reconfigure API, and during the reconfiguration we don't recalculate the number of reserved session slots, causing potential running out of available session slots problem.

      Suggested change

      For lsm_manager workers we should use the macro WT_LSM_MAX_WORKERS(The max value we can configure for lsm_manager.worker_thread_max) to calculate the session slots. We should do the same for eviction, add a WT_EVICT_MAX_WORKERS in evict.h and use the value to calculate the session slots as well.

      diff --git a/src/conn/conn_api.c b/src/conn/conn_api.c
      index 4ee1d6957..333d2750f 100644
      --- a/src/conn/conn_api.c
      +++ b/src/conn/conn_api.c
      @@ -2556,11 +2556,9 @@ __conn_session_size(WT_SESSION_IMPL *session, const char *cfg[], uint32_t *vp)
           v = WT_EXTRA_INTERNAL_SESSIONS;
       
           /* Then, add in the thread counts applications can configure. */
      -    WT_RET(__wt_config_gets(session, cfg, "eviction.threads_max", &cval));
      -    v += cval.val;
      +    v += WT_EVICT_MAX_WORKERS;
       
      -    WT_RET(__wt_config_gets(session, cfg, "lsm_manager.worker_thread_max", &cval));
      -    v += cval.val;
      +    v += WT_LSM_MAX_WORKERS;
       
           WT_RET(__wt_config_gets(session, cfg, "session_max", &cval));
           v += cval.val;
      diff --git a/src/evict/evict.h b/src/evict/evict.h
      index 600a39d2d..78338754d 100644
      --- a/src/evict/evict.h
      +++ b/src/evict/evict.h
      @@ -137,6 +137,8 @@ struct __wt_evict {
       #define WT_EVICT_CALL_URGENT 0x4u   /* Urgent eviction */
       /* AUTOMATIC FLAG VALUE GENERATION STOP 32 */
       
      +#define WT_EVICT_MAX_WORKERS 20
      +
       /* DO NOT EDIT: automatically built by prototypes.py: BEGIN */
       
       extern bool __wt_evict_page_urgent(WT_SESSION_IMPL *session, WT_REF *ref)
      

            Assignee:
            backlog-server-storage-engines [DO NOT USE] Backlog - Storage Engines Team
            Reporter:
            zunyi.liu@mongodb.com Zunyi Liu
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: