I am not sure if my setup is wrong or something else but I am not able to run a simple request in a transaction. I have 3 replicas with an arbiter locally. I try to do a simple find, but I keep getting an error that operation is not supported
def find_record():
# Connect to an existing database
mongodb_client = pymongo.MongoClient("mongodb://localhost:27019/?replicaSet=dmitriy_test")
print("============== find_record =============")
claim_details = mongodb_client.local.claim_details
print(claim_details)
with mongodb_client.start_session() as session:
with session.start_transaction():
print(f"+++++++++++++++++SEARCHING FOR===={pnr_id_to_search}")
# result_from_search = claim_details.find_one({"claim_detail.assetDetails.bookingInformation.pnrId": pnr_id_to_search}, {'_id': False})
result_from_search = claim_details.find_one({"claim_detail.assetDetails.bookingInformation.pnrId": pnr_id_to_search}, {'_id': False}, session=session)
if(result_from_search is not None):
print("=========================SUCCESS===============================")
else:
print("=========================FAILURE===============================")
print(f"=== RESULT OF SEARCH ===")
print(result_from_search)
this is the error that I am getting
pymongo.errors.OperationFailure: Cannot run command against the 'local' database in a transaction., full error: {'ok': 0.0, 'errmsg': "Cannot run command against the 'local' database in a transaction.", 'code': 263, 'codeName': 'OperationNotSupportedInTransaction', '$clusterTime': {'clusterTime': Timestamp(1661955990, 1), '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}}, 'operationTime': Timestamp(1661955990, 1)}