summaryrefslogtreecommitdiff
path: root/s/d_migrate.cpp
diff options
context:
space:
mode:
authorAntonin Kral <a.kral@bobek.cz>2010-08-18 09:23:15 +0200
committerAntonin Kral <a.kral@bobek.cz>2010-08-18 09:23:15 +0200
commit3b9581e84e19723087b31b79674801b6c06ae533 (patch)
tree5568dbd7199b1ce64ace1cec26b590c1431e872d /s/d_migrate.cpp
parentd7ec8115ec4b160ed74c1a8a06a1c171d76370ac (diff)
downloadmongodb-3b9581e84e19723087b31b79674801b6c06ae533.tar.gz
Imported Upstream version 1.6.1
Diffstat (limited to 's/d_migrate.cpp')
-rw-r--r--s/d_migrate.cpp22
1 files changed, 16 insertions, 6 deletions
diff --git a/s/d_migrate.cpp b/s/d_migrate.cpp
index 84d70c5..fac63af 100644
--- a/s/d_migrate.cpp
+++ b/s/d_migrate.cpp
@@ -528,7 +528,8 @@ namespace mongo {
log(0) << "_recvChunkStatus : " << res << endl;
- if ( ! ok ){
+ if ( ! ok || res["state"].String() == "fail" ){
+ log( LL_ERROR ) << "_recvChunkStatus error : " << res << endl;
errmsg = "_recvChunkStatus error";
result.append( "cause" ,res );
return false;
@@ -544,7 +545,7 @@ namespace mongo {
// 5.a
migrateFromStatus._inCriticalSection = true;
ShardChunkVersion myVersion = maxVersion;
- ++myVersion;
+ myVersion.incMajor();
{
dblock lk;
@@ -587,7 +588,8 @@ namespace mongo {
if ( ! x.isEmpty() ){
BSONObjBuilder temp2;
- ++myVersion;
+ myVersion.incMinor();
+
temp2.appendTimestamp( "lastmod" , myVersion );
shardingState.setVersion( ns , myVersion );
@@ -685,10 +687,12 @@ namespace mongo {
catch ( std::exception& e ){
state = FAIL;
errmsg = e.what();
+ log( LL_ERROR ) << "migrate failed: " << e.what() << endl;
}
catch ( ... ){
state = FAIL;
errmsg = "UNKNOWN ERROR";
+ log( LL_ERROR ) << "migrate failed with unknown exception" << endl;
}
active = false;
}
@@ -739,7 +743,7 @@ namespace mongo {
auto_ptr<DBClientCursor> cursor = conn->query( ns , Query().minKey( min ).maxKey( max ) , /* QueryOption_Exhaust */ 0 );
assert( cursor.get() );
while ( cursor->more() ){
- BSONObj o = cursor->next();
+ BSONObj o = cursor->next().getOwned();
{
writelock lk( ns );
Helpers::upsert( ns , o );
@@ -756,7 +760,11 @@ namespace mongo {
BSONObj res;
if ( ! conn->runCommand( "admin" , BSON( "_transferMods" << 1 ) , res ) ){
state = FAIL;
+ errmsg = "_transferMods failed: ";
+ errmsg += res.toString();
log( LL_ERROR ) << "_transferMods failed: " << res << endl;
+ conn.done();
+ return;
}
if ( res["size"].number() == 0 )
break;
@@ -775,6 +783,7 @@ namespace mongo {
log() << "_transferMods failed in STEADY state: " << res << endl;
errmsg = res.toString();
state = FAIL;
+ conn.done();
return;
}
@@ -801,9 +810,10 @@ namespace mongo {
b.append( "from" , from );
b.append( "min" , min );
b.append( "max" , max );
-
+
b.append( "state" , stateString() );
-
+ if ( state == FAIL )
+ b.append( "errmsg" , errmsg );
{
BSONObjBuilder bb( b.subobjStart( "counts" ) );
bb.append( "cloned" , numCloned );