Core Server
  1. Core Server
  2. SERVER-1263

setSlaveOk has no effect with group() queries

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Minor - P4 Minor - P4
    • Resolution: Duplicate
    • Affects Version/s: 1.4.1, 1.4.3
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None
    • Environment:
    • Backport:
      No
    • Operating System:
      ALL
    • # Replies:
      4
    • Last comment by Customer:
      true

      Description

      Executing db.getMongo().setSlaveOk() allows me to run a map reduce query on a replica pair slave but the equivalent group() query does not work. Reproduced on v1.4.1 and v1.4.3.

      Master:

      > db.sd_boxedice_checksLoadAvrg.group(
      ... {
      ... initial:

      {count: 0, running_average: 0}

      ,
      ... reduce: function(doc, out)
      ...

      { ... out.count++; ... out.running_average+=doc.v; ... },
      ... finalize: function(out)
      ... { ... out.average = out.running_average / out.count; ... }
      ... }
      ... );
      [
      { "count" : 204931, "running_average" : 131253.02999999493, "average" : 0.6404742571889803 }
      ]

      Slave


      > db.sd_boxedice_checksLoadAvrg.group(
      ... {
      ... initial: {count: 0, running_average: 0},
      ... reduce: function(doc, out)
      ... { ... out.count++; ... out.running_average+=doc.v; ... }

      ,
      ... finalize: function(out)
      ...

      { ... out.average = out.running_average / out.count; ... }

      ... }
      ... );
      [

      { "count" : 1, "running_average" : NaN, "average" : NaN }

      ]

        Activity

        Hide
        Dwight Merriman
        added a comment -

        replica pairs are deprecated so i would propose we close this as "wrong but will not fix".

        Show
        Dwight Merriman
        added a comment - replica pairs are deprecated so i would propose we close this as "wrong but will not fix".
        Hide
        Antoine Girbal
        added a comment -

        I am not able to reproduce the issue.
        I started 1 mongod on 27017 as master, and 1 mongod on 27018 as slave.
        Then connected client to to 27018 and killed master mongod.
        I was still able to run group queries on the slave:

        > db.test.find()

        { "_id" : ObjectId("4d112911220ecff98cc83d96"), "a" : 1 } { "_id" : ObjectId("4d11291f220ecff98cc83d97"), "a" : 2 }

        > db.test.group({
        ... initial:

        {count: 0}

        ,
        ... reduce: function(obj,out)

        { ... out.count++; ... }

        ,
        ... finalize: function(out)

        { ... out.count *= 10; ... }

        ... })
        [

        { "count" : 20 }

        ]
        > db.test.insert(

        {b:1}

        )
        not master
        >

        Show
        Antoine Girbal
        added a comment - I am not able to reproduce the issue. I started 1 mongod on 27017 as master, and 1 mongod on 27018 as slave. Then connected client to to 27018 and killed master mongod. I was still able to run group queries on the slave: > db.test.find() { "_id" : ObjectId("4d112911220ecff98cc83d96"), "a" : 1 } { "_id" : ObjectId("4d11291f220ecff98cc83d97"), "a" : 2 } > db.test.group({ ... initial: {count: 0} , ... reduce: function(obj,out) { ... out.count++; ... } , ... finalize: function(out) { ... out.count *= 10; ... } ... }) [ { "count" : 20 } ] > db.test.insert( {b:1} ) not master >
        Hide
        Eliot Horowitz
        added a comment -

        Was that as a replica set?
        THe best test would be bring up a 3 node replica set.
        Run against a secondary
        without SLAVE_OK should fail
        with SLAVE_OK should work

        Show
        Eliot Horowitz
        added a comment - Was that as a replica set? THe best test would be bring up a 3 node replica set. Run against a secondary without SLAVE_OK should fail with SLAVE_OK should work
        Hide
        Antoine Girbal
        added a comment -

        this is covered by SERVER-2286

        Show
        Antoine Girbal
        added a comment - this is covered by SERVER-2286

          People

          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:
              Days since reply:
              3 years, 16 weeks ago
              Date of 1st Reply: