Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-38081

Query with `secondary` read preference don't use SHARDING_FILTER

    • Type: Icon: Bug Bug
    • Resolution: Works as Designed
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 3.6.8, 4.0.4
    • Component/s: Sharding
    • Labels:
      None
    • ALL
    • Hide

      Steps for reproduce:

      1. Start cluster with 2 replicasets with 3 nodes in each;
      2. Run commands:
        > use test
        > db.foo.insert({_id: 1, a: 1})
        > sh.enableSharding("test")
        > sh.shardCollection("test.foo", { a: 1 })
        > sh.splitAt( "test.foo", { a: 10 } ) 
      1. Wait few seconds for balancing `test.foo`
      > sh.status()
                              { "a" : { "$minKey" : 1 } } -->> { "a" : 10 } on : rs1 Timestamp(2, 0) 
                              { "a" : 10 } -->> { "a" : { "$maxKey" : 1 } } on : rs0 Timestamp(2, 1)  
      1. Run commands:
        > db.foo.find()
        { "_id" : 1, "a" : 1 }
        > db.getMongo().setReadPref('secondary')
        > db.foo.find()
        { "_id" : 1, "a" : 1 }
        { "_id" : 1, "a" : 1 }

         

      Expected result: second db.foo.find() returns exactly one record.

      Actual result: second db.foo.find() return two records (one orphaned records from `rs0` shard and actual record from `rs1` shard).

      Show
      Steps for reproduce: Start cluster with 2 replicasets with 3 nodes in each; Run commands: > use test > db.foo.insert({_id: 1, a: 1}) > sh.enableSharding( "test" ) > sh.shardCollection( "test.foo" , { a: 1 }) > sh.splitAt( "test.foo" , { a: 10 } ) Wait few seconds for balancing `test.foo` > sh.status()                         { "a" : { "$minKey" : 1 } } -->> { "a" : 10 } on : rs1 Timestamp(2, 0)                         { "a" : 10 } -->> { "a" : { "$maxKey" : 1 } } on : rs0 Timestamp(2, 1) Run commands: > db.foo.find() { "_id" : 1, "a" : 1 } > db.getMongo().setReadPref( 'secondary' ) > db.foo.find() { "_id" : 1, "a" : 1 } { "_id" : 1, "a" : 1 }   Expected result: second db.foo.find() returns exactly one record. Actual result: second db.foo.find() return two records (one orphaned records from `rs0` shard and actual record from `rs1` shard).

      Query on `secondary` don't use SHARDING_FILTER stage, although `secondary` have all data for SHARDING_FILTER in `cache` database.

      I understand, that I can get inconsistent data from `secondary`, but I expected inconsistency by in-progress chunk moving and oplog delay.

      In this case I got permanent inconsistency event on up-to-date replicasets with stopped balancer. Also I see very old orphaned documents (above week age).

            Assignee:
            daniel.hatcher@mongodb.com Danny Hatcher (Inactive)
            Reporter:
            bozaro Artem
            Votes:
            1 Vote for this issue
            Watchers:
            10 Start watching this issue

              Created:
              Updated:
              Resolved: