From 1e58c0374677a37c09438aa8c21d745cd5b08468 Mon Sep 17 00:00:00 2001 From: Benety Goh Date: Tue, 3 Feb 2015 17:13:01 -0500 Subject: SERVER-15308 SERVER-17150 cancel current command on the primary when the node is stepped down --- src/mongo/s/d_migrate.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/mongo/s') diff --git a/src/mongo/s/d_migrate.cpp b/src/mongo/s/d_migrate.cpp index e416e726dd6..22611714860 100644 --- a/src/mongo/s/d_migrate.cpp +++ b/src/mongo/s/d_migrate.cpp @@ -1942,6 +1942,14 @@ namespace mongo { ScopedTransaction transaction(txn, MODE_IX); Lock::DBLock lk(txn->lockState(), nsToDatabaseSubstring(ns), MODE_X); Client::Context ctx(txn, ns); + if (!repl::getGlobalReplicationCoordinator()->canAcceptWritesForDatabase( + nsToDatabaseSubstring(ns))) { + errmsg = str::stream() << "Not primary during migration: " << ns; + warning() << errmsg; + setState(FAIL); + return; + } + Database* db = ctx.db(); Collection* collection = db->getCollection( ns ); if ( !collection ) { -- cgit v1.2.1