...
I start a 4.7.0 standalone mongod like: mongod --setParameter requireApiVersion=true If I don’t include apiVersion: "1" in the getMore command, I get the error: { “ok”: 0.0, “errmsg”: “The apiVersion parameter is required, please configure your MongoClient’s API version”, “code”: 498870, “codeName”: “Location498870" } and if I do include it I get: { “ok”: 0.0, “errmsg”: “Cannot pass in API parameter field apiVersion”, “code”: 4937600, “codeName”: “Location4937600" } According to spec the server should not accept api version in getMore commands: The getMore command does not accept API parameters; cursors inherit their API parameters from the initiating command. so I expect the second error but not the first.
jesse commented on Tue, 18 May 2021 16:07:37 +0000: Update: a few months later we reversed, getMore and transaction-continuing commands now require the same API params as the cursor/transaction-initiating command. jesse commented on Wed, 2 Dec 2020 20:47:33 +0000: One more bug I found: commit/abortTransaction should ban API parameters such as apiVersion, because commit/abortTransaction are transaction-continuing commands and all transaction-continuing commands must ban API params. However, on mongos commitTransaction didn't. Fixed in a followup commit along with more testing. xgen-internal-githook commented on Wed, 2 Dec 2020 18:57:41 +0000: Author: {'name': 'A. Jesse Jiryu Davis', 'email': 'jesse@mongodb.com', 'username': 'ajdavis'} Message: SERVER-52612 Test requireApiVersion with txn commit/abort Branch: master https://github.com/mongodb/mongo/commit/7da20590e81e8e9396d4a9771698ff689c2308ef xgen-internal-githook commented on Mon, 30 Nov 2020 16:42:11 +0000: Author: {'name': 'A. Jesse Jiryu Davis', 'email': 'jesse@mongodb.com', 'username': 'ajdavis'} Message: SERVER-52612 Fix requireApiVersion for getMore and transactions Branch: master https://github.com/mongodb/mongo/commit/d498981d509964a6540e2064ea7c0bda7b5fd77b jeff.yemin commented on Wed, 25 Nov 2020 15:36:47 +0000: They do, I just recalled incorrectly that I had run the tests against a replica set. I can confirm now that most transaction spec tests fail when requireApiVersion is on. Good catch. Thanks! jesse commented on Wed, 25 Nov 2020 04:19:52 +0000: Transaction-continuing commands seem to have the same problem. Run "mongo --nodb" and paste: var rst = new ReplSetTest({nodes: 1}); rst.startSet(); rst.initiate(); primary = rst.getPrimary(); assert.commandWorked(primary.getDB("test").runCommand({insert: "collection", documents: [{}, {}, {}]})); assert.commandWorked(primary.getDB("admin").runCommand({setParameter: 1, requireApiVersion: true})); session = primary.startSession({causalConsistency: false}); sessionDb = session.getDatabase("test"); reply = sessionDb.runCommand({ find: "collection", batchSize: 1, apiVersion: "1", txnNumber: NumberLong(0), stmtId: NumberInt(0), startTransaction: true, autocommit: false }); assert.commandWorked(reply); assert.commandWorked(sessionDb.runCommand({ getMore: reply.cursor.id, collection: "collection", txnNumber: NumberLong(0), stmtId: NumberInt(1), autocommit: false })); assert.commandWorked(sessionDb.runCommand({ find: "collection", batchSize: 1, txnNumber: NumberLong(0), stmtId: NumberInt(2), autocommit: false })); The last two commands should succeed, but on master #5f72078a both fail with "The apiVersion parameter is required, please configure your MongoClient's API version". This might be a testing gap. Do the the transaction spec tests cover transaction-continuing commands? jeff.yemin commented on Tue, 24 Nov 2020 22:05:49 +0000: jesse definitely that should be tested, but iirc I ran all of our txn spec tests against a server configured this way, and they pass. jesse commented on Tue, 24 Nov 2020 21:50:53 +0000: I wonder if we made the same mistake with transaction-continuing commands. jeff.yemin commented on Wed, 4 Nov 2020 12:50:24 +0000: Simple repro in the shell: MongoDB Enterprise > db.test.insert({}) WriteResult({ "nInserted" : 1 }) MongoDB Enterprise > db.test.insert({}) WriteResult({ "nInserted" : 1 }) MongoDB Enterprise > db.test.insert({}) WriteResult({ "nInserted" : 1 }) MongoDB Enterprise > db.test.find().batchSize(1) { "_id" : ObjectId("5fa2a31be47b78dd209c5330") } Error: command failed: { "ok" : 0, "errmsg" : "Cannot pass in API parameter field apiVersion", "code" : 4937600, "codeName" : "Location4937600" } : getMore command failed: { "ok" : 0, "errmsg" : "Cannot pass in API parameter field apiVersion", "code" : 4937600, "codeName" : "Location4937600" }