Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-104653

Standardize support for per-service analogue to server parameters

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Server Programmability
    • None
    • 3
    • TBD
    • None
    • None
    • None
    • None
    • None
    • None

      In SERVER-88953, a nontrivial number of server parameters are discussed that are indicative of a developer need to support "server parameter" values via set and get commands, but only to set the value for a scope that affects the client doing the operation. Currently these are all mixed in with the true server parameters, which have a process-wide scope. This is very ad hoc and thus parameters have surprising bevavior. We're relying on global currentClient singleton of the setters and getters. I feel like this needs a comprehensive structural solution.

      SERVER-88953 added opCtx to every setter, which is a tactical fix to the currentClient thread_local access concern. However it doesn't install a distinction among the different parameters as to which are client-scoped and which are global, which I feel we should do in order to reduce churn and treat these different kinds of parameters with approriate and standardized semantics.

      — example current ad hoc code —

      This parameter affects the whole server.

          ttlMonitorSleepSecs: 
              description: "Period of TTL monitor thread (used for testing)."
              set_at: [startup, runtime]
              cpp_vartype: AtomicWord<int>
              cpp_varname: ttlMonitorSleepSecs
              on_update: "TTLMonitor::onUpdateTTLMonitorSleepSeconds"
              default: 60
              validator: 
                  gt: 0
              redact: false
      
      Status TTLMonitor::onUpdateTTLMonitorSleepSeconds(int newSleepSeconds) {
          if (auto client = Client::getCurrent()) {
              if (auto ttlMonitor = TTLMonitor::get(client->getServiceContext())) {
                  ttlMonitor->updateSleepSeconds(Seconds{newSleepSeconds});
              }
          }
          return Status::OK();
      }
      

      ... But others are less clear in scope.
      Because this passes an entire opCtx to writer, it could be client-specific or not.
      There seems to be no way to know.

      Status TicketHolderManager::updateConcurrentWriteTransactions(const int32_t& newWriteTransactions) {
          if (auto client = Client::getCurrent()) {
              auto opCtx = client->getOperationContext();
              ...
                          writer->resize(opCtx, newWriteTransactions, Date_t::max());
              ...
          }
      }
      

      https://github.com/10gen/mongo/blob/654700fe9b03de6dbe38e1d61ee9625dae064b34/src/mongo/db/admission/ticketholder_manager.cpp#L132

      — the list! —
      https://jira.mongodb.org/browse/SERVER-88953?focusedCommentId=7272236&focusedId=7272236&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-7272236

            Assignee:
            Unassigned Unassigned
            Reporter:
            billy.donahue@mongodb.com Billy Donahue
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: