From 8cf51d1d88c8301253ba42c44db0f2fcb0e9a62e Mon Sep 17 00:00:00 2001 From: Benety Goh Date: Fri, 6 Feb 2015 16:45:15 -0500 Subject: SERVER-17205 do not proceed with bulk update on the primary when it is stepped down --- src/mongo/db/commands/write_commands/batch_executor.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/mongo/db/commands/write_commands') 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)) { -- cgit v1.2.1