[SERVER-40423] Misleading error message when 'count' is run as the first command in a transaction Created: 01/Apr/19  Updated: 29/Oct/23  Resolved: 09/May/19

Status: Closed
Project: Core Server
Component/s: Usability
Affects Version/s: 4.0.7
Fix Version/s: 4.0.10, 4.1.12

Type: Bug Priority: Minor - P4
Reporter: Shane Harvey Assignee: Lingzhi Deng
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Problem/Incident
Backwards Compatibility: Fully Compatible
Operating System: ALL
Steps To Reproduce:

import pymongo
 
client = pymongo.MongoClient()
try:
    with client.start_session() as s, s.start_transaction():
        client.t.t.count({}, session=s)
except pymongo.errors.OperationFailure as exc:
    print(exc.details)

Sprint: Repl 2019-05-20
Participants:

 Description   

On 4.0.6, when count is run as the first command in a transaction the error message is:

{'code': 263, 'ok': 0.0, 'codeName': 'OperationNotSupportedInTransaction',
 'errmsg': "Cannot run 'count' in a multi-document transaction. Please see http://dochub.mongodb.org/core/transaction-count for a recommended alternative."}

On 4.0.7, when count is run as the first command in a transaction the error message is:

{'code': 263, 'ok': 0.0, 'codeName': 'OperationNotSupportedInTransaction',
 'errmsg': 'Command is not supported as the first command in a transaction'}

The new error message makes it seem like count might be supported as the second (or third, etc..) command in a transaction. However, when running count as the second command the error message is again:

{'code': 263, 'ok': 0.0, 'codeName': 'OperationNotSupportedInTransaction',
 'errmsg': "Cannot run 'count' in a multi-document transaction. Please see http://dochub.mongodb.org/core/transaction-count for a recommended alternative."}



 Comments   
Comment by Githook User [ 09/May/19 ]

Author:

{'name': 'Lingzhi Deng', 'username': 'ldennis', 'email': 'lingzhi.deng@mongodb.com'}

Message: SERVER-40423: Move command validation from session to CommandHelpers

(cherry picked from commit 5674fa1f3087f65ea326b33f5b81647d4dcfb8d6 and 52b2cc0886cdb992e2491067bdc029301d5bb6af)
Branch: v4.0
https://github.com/mongodb/mongo/commit/8845fb09ae597dc3eb4cdf85a2c22a9ad31f11f2

Comment by Githook User [ 09/May/19 ]

Author:

{'name': 'Lingzhi Deng', 'username': 'ldennis', 'email': 'lingzhi.deng@mongodb.com'}

Message: SERVER-40423: Validate error messages in test commands_not_allowed_in_txn.js
Branch: master
https://github.com/mongodb/mongo/commit/399fad74e2f313b87886c9511a66ae2bab102a24

Generated at Thu Feb 08 04:54:56 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.