-
Type: Bug
-
Resolution: Duplicate
-
Priority: Major - P3
-
None
-
Affects Version/s: 4.1.7
-
Component/s: Sharding
-
None
-
Sharding
-
ALL
-
Sharding 2019-02-25
Found by a python test in PYTHON-1725.
Concurrently inserting into a collection when the database does not exist often fails on mongos 4.1.7 with "unable to initialize targeter for write op for collection auth_test_46.test :: caused by :: Database auth_test_46 not found :: caused by :: database auth_test_46 not found"
Here's a simple python repro: repro-1725.py. First start a sharded cluster (with or without auth) and then run the script:
$ python3.7 repro-1725.py Exception in thread Thread-551: Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/threading.py", line 917, in _bootstrap_inner self.run() File "repro-1725.py", line 33, in run self.coll.insert_one({'num': i}) File "/Users/shane/git/mongo-python-driver/pymongo/collection.py", line 694, in insert_one session=session), File "/Users/shane/git/mongo-python-driver/pymongo/collection.py", line 608, in _insert bypass_doc_val, session) File "/Users/shane/git/mongo-python-driver/pymongo/collection.py", line 596, in _insert_one acknowledged, _insert_command, session) File "/Users/shane/git/mongo-python-driver/pymongo/mongo_client.py", line 1329, in _retryable_write return self._retry_with_session(retryable, func, s, None) File "/Users/shane/git/mongo-python-driver/pymongo/mongo_client.py", line 1282, in _retry_with_session return func(session, sock_info, retryable) File "/Users/shane/git/mongo-python-driver/pymongo/collection.py", line 591, in _insert_command retryable_write=retryable_write) File "/Users/shane/git/mongo-python-driver/pymongo/pool.py", line 579, in command unacknowledged=unacknowledged) File "/Users/shane/git/mongo-python-driver/pymongo/network.py", line 150, in command parse_write_concern_error=parse_write_concern_error) File "/Users/shane/git/mongo-python-driver/pymongo/helpers.py", line 155, in _check_command_response raise OperationFailure(msg % errmsg, code, response) pymongo.errors.OperationFailure: unable to initialize targeter for write op for collection db_11.test :: caused by :: Database db_11 not found :: caused by :: database db_11 not found Traceback (most recent call last): File "repro-1725.py", line 62, in <module> repro() File "repro-1725.py", line 56, in repro assert t.success AssertionError
The failing command and response is:
23 Jan 19 16:23 -0800 (Connection: 104:657430200) op_msg insert db_2 Request:{"sections":[{"payload":{"$clusterTime":{"clusterTime":{"$timestamp":{"t":1548289382,"i":191}},"signature":{"hash":{"$binary":"AI87y83wEE6V+ELmJaUtbleLSHY=","$type":"00"},"keyId":{"$numberLong":"6649842944649986060"}}},"$db":"db_2","$readPreference":{"mode":"primary"},"insert":"test","lsid":{"id":{"$binary":"srMbo3+9SlS8J+jwS2CMlg==","$type":"04"}},"ordered":true},"payloadType":0},{"payload":{"documents":[{"_id":{"$oid":"5c49056618a944e27153a1f5"},"num":0}],"identifier":"documents","size":45},"payloadType":1}]} 23 Jan 19 16:23 -0800 (Connection: 104:657430200) +118.636ms op_msg reply Response:{"sections":[{"payload":{"$clusterTime":{"clusterTime":{"$timestamp":{"t":1548289382,"i":196}},"signature":{"hash":{"$binary":"AI87y83wEE6V+ELmJaUtbleLSHY=","$type":"00"},"keyId":{"$numberLong":"6649842944649986060"}}},"code":26,"codeName":"NamespaceNotFound","errmsg":"unable to initialize targeter for write op for collection db_2.test :: caused by :: Database db_2 not found :: caused by :: database db_2 not found","ok":0.0,"operationTime":{"$timestamp":{"t":1548289382,"i":194}}},"payloadType":0}]}
Edit: This is reproducible with and without auth enabled.
- causes
-
PYTHON-1725 Test failure - test_threads.TestThreadsAuth.test_auto_auth_login
- Closed
- duplicates
-
SERVER-17397 Dropping a Database or Collection in a Sharded Cluster may not fully succeed
- Closed