Skip to content

Commit 16e30e9

Browse files
committed
SERVER-23905 Remove isPrimaryFor from OperationContext.
1 parent 47a685f commit 16e30e9

File tree

5 files changed

+4
-16
lines changed

5 files changed

+4
-16
lines changed

src/mongo/db/index/index_access_method.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
#include "mongo/db/jsobj.h"
4444
#include "mongo/db/keypattern.h"
4545
#include "mongo/db/operation_context.h"
46+
#include "mongo/db/repl/replication_coordinator.h"
4647
#include "mongo/db/server_parameters.h"
4748
#include "mongo/db/storage/storage_options.h"
4849
#include "mongo/util/log.h"
@@ -109,7 +110,9 @@ IndexAccessMethod::IndexAccessMethod(IndexCatalogEntry* btreeState, SortedDataIn
109110

110111
bool IndexAccessMethod::ignoreKeyTooLong(OperationContext* txn) {
111112
// Ignore this error if we're on a secondary or if the user requested it
112-
return !txn->isPrimaryFor(_btreeState->ns()) || !failIndexKeyTooLong;
113+
const auto canAcceptWritesForNs = repl::ReplicationCoordinator::get(txn)
114+
->canAcceptWritesFor(NamespaceString(_btreeState->ns()));
115+
return !canAcceptWritesForNs || !failIndexKeyTooLong;
113116
}
114117

115118
// Find the keys for obj, put them in the tree pointing to loc

src/mongo/db/operation_context.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -163,11 +163,6 @@ class OperationContext : public Decorable<OperationContext> {
163163
return _opId;
164164
}
165165

166-
/**
167-
* @return true if this instance is primary for this namespace
168-
*/
169-
virtual bool isPrimaryFor(StringData ns) = 0;
170-
171166
/**
172167
* Returns WriteConcernOptions of the current operation
173168
*/

src/mongo/db/operation_context_impl.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,4 @@ string OperationContextImpl::getNS() const {
9999
return CurOp::get(this)->getNS();
100100
}
101101

102-
bool OperationContextImpl::isPrimaryFor(StringData ns) {
103-
return repl::getGlobalReplicationCoordinator()->canAcceptWritesFor(NamespaceString(ns));
104-
}
105-
106102
} // namespace mongo

src/mongo/db/operation_context_impl.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,6 @@ class OperationContextImpl final : public OperationContext {
4444

4545
virtual std::string getNS() const override;
4646

47-
virtual bool isPrimaryFor(StringData ns) override;
48-
4947
private:
5048
friend class ServiceContextMongoD;
5149

src/mongo/db/operation_context_noop.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,6 @@ class OperationContextNoop : public OperationContext {
7777
return &_pm;
7878
}
7979

80-
virtual bool isPrimaryFor(StringData ns) override {
81-
return true;
82-
}
83-
8480
virtual std::string getNS() const override {
8581
return std::string();
8682
};

0 commit comments

Comments
 (0)