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

Slave Connections #128

Open
MrParano1d opened this issue May 8, 2018 · 4 comments
Open

Slave Connections #128

MrParano1d opened this issue May 8, 2018 · 4 comments

Comments

@MrParano1d
Copy link

MrParano1d commented May 8, 2018

Will you gonna implement slave connections in the near future?

I always recieve a

 MongoDart Error: No master connection 
#0      _ConnectionManager.masterConnectionVerified (package:mongo_dart/src/network/connection_manager.dart:18:7)
#1      Db._masterConnectionVerified (package:mongo_dart/src/database/db.dart:126:26)

even with this DbCommand

return new DbCommand(
        db,
        DbCommand.SYSTEM_COMMAND_COLLECTION,
        MongoQueryMessage.OPTS_NO_CURSOR_TIMEOUT | MongoQueryMessage.OPTS_SLAVE,
        0,
        -1,
        {
          'aggregate': collection.collectionName,
          'pipeline': pipeline,
          'cursor': cursorOptions,
          'allowDiskUse': this.allowDiskUse
        },
        null);
  }

Without this feature we have to stop our dart experiment. :(
Am I missing something?
Why do you force a master connection?

@thosakwe
Copy link
Contributor

What kind of functionality are you expecting? I'm wondering what an implementation might look like.

@thosakwe thosakwe self-assigned this Jun 10, 2018
@MrParano1d
Copy link
Author

MrParano1d commented Jun 15, 2018

I'm trying to connect to a mongodb that is secondary and not primary. But this library always depends on a master(primary) connection.

I removed this if: https://github.com/mongo-dart/mongo_dart/blob/master/lib/src/network/connection_manager.dart#L29
locally and then I could connect to our secondary mongodb server.

I would like to have some sort of read preferences (https://docs.mongodb.com/manual/core/read-preference/) or slaveOk (https://docs.mongodb.com/manual/reference/method/rs.slaveOk/).

I hope you know what I mean.

@sstinger
Copy link

sstinger commented Jul 5, 2018

I noticed the same problem and also commented out the lines.
Now I can handel the Unhandled exception "Not primary while writing" in my code.
I have to handle the exception anyway.

I think the only way would be to set a bool allowSecondaryRead on db open and if true to disallow all write function and throw an no primary exeption or something else.

@metatecnologia-mpro
Copy link

metatecnologia-mpro commented Jun 9, 2021

I'm also having the same problem, has anyone been able to solve it?

@thosakwe thosakwe removed their assignment Jun 9, 2021
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

4 participants