Skip to content

Parse does not re-authorize connection to MongoDB #3775

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

Closed
MihalySzabo opened this issue May 3, 2017 · 4 comments
Closed

Parse does not re-authorize connection to MongoDB #3775

MihalySzabo opened this issue May 3, 2017 · 4 comments

Comments

@MihalySzabo
Copy link

Issue Description

If the user that Parse uses to connect to MongoDB is deleted, Parse will not be able to fetch any data from the DB - as expected. But if the user is put back, Parse will still not get any data until restart.

Steps to reproduce

  • Set up Parse with MongoDB using for authentication.
  • If everything is OK (Parse can access the DB normally), delete from MongoDB.
  • Parse starts to throw errors like: Uncaught internal server error. { MongoError: not authorized on to execute command { find: "_SCHEMA", filter: {} }
  • Add back to MongoDB.

Expected Results

Parse should continue to access MongoDB normally.

Actual Outcome

Parse throws errors until restart.

Environment Setup

  • Server

    • parse-server version: 2.3.8
    • Operating System: 64bit Amazon Linux 2016.09 v4.0.1 running Node.js
    • Hardware: t2.micro
    • Localhost or remote server? (AWS, Heroku, Azure, Digital Ocean, etc): AWS
  • Database

    • MongoDB version: 3.2.13
    • Storage engine: MMAPv1
    • Hardware: Shared Cluster
    • Localhost or remote server? (AWS, mLab, ObjectRocket, Digital Ocean, etc): mLab

Logs/Trace

error: Uncaught internal server error. { MongoError: not authorized on to execute command { find: "_SCHEMA", filter: {} }
at Function.MongoError.create (/var/app/current/node_modules/mongodb-core/lib/error.js:31:11)
at queryCallback (/var/app/current/node_modules/mongodb-core/lib/cursor.js:212:36)
at /var/app/current/node_modules/mongodb-core/lib/connection/pool.js:461:18
at _combinedTickCallback (internal/process/next_tick.js:67:7)
at process._tickDomainCallback (internal/process/next_tick.js:122:9)
name: 'MongoError',
message: 'not authorized on to execute command { find: "_SCHEMA", filter: {} }',
ok: 0,
errmsg: 'not authorized on to execute command { find: "_SCHEMA", filter: {} }',
code: 13 } MongoError: not authorized on to execute command { find: "_SCHEMA", filter: {} }
at Function.MongoError.create (/var/app/current/node_modules/mongodb-core/lib/error.js:31:11)
at queryCallback (/var/app/current/node_modules/mongodb-core/lib/cursor.js:212:36)
at /var/app/current/node_modules/mongodb-core/lib/connection/pool.js:461:18
at _combinedTickCallback (internal/process/next_tick.js:67:7)
at process._tickDomainCallback (internal/process/next_tick.js:122:9)
MongoError: not authorized on to execute command { find: "_SCHEMA", filter: {} }
at Function.MongoError.create (/var/app/current/node_modules/mongodb-core/lib/error.js:31:11)
at queryCallback (/var/app/current/node_modules/mongodb-core/lib/cursor.js:212:36)
at /var/app/current/node_modules/mongodb-core/lib/connection/pool.js:461:18
at _combinedTickCallback (internal/process/next_tick.js:67:7)
at process._tickDomainCallback (internal/process/next_tick.js:122:9)

@flovilmart
Copy link
Contributor

@MihalySzabo what do you suggest we should do? invalidate the connection on errors?

@MihalySzabo
Copy link
Author

@flovilmart I do not know the exact state transitions of Parse's connection handling, but I think invalidating connection on errors in general would not be a good solution, because a query can also raise an error even if the connection is OK. If the Mongo user has a read only access to the DB, that also raises a "not authorised" exception (?) on a write, but still nothing is wrong with the connection. Maybe an error callback would be nice where the developer could decide what to do with the error with a return of an instruction what Parse should do, e.g.: {'invalidateConnection':true} or {'retryInMillisecs': 1000}.

On the other hand have you any idea why the one direction works as expected (if Mongo user is deleted, Parse cannot access DB), but not the other (Mongo user is put back, but Parse is still unauthorised)?

@flovilmart
Copy link
Contributor

Uhh I'm not sure why, this is probably inside the mongodb driver, not sure about that. We can probably find something for the error handling, removing / closing the connection so it's re-established next time.

@dplewis
Copy link
Member

dplewis commented Mar 23, 2018

Closed via #4576

@dplewis dplewis closed this as completed Mar 23, 2018
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

3 participants