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

Make VectorClock::Component protected

    • Fully Compatible

      Instead provide an accessor for each Component in VectorTime. This will make external usage less clunky:

      Unable to find source-code formatter for language: diff. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
       auto now = VectorClock::get(opCtx)->getTime();
      -auto clusterTime = now[VectorClock::Component::ClusterTime];
      +auto clusterTime = now.clusterTime();

      The accessors can also use an lvalue ref-qualifier to ensure that the current time is properly stored somewhere, ie. prevent the anti-pattern of:

      auto clusterTime = VectorClock::get(opCtx)->getTime().clusterTime();
      auto configTime = VectorClock::get(opCtx)->getTime().configTime();
      // Cannot assume that configTime <= clusterTime.

      which is potentially incorrect, relative to:

      auto now = VectorClock::get(opCtx)->getTime();
      auto clusterTime = now.clusterTime();
      auto configTime = now.configTime();
      // Must be true that configTime <= clusterTime.

      The advanceTime_forTest will also need some consideration, likely by returning a temporary object that provides a mutator for each Component.

            pierlauro.sciarelli@mongodb.com Pierlauro Sciarelli
            kevin.pulo@mongodb.com Kevin Pulo
            0 Vote for this issue
            3 Start watching this issue