summaryrefslogtreecommitdiff
path: root/src/mongo/db/repl/repl_set_request_votes.cpp
diff options
context:
space:
mode:
authorSiyuan Zhou <siyuan.zhou@mongodb.com>2015-10-13 15:39:13 -0400
committerSiyuan Zhou <siyuan.zhou@mongodb.com>2015-10-14 11:31:14 -0400
commitbededc2f0496162a188d66835638a2dc714b8b98 (patch)
tree84338711ab925d867239428eadfb750d605f57da /src/mongo/db/repl/repl_set_request_votes.cpp
parent5eaf403f3659f7e4b6372be0f50d82863b704b47 (diff)
downloadmongo-bededc2f0496162a188d66835638a2dc714b8b98.tar.gz
SERVER-20812 Tag vote request connection to skip closing it when relinquishing primary
Diffstat (limited to 'src/mongo/db/repl/repl_set_request_votes.cpp')
-rw-r--r--src/mongo/db/repl/repl_set_request_votes.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/mongo/db/repl/repl_set_request_votes.cpp b/src/mongo/db/repl/repl_set_request_votes.cpp
index 92a72a1a6c4..0c0f209d1b6 100644
--- a/src/mongo/db/repl/repl_set_request_votes.cpp
+++ b/src/mongo/db/repl/repl_set_request_votes.cpp
@@ -28,10 +28,14 @@
#include "mongo/platform/basic.h"
+#include "mongo/db/client.h"
+#include "mongo/db/operation_context.h"
#include "mongo/db/repl/optime.h"
#include "mongo/db/repl/repl_set_command.h"
#include "mongo/db/repl/repl_set_request_votes_args.h"
#include "mongo/db/repl/replication_coordinator_global.h"
+#include "mongo/executor/network_interface.h"
+#include "mongo/util/scopeguard.h"
namespace mongo {
namespace repl {
@@ -58,6 +62,21 @@ private:
return appendCommandStatus(result, status);
}
+ // We want to keep request vote connection open when relinquishing primary.
+ // Tag it here.
+ unsigned originalTag = 0;
+ AbstractMessagingPort* mp = txn->getClient()->port();
+ if (mp) {
+ originalTag = mp->tag;
+ mp->tag |= executor::NetworkInterface::kMessagingPortKeepOpen;
+ }
+ // Untag the connection on exit.
+ ON_BLOCK_EXIT([mp, originalTag]() {
+ if (mp) {
+ mp->tag = originalTag;
+ }
+ });
+
ReplSetRequestVotesResponse response;
status = getGlobalReplicationCoordinator()->processReplSetRequestVotes(
txn, parsedArgs, &response);