Uploaded image for project: 'MongoDB ETL Tools'
  1. MongoDB ETL Tools
  2. TOOLS-1972

Hint the _id index instead of using $snapshot query option

    XMLWordPrintable

    Details

    • Type: Task
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 3.7.4
    • Component/s: None
    • Labels:
      None

      Description

      $snapshot is being removed in MongoDB 4.0, SERVER-32174. As a workaround, hint the _id index:

      diff --git a/src/mongo/gotools/common/db/command.go b/src/mongo/gotools/common/db/command.go
      index f777d94..159bdfb 100644
      --- a/src/mongo/gotools/common/db/command.go
      +++ b/src/mongo/gotools/common/db/command.go
      @@ -204,7 +204,9 @@ func (sp *SessionProvider) FindOne(db, collection string, skip int, query interf
       // ApplyFlags applies flags to the given query session.
       func ApplyFlags(q *mgo.Query, session *mgo.Session, flags int) *mgo.Query {
       	if flags&Snapshot > 0 {
      -		q = q.Snapshot()
      +		// The snapshot option for find has been removed in the server, workaround by hinting the 
      +		// _id index instead.
      +		q = q.Hint("_id")
       	}
       	if flags&LogReplay > 0 {
       		q = q.LogReplay()
      diff --git a/src/mongo/gotools/mongodump/mongodump.go b/src/mongo/gotools/mongodump/mongodump.go
      index 41b37e3..e05b83e 100644
      --- a/src/mongo/gotools/mongodump/mongodump.go
      +++ b/src/mongo/gotools/mongodump/mongodump.go
      @@ -544,7 +544,7 @@ func (dump *MongoDump) DumpIntent(intent *intents.Intent, buffer resettableOutpu
       		// ---forceTablesScan runs the query without snapshot enabled
       		findQuery = session.DB(intent.DB).C(intent.C).Find(nil)
       	default:
      -		findQuery = session.DB(intent.DB).C(intent.C).Find(nil).Snapshot()
      +		findQuery = session.DB(intent.DB).C(intent.C).Find(nil).Hint("_id")
       	}
       
       	var dumpCount int64
      -- 
      2.7.4
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                nicholas.zolnierz Nicholas Zolnierz
                Reporter:
                kelsey.schubert Kelsey T Schubert
              • Votes:
                0 Vote for this issue
                Watchers:
                9 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: