summaryrefslogtreecommitdiff
path: root/src/mongo/db/commands/write_commands
diff options
context:
space:
mode:
authorBenety Goh <benety@mongodb.com>2015-02-06 16:45:15 -0500
committerBenety Goh <benety@mongodb.com>2015-02-06 22:34:56 -0500
commit8cf51d1d88c8301253ba42c44db0f2fcb0e9a62e (patch)
tree698aef0b444c8370cc91f2991643d91c3b2847cf /src/mongo/db/commands/write_commands
parent7d392afddc79b48ffb69a63845f249a99375fcf8 (diff)
downloadmongo-8cf51d1d88c8301253ba42c44db0f2fcb0e9a62e.tar.gz
SERVER-17205 do not proceed with bulk update on the primary when it is stepped down
Diffstat (limited to 'src/mongo/db/commands/write_commands')
-rw-r--r--src/mongo/db/commands/write_commands/batch_executor.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/mongo/db/commands/write_commands/batch_executor.cpp b/src/mongo/db/commands/write_commands/batch_executor.cpp
index 7f7155f6ab7..e187b8f359a 100644
--- a/src/mongo/db/commands/write_commands/batch_executor.cpp
+++ b/src/mongo/db/commands/write_commands/batch_executor.cpp
@@ -1221,6 +1221,11 @@ namespace mongo {
ScopedTransaction transaction(txn, MODE_IX);
Lock::DBLock lk(txn->lockState(), nsString.db(), MODE_X);
Client::Context ctx(txn, nsString.ns(), false /* don't check version */);
+
+ if (!checkIsMasterForDatabase(nsString, result)) {
+ return;
+ }
+
Database* db = ctx.db();
if ( db->getCollection( nsString.ns() ) ) {
// someone else beat us to it
@@ -1242,6 +1247,10 @@ namespace mongo {
MODE_IX);
///////////////////////////////////////////
+ if (!checkIsMasterForDatabase(nsString, result)) {
+ return;
+ }
+
if (!checkShardVersion(txn, &shardingState, *updateItem.getRequest(), result))
return;
@@ -1378,6 +1387,10 @@ namespace mongo {
Lock::CollectionLock collLock(txn->lockState(), nss.ns(), MODE_IX);
+ // getExecutorDelete() also checks if writes are allowed.
+ if (!checkIsMasterForDatabase(nss, result)) {
+ return;
+ }
// Check version once we're locked
if (!checkShardVersion(txn, &shardingState, *removeItem.getRequest(), result)) {