From e2993ff9da726c50397b6de20e2013087ed18606 Mon Sep 17 00:00:00 2001 From: Benety Goh Date: Tue, 4 Oct 2016 13:45:05 -0400 Subject: SERVER-26448 added a progress meter to the CollectionBulkLoader --- src/mongo/db/repl/collection_bulk_loader_impl.cpp | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'src/mongo/db/repl/collection_bulk_loader_impl.cpp') 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(txn, coll)), _secondaryIndexesBlock(stdx::make_unique(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::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(); }, -- cgit v1.2.1