Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Swap NotMasterError with NotPrimaryError. #11016

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ pep8~=1.7.1 # wmagent-devtools
psutil~=5.8.0 # wmagent,wmagent-devtools,reqmgr2,reqmon,global-workqueue
pycurl~=7.43.0.6 # wmagent,reqmgr2,reqmon,global-workqueue,reqmgr2ms
pylint~=2.7.0 # wmagent-devtools
pymongo~=3.10.1 # wmagent-devtools,reqmgr2ms
pymongo~=4.0.1 # wmagent-devtools,reqmgr2ms
pyOpenSSL~=18.0.0 # wmagent
pyzmq~=19.0.2 # wmagent
retry~=0.9.2 # wmagent,wmagent-devtools,reqmgr2,reqmon,global-workqueue,reqmgr2ms
Expand Down
2 changes: 1 addition & 1 deletion src/python/WMCore/Database/MongoDB.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def _dbTest(self, db):
raise ex

# Test for database existence
if db not in self.client.database_names():
if db not in self.client.list_database_names():
msg = "Missing MongoDB databases: %s" % db
self.logger.error(msg)
raise errors.InvalidName
Expand Down
6 changes: 3 additions & 3 deletions src/python/WMCore/MicroService/MSUnmerged/MSUnmerged.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
gfal2 = None

from pymongo import IndexModel
from pymongo.errors import NotMasterError
from pymongo.errors import NotPrimaryError

# WMCore modules
from WMCore.MicroService.DataStructs.DefaultStructs import UNMERGED_REPORT
Expand Down Expand Up @@ -517,7 +517,7 @@ def consRecordAge(self, rse):
self.logger.info(msg)
try:
rse.resetRSE(self.msUnmergedColl, keepTimestamps=True, retryCount=self.msConfig['mongoDBRetryCount'])
except NotMasterError:
except NotPrimaryError:
msg = "Could not reset RSE to MongoDB for the maximum of %s mongoDBRetryCounts configured." % self.msConfig['mongoDBRetryCount']
msg += "Giving up now. The whole cleanup process will be retried for this RSE on the next run."
msg += "Duplicate deletion retries may cause error messages from false positives and wrong counters during next polling cycle."
Expand Down Expand Up @@ -803,7 +803,7 @@ def uploadRSEToMongoDB(self, rse, fullRSEToDB=False, overwrite=True):
try:
self.logger.info("RSE: %s Writing rse data to MongoDB." % rse['name'])
rse.writeRSEToMongoDB(self.msUnmergedColl, fullRSEToDB=fullRSEToDB, overwrite=overwrite, retryCount=self.msConfig['mongoDBRetryCount'])
except NotMasterError:
except NotPrimaryError:
msg = "Could not write RSE to MongoDB for the maximum of %s mongoDBRetryCounts configured." % self.msConfig['mongoDBRetryCount']
msg += "Giving up now. The whole cleanup process will be retried for this RSE on the next run."
msg += "Duplicate deletion retries may cause error messages from false positives and wrong counters during next polling cycle."
Expand Down
10 changes: 5 additions & 5 deletions src/python/WMCore/MicroService/MSUnmerged/MSUnmergedRSE.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Description: Provides a document Template for the MSUnmerged MicroServices
"""

from pymongo.errors import NotMasterError
from pymongo.errors import NotPrimaryError
# from pymongo.results import results as MongoResults


Expand Down Expand Up @@ -130,7 +130,7 @@ def writeRSEToMongoDB(self, collection, fullRSEToDB=False, overwrite=False, retr
the database is about to be completely replaced or just
fields update is to happen.
:param retryCount: The number of retries for the write operation if failed due to
`NotMasterError. Possible values:
`NotPrimaryError. Possible values:
0 - the write operation will be tried exactly once and no retries will happen
> 0 - the write operation will be retried this number of times
< 0 - the write operation will never be tried
Expand Down Expand Up @@ -166,7 +166,7 @@ def writeRSEToMongoDB(self, collection, fullRSEToDB=False, overwrite=False, retr
updateFields[field] = self[field]

updateOps = {'$set': updateFields}
# NOTE: NotMasterError is a recoverable error, caused by a session to a
# NOTE: NotPrimaryError is a recoverable error, caused by a session to a
# non primary backend part of a replicaset.
while retryCount >= 0:
try:
Expand All @@ -175,7 +175,7 @@ def writeRSEToMongoDB(self, collection, fullRSEToDB=False, overwrite=False, retr
else:
result = collection.update_one(self.mongoFilter, updateOps, upsert=True)
break
except NotMasterError:
except NotPrimaryError:
if retryCount:
# msg = "Failed write operation to MongoDB. %s retries left."
# self.logger.warning(msg, retryCount)
Expand All @@ -198,7 +198,7 @@ def resetRSE(self, collection, keepTimestamps=False, keepCounters=False, retryCo
document to MongoDB
:param keepTimestamps: Bool flag to keep the timestamps
:param keepCounters: Bool flag to keep the counters
:param retryCount: The number of retries for the write operation if failed due to `NotMasterError.
:param retryCount: The number of retries for the write operation if failed due to `NotPrimaryError.
:return: True if operation succeeded.
"""
resetDoc = self.defaultDoc()
Expand Down