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

Misleading error message when 'count' is run as the first command in a transaction

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Minor - P4 Minor - P4
    • 4.0.10, 4.1.12
    • Affects Version/s: 4.0.7
    • Component/s: Usability
    • None
    • Fully Compatible
    • ALL
    • Hide
      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)
      
      Show
      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)
    • Repl 2019-05-20

      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."}
      

            Assignee:
            lingzhi.deng@mongodb.com Lingzhi Deng
            Reporter:
            shane.harvey@mongodb.com Shane Harvey
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: