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

CommandHelpers::canUseTransactions() doesn't guard against uninitialized FCV

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 4.3.4
    • Affects Version/s: None
    • Component/s: Replication
    • Labels:
      None
    • Fully Compatible
    • ALL
    • Execution Team 2020-02-24

      I hit this by fluke while testing unrelated changes. I happened to be running jstests/noPassthrough/router_transactions_metrics.js, but I suspect other places can cause it. No repro, but the backtrace shows the problem clearly enough.

      [js_test:router_transactions_metrics] 2020-02-06T23:10:09.352+1100 d20021| 2020-02-06T23:10:09.352+1100 I  NETWORK  [conn2] received client metadata from 127.0.0.1:41438 conn2: { driver: { name: "NetworkInterfaceTL", version: "0.0.0" }, os: { type: "Linux", name: "Ubuntu", architecture: "x86_64", version: "18.04" } }
      [js_test:router_transactions_metrics] 2020-02-06T23:10:09.353+1100 c20022| 2020-02-06T23:10:09.352+1100 I  NETWORK  [listener] connection accepted from 127.0.0.1:43358 #3 (3 connections now open)
      [js_test:router_transactions_metrics] 2020-02-06T23:10:09.353+1100 d20021| 2020-02-06T23:10:09.352+1100 F  -        [conn2] Invariant failure isVersionInitialized() src/mongo/db/server_options.h 219
      [js_test:router_transactions_metrics] 2020-02-06T23:10:09.353+1100 d20021| 2020-02-06T23:10:09.352+1100 F  -        [conn2]
      [js_test:router_transactions_metrics] 2020-02-06T23:10:09.353+1100 d20021|
      [js_test:router_transactions_metrics] 2020-02-06T23:10:09.353+1100 d20021| ***aborting after invariant() failure
      ...
      [js_test:router_transactions_metrics] 2020-02-06T23:10:09.590+1100 2020-02-06T23:10:09.590+1100 I  NETWORK  [js] DBClientConnection failed to receive message from 127.0.0.1:20021 - HostUnreachable: Connection closed by peer
      [js_test:router_transactions_metrics] 2020-02-06T23:10:09.591+1100 2020-02-06T23:10:09.591+1100 E  QUERY    [js] uncaught exception: Error: error doing query: failed: network error while attempting to run command 'serverStatus' on host '127.0.0.1:20021'
      :
      [js_test:router_transactions_metrics] 2020-02-06T23:10:09.591+1100 DB.prototype.runCommand@src/mongo/shell/db.js:169:19
      [js_test:router_transactions_metrics] 2020-02-06T23:10:09.591+1100 Mongo.prototype.adminCommand@src/mongo/shell/mongo.js:149:12
      [js_test:router_transactions_metrics] 2020-02-06T23:10:09.591+1100 _isRunningWithoutJournaling/result<@src/mongo/shell/replsettest.js:182:53
      [js_test:router_transactions_metrics] 2020-02-06T23:10:09.591+1100 asCluster@src/mongo/shell/replsettest.js:173:20
      [js_test:router_transactions_metrics] 2020-02-06T23:10:09.591+1100 _isRunningWithoutJournaling@src/mongo/shell/replsettest.js:181:22
      [js_test:router_transactions_metrics] 2020-02-06T23:10:09.591+1100 ReplSetTest/this._updateConfigIfNotDurable@src/mongo/shell/replsettest.js:1060:13
      [js_test:router_transactions_metrics] 2020-02-06T23:10:09.591+1100 ReplSetTest/this._setDefaultConfigOptions@src/mongo/shell/replsettest.js:1069:9
      [js_test:router_transactions_metrics] 2020-02-06T23:10:09.591+1100 ReplSetTest/this.initiateWithAnyNodeAsPrimary@src/mongo/shell/replsettest.js:1124:9
      [js_test:router_transactions_metrics] 2020-02-06T23:10:09.591+1100 ShardingTest@src/mongo/shell/shardingtest.js:1463:13
      [js_test:router_transactions_metrics] 2020-02-06T23:10:09.592+1100 @jstests/noPassthrough/router_transactions_metrics.js:199:12
      [js_test:router_transactions_metrics] 2020-02-06T23:10:09.592+1100 @jstests/noPassthrough/router_transactions_metrics.js:4:2
      [js_test:router_transactions_metrics] 2020-02-06T23:10:09.592+1100 2020-02-06T23:10:09.591+1100 F  -        [main] failed to load: jstests/noPassthrough/router_transactions_metrics.js
      [js_test:router_transactions_metrics] 2020-02-06T23:10:09.592+1100 2020-02-06T23:10:09.591+1100 E  -        [main] exiting with code -3
      

      The line numbers in the backtrace are a bit off because of my local changes.

      ...
      .../src/mongo/util/assert_util.cpp:106:15: mongo::invariantFailed(char const*, char const*, unsigned int)
      .../src/mongo/util/invariant.h:69:33: void mongo::invariantWithLocation<bool>(bool const&, char const*, char const*, unsigned int)
      .../src/mongo/db/server_options.h:219:13: mongo::ServerGlobalParams::FeatureCompatibility::getVersion() const
      .../src/mongo/db/commands.cpp:461:60: mongo::CommandHelpers::canUseTransactions(mongo::NamespaceString const&, mongo::StringData, bool) (.cold.714)
      .../src/mongo/db/transaction_validation.cpp:90:43: mongo::validateSessionOptions(mongo::OperationSessionInfoFromClient const&, mongo::StringData, mongo::NamespaceString const&, bool)
      .../src/mongo/db/service_entry_point_common.cpp:834:31: execCommandDatabase
      ...
      

      But anyway, this is the problem and its fix, introduced on cb293d4de806 on SERVER-44139:

      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
      diff --git a/src/mongo/db/commands.cpp b/src/mongo/db/commands.cpp
      index 338b427e024..9117b157891 100644
      --- a/src/mongo/db/commands.cpp
      +++ b/src/mongo/db/commands.cpp
      @@ -455,7 +455,8 @@ void CommandHelpers::canUseTransactions(const NamespaceString& nss,
           auto inTxnWhitelist = txnCmdWhitelist.find(cmdName) != txnCmdWhitelist.cend();
           auto inTxnWhitelistFCV44 = txnCmdWhitelistFCV44.find(cmdName) != txnCmdWhitelistFCV44.cend();
           auto isFullyUpgradedTo44 =
      -        (serverGlobalParams.featureCompatibility.getVersion() ==
      +        (serverGlobalParams.featureCompatibility.isVersionInitialized() &&
      +         serverGlobalParams.featureCompatibility.getVersion() ==
                ServerGlobalParams::FeatureCompatibility::Version::kFullyUpgradedTo44);
      
           uassert(ErrorCodes::OperationNotSupportedInTransaction,
      

            Assignee:
            maria.vankeulen@mongodb.com Maria van Keulen
            Reporter:
            kevin.pulo@mongodb.com Kevin Pulo
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: