summaryrefslogtreecommitdiff
path: root/src/mongo/s/d_logic.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/s/d_logic.cpp')
-rw-r--r--src/mongo/s/d_logic.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/mongo/s/d_logic.cpp b/src/mongo/s/d_logic.cpp
index 4d04eea2be9..dcf66033428 100644
--- a/src/mongo/s/d_logic.cpp
+++ b/src/mongo/s/d_logic.cpp
@@ -100,7 +100,7 @@ namespace mongo {
dbresponse->responseTo = m.header()->id;
return true;
}
-
+
uassert( 9517 , "writeback" , ( d.reservedField() & Reserved_FromWriteback ) == 0 );
OID writebackID;
@@ -109,6 +109,13 @@ namespace mongo {
const OID& clientID = ShardedConnectionInfo::get(false)->getID();
massert( 10422 , "write with bad shard config and no server id!" , clientID.isSet() );
+ // We need to check this here, since otherwise we'll get errors wrapping the writeback -
+ // not just here, but also when returning as a command result.
+ // We choose 1/2 the overhead of the internal maximum so that we can still handle ops of
+ // 16MB exactly.
+ massert( 16437, "data size of operation is too large to queue for writeback",
+ m.dataSize() < BSONObjMaxInternalSize - (8 * 1024));
+
LOG(1) << "writeback queued for " << m.toString() << endl;
BSONObjBuilder b;
@@ -123,11 +130,14 @@ namespace mongo {
b.appendBinData( "msg" , m.header()->len , bdtCustom , (char*)(m.singleData()) );
LOG(2) << "writing back msg with len: " << m.header()->len << " op: " << m.operation() << endl;
+ // Convert to new BSONObj here just to be safe
+ BSONObj wbObj = b.obj();
+
// Don't register the writeback until immediately before we queue it -
// after this line, mongos will wait for an hour if we don't queue correctly
lastError.getSafe()->writeback( writebackID );
- writeBackManager.queueWriteBack( clientID.str() , b.obj() );
+ writeBackManager.queueWriteBack( clientID.str() , wbObj );
return true;
}