summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlberto Lerner <alerner@10gen.com>2013-04-08 19:32:36 -0400
committerAlberto Lerner <alerner@10gen.com>2013-04-08 19:38:14 -0400
commita3dae84adeeff7b062c0a969d5122d17b838bd4b (patch)
tree57fd7032e32a9c2a179a7e597dd3951a7e6f4eb2
parent1a6239025624c7660b65970d3258f1a242ab4512 (diff)
downloadmongo-a3dae84adeeff7b062c0a969d5122d17b838bd4b.tar.gz
SERVER-9125 Fix memory ownership during large collection copy
-rw-r--r--src/mongo/s/config_upgrade_helpers.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/mongo/s/config_upgrade_helpers.cpp b/src/mongo/s/config_upgrade_helpers.cpp
index 9b316fa9835..40a02ef4fec 100644
--- a/src/mongo/s/config_upgrade_helpers.cpp
+++ b/src/mongo/s/config_upgrade_helpers.cpp
@@ -258,8 +258,10 @@ namespace mongo {
Timer t;
int64_t docCount = 0;
- const int32_t maxBatchSize = BSONObjMaxUserSize / 2;
+ const int32_t maxBatchSize = BSONObjMaxUserSize / 16;
try {
+ log() << "About to copy " << fromNS << " to " << toNS << endl;
+
ScopedDbConnection& conn = *connPtr;
scoped_ptr<DBClientCursor> cursor(_safeCursor(conn->query(fromNS, BSONObj())));
@@ -267,7 +269,7 @@ namespace mongo {
int32_t insertSize = 0;
while (cursor->more()) {
- BSONObj next = cursor->nextSafe();
+ BSONObj next = cursor->nextSafe().getOwned();
++docCount;
if (insertSize + next.objsize() > maxBatchSize ) {
@@ -280,10 +282,10 @@ namespace mongo {
insertBatch.push_back(next);
insertSize += next.objsize();
- if (t.seconds() > 10) {
+ if (t.seconds() >= 10) {
t.reset();
log() << "Copied " << docCount << " documents so far from "
- << fromNS << " to " << toNS;
+ << fromNS << " to " << toNS << endl;
}
}
@@ -291,6 +293,10 @@ namespace mongo {
conn->insert(toNS, insertBatch);
_checkGLE(conn);
}
+
+ log() << "Finished copying " << docCount << " documents from "
+ << fromNS << " to " << toNS << endl;
+
}
catch (const DBException& e) {
return e.toStatus("could not copy data into new collection");