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

SnapshotUnavailable error on sharded clusters/replica sets

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 7.0.0-rc0
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None
    • Storage Execution
    • Fully Compatible
    • ALL
    • Hide

      Note that I haven't been able to reproduce this locally, only on CI. Here is the patch that I ran. The code I'm using is as follows:

       client = Mongo::Client.new(uri_string, database: "pets")
       client['cats'].delete_many({})
       client['dogs'].delete_many({})
      
      client['cats'].insert_one({ 
          name:"Whiskers", 
          color:"white", 
          age:10, 
          adoptable:true 
      })
      
      client['dogs'].insert_one({ 
       name:"Pebbles", 
       color:"Brown", 
       age:10, 
       adoptable:true 
      })
      client.close
        
      adoptablePetsCount = 0
      
      # Start Snapshot Query Example 1
      # note that I create the client twice because this part needs to be in the example
      
      client = Mongo::Client.new(uri_string, database:"pets")
      client.start_session(snapshot:true) do |session|
          adoptablePetsCount = client['cats'].aggregate([
              { "$match": { "adoptable": true } },
              { "$count": "adoptableCatsCount" }
          ], session: session).first["adoptableCatsCount"]
      
          adoptablePetsCount += client['dogs'].aggregate([
               { "$match": \{ "adoptable": true } },
               { "$count": "adoptableDogsCount" }
          ], session: session).first["adoptableDogsCount"]
          
          puts adoptablePetsCount
      end
      Show
      Note that I haven't been able to reproduce this locally, only on CI. Here is the patch that I ran. The code I'm using is as follows:  client = Mongo::Client. new (uri_string, database: "pets" ) client[ 'cats' ].delete_many({}) client[ 'dogs' ].delete_many({}) client[ 'cats' ].insert_one({ name: "Whiskers" , color: "white" , age:10, adoptable: true }) client[ 'dogs' ].insert_one({ name: "Pebbles" , color: "Brown" , age:10, adoptable: true }) client.close   adoptablePetsCount = 0 # Start Snapshot Query Example 1 # note that I create the client twice because this part needs to be in the example client = Mongo::Client. new (uri_string, database: "pets" ) client.start_session(snapshot: true ) do |session| adoptablePetsCount = client[ 'cats' ].aggregate([ { "$match" : { "adoptable" : true } }, { "$count" : "adoptableCatsCount" } ], session: session).first[ "adoptableCatsCount" ] adoptablePetsCount += client[ 'dogs' ].aggregate([ { "$match" : \{ "adoptable" : true } }, { "$count" : "adoptableDogsCount" } ], session: session).first[ "adoptableDogsCount" ] puts adoptablePetsCount end
    • Execution Team 2023-04-03

      Summary

      I was implementing DRIVERS-2181 in Ruby, and these tests pass locally but fail on CI (but only very occasionally). This ticket is for implementing snapshot query example tests. When running these tests on CI (it passes locally) I occasionally get the following error on both replica sets and sharded clusters.

      Something like this error has been reported before. See SERVER-41532.

      The error is as follows:  

       Mongo::Error::OperationFailure: command failed because can not establish a snapshot :: caused by :: Unable to read from a snapshot due to pending collection catalog changes; please retry the operation. Snapshot timestamp is Timestamp(1645560051, 6). Collection minimum is Timestamp(1645560051, 7) (on localhost:27017, modern retry, attempt 1)

      Note that sending distinct commands seems to fix this for sharded clusters. See the comments under SERVER-39704. This still fails for replica sets.

      Motivation

      Who is the affected end user?

      mongo-ruby-driver spec tests are failing

      How does this affect the end user?

      I'm not sure that it does, since I'm having a hard time reproducing it

      How likely is it that this problem or use case will occur?

      It doesn't seem very likely since I'm having a hard time reproducing it.

      If the problem does occur, what are the consequences and how severe are they?

      The snapshot fails, but it seems like if you retry it, it will work. See SERVER-41532.

       

            Assignee:
            henrik.edin@mongodb.com Henrik Edin
            Reporter:
            neil.shweky@mongodb.com Neil Shweky (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved: