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

    • Bug
    • Status: Closed
    • Minor - P4
    • Resolution: Fixed
    • 4.0.7
    • 4.0.10, 4.1.12
    • 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

    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

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

            Dates

              Created:
              Updated:
              Resolved: