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

MONGO_REPLICA_SET not working (not used anymore ?) #1302

Closed
Altiire opened this issue Aug 7, 2019 · 1 comment
Closed

MONGO_REPLICA_SET not working (not used anymore ?) #1302

Altiire opened this issue Aug 7, 2019 · 1 comment
Milestone

Comments

@Altiire
Copy link

Altiire commented Aug 7, 2019

Expected Behavior

Tell us what should happen.

MONGO_REPLICA_SET = os.getenv('MONGO_REPLICA_SET')

MongoClient in io/mongo/flask_pymongo.py should be called with option replicaset as follow : MongoClient('localhost', replicaset='foo') (see: https://api.mongodb.com/python/current/examples/high_availability.html#id1)

MongoClient is called with MongoClient(**client_kwargs) and MONGO_REPLICA_SET value is not transfered as you can see in io/mongo/flask_pymongo.py:35:config_to_kwargs()

Actual Behavior

Tell us what happens instead.

[2019-08-07 14:43:22,388] ERROR in app: Exception on /companies [POST]
Traceback (most recent call last):
  File "/home/altiire/.local/share/virtualenvs/MongoREST-1Av1QWwL/lib/python3.7/site-packages/flask/app.py", line 2446, in wsgi_app
    response = self.full_dispatch_request()
  File "/home/altiire/.local/share/virtualenvs/MongoREST-1Av1QWwL/lib/python3.7/site-packages/flask/app.py", line 1951, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/home/altiire/.local/share/virtualenvs/MongoREST-1Av1QWwL/lib/python3.7/site-packages/flask/app.py", line 1820, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/home/altiire/.local/share/virtualenvs/MongoREST-1Av1QWwL/lib/python3.7/site-packages/flask/_compat.py", line 39, in reraise
    raise value
  File "/home/altiire/.local/share/virtualenvs/MongoREST-1Av1QWwL/lib/python3.7/site-packages/flask/app.py", line 1949, in full_dispatch_request
    rv = self.dispatch_request()
  File "/home/altiire/.local/share/virtualenvs/MongoREST-1Av1QWwL/lib/python3.7/site-packages/flask/app.py", line 1935, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/home/altiire/.local/share/virtualenvs/MongoREST-1Av1QWwL/lib/python3.7/site-packages/eve/endpoints.py", line 58, in collections_endpoint
    response = post(resource)
  File "/home/altiire/.local/share/virtualenvs/MongoREST-1Av1QWwL/lib/python3.7/site-packages/eve/methods/common.py", line 318, in rate_limited
    return f(*args, **kwargs)
  File "/home/altiire/.local/share/virtualenvs/MongoREST-1Av1QWwL/lib/python3.7/site-packages/eve/auth.py", line 80, in decorated
    return f(*args, **kwargs)
  File "/home/altiire/.local/share/virtualenvs/MongoREST-1Av1QWwL/lib/python3.7/site-packages/eve/methods/common.py", line 1354, in decorated
    r = f(resource, **combined_args)
  File "/home/altiire/.local/share/virtualenvs/MongoREST-1Av1QWwL/lib/python3.7/site-packages/eve/methods/post.py", line 49, in post
    return post_internal(resource, payl, skip_validation=False)
  File "/home/altiire/.local/share/virtualenvs/MongoREST-1Av1QWwL/lib/python3.7/site-packages/eve/methods/post.py", line 260, in post_internal
    ids = app.data.insert(resource, documents)
  File "/home/altiire/.local/share/virtualenvs/MongoREST-1Av1QWwL/lib/python3.7/site-packages/eve/io/mongo/mongo.py", line 461, in insert
    return coll.insert_many(doc_or_docs, ordered=True).inserted_ids
  File "/home/altiire/.local/share/virtualenvs/MongoREST-1Av1QWwL/lib/python3.7/site-packages/pymongo/collection.py", line 760, in insert_many
    blk.execute(write_concern, session=session)
  File "/home/altiire/.local/share/virtualenvs/MongoREST-1Av1QWwL/lib/python3.7/site-packages/pymongo/bulk.py", line 522, in execute
    return self.execute_command(generator, write_concern, session)
  File "/home/altiire/.local/share/virtualenvs/MongoREST-1Av1QWwL/lib/python3.7/site-packages/pymongo/bulk.py", line 347, in execute_command
    self.is_retryable, retryable_bulk, s, self)
  File "/home/altiire/.local/share/virtualenvs/MongoREST-1Av1QWwL/lib/python3.7/site-packages/pymongo/mongo_client.py", line 1233, in _retry_with_session
    return func(session, sock_info, retryable)
  File "/home/altiire/.local/share/virtualenvs/MongoREST-1Av1QWwL/lib/python3.7/site-packages/pymongo/bulk.py", line 342, in retryable_bulk
    retryable, full_result)
  File "/home/altiire/.local/share/virtualenvs/MongoREST-1Av1QWwL/lib/python3.7/site-packages/pymongo/bulk.py", line 295, in _execute_command
    result = bwc.write_command(request_id, msg, to_send)
  File "/home/altiire/.local/share/virtualenvs/MongoREST-1Av1QWwL/lib/python3.7/site-packages/pymongo/message.py", line 919, in write_command
    reply = self.sock_info.write_command(request_id, msg)
  File "/home/altiire/.local/share/virtualenvs/MongoREST-1Av1QWwL/lib/python3.7/site-packages/pymongo/pool.py", line 660, in write_command
    helpers._check_command_response(result)
  File "/home/altiire/.local/share/virtualenvs/MongoREST-1Av1QWwL/lib/python3.7/site-packages/pymongo/helpers.py", line 132, in _check_command_response
    raise NotMasterError(errmsg, response)
pymongo.errors.NotMasterError: not master

Environment

  • Python version: 3.7.3
  • Eve version: 0.9.2
@nicolaiarocci nicolaiarocci added this to the 0.10 milestone Aug 9, 2019
@nicolaiarocci
Copy link
Member

thanks for reporting this. You'd normally use MONGO_URI to set the replicaset, but I agree that this alternative/optional method needs to be still supported.

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

No branches or pull requests

2 participants