summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenety Goh <benety@mongodb.com>2015-02-06 16:45:15 -0500
committerRamon Fernandez <ramon.fernandez@mongodb.com>2015-02-07 09:34:12 -0500
commite2e41c48d6d8f1793177abf3299066caf37cea52 (patch)
tree32a68c1c108915911ae0a975b96a99e4f2e59b3a
parent9446e2d4fb6bc41883788f25e040bba426fdb56e (diff)
downloadmongo-e2e41c48d6d8f1793177abf3299066caf37cea52.tar.gz
SERVER-17205 do not proceed with bulk update on the primary when it is stepped down
(cherry picked from commit 8cf51d1d88c8301253ba42c44db0f2fcb0e9a62e)
-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)) {