Files
mongo/buildscripts/resmokelib/utils/sharded_cluster_util.py
Abdul Qadeer 187accf486 SERVER-98973 Add retries for refreshLogicalSessionCacheNow (#30796)
GitOrigin-RevId: 9e1e3ad8407738f5b78dce2a8047462b9ddc87a0
2025-01-10 19:35:32 +00:00

17 lines
591 B
Python

import pymongo.errors
def refresh_logical_session_cache_with_retry(mongo_client):
retry_count = 10
while retry_count > 0:
try:
mongo_client.admin.command({"refreshLogicalSessionCacheNow": 1})
break
except pymongo.errors.OperationFailure as err:
if err.code == 70: # ShardNotFound
time.sleep(0.5) # Wait a little bit before trying again.
retry_count -= 1
raise err
if retry_count == 0:
raise Exception("Unable to refresh the logical session cache for the config server.")