Uploaded image for project: 'MongoDB Database Tools'
  1. MongoDB Database Tools
  2. TOOLS-2103

mongoexport uses deprecated snapshot query option

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: mongoexport
    • Labels:

      The snapshot query option was deprecated in 3.6.1.

      Still, latest mongoexport 4.1.2 uses snapshot option by default, unless --forceTableScan is specified.

              
              // don't snapshot if we've been asked not to,
              // or if we cannot because  we are querying, sorting, or if the collection is a view
              if !exp.InputOpts.ForceTableScan && len(query) == 0 && exp.InputOpts != nil && exp.InputOpts.Sort == "" && !collInfo.IsView() && !collInfo.IsSystemCollection() {
                      flags = flags | db.Snapshot
              }
      

      This behavior makes MongoDB to log a warning message once per 128 events:

          if (query.getQueryRequest().isSnapshot()) {
              RARELY {
                  warning() << "The snapshot option is deprecated. See "
                               "http://dochub.mongodb.org/core/snapshot-deprecation";
              }
      

      Since the option is deprecated, mongoexport should use the the workarounds available:

      • For MMAPv1, use hint() on the { _id: 1}

        index instead to prevent a cursor from returning a document more than once if an intervening write operation results in a move of the document.

      • For other storage engines, use hint() with { $natural : 1 }

        instead.

            Assignee:
            Unassigned Unassigned
            Reporter:
            miguel.nieto@mongodb.com Miguel Angel Nieto
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: