diff options
author | David Golden <xdg@xdg.me> | 2019-05-14 10:42:39 -0400 |
---|---|---|
committer | David Golden <xdg@xdg.me> | 2019-05-14 10:42:39 -0400 |
commit | 4a0a2a1d30a556b0bcefbdd4e862f85f289b3494 (patch) | |
tree | 0fb711b68f0b8b7efde4c2841b9e20c01e9b00bb | |
parent | be4af0a025853999181a2bed0d70d14230b4ba86 (diff) | |
download | mongo-4a0a2a1d30a556b0bcefbdd4e862f85f289b3494.tar.gz |
Import tools: 2aeced60bec4310f9d87fd0c2dd535945e253126 from branch v4.0
ref: 5db0b4a18c..2aeced60be
for: 4.0.10
TOOLS-2068 mongodump oplog delay
TOOLS-2290 mongorestore should not treat % in collection names as URL escape character
3 files changed, 23 insertions, 16 deletions
diff --git a/src/mongo/gotools/src/github.com/mongodb/mongo-tools/common/archive/prelude.go b/src/mongo/gotools/src/github.com/mongodb/mongo-tools/common/archive/prelude.go index 2d50bc66dce..e3214af4623 100644 --- a/src/mongo/gotools/src/github.com/mongodb/mongo-tools/common/archive/prelude.go +++ b/src/mongo/gotools/src/github.com/mongodb/mongo-tools/common/archive/prelude.go @@ -197,11 +197,6 @@ func (hpc *preludeParserConsumer) BodyBSON(data []byte) error { if err != nil { return err } - cm.Collection, err = util.UnescapeCollectionName(cm.Collection) - if err != nil { - return err - } - hpc.prelude.AddMetadata(cm) return nil } diff --git a/src/mongo/gotools/src/github.com/mongodb/mongo-tools/import.data b/src/mongo/gotools/src/github.com/mongodb/mongo-tools/import.data index ae0244c3c08..1f067e87b2b 100644 --- a/src/mongo/gotools/src/github.com/mongodb/mongo-tools/import.data +++ b/src/mongo/gotools/src/github.com/mongodb/mongo-tools/import.data @@ -1,5 +1,5 @@ { - "commit": "5db0b4a18cc1366ebd368eed8e7c4d426d851f13", + "commit": "2aeced60bec4310f9d87fd0c2dd535945e253126", "github": "mongodb/mongo-tools.git", "vendor": "tools", "branch": "v4.0" diff --git a/src/mongo/gotools/src/github.com/mongodb/mongo-tools/mongodump/mongodump.go b/src/mongo/gotools/src/github.com/mongodb/mongo-tools/mongodump/mongodump.go index e5e214c35b2..e21a3c5b25d 100644 --- a/src/mongo/gotools/src/github.com/mongodb/mongo-tools/mongodump/mongodump.go +++ b/src/mongo/gotools/src/github.com/mongodb/mongo-tools/mongodump/mongodump.go @@ -608,6 +608,23 @@ func (dump *MongoDump) dumpQueryToIntent( return dump.dumpFilteredQueryToIntent(query, intent, buffer, copyDocumentFilter) } +// getCount counts the number of documents in the namespace for the given intent. It does not run the count for +// the oplog collection to avoid the performance issue in TOOLS-2068. +func (dump *MongoDump) getCount(query *mgo.Query, intent *intents.Intent) (int64, error) { + if len(dump.query) != 0 || intent.IsOplog() { + log.Logvf(log.DebugLow, "not counting query on %v", intent.Namespace()) + return 0, nil + } + + total, err := query.Count() + if err != nil { + return 0, fmt.Errorf("error getting count from db: %v", err) + } + + log.Logvf(log.DebugLow, "counted %v %v in %v", total, docPlural(int64(total)), intent.Namespace()) + return int64(total), nil +} + // dumpFilterQueryToIntent takes an mgo Query, its intent, a writer, and a document filter, performs the query, // passes the results through the filter // and writes the raw bson results to the writer. Returns a final count of documents @@ -631,18 +648,13 @@ func (dump *MongoDump) dumpFilteredQueryToIntent( if intent.IsView() && !dump.OutputOptions.ViewsAsCollections { return 0, nil } - var total int - if len(dump.query) == 0 { - total, err = query.Count() - if err != nil { - return int64(0), fmt.Errorf("error reading from db: %v", err) - } - log.Logvf(log.DebugLow, "counted %v %v in %v", total, docPlural(int64(total)), intent.Namespace()) - } else { - log.Logvf(log.DebugLow, "not counting query on %v", intent.Namespace()) + + total, err := dump.getCount(query, intent) + if err != nil { + return 0, err } - dumpProgressor := progress.NewCounter(int64(total)) + dumpProgressor := progress.NewCounter(total) if dump.ProgressManager != nil { dump.ProgressManager.Attach(intent.Namespace(), dumpProgressor) defer dump.ProgressManager.Detach(intent.Namespace()) |