diff options
author | William Schultz <william.schultz@mongodb.com> | 2018-05-02 13:23:13 -0400 |
---|---|---|
committer | William Schultz <william.schultz@mongodb.com> | 2018-05-02 13:23:13 -0400 |
commit | e8fe32029aded4d0e909f531196edff43c96cfff (patch) | |
tree | d9f4e02e7ad6fc9e07083908761ae230c9ab4b34 /src/mongo/db/commands/haystack.cpp | |
parent | bbe227d11d937088f832c5e485f16621d4251966 (diff) | |
download | mongo-e8fe32029aded4d0e909f531196edff43c96cfff.tar.gz |
SERVER-34557 Restrict transactions to only run against replica set primaries
Diffstat (limited to 'src/mongo/db/commands/haystack.cpp')
-rw-r--r-- | src/mongo/db/commands/haystack.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/mongo/db/commands/haystack.cpp b/src/mongo/db/commands/haystack.cpp index 695e8f90a6f..6b67b468de7 100644 --- a/src/mongo/db/commands/haystack.cpp +++ b/src/mongo/db/commands/haystack.cpp @@ -103,6 +103,11 @@ public: AutoGetCollectionForReadCommand ctx(opCtx, nss); + // Check whether we are allowed to read from this node after acquiring our locks. + auto replCoord = repl::ReplicationCoordinator::get(opCtx); + uassertStatusOK(replCoord->checkCanServeReadsFor( + opCtx, nss, ReadPreferenceSetting::get(opCtx).canRunOnSecondary())); + Collection* collection = ctx.getCollection(); if (!collection) { errmsg = "can't find ns"; |