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

Transaction fails with StaleConfig inserting into newly created unsharded collection on v4.5.0-920-ge5e378e

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 4.7.0
    • Affects Version/s: None
    • Component/s: None
    • Fully Compatible
    • Sharding 2020-05-04, Sharding 2020-05-18, Sharding 2020-06-01
    • 14

      A transaction that creates a new unsharded collection will fail when attempting to insert data:

      >>> with client.start_session() as s, s.start_transaction():
      ...     client.db.command('create', 'test', session=s)   # Succeeds
      ...     client.db.test.insert_one({}, session=s)   # Fails
      ...
      {'ok': 1.0, 'operationTime': Timestamp(1588016473, 4), '$clusterTime': {'clusterTime': Timestamp(1588016473, 4), 'signature': {'hash': b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', 'keyId': 0}}, 'recoveryToken': {'recoveryShardId': 'demo-set-0'}}
      Traceback (most recent call last):
        File "<stdin>", line 3, in <module>
        File "/Users/shane/git/mongo-python-driver/pymongo/collection.py", line 694, in insert_one
          self._insert(document,
        File "/Users/shane/git/mongo-python-driver/pymongo/collection.py", line 609, in _insert
          return self._insert_one(
        File "/Users/shane/git/mongo-python-driver/pymongo/collection.py", line 598, in _insert_one
          self.__database.client._retryable_write(
        File "/Users/shane/git/mongo-python-driver/pymongo/mongo_client.py", line 1500, in _retryable_write
          return self._retry_with_session(retryable, func, s, None)
        File "/Users/shane/git/mongo-python-driver/pymongo/mongo_client.py", line 1393, in _retry_with_session
          return func(session, sock_info, retryable)
        File "/Users/shane/git/mongo-python-driver/pymongo/collection.py", line 586, in _insert_command
          result = sock_info.command(
        File "/Users/shane/git/mongo-python-driver/pymongo/pool.py", line 594, in command
          return command(self.sock, dbname, spec, slave_ok,
        File "/Users/shane/git/mongo-python-driver/pymongo/network.py", line 150, in command
          helpers._check_command_response(
        File "/Users/shane/git/mongo-python-driver/pymongo/helpers.py", line 161, in _check_command_response
          raise OperationFailure(msg % errmsg, code, response)
      pymongo.errors.OperationFailure: Transaction 7dc4b97f-00da-46b4-8658-6f647acf6b78:1 was aborted on statement 1 due to: an error from cluster data placement change :: caused by :: Encountered error from localhost:27019 during a transaction :: caused by :: sharding status of collection db.test is not currently known and needs to be recovered
      

      This reproduces consistently on 4.5-latest, even after the fix in SERVER-47472:

      mongodb-macos-x86_64-enterprise-4.5.0-920-ge5e378e/bin/mongos --version
      mongos version v4.5.0-920-ge5e378e
      Build Info:{"version":"4.5.0-920-ge5e378e"
       ,"gitVersion":"e5e378e2d10eccf4eb3aeda9b621e41854c24a5c"
       ,"modules":["enterprise"]
       ,"allocator":"system"
       ,"environment":{"distarch":"x86_64"
         ,"target_arch":"x86_64"}}
      

            Assignee:
            marcos.grillo@mongodb.com Marcos José Grillo Ramirez
            Reporter:
            shane.harvey@mongodb.com Shane Harvey
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved: