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

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor - P4
    • Resolution: Fixed
    • Affects Version/s: 4.0.7
    • Fix Version/s: 4.0.10, 4.1.12
    • Component/s: Usability
    • Labels:
      None
    • Backwards Compatibility:
      Fully Compatible
    • Operating System:
      ALL
    • Steps To Reproduce:
      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)
    • Sprint:
      Repl 2019-05-20

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

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: