summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregory Wlodarek <gregory.wlodarek@mongodb.com>2019-12-20 21:32:50 +0000
committerevergreen <evergreen@mongodb.com>2019-12-20 21:32:50 +0000
commitc639699a24f389532b61f4f23323ef449c6813a5 (patch)
tree0ac0a0b236c7a9ebd08bf1b35891a2fdf80c1c45
parent0e079cef6ba967a3cc930c6fb7960a9125a387ad (diff)
downloadmongo-c639699a24f389532b61f4f23323ef449c6813a5.tar.gz
SERVER-44438 Have queryableBackupMode open WT in read/write mode
-rw-r--r--jstests/readonly/lib/read_only_test.js110
-rw-r--r--src/mongo/db/mongod_options_storage.idl5
-rw-r--r--src/mongo/db/pipeline/pipeline.cpp3
-rw-r--r--src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp5
4 files changed, 40 insertions, 83 deletions
diff --git a/jstests/readonly/lib/read_only_test.js b/jstests/readonly/lib/read_only_test.js
index 3a631a66057..c42e9535179 100644
--- a/jstests/readonly/lib/read_only_test.js
+++ b/jstests/readonly/lib/read_only_test.js
@@ -3,22 +3,6 @@ var StandaloneFixture, ShardedFixture, runReadOnlyTest, zip2, cycleN;
(function() {
"use strict";
-function makeDirectoryReadOnly(dir) {
- if (_isWindows()) {
- run("attrib", "+r", dir + "\\*.*", "/s");
- } else {
- run("chmod", "-R", "a-w", dir);
- }
-}
-
-function makeDirectoryWritable(dir) {
- if (_isWindows()) {
- run("attrib", "-r", dir + "\\*.*", "/s");
- } else {
- run("chmod", "-R", "a+w", dir);
- }
-}
-
StandaloneFixture = function() {};
StandaloneFixture.prototype.runLoadPhase = function runLoadPhase(test) {
@@ -31,20 +15,11 @@ StandaloneFixture.prototype.runLoadPhase = function runLoadPhase(test) {
};
StandaloneFixture.prototype.runExecPhase = function runExecPhase(test) {
- try {
- makeDirectoryReadOnly(this.dbpath);
-
- var options = {queryableBackupMode: "", noCleanData: true, dbpath: this.dbpath};
-
- this.mongod = MongoRunner.runMongod(options);
- assert.neq(this.mongod, null);
-
- test.exec(this.mongod.getDB("test")[test.name]);
-
- MongoRunner.stopMongod(this.mongod);
- } finally {
- makeDirectoryWritable(this.dbpath);
- }
+ var options = {queryableBackupMode: "", noCleanData: true, dbpath: this.dbpath};
+ this.mongod = MongoRunner.runMongod(options);
+ assert.neq(this.mongod, null);
+ test.exec(this.mongod.getDB("test")[test.name]);
+ MongoRunner.stopMongod(this.mongod);
};
ShardedFixture = function() {
@@ -70,60 +45,41 @@ ShardedFixture.prototype.runLoadPhase = function runLoadPhase(test) {
ShardedFixture.prototype.runExecPhase = function runExecPhase(test) {
jsTest.log("restarting shards...");
- try {
- for (var i = 0; i < this.nShards; ++i) {
- // Write the shard's shardIdentity to a config file under
- // sharding._overrideShardIdentity, since the shardIdentity must be provided through
- // overrideShardIdentity when running in queryableBackupMode, and is only allowed to
- // be set via config file.
-
- var shardIdentity =
- this.shardingTest["d" + i].getDB("admin").getCollection("system.version").findOne({
- _id: "shardIdentity"
- });
- assert.neq(null, shardIdentity);
-
- // Construct a string representation of the config file (replace all instances of
- // multiple consecutive whitespace characters in the string representation of the
- // shardIdentity JSON document, including newlines, with single white spaces).
- var configFileStr = "sharding:\n _overrideShardIdentity: '" +
- tojson(shardIdentity).replace(/\s+/g, ' ') + "'";
-
- // Use the os-specific path delimiter.
- var delim = _isWindows() ? '\\' : '/';
- var configFilePath = this.paths[i] + delim + "config-for-shard-" + i + ".yml";
-
- writeFile(configFilePath, configFileStr);
-
- var opts = {
- config: configFilePath,
- queryableBackupMode: "",
- shardsvr: "",
- dbpath: this.paths[i]
- };
-
- assert.commandWorked(this.shardingTest["d" + i].getDB("local").dropDatabase());
- this.shardingTest.restartMongod(i, opts, () => {
- makeDirectoryReadOnly(this.paths[i]);
+ for (var i = 0; i < this.nShards; ++i) {
+ // Write the shard's shardIdentity to a config file under
+ // sharding._overrideShardIdentity, since the shardIdentity must be provided through
+ // overrideShardIdentity when running in queryableBackupMode, and is only allowed to
+ // be set via config file.
+
+ var shardIdentity =
+ this.shardingTest["d" + i].getDB("admin").getCollection("system.version").findOne({
+ _id: "shardIdentity"
});
- }
+ assert.neq(null, shardIdentity);
- jsTest.log("restarting mongos...");
+ // Construct a string representation of the config file (replace all instances of
+ // multiple consecutive whitespace characters in the string representation of the
+ // shardIdentity JSON document, including newlines, with single white spaces).
+ var configFileStr = "sharding:\n _overrideShardIdentity: '" +
+ tojson(shardIdentity).replace(/\s+/g, ' ') + "'";
- this.shardingTest.restartMongos(0);
+ // Use the os-specific path delimiter.
+ var delim = _isWindows() ? '\\' : '/';
+ var configFilePath = this.paths[i] + delim + "config-for-shard-" + i + ".yml";
- test.exec(this.shardingTest.getDB("test")[test.name]);
+ writeFile(configFilePath, configFileStr);
- this.paths.forEach((path) => {
- makeDirectoryWritable(path);
- });
+ var opts =
+ {config: configFilePath, queryableBackupMode: "", shardsvr: "", dbpath: this.paths[i]};
- this.shardingTest.stop();
- } finally {
- this.paths.forEach((path) => {
- makeDirectoryWritable(path);
- });
+ assert.commandWorked(this.shardingTest["d" + i].getDB("local").dropDatabase());
+ this.shardingTest.restartMongod(i, opts);
}
+
+ jsTest.log("restarting mongos...");
+ this.shardingTest.restartMongos(0);
+ test.exec(this.shardingTest.getDB("test")[test.name]);
+ this.shardingTest.stop();
};
runReadOnlyTest = function(test) {
diff --git a/src/mongo/db/mongod_options_storage.idl b/src/mongo/db/mongod_options_storage.idl
index 9718e01131b..0171782c32e 100644
--- a/src/mongo/db/mongod_options_storage.idl
+++ b/src/mongo/db/mongod_options_storage.idl
@@ -56,7 +56,10 @@ configs:
arg_vartype: Switch
'storage.queryableBackupMode':
- description: 'Enable read-only mode - if true the server will not accept writes'
+ description: >-
+ Enables queryable backup mode which starts the storage engine in read/write mode to
+ allow for replication recovery. After replication recovery the server above the
+ storage engine layer will be in read-only mode.
short_name: queryableBackupMode
arg_vartype: Switch
hidden: true
diff --git a/src/mongo/db/pipeline/pipeline.cpp b/src/mongo/db/pipeline/pipeline.cpp
index 4990e916245..63dc6bb89b3 100644
--- a/src/mongo/db/pipeline/pipeline.cpp
+++ b/src/mongo/db/pipeline/pipeline.cpp
@@ -50,6 +50,7 @@
#include "mongo/db/pipeline/document_source_unwind.h"
#include "mongo/db/pipeline/expression.h"
#include "mongo/db/pipeline/expression_context.h"
+#include "mongo/db/storage/storage_options.h"
#include "mongo/util/fail_point.h"
#include "mongo/util/str.h"
@@ -574,7 +575,7 @@ Status Pipeline::_pipelineCanRunOnMongoS() const {
const bool mustWriteToDisk =
(constraints.diskRequirement == DiskUseRequirement::kWritesPersistentData);
const bool mayWriteTmpDataAndDiskUseIsAllowed =
- (pCtx->allowDiskUse &&
+ (pCtx->allowDiskUse && !storageGlobalParams.readOnly &&
constraints.diskRequirement == DiskUseRequirement::kWritesTmpData);
const bool needsDisk = (mustWriteToDisk || mayWriteTmpDataAndDiskUseIsAllowed);
diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp
index 5f06686a2de..2013e2fed91 100644
--- a/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp
+++ b/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp
@@ -714,10 +714,7 @@ WiredTigerKVEngine::WiredTigerKVEngine(const std::string& canonicalName,
->getTableCreateConfig("system");
ss << WiredTigerExtensions::get(getGlobalServiceContext())->getOpenExtensionsConfig();
ss << extraOpenOptions;
- if (_readOnly) {
- invariant(!_durable);
- ss << ",readonly=true,";
- }
+
if (!_durable && !_readOnly) {
// If we started without the journal, but previously used the journal then open with the
// WT log enabled to perform any unclean shutdown recovery and then close and reopen in