Ctrl-C send update no delay update after replica set failover uses txnNumber = 1 which is the txnNumber that was used for the previous insert command. reply shows as a successful update with upsert. upsert was false in the update request and returns a different _id than what was requested to update. No update to the collection was done. ~/stuff]$ python pymongo_test.py Command drop with request id 287183967 started on server 27019 command SON([('drop', 'update_test'), ('writeConcern', {'w': 'majority', 'j': True}), ('lsid', {'id': Binary(b'\x9b\x1f\xd7\x1ekr@G\xaa\x02\xc6\xb4\x18\xe2*\x88', 4)}), ('$clusterTime', {'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}, 'clusterTime': Timestamp(1538691172, 1)}), ('$db', 'py_test'), ('$readPreference', {'mode': 'primary'})]) Command drop with request id 287183967 on server 27019 succeeded in 27360 microseconds reply {'ok': 1.0, 'ns': 'py_test.update_test', 'operationTime': Timestamp(1538691179, 1), '$clusterTime': {'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}, 'clusterTime': Timestamp(1538691179, 1)}, 'nIndexesWas': 1} Command insert with request id 84900699 started on server 27019 command SON([('insert', 'update_test'), ('ordered', True), ('writeConcern', {'w': 'majority', 'j': True}), ('lsid', {'id': Binary(b'\x9b\x1f\xd7\x1ekr@G\xaa\x02\xc6\xb4\x18\xe2*\x88', 4)}), ('txnNumber', 1), ('$clusterTime', {'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}, 'clusterTime': Timestamp(1538691179, 1)}), ('$db', 'py_test'), ('documents', [{'sample': 'text', '_id': 1}, {'sample': 'some stuff', '_id': 2}])]) Command insert with request id 84900699 on server 27019 succeeded in 62771 microseconds reply {'opTime': {'ts': Timestamp(1538691179, 4), 't': 195}, 'electionId': ObjectId('7fffffff00000000000000c3'), 'n': 2, 'ok': 1.0, '$clusterTime': {'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}, 'clusterTime': Timestamp(1538691179, 4)}, 'operationTime': Timestamp(1538691179, 4)} Shut down the Primary member, Ready? (y/n) y Command update with request id 1293275138 started on server 27018 command SON([('update', 'update_test'), ('ordered', True), ('writeConcern', {'w': 'majority', 'j': True}), ('lsid', {'id': Binary(b'\x9b\x1f\xd7\x1ekr@G\xaa\x02\xc6\xb4\x18\xe2*\x88', 4)}), ('txnNumber', 1), ('$clusterTime', {'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}, 'clusterTime': Timestamp(1538691211, 1)}), ('$db', 'py_test'), ('$readPreference', {'mode': 'primary'}), ('updates', [SON([('q', {'_id': 2}), ('u', {'$set': {'test_key': 'test_value'}}), ('multi', False), ('upsert', False)])])]) Command update with request id 1293275138 on server 27018 succeeded in 1186151 microseconds reply {'upserted': [{'_id': 1, 'index': 0}], 'opTime': {'ts': Timestamp(1538691211, 1), 't': 196}, 'n': 1, 'ok': 1.0, 'operationTime': Timestamp(1538691211, 1), 'nModified': 0, '$clusterTime': {'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}, 'clusterTime': Timestamp(1538691211, 1)}, 'electionId': ObjectId('7fffffff00000000000000c4')} Ctrl-c send update after ~5 secs Works as expected. ~/stuff]$ python pymongo_test.py Command drop with request id 826424956 started on server 27017 command SON([('drop', 'update_test'), ('writeConcern', {'j': True, 'w': 'majority'}), ('lsid', {'id': Binary(b'sq\xdf4\x1cdK\xae\x9c\x12\xb7xFw\xcc\xb8', 4)}), ('$clusterTime', {'clusterTime': Timestamp(1538691796, 1), 'signature': {'keyId': 0, 'hash': b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'}}), ('$db', 'py_test'), ('$readPreference', {'mode': 'primary'})]) Command drop with request id 826424956 on server 27017 succeeded in 31801 microseconds reply {'operationTime': Timestamp(1538691802, 1), 'ok': 1.0, 'nIndexesWas': 1, 'ns': 'py_test.update_test', '$clusterTime': {'clusterTime': Timestamp(1538691802, 1), 'signature': {'keyId': 0, 'hash': b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'}}} Command insert with request id 746976870 started on server 27017 command SON([('insert', 'update_test'), ('ordered', True), ('writeConcern', {'j': True, 'w': 'majority'}), ('lsid', {'id': Binary(b'sq\xdf4\x1cdK\xae\x9c\x12\xb7xFw\xcc\xb8', 4)}), ('txnNumber', 1), ('$clusterTime', {'clusterTime': Timestamp(1538691802, 1), 'signature': {'keyId': 0, 'hash': b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'}}), ('$db', 'py_test'), ('documents', [{'sample': 'text', '_id': 1}, {'sample': 'some stuff', '_id': 2}])]) Command insert with request id 746976870 on server 27017 succeeded in 68658 microseconds reply {'opTime': {'t': 197, 'ts': Timestamp(1538691802, 4)}, 'n': 2, 'operationTime': Timestamp(1538691802, 4), 'ok': 1.0, 'electionId': ObjectId('7fffffff00000000000000c5'), '$clusterTime': {'clusterTime': Timestamp(1538691802, 4), 'signature': {'keyId': 0, 'hash': b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'}}} Shut down the Primary member, Ready? (y/n) y Command update with request id 1727176199 started on server 27018 command SON([('update', 'update_test'), ('ordered', True), ('writeConcern', {'j': True, 'w': 'majority'}), ('lsid', {'id': Binary(b'sq\xdf4\x1cdK\xae\x9c\x12\xb7xFw\xcc\xb8', 4)}), ('txnNumber', 2), ('$clusterTime', {'clusterTime': Timestamp(1538691828, 1), 'signature': {'keyId': 0, 'hash': b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'}}), ('$db', 'py_test'), ('$readPreference', {'mode': 'primary'}), ('updates', [SON([('q', {'_id': 2}), ('u', {'$set': {'test_key': 'test_value'}}), ('multi', False), ('upsert', False)])])]) Command update with request id 1727176199 on server 27018 succeeded in 5037253 microseconds reply {'opTime': {'t': 198, 'ts': Timestamp(1538691829, 1)}, 'n': 1, 'operationTime': Timestamp(1538691829, 1), 'nModified': 1, 'ok': 1.0, 'electionId': ObjectId('7fffffff00000000000000c6'), '$clusterTime': {'clusterTime': Timestamp(1538691829, 1), 'signature': {'keyId': 0, 'hash': b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'}}} stepdown primary send update immediately Works as expected. ~/stuff]$ python pymongo_test.py Command drop with request id 1985832378 started on server 27019 command SON([('drop', 'update_test'), ('writeConcern', {'w': 'majority', 'j': True}), ('lsid', {'id': Binary(b'\xd7\x17\x90\x05\xf9\xa4@\x0e\x92\x82\xb3\xb4X\xe1\x06\xdd', 4)}), ('$clusterTime', {'clusterTime': Timestamp(1538692112, 1), 'signature': {'keyId': 0, 'hash': b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'}}), ('$db', 'py_test'), ('$readPreference', {'mode': 'primary'})]) Command drop with request id 1985832378 on server 27019 succeeded in 28575 microseconds reply {'nIndexesWas': 1, 'operationTime': Timestamp(1538692116, 1), 'ns': 'py_test.update_test', '$clusterTime': {'clusterTime': Timestamp(1538692116, 1), 'signature': {'keyId': 0, 'hash': b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'}}, 'ok': 1.0} Command insert with request id 1540147905 started on server 27019 command SON([('insert', 'update_test'), ('ordered', True), ('writeConcern', {'w': 'majority', 'j': True}), ('lsid', {'id': Binary(b'\xd7\x17\x90\x05\xf9\xa4@\x0e\x92\x82\xb3\xb4X\xe1\x06\xdd', 4)}), ('txnNumber', 1), ('$clusterTime', {'clusterTime': Timestamp(1538692116, 1), 'signature': {'keyId': 0, 'hash': b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'}}), ('$db', 'py_test'), ('documents', [{'_id': 1, 'sample': 'text'}, {'_id': 2, 'sample': 'some stuff'}])]) Command insert with request id 1540147905 on server 27019 succeeded in 80161 microseconds reply {'n': 2, 'electionId': ObjectId('7fffffff00000000000000c7'), 'opTime': {'t': 199, 'ts': Timestamp(1538692116, 4)}, 'operationTime': Timestamp(1538692116, 4), '$clusterTime': {'clusterTime': Timestamp(1538692116, 4), 'signature': {'keyId': 0, 'hash': b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'}}, 'ok': 1.0} Shut down the Primary member, Ready? (y/n) y Command update with request id 848254954 started on server 27019 command SON([('update', 'update_test'), ('ordered', True), ('writeConcern', {'w': 'majority', 'j': True}), ('lsid', {'id': Binary(b'\xd7\x17\x90\x05\xf9\xa4@\x0e\x92\x82\xb3\xb4X\xe1\x06\xdd', 4)}), ('txnNumber', 2), ('$clusterTime', {'clusterTime': Timestamp(1538692116, 4), 'signature': {'keyId': 0, 'hash': b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'}}), ('$db', 'py_test'), ('$readPreference', {'mode': 'primary'}), ('updates', [SON([('q', {'_id': 2}), ('u', {'$set': {'test_key': 'test_value'}}), ('multi', False), ('upsert', False)])])]) Command update with request id 848254954 on server 27019 failed in 1262 microseconds reply {'errmsg': 'not master', 'code': 10107, 'operationTime': Timestamp(1538692116, 4), 'ok': 0.0, '$clusterTime': {'clusterTime': Timestamp(1538692116, 4), 'signature': {'keyId': 0, 'hash': b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'}}, 'codeName': 'NotMaster'} Command update with request id 474372657 started on server 27017 command SON([('update', 'update_test'), ('ordered', True), ('writeConcern', {'w': 'majority', 'j': True}), ('lsid', {'id': Binary(b'\xd7\x17\x90\x05\xf9\xa4@\x0e\x92\x82\xb3\xb4X\xe1\x06\xdd', 4)}), ('txnNumber', 2), ('$clusterTime', {'clusterTime': Timestamp(1538692135, 1), 'signature': {'keyId': 0, 'hash': b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'}}), ('$db', 'py_test'), ('$readPreference', {'mode': 'primary'}), ('updates', [SON([('q', {'_id': 2}), ('u', {'$set': {'test_key': 'test_value'}}), ('multi', False), ('upsert', False)])])]) Command update with request id 474372657 on server 27017 succeeded in 138370 microseconds reply {'n': 1, 'electionId': ObjectId('7fffffff00000000000000c8'), 'nModified': 1, 'opTime': {'t': 200, 'ts': Timestamp(1538692136, 1)}, 'operationTime': Timestamp(1538692136, 1), '$clusterTime': {'clusterTime': Timestamp(1538692136, 1), 'signature': {'keyId': 0, 'hash': b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'}}, 'ok': 1.0}