summaryrefslogtreecommitdiff
path: root/src/mongo/db/repl
diff options
context:
space:
mode:
authorHari Khalsa <hkhalsa@10gen.com>2013-08-20 13:55:53 -0400
committerHari Khalsa <hkhalsa@10gen.com>2013-08-26 10:43:10 -0400
commitc8c9cf9abe7636b75c876752656b3b730c8b2bdd (patch)
treeb3d8c8dd6d54bc2b5ad5f2d385c030ba003b83fc /src/mongo/db/repl
parent6a6bc2da6536ebf4a4c2faae99f1963cd8772f87 (diff)
downloadmongo-c8c9cf9abe7636b75c876752656b3b730c8b2bdd.tar.gz
SERVER-10026 SERVER-10546 get tailable cursors right and enable repl to work
Diffstat (limited to 'src/mongo/db/repl')
-rw-r--r--src/mongo/db/repl/repl_reads_ok.cpp25
-rw-r--r--src/mongo/db/repl/repl_reads_ok.h5
2 files changed, 30 insertions, 0 deletions
diff --git a/src/mongo/db/repl/repl_reads_ok.cpp b/src/mongo/db/repl/repl_reads_ok.cpp
index 2212925b0bc..be42cfa610b 100644
--- a/src/mongo/db/repl/repl_reads_ok.cpp
+++ b/src/mongo/db/repl/repl_reads_ok.cpp
@@ -18,6 +18,7 @@
#include "mongo/client/dbclientinterface.h"
#include "mongo/db/parsed_query.h"
+#include "mongo/db/query/lite_parsed_query.h"
#include "mongo/db/repl/is_master.h"
#include "mongo/db/repl/replication_server_status.h"
#include "mongo/db/repl/rs.h"
@@ -49,4 +50,28 @@ namespace mongo {
}
}
+ /** we allow queries to SimpleSlave's */
+ void replVerifyReadsOk(const LiteParsedQuery* pq) {
+ if( replSet ) {
+ // todo: speed up the secondary case. as written here there are 2 mutex entries, it
+ // can b 1.
+ if( isMaster() ) return;
+ if ( cc().isGod() ) return;
+
+ uassert(17069, "not master and slaveOk=false",
+ !pq || pq->hasOption(QueryOption_SlaveOk) || pq->hasReadPref());
+ uassert(17070,
+ "not master or secondary; cannot currently read from this replSet member",
+ theReplSet && theReplSet->isSecondary() );
+ }
+ else {
+ // master/slave
+ uassert(17071,
+ "not master",
+ isMaster() ||
+ (!pq || pq->hasOption(QueryOption_SlaveOk)) ||
+ replSettings.slave == SimpleSlave );
+ }
+ }
+
} // namespace mongo
diff --git a/src/mongo/db/repl/repl_reads_ok.h b/src/mongo/db/repl/repl_reads_ok.h
index 3ff996eba43..1b87277284c 100644
--- a/src/mongo/db/repl/repl_reads_ok.h
+++ b/src/mongo/db/repl/repl_reads_ok.h
@@ -19,8 +19,13 @@
namespace mongo {
class ParsedQuery;
+ class LiteParsedQuery;
// Check to see if slaveOk reads are allowed,
// based on read preference and query options
+
+ // DEPRECATED impl
void replVerifyReadsOk(const ParsedQuery* pq = 0);
+
+ void replVerifyReadsOk(const LiteParsedQuery* pq);
}