If I define multiple replica set servers in mongo connections settings mdbc will choke and die trying to connect to "192.168.0.1,192.168.0.2" if replica set option is enabled drush should figure out which is primary and connect to that one by default and also allow option for user to connect to any of the secondaries.

Comments

Rok Žlender’s picture

Status:Active» Needs review
FileSize
2.82 KB
None View

Patch supports running drush command on replica set configuration options.

Rok Žlender’s picture

FileSize
3.5 KB
None View

Revisited patch created new constant for primary member status value and added a msg to users when connecting to secondary how to send queries against it.

fgm’s picture

Issue summary:View changes
Status:Needs review» Needs work

Patch no longer applies, so setting CNW. This is not just a matter of rerolling : the connection process changed in 3 years.

At this point, drush mdbc does not even work on a standalone host.

  • fgm committed 474ddf8 on 7.x-1.x
    Issue #1823478: first step of fix: fixed drush commands no longer...
fgm’s picture

The commit above restores mdbc and the other drush operations on single hosts : the patch is still needed for replicasets.

fgm’s picture

The connection string issue with authenticated users had another partial patch on #1930822: drush mongo shell host scheme error, probably good to merge with this one.

disasm’s picture

Status:Needs work» Needs review
FileSize
7.29 KB

I ended up rerolling this to get it to work with mongo 3.x client which no longer likes the old ; separated params. Here's a patch.

alasda’s picture

Rolls together Rok Zlender and disam's patches against current head. Fixes a few formatting and coding standards issues.

alasda’s picture

Fixes a couple missed formatting issues from previous patch.

marcingy’s picture

Status:Needs review» Reviewed & tested by the community
fgm’s picture

Status:Reviewed & tested by the community» Needs review
FileSize
6.6 KB

Patch no longer applied : rerolled on today's HEAD for review.

fgm’s picture

Status:Needs review» Needs work
  1. +++ b/mongodb.drush.inc
    @@ -111,15 +107,9 @@ function drush_mongodb_connect($alias = 'default') {
    +  drush_print(proc_close(proc_open(escapeshellcmd($command), array(0 => STDIN, 1 => STDOUT, 2 => STDERR), $pipes)));
    

    Any reason to wrap this on a single too long line ? I find it less readable, and if kept, the array needs to be multiline anyway, as per coding standards.

  2. +++ b/mongodb.drush.inc
    @@ -132,12 +122,84 @@ function _drush_mongodb_connect($alias) {
    +  // If we are dealing with connection to replica set by default connect
    

    The whole code in this function is replicating/replacing code from the mongodb() function in the main module, but missing some functionality like supporting debug and returning MongoDummy on failures. We should not have two different connection methods : if the RS support in this method is better than the one in mongodb(), it needs to be merged there, not duplicated here.

  3. +++ b/mongodb.drush.inc
    @@ -132,12 +122,84 @@ function _drush_mongodb_connect($alias) {
    +  // selected secondary member lets notify users how to send queries against
    

    Seeing the code on the next lines, "lets" should probably be "then" ? As such, the sentence is not clear

  4. +++ b/mongodb.module
    @@ -4,6 +4,10 @@
    +define("MONGODB_REPLICA_SET_PRIMARY", 1);
    

    This constant is not used anywhere, so it should probably be removed.

  5. +++ b/mongodb.module
    @@ -4,6 +4,10 @@
    +define("MONTODB_SLAVE_NOT_CONNECTED", 1);
    

    This constant looks like it has a typo, and it is used as MONGODB_SLAVE_NOT_CONNECTED, not with the typo, so it needs to be changed.