In 3.6, isMaster can fail because of an invalid "$clusterTime". For example:
{'operationTime': Timestamp(1512689435, 1), 'ok': 0.0, 'errmsg': 'Cache Reader No keys found for HMAC that is valid for time: { ts: Timestamp(1512689525, 0) } with id: 0', 'code': 211, 'codeName': 'KeyNotFound', '$clusterTime': {'clusterTime': Timestamp(1512689435, 1), 'signature': {'hash': b'\xeey\x10\x19\xa32/\x1fD\xaa8\x9c\x97*\xa2\xf3\xe7\x8f\xfe[', 'keyId': 6496946060282298369}}}
After isMaster fails, PyMongo sets the server type to UNKNOWN. On the next check, the Monitor will erroneously resend client metadata: https://github.com/mongodb/mongo-python-driver/blob/3.6.0/pymongo/monitor.py#L117-L119.
Sending client metadata a second time on the same connection is an error:
{'ok': 0.0, 'errmsg': 'The client metadata document may only be sent in the first isMaster', 'code': 186, 'codeName': 'ClientMetadataCannotBeMutated', 'operationTime': Timestamp(1512689445, 1), '$clusterTime': {'clusterTime': Timestamp(1512689445, 1), 'signature': {'hash': b'\xaf\xeemS\x80\xd4\\t\x84\xaf\xe03\x7f\x93\xf3S\xfc\x85E\xfc', 'keyId': 6496946060282298369}}}
The server type is reset to UNKNOWN and client metadata is resent. Repeat forever. Attempting to use the client in this state results in a "ServerSelectionTimeoutError: No servers found yet" error.
This means that a single invalid "$clusterTime" returned from the server, such as SERVER-31916, can prevent a MongoClient from connecting forever.
Related to: https://github.com/10gen/mongo-orchestration/issues/235
- related to
-
SERVER-31916 Initial request to a shardsvr mongod can return a clustertime signed with the null key
- Closed