summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenety Goh <benety@mongodb.com>2016-10-04 13:45:05 -0400
committerBenety Goh <benety@mongodb.com>2016-10-05 10:13:41 -0400
commite2993ff9da726c50397b6de20e2013087ed18606 (patch)
tree231eabc0f157f68388a6991f4b18bd34a473f28a
parent75e6ae5618169108545425894f02a0a565fb21d5 (diff)
downloadmongo-e2993ff9da726c50397b6de20e2013087ed18606.tar.gz
SERVER-26448 added a progress meter to the CollectionBulkLoader
-rw-r--r--src/mongo/db/repl/SConscript1
-rw-r--r--src/mongo/db/repl/collection_bulk_loader_impl.cpp22
-rw-r--r--src/mongo/db/repl/collection_bulk_loader_impl.h2
3 files changed, 24 insertions, 1 deletions
diff --git a/src/mongo/db/repl/SConscript b/src/mongo/db/repl/SConscript
index 2ade8283ac6..6ba5e0fe2a6 100644
--- a/src/mongo/db/repl/SConscript
+++ b/src/mongo/db/repl/SConscript
@@ -72,6 +72,7 @@ env.Library(
'$BUILD_DIR/mongo/db/common',
'$BUILD_DIR/mongo/db/query/internal_plans',
'$BUILD_DIR/mongo/db/serveronly', # For OperationContextImpl
+ '$BUILD_DIR/mongo/util/progress_meter',
],
)
diff --git a/src/mongo/db/repl/collection_bulk_loader_impl.cpp b/src/mongo/db/repl/collection_bulk_loader_impl.cpp
index 226e5bcb898..8cf62682f23 100644
--- a/src/mongo/db/repl/collection_bulk_loader_impl.cpp
+++ b/src/mongo/db/repl/collection_bulk_loader_impl.cpp
@@ -51,6 +51,12 @@
namespace mongo {
namespace repl {
+namespace {
+
+const int kProgressMeterSecondsBetween = 60;
+const int kProgressMeterCheckInterval = 128;
+}
+
CollectionBulkLoaderImpl::CollectionBulkLoaderImpl(OperationContext* txn,
Collection* coll,
const BSONObj idIndexSpec,
@@ -67,7 +73,12 @@ CollectionBulkLoaderImpl::CollectionBulkLoaderImpl(OperationContext* txn,
_nss{coll->ns()},
_idIndexBlock(stdx::make_unique<MultiIndexBlock>(txn, coll)),
_secondaryIndexesBlock(stdx::make_unique<MultiIndexBlock>(txn, coll)),
- _idIndexSpec(idIndexSpec) {
+ _idIndexSpec(idIndexSpec),
+ _progressMeter(1U,
+ kProgressMeterSecondsBetween,
+ kProgressMeterCheckInterval,
+ "documents copied",
+ str::stream() << coll->ns().toString() << " collection clone progress") {
invariant(txn);
invariant(coll);
invariant(_runner);
@@ -75,6 +86,10 @@ CollectionBulkLoaderImpl::CollectionBulkLoaderImpl(OperationContext* txn,
invariant(_autoColl);
invariant(_autoDB->getDb());
invariant(_autoColl->getDb() == _autoDB->getDb());
+ // Hide collection size in progress output because this information is not available.
+ // Additionally, even if the collection size is known, it may change while we are copying the
+ // documents from the sync source.
+ _progressMeter.showTotal(false);
}
CollectionBulkLoaderImpl::~CollectionBulkLoaderImpl() {
@@ -146,6 +161,9 @@ Status CollectionBulkLoaderImpl::insertDocuments(const std::vector<BSONObj>::con
++count;
}
+
+ _progressMeter.hit(count);
+
return Status::OK();
});
}
@@ -217,6 +235,8 @@ Status CollectionBulkLoaderImpl::commit() {
LOG(2) << "Done creating indexes for ns: " << _nss.ns()
<< ", stats: " << _stats.toString();
+ _progressMeter.finished();
+
_releaseResources();
return Status::OK();
},
diff --git a/src/mongo/db/repl/collection_bulk_loader_impl.h b/src/mongo/db/repl/collection_bulk_loader_impl.h
index 61928e4c385..0d3a63d87e0 100644
--- a/src/mongo/db/repl/collection_bulk_loader_impl.h
+++ b/src/mongo/db/repl/collection_bulk_loader_impl.h
@@ -40,6 +40,7 @@
#include "mongo/db/repl/storage_interface.h"
#include "mongo/db/repl/task_runner.h"
#include "mongo/util/concurrency/old_thread_pool.h"
+#include "mongo/util/progress_meter.h"
namespace mongo {
namespace repl {
@@ -98,6 +99,7 @@ private:
std::unique_ptr<MultiIndexBlock> _secondaryIndexesBlock;
BSONObj _idIndexSpec;
Stats _stats;
+ ProgressMeter _progressMeter;
};
} // namespace repl