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

NotPrimaryError handling fix #12

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

v1k1nghawk
Copy link

@v1k1nghawk v1k1nghawk commented Oct 9, 2022

Setup:
Improperly configured replica set on a server side (server's rs.status() output is "MongoServerError: Our replica set config is invalid or we are not a member of it", client will get NotPrimaryError).
MongoDB - 5.0.9
Mongosh - 1.5.0
Server OS, Client OS - Ubuntu 20.04.4 LTS (GNU/Linux 5.15.0-1020-aws x86_64)

Client's command:

./tpcc.py --config mconfig --warehouses 1000 --clients=100 --no-load --debug mongodb

Crash's output:

"Traceback (most recent call last): File "./tpcc.py", line 244, in driver.loadConfig(config) File "/home/ubuntu/TPCC_1/py-tpcc/pytpcc/drivers/mongodbdriver.py", line 346, in loadConfig exc.code, exc.details, display_uri) UnboundLocalError: local variable 'exc' referenced before assignment"

Proper variable introduced

Subsequent errors have been fixed:

"2022-10-07 15:58:23,821 [:283] INFO : Final Results 2022-10-07 15:58:23,821 [:284] INFO : Threads: 100 Traceback (most recent call last): File "./tpcc.py", line 285, in logging.info(results.show(load_time, driver, args['clients'])) File "/home/ubuntu/TPCC_1/py-tpcc/pytpcc/util/results.py", line 241, in show ("off", "on")[driver.batch_writes], total_retries, str(100.0*total_retries/total_cnt)[:5], ZeroDivisionError: float division by zero"

ZeroDivisionError, raised by total_retries/0, handled

"File "/home/ubuntu/.local/lib/python2.7/site-packages/pymongo/helpers.py", line 154, in _check_command_response raise NotPrimaryError(errmsg, response) pymongo.errors.NotPrimaryError: not primary, full error: {u'topologyVersion': {u'processId': ObjectId('634007d510aebb79c4e997b5'), u'counter': 1L}, u'code': 10107, u'ok': 0.0, u'codeName': u'NotWritablePrimary', u'errmsg': u'not primary'}

Traceback (most recent call last): File "./tpcc.py", line 288, in logging.info(results.show(load_time, driver, args['clients'])) File "/home/ubuntu/TPCC_1/py-tpcc/pytpcc/util/results.py", line 251, in show driver.save_result(result_doc) File "/home/ubuntu/TPCC_1/py-tpcc/pytpcc/drivers/mongodbdriver.py", line 1152, in save_result self.client.test.results.insert_one(self.result_doc) File "/home/ubuntu/.local/lib/python2.7/site-packages/pymongo/collection.py", line 708, in insert_one session=session), File "/home/ubuntu/.local/lib/python2.7/site-packages/pymongo/collection.py", line 622, in _insert bypass_doc_val, session) File "/home/ubuntu/.local/lib/python2.7/site-packages/pymongo/collection.py", line 610, in _insert_one acknowledged, _insert_command, session) File "/home/ubuntu/.local/lib/python2.7/site-packages/pymongo/mongo_client.py", line 1552, in _retryable_write return self._retry_with_session(retryable, func, s, None) File "/home/ubuntu/.local/lib/python2.7/site-packages/pymongo/mongo_client.py", line 1438, in _retry_with_session return self._retry_internal(retryable, func, session, bulk) File "/home/ubuntu/.local/lib/python2.7/site-packages/pymongo/mongo_client.py", line 1470, in _retry_internal return func(session, sock_info, retryable) File "/home/ubuntu/.local/lib/python2.7/site-packages/pymongo/collection.py", line 605, in _insert_command retryable_write=retryable_write) File "/home/ubuntu/.local/lib/python2.7/site-packages/pymongo/pool.py", line 721, in command exhaust_allowed=exhaust_allowed) File "/home/ubuntu/.local/lib/python2.7/site-packages/pymongo/network.py", line 163, in command parse_write_concern_error=parse_write_concern_error) File "/home/ubuntu/.local/lib/python2.7/site-packages/pymongo/helpers.py", line 154, in _check_command_response raise NotPrimaryError(errmsg, response) pymongo.errors.NotPrimaryError: not primary, full error: {u'topologyVersion': {u'processId': ObjectId('634007d510aebb79c4e997b5'), u'counter': 1L}, u'code': 10107, u'ok': 0.0, u'codeName': u'NotWritablePrimary', u'errmsg': u'not primary'}"

NotPrimaryError, raised by self.client.test.results.insert_one(), handled

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant