Compare commits
63 Commits
r4.7.0
...
fixed_thre
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
63338e0dd6 | ||
|
|
13bb35d34d | ||
|
|
f4373b85f0 | ||
|
|
51067e0952 | ||
|
|
9262aac9e7 | ||
|
|
5b57abab3e | ||
|
|
907bf93c57 | ||
|
|
243a506fca | ||
|
|
8cff99b2c4 | ||
|
|
439730c7f4 | ||
|
|
18f1d00029 | ||
|
|
fa29e47f37 | ||
|
|
b03c93d55b | ||
|
|
1d6af89487 | ||
|
|
38f350478a | ||
|
|
4c283d5c34 | ||
|
|
efb3f7689e | ||
|
|
66b412e165 | ||
|
|
5f3f8d9745 | ||
|
|
dabf0e0842 | ||
|
|
92e7ecf4ba | ||
|
|
46b220b83e | ||
|
|
575f370475 | ||
|
|
6a031f67c7 | ||
|
|
d735d9cf70 | ||
|
|
8dfebbb8bc | ||
|
|
b39aecbdf4 | ||
|
|
1373280c25 | ||
|
|
642adc7547 | ||
|
|
a5f72d4b37 | ||
|
|
712013ffd4 | ||
|
|
94e5a1620a | ||
|
|
a70ac5e30e | ||
|
|
8216b783d1 | ||
|
|
8222bf3550 | ||
|
|
f10e0ad7ca | ||
|
|
b68df4e87d | ||
|
|
4ff797fa43 | ||
|
|
0927e74e9d | ||
|
|
11c68393df | ||
|
|
ce0487190c | ||
|
|
93a5cd255c | ||
|
|
3e453b013e | ||
|
|
759787fd5a | ||
|
|
9dac088a96 | ||
|
|
57cb74336b | ||
|
|
0ce948778c | ||
|
|
c7efb504fd | ||
|
|
09ba65f429 | ||
|
|
74c76f296c | ||
|
|
2b5dc35f01 | ||
|
|
ee106b978c | ||
|
|
4b2be90987 | ||
|
|
377b8fe439 | ||
|
|
f9d4a15397 | ||
|
|
10ecbbca34 | ||
|
|
4e6da58756 | ||
|
|
1327ea6366 | ||
|
|
2795d76c63 | ||
|
|
067c84541c | ||
|
|
705f35bfd7 | ||
|
|
5665906d24 | ||
|
|
700e7a60b0 |
3
.gitignore
vendored
3
.gitignore
vendored
@@ -176,6 +176,9 @@ src/mongo/embedded/java/aar/build/
|
||||
src/mongo/embedded/java/jar/build/
|
||||
local.properties
|
||||
|
||||
# clangd language server
|
||||
.clangd/
|
||||
|
||||
compile_commands.json
|
||||
generated_resmoke_config
|
||||
selected_tests_config
|
||||
|
||||
@@ -19,40 +19,40 @@ not authored by MongoDB, and has a license which requires reproduction,
|
||||
a notice will be included in
|
||||
`THIRD-PARTY-NOTICES`.
|
||||
|
||||
| Name | License | Upstream Version | Vendored Version | Emits persisted data | Distributed in Release Binaries |
|
||||
| ---------------------------| ----------------- | ---------------- | ------------------| :------------------: | :-----------------------------: |
|
||||
| [abseil-cpp] | Apache-2.0 | | 070f6e47b3 | | ✗ |
|
||||
| Aladdin MD5 | Zlib | | Unknown | ✗ | ✗ |
|
||||
| [ASIO] | BSL-1.0 | 1.16.1 | b0926b61b0 | | ✗ |
|
||||
| [benchmark] | Apache-2.0 | 1.5.1 | 1.5.0 | | |
|
||||
| [Boost] | BSL-1.0 | 1.73.0 | 1.70.0 | | ✗ |
|
||||
| [fmt] | BSD-2-Clause | 6.2.1 | 6.1.1 | | ✗ |
|
||||
| [GPerfTools] | BSD-3-Clause | 2.8 | 2.8 | | ✗ |
|
||||
| [ICU4] | ICU | 67.1 | 57.1 | ✗ | ✗ |
|
||||
| [Intel Decimal FP Library] | BSD-3-Clause | 2.0 Update 2 | 2.0 Update 1 | | ✗ |
|
||||
| [JSON-Schema-Test-Suite] | MIT | | 728066f9c5 | | |
|
||||
| [kms-message] | | | 75e391a037 | | ✗ |
|
||||
| [libstemmer] | BSD-3-Clause | | Unknown | ✗ | ✗ |
|
||||
| [linenoise] | BSD-3-Clause | | Unknown + changes | | ✗ |
|
||||
| [MozJS] | MPL-2.0 | ESR 68.9 | ESR 60.3.0 | | ✗ |
|
||||
| [MurmurHash3] | Public Domain | | Unknown + changes | ✗ | ✗ |
|
||||
| [ocspbuilder] | MIT | 0.10.2 | 0.10.2 | | |
|
||||
| [ocspresponder] | Apache-2.0 | 0.5.0 | 0.5.0 | | |
|
||||
| [peglib] | MIT | 0.1.12 | 0.1.12 | | ✗ |
|
||||
| [Pcre] | BSD-3-Clause | 8.44 | 8.42 | | ✗ |
|
||||
| [S2] | Apache-2.0 | | Unknown | ✗ | ✗ |
|
||||
| [SafeInt] | MIT | 3.24 | 3.23 | | |
|
||||
| [scons] | MIT | 3.1.2 | 3.1.2 | | |
|
||||
| [Snappy] | BSD-3-Clause | 1.1.8 | 1.1.7 | ✗ | ✗ |
|
||||
| [timelib] | MIT | 2018.03 | 2018.01 | | ✗ |
|
||||
| [TomCrypt] | Public Domain | 1.18.2 | 1.18.2 | ✗ | ✗ |
|
||||
| [Unicode] | Unicode-DFS-2015 | 13.0.0 | 8.0.0 | ✗ | ✗ |
|
||||
| [Valgrind] | BSD-3-Clause<sup>\[<a href="#note_vg" id="ref_vg">1</a>]</sup> | 3.16.1 | 3.11.0 | | ✗ |
|
||||
| [variant] | BSL-1.0 | 1.4.0 | 1.4.0 | | ✗ |
|
||||
| [wiredtiger] | | | <sup>\[<a href="#note_wt" id="ref_wt">2</a>]</sup> | ✗ | ✗ |
|
||||
| [yaml-cpp] | MIT | 0.6.3 | 0.6.2 | | ✗ |
|
||||
| [Zlib] | Zlib | 1.2.11 | 1.2.11 | ✗ | ✗ |
|
||||
| [Zstandard] | BSD-3-Clause | 1.4.5 | 1.4.4 | ✗ | ✗ |
|
||||
| Name | License | Vendored Version | Emits persisted data | Distributed in Release Binaries |
|
||||
| ---------------------------| ----------------- | ------------------| :------------------: | :-----------------------------: |
|
||||
| [abseil-cpp] | Apache-2.0 | 070f6e47b3 | | ✗ |
|
||||
| Aladdin MD5 | Zlib | Unknown | ✗ | ✗ |
|
||||
| [ASIO] | BSL-1.0 | b0926b61b0 | | ✗ |
|
||||
| [benchmark] | Apache-2.0 | 1.5.0 | | |
|
||||
| [Boost] | BSL-1.0 | 1.70.0 | | ✗ |
|
||||
| [fmt] | BSD-2-Clause | 6.1.1 | | ✗ |
|
||||
| [GPerfTools] | BSD-3-Clause | 2.8 | | ✗ |
|
||||
| [ICU4] | ICU | 57.1 | ✗ | ✗ |
|
||||
| [Intel Decimal FP Library] | BSD-3-Clause | 2.0 Update 1 | | ✗ |
|
||||
| [JSON-Schema-Test-Suite] | MIT | 728066f9c5 | | |
|
||||
| [kms-message] | | 75e391a037 | | ✗ |
|
||||
| [libstemmer] | BSD-3-Clause | Unknown | ✗ | ✗ |
|
||||
| [linenoise] | BSD-3-Clause | Unknown + changes | | ✗ |
|
||||
| [MozJS] | MPL-2.0 | ESR 60.3.0 | | ✗ |
|
||||
| [MurmurHash3] | Public Domain | Unknown + changes | ✗ | ✗ |
|
||||
| [ocspbuilder] | MIT | 0.10.2 | | |
|
||||
| [ocspresponder] | Apache-2.0 | 0.5.0 | | |
|
||||
| [peglib] | MIT | 0.1.12 | | ✗ |
|
||||
| [Pcre] | BSD-3-Clause | 8.42 | | ✗ |
|
||||
| [S2] | Apache-2.0 | Unknown | ✗ | ✗ |
|
||||
| [SafeInt] | MIT | 3.23 | | |
|
||||
| [scons] | MIT | 3.1.2 | | |
|
||||
| [Snappy] | BSD-3-Clause | 1.1.7 | ✗ | ✗ |
|
||||
| [timelib] | MIT | 2018.01 | | ✗ |
|
||||
| [TomCrypt] | Public Domain | 1.18.2 | ✗ | ✗ |
|
||||
| [Unicode] | Unicode-DFS-2015 | 8.0.0 | ✗ | ✗ |
|
||||
| [Valgrind] | BSD-3-Clause<sup>\[<a href="#note_vg" id="ref_vg">1</a>]</sup> | 3.11.0 | | ✗ |
|
||||
| [variant] | BSL-1.0 | 1.4.0 | | ✗ |
|
||||
| [wiredtiger] | | <sup>\[<a href="#note_wt" id="ref_wt">2</a>]</sup> | ✗ | ✗ |
|
||||
| [yaml-cpp] | MIT | 0.6.2 | | ✗ |
|
||||
| [Zlib] | Zlib | 1.2.11 | ✗ | ✗ |
|
||||
| [Zstandard] | BSD-3-Clause | 1.4.4 | ✗ | ✗ |
|
||||
|
||||
[abseil-cpp]: https://github.com/abseil/abseil-cpp
|
||||
[ASIO]: https://github.com/chriskohlhoff/asio
|
||||
|
||||
@@ -128,7 +128,7 @@ class Process(object):
|
||||
logger=self.logger.name.replace('/', '-'),
|
||||
process=os.path.basename(self.args[0]), pid=self.pid, t=now_str)
|
||||
recorder_args = [
|
||||
_config.UNDO_RECORDER_PATH, "--thread-fuzzing", "-p",
|
||||
_config.UNDO_RECORDER_PATH, "-p",
|
||||
str(self.pid), "-o", recorder_output_file
|
||||
]
|
||||
self._recorder = subprocess.Popen(recorder_args, bufsize=buffer_size, env=self.env,
|
||||
|
||||
@@ -66,6 +66,16 @@ all:
|
||||
test_file: jstests/replsets/secondaryOk_slaveOk_aliases.js
|
||||
- ticket: SERVER-43902
|
||||
test_file: jstests/sharding/scaled_collection_stats.js
|
||||
- ticket: SERVER-50416
|
||||
test_file: jstests/replsets/disconnect_on_legacy_write_to_secondary.js
|
||||
- ticket: SERVER-50417
|
||||
test_file: jstests/replsets/no_disconnect_on_stepdown.js
|
||||
- ticket: SERVER-50417
|
||||
test_file: jstests/replsets/not_master_unacknowledged_write.js
|
||||
- ticket: SERVER-50417
|
||||
test_file: jstests/replsets/read_operations_during_step_down.js
|
||||
- ticket: SERVER-50417
|
||||
test_file: jstests/replsets/read_operations_during_step_up.js
|
||||
|
||||
# Tests that should only be excluded from particular suites should be listed under that suite.
|
||||
suites:
|
||||
|
||||
@@ -768,12 +768,12 @@ functions:
|
||||
set -o errexit
|
||||
|
||||
cat <<EOF > notary_env.sh
|
||||
export NOTARY_TOKEN=${signing_auth_token_46}
|
||||
export NOTARY_TOKEN=${signing_auth_token_48}
|
||||
export BARQUE_USERNAME=${barque_user}
|
||||
export BARQUE_API_KEY=${barque_api_key}
|
||||
EOF
|
||||
|
||||
echo "${signing_auth_token_46}" > signing_auth_token
|
||||
echo "${signing_auth_token_48}" > signing_auth_token
|
||||
|
||||
"set up remote credentials": &set_up_remote_credentials
|
||||
command: shell.exec
|
||||
@@ -7797,7 +7797,7 @@ tasks:
|
||||
mv distsrc.${ext|tgz} mongodb-src-${src_suffix}.${ext|tar.gz} || true
|
||||
/usr/bin/find build/ -type f | grep msi$ | xargs -I original_filename cp original_filename mongodb-${push_name}-${push_arch}-${suffix}.msi || true
|
||||
|
||||
/usr/local/bin/notary-client.py --key-name "server-4.6" --auth-token-file ${workdir}/src/signing_auth_token --comment "Evergreen Automatic Signing ${revision} - ${build_variant} - ${branch_name}" --notary-url http://notary-service.build.10gen.cc:5000 --skip-missing mongodb-${push_name}-${push_arch}-${suffix}.${ext|tgz} mongodb-shell-${push_name}-${push_arch}-${suffix}.${ext|tgz} mongodb-${push_name}-${push_arch}-debugsymbols-${suffix}.${ext|tgz} mongodb-${push_name}-${push_arch}-${suffix}.msi mongodb-src-${src_suffix}.${ext|tar.gz} mongodb-cryptd-${push_name}-${push_arch}-${suffix}.${ext|tgz}
|
||||
/usr/local/bin/notary-client.py --key-name "server-4.8" --auth-token-file ${workdir}/src/signing_auth_token --comment "Evergreen Automatic Signing ${revision} - ${build_variant} - ${branch_name}" --notary-url http://notary-service.build.10gen.cc:5000 --skip-missing mongodb-${push_name}-${push_arch}-${suffix}.${ext|tgz} mongodb-shell-${push_name}-${push_arch}-${suffix}.${ext|tgz} mongodb-${push_name}-${push_arch}-debugsymbols-${suffix}.${ext|tgz} mongodb-${push_name}-${push_arch}-${suffix}.msi mongodb-src-${src_suffix}.${ext|tar.gz} mongodb-cryptd-${push_name}-${push_arch}-${suffix}.${ext|tgz}
|
||||
|
||||
# Put the binaries tarball/zipfile
|
||||
- command: s3.put
|
||||
@@ -12600,6 +12600,38 @@ buildvariants:
|
||||
distros:
|
||||
- ubuntu1804-build
|
||||
|
||||
- name: enterprise-ubuntu-fixed-service-executor-1604-64-bit
|
||||
display_name: "~ Enterprise Ubuntu 16.04 (with FixedServiceExecutor)"
|
||||
batchtime: 1440 # 1 day
|
||||
run_on:
|
||||
- ubuntu1604-test
|
||||
modules:
|
||||
- enterprise
|
||||
expansions:
|
||||
scons_cache_scope: shared
|
||||
compile_flags: MONGO_DISTMOD=ubuntu1604 -j$(grep -c ^processor /proc/cpuinfo) --variables-files=etc/scons/mongodbtoolchain_v3_gcc.vars
|
||||
multiversion_platform: ubuntu1604
|
||||
multiversion_edition: enterprise
|
||||
test_flags: >-
|
||||
--mongosSetParameters="{initialServiceExecutorThreadingModel: borrowed}"
|
||||
--mongodSetParameters="{initialServiceExecutorThreadingModel: borrowed}"
|
||||
|
||||
tasks:
|
||||
- name: compile_all_run_unittests_TG
|
||||
distros:
|
||||
- ubuntu1604-build
|
||||
- name: .aggregation !.no_async
|
||||
- name: .sharding .auth
|
||||
- name: .sharding .causally_consistent !.wo_snapshot
|
||||
- name: .concurrency .common !.kill_terminate
|
||||
- name: .integration !.audit
|
||||
- name: .jscore .common
|
||||
- name: noPassthrough_gen
|
||||
- name: noPassthroughWithMongod_gen
|
||||
- name: .logical_session_cache .one_sec
|
||||
- name: .sharding .jscore !.wo_snapshot !.multi_stmt
|
||||
- name: .sharding .common !.csrs
|
||||
|
||||
- name: enterprise-ubuntu-scanning-replica-set-monitor-1604-64-bit
|
||||
display_name: "~ Enterprise Ubuntu 16.04 (with ScanningReplicaSetMonitor)"
|
||||
batchtime: 1440 # 1 day
|
||||
@@ -12751,6 +12783,7 @@ buildvariants:
|
||||
num_scons_link_jobs_available: 0.99
|
||||
record_with: --recordWith /opt/undodb5/bin/live-record
|
||||
exec_timeout_secs: 14400 # 4 hours
|
||||
test_flags: --excludeWithAnyTags=requires_fast_memory
|
||||
tasks:
|
||||
- name: compile_without_package_TG
|
||||
- name: .jscore .common
|
||||
@@ -12764,6 +12797,24 @@ buildvariants:
|
||||
- name: sharded_jscore_txns_sharded_collections
|
||||
- name: sharding_jscore_passthrough
|
||||
- name: sharding_jscore_op_query_passthrough
|
||||
- name: aggregation
|
||||
- name: aggregation_auth
|
||||
- name: aggregation_disabled_optimization
|
||||
- name: aggregation_ese
|
||||
- name: aggregation_ese_gcm
|
||||
- name: aggregation_facet_unwind_passthrough
|
||||
- name: aggregation_slot_based_execution
|
||||
- name: .auth .gle
|
||||
- name: .jscore .encrypt
|
||||
- name: noPassthroughWithMongod_gen
|
||||
- name: parallel_compatibility
|
||||
- name: serial_run
|
||||
- name: session_jscore_passthrough
|
||||
- name: .aggfuzzer
|
||||
- name: query_fuzzer_standalone_gen
|
||||
- name: update_fuzzer_gen
|
||||
- name: jstestfuzz_gen
|
||||
- name: jstestfuzz_interrupt_gen
|
||||
|
||||
- <<: *enterprise-rhel-62-64-bit-dynamic-required-template
|
||||
name: rhel-62-64-bit-dynamic-visibility-test
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Test that authorization information gets propogated correctly to secondaries and slaves.
|
||||
// Test that authorization information gets propogated correctly to secondaries.
|
||||
|
||||
var baseName = "jstests_auth_repl";
|
||||
var rsName = baseName + "_rs";
|
||||
@@ -26,7 +26,7 @@ var AuthReplTest = function(spec) {
|
||||
assert(adminPri.auth("super", "super"), "could not authenticate as superuser");
|
||||
|
||||
if (secondaryConn != null) {
|
||||
secondaryConn.setSlaveOk(true);
|
||||
secondaryConn.setSecondaryOk();
|
||||
adminSec = secondaryConn.getDB("admin");
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ var AuthReplTest = function(spec) {
|
||||
|
||||
/**
|
||||
* Use the rolesInfo command to check that the test
|
||||
* role is as expected on the secondary/slave
|
||||
* role is as expected on the secondary
|
||||
*/
|
||||
var confirmRolesInfo = function(actionType) {
|
||||
var role = adminSec.getRole(testRole, {showPrivileges: true});
|
||||
@@ -48,7 +48,7 @@ var AuthReplTest = function(spec) {
|
||||
|
||||
/**
|
||||
* Use the usersInfo command to check that the test
|
||||
* user is as expected on the secondary/slave
|
||||
* user is as expected on the secondary
|
||||
*/
|
||||
var confirmUsersInfo = function(roleName) {
|
||||
var user = adminSec.getUser(testUser);
|
||||
@@ -58,7 +58,7 @@ var AuthReplTest = function(spec) {
|
||||
|
||||
/**
|
||||
* Ensure that the test user has the proper privileges
|
||||
* on the secondary/slave
|
||||
* on the secondary
|
||||
*/
|
||||
var confirmPrivilegeBeforeUpdate = function() {
|
||||
// can run hostInfo
|
||||
@@ -87,7 +87,7 @@ var AuthReplTest = function(spec) {
|
||||
|
||||
/**
|
||||
* Ensure that the auth changes have taken effect
|
||||
* properly on the secondary/slave
|
||||
* properly on the secondary
|
||||
*/
|
||||
var confirmPrivilegeAfterUpdate = function() {
|
||||
// cannot run hostInfo
|
||||
@@ -117,7 +117,7 @@ var AuthReplTest = function(spec) {
|
||||
*/
|
||||
that.setSecondary = function(secondary) {
|
||||
secondaryConn = secondary;
|
||||
secondaryConn.setSlaveOk(true);
|
||||
secondaryConn.setSecondaryOk();
|
||||
adminSec = secondaryConn.getDB("admin");
|
||||
};
|
||||
|
||||
@@ -149,7 +149,7 @@ var AuthReplTest = function(spec) {
|
||||
|
||||
/**
|
||||
* Top-level test for updating users and roles and ensuring that the update
|
||||
* has the correct effect on the secondary/slave
|
||||
* has the correct effect on the secondary
|
||||
*/
|
||||
that.testAll = function() {
|
||||
authOnSecondary();
|
||||
|
||||
@@ -72,7 +72,7 @@ var $config = (function() {
|
||||
// Create a new connection to any node which isn't "me".
|
||||
const conn = new Mongo(node);
|
||||
assert(conn);
|
||||
conn.setSlaveOk();
|
||||
conn.setSecondaryOk();
|
||||
RSnodes.push(conn);
|
||||
});
|
||||
|
||||
|
||||
66
jstests/core/resume_query_from_non_existent_record.js
Normal file
66
jstests/core/resume_query_from_non_existent_record.js
Normal file
@@ -0,0 +1,66 @@
|
||||
/**
|
||||
* Test that an error is raised when we try to resume a query from a record which doesn't exist.
|
||||
*
|
||||
* @tags: [
|
||||
* assumes_against_mongod_not_mongos,
|
||||
* requires_find_command,
|
||||
* multiversion_incompatible,
|
||||
* ]
|
||||
*/
|
||||
|
||||
(function() {
|
||||
"use strict";
|
||||
|
||||
const collName = "resume_query_from_non_existent_record";
|
||||
const coll = db[collName];
|
||||
|
||||
coll.drop();
|
||||
|
||||
const testData = [{_id: 0, a: 1}, {_id: 1, a: 2}, {_id: 2, a: 3}];
|
||||
assert.commandWorked(coll.insert(testData));
|
||||
|
||||
// Run the initial query and request to return a resume token. We're interested only in a single
|
||||
// document, so 'batchSize' is set to 1.
|
||||
let res = assert.commandWorked(
|
||||
db.runCommand({find: collName, hint: {$natural: 1}, batchSize: 1, $_requestResumeToken: true}));
|
||||
assert.eq(1, res.cursor.firstBatch.length);
|
||||
assert.contains(res.cursor.firstBatch[0], testData);
|
||||
const savedData = res.cursor.firstBatch;
|
||||
|
||||
// Make sure the query returned a resume token which will be used to resume the query from.
|
||||
assert.hasFields(res.cursor, ["postBatchResumeToken"]);
|
||||
const resumeToken = res.cursor.postBatchResumeToken;
|
||||
|
||||
// Kill the cursor before attempting to resume.
|
||||
assert.commandWorked(db.runCommand({killCursors: collName, cursors: [res.cursor.id]}));
|
||||
|
||||
// Try to resume the query from the saved resume token.
|
||||
res = assert.commandWorked(db.runCommand({
|
||||
find: collName,
|
||||
hint: {$natural: 1},
|
||||
batchSize: 1,
|
||||
$_requestResumeToken: true,
|
||||
$_resumeAfter: resumeToken
|
||||
}));
|
||||
assert.eq(1, res.cursor.firstBatch.length);
|
||||
assert.contains(res.cursor.firstBatch[0], testData);
|
||||
assert.neq(savedData[0], res.cursor.firstBatch[0]);
|
||||
|
||||
// Kill the cursor before attempting to resume.
|
||||
assert.commandWorked(db.runCommand({killCursors: collName, cursors: [res.cursor.id]}));
|
||||
|
||||
// Delete a document which corresponds to the saved resume token, so that we can guarantee it does
|
||||
// not exist.
|
||||
assert.commandWorked(coll.remove({_id: savedData[0]._id}, {justOne: true}));
|
||||
|
||||
// Try to resume the query from the same token and check that it fails to position the cursor to
|
||||
// the record specified in the resume token.
|
||||
assert.commandFailedWithCode(db.runCommand({
|
||||
find: collName,
|
||||
hint: {$natural: 1},
|
||||
batchSize: 1,
|
||||
$_requestResumeToken: true,
|
||||
$_resumeAfter: resumeToken
|
||||
}),
|
||||
ErrorCodes.KeyNotFound);
|
||||
})();
|
||||
@@ -4,11 +4,15 @@ shellHelper("show", "tables;");
|
||||
shellHelper("show", "tables");
|
||||
shellHelper("show", "tables ;");
|
||||
|
||||
// test slaveOk levels
|
||||
assert(!db.getSlaveOk() && !db.test.getSlaveOk() && !db.getMongo().getSlaveOk(), "slaveOk 1");
|
||||
db.getMongo().setSlaveOk();
|
||||
assert(db.getSlaveOk() && db.test.getSlaveOk() && db.getMongo().getSlaveOk(), "slaveOk 2");
|
||||
db.setSlaveOk(false);
|
||||
assert(!db.getSlaveOk() && !db.test.getSlaveOk() && db.getMongo().getSlaveOk(), "slaveOk 3");
|
||||
db.test.setSlaveOk(true);
|
||||
assert(!db.getSlaveOk() && db.test.getSlaveOk() && db.getMongo().getSlaveOk(), "slaveOk 4");
|
||||
// test secondaryOk levels
|
||||
assert(!db.getSecondaryOk() && !db.test.getSecondaryOk() && !db.getMongo().getSecondaryOk(),
|
||||
"secondaryOk 1");
|
||||
db.getMongo().setSecondaryOk();
|
||||
assert(db.getSecondaryOk() && db.test.getSecondaryOk() && db.getMongo().getSecondaryOk(),
|
||||
"secondaryOk 2");
|
||||
db.setSecondaryOk(false);
|
||||
assert(!db.getSecondaryOk() && !db.test.getSecondaryOk() && db.getMongo().getSecondaryOk(),
|
||||
"secondaryOk 3");
|
||||
db.test.setSecondaryOk();
|
||||
assert(!db.getSecondaryOk() && db.test.getSecondaryOk() && db.getMongo().getSecondaryOk(),
|
||||
"secondaryOk 4");
|
||||
|
||||
@@ -338,6 +338,8 @@ let viewsCommandTests = {
|
||||
hello: {skip: isUnrelated},
|
||||
hostInfo: {skip: isUnrelated},
|
||||
httpClientRequest: {skip: isAnInternalCommand},
|
||||
exportCollection: {skip: isUnrelated},
|
||||
importCollection: {skip: isUnrelated},
|
||||
insert: {command: {insert: "view", documents: [{x: 1}]}, expectFailure: true},
|
||||
internalRenameIfOptionsAndIndexesMatch: {skip: isAnInternalCommand},
|
||||
invalidateUserCache: {skip: isUnrelated},
|
||||
|
||||
@@ -88,7 +88,7 @@ function CollectionValidator() {
|
||||
try {
|
||||
print('Running validate() on ' + host);
|
||||
const conn = new Mongo(host);
|
||||
conn.setSlaveOk();
|
||||
conn.setSecondaryOk();
|
||||
jsTest.authenticate(conn);
|
||||
|
||||
// Skip validating collections for arbiters.
|
||||
|
||||
@@ -120,7 +120,7 @@ var _kill_sessions_api_module = (function() {
|
||||
// hosts. We identify particular ops by secs sleeping.
|
||||
this.visit(function(client) {
|
||||
let admin = client.getDB("admin");
|
||||
admin.getMongo().setSlaveOk();
|
||||
admin.getMongo().setSecondaryOk();
|
||||
|
||||
assert.soon(function() {
|
||||
let inProgressOps = admin.aggregate([{$currentOp: {'allUsers': true}}]);
|
||||
@@ -183,7 +183,7 @@ var _kill_sessions_api_module = (function() {
|
||||
Fixture.prototype.assertNoSessionsInCursors = function() {
|
||||
this.visit(function(client) {
|
||||
var db = client.getDB("admin");
|
||||
db.setSlaveOk();
|
||||
db.setSecondaryOk();
|
||||
assert.soon(() => {
|
||||
let cursors = db.aggregate([
|
||||
{"$currentOp": {"idleCursors": true, "allUsers": true}}
|
||||
@@ -205,7 +205,7 @@ var _kill_sessions_api_module = (function() {
|
||||
});
|
||||
|
||||
var db = client.getDB("admin");
|
||||
db.setSlaveOk();
|
||||
db.setSecondaryOk();
|
||||
var cursors = db.aggregate([
|
||||
{"$currentOp": {"idleCursors": true, "allUsers": true}},
|
||||
{"$match": {type: "idleCursor"}}
|
||||
|
||||
@@ -29,8 +29,8 @@ MongoRunner.validateCollectionsCallback = function(port) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Set slaveOk=true so that we can run commands against any secondaries.
|
||||
conn.setSlaveOk();
|
||||
// Set secondaryOk=true so that we can run commands against any secondaries.
|
||||
conn.setSecondaryOk();
|
||||
|
||||
let dbNames;
|
||||
let result =
|
||||
|
||||
@@ -29,7 +29,7 @@ assert.commandWorked(secondary.getDB("admin").runCommand(
|
||||
{configureFailPoint: "waitInFindBeforeMakingBatch", mode: "alwaysOn"}));
|
||||
|
||||
const findWait = startParallelShell(function() {
|
||||
db.getMongo().setSlaveOk();
|
||||
db.getMongo().setSecondaryOk();
|
||||
assert.eq(
|
||||
db.getSiblingDB('read').getCollection('readColl').find().comment('read hangs').itcount(),
|
||||
1);
|
||||
|
||||
@@ -12,9 +12,9 @@ rst.startSet();
|
||||
rst.initiate();
|
||||
rst.awaitSecondaryNodes();
|
||||
|
||||
// Disable "slaveOk" on the connection so that we are not allowed to run on the Secondary.
|
||||
// Disable "secondaryOk" on the connection so that we are not allowed to run on the Secondary.
|
||||
const testDB = rst.getSecondary().getDB(jsTestName());
|
||||
testDB.getMongo().setSlaveOk(false);
|
||||
testDB.getMongo().setSecondaryOk(false);
|
||||
const coll = testDB.test;
|
||||
|
||||
// Issue a change stream. We should fail with a NotPrimaryNoSecondaryOk error.
|
||||
@@ -28,8 +28,8 @@ assert.contains("ResumableChangeStreamError", err.errorLabels, err);
|
||||
// Now verify that the 'failGetMoreAfterCursorCheckout' failpoint can effectively exercise the
|
||||
// error label generation logic for change stream getMores.
|
||||
function testFailGetMoreAfterCursorCheckoutFailpoint({errorCode, expectedLabel}) {
|
||||
// Re-enable "slaveOk" on the test connection.
|
||||
testDB.getMongo().setSlaveOk(true);
|
||||
// Re-enable "secondaryOk" on the test connection.
|
||||
testDB.getMongo().setSecondaryOk();
|
||||
|
||||
// Activate the failpoint and set the exception that it will throw.
|
||||
assert.commandWorked(testDB.adminCommand({
|
||||
|
||||
@@ -73,7 +73,6 @@ replTest.start(second,
|
||||
{
|
||||
setParameter: {
|
||||
"failpoint.hangAfterSettingUpIndexBuildUnlocked": tojson({mode: "alwaysOn"}),
|
||||
"failpoint.hangAfterSettingUpResumableIndexBuild": tojson({mode: "alwaysOn"})
|
||||
}
|
||||
},
|
||||
/*restart=*/true,
|
||||
@@ -93,14 +92,9 @@ try {
|
||||
// Verify that we do not wait for the index build to complete on startup.
|
||||
assert.eq(size, secondDB.getCollection(collectionName).find({}).itcount());
|
||||
|
||||
// Verify that only the _id index is ready.
|
||||
const supportsCommittedReads =
|
||||
assert.commandWorked(secondDB.serverStatus()).storageEngine.supportsCommittedReads;
|
||||
if (ResumableIndexBuildTest.resumableIndexBuildsEnabled(second) && supportsCommittedReads) {
|
||||
checkLog.containsJson(second, 4841704);
|
||||
} else {
|
||||
checkLog.containsJson(second, 4585201);
|
||||
}
|
||||
// The hangAfterSettingUpIndexBuildUnlocked fail point logs this message when it is active.
|
||||
checkLog.containsJson(second, 4585201);
|
||||
|
||||
IndexBuildTest.assertIndexes(secondDB.getCollection(collectionName),
|
||||
4,
|
||||
["_id_"],
|
||||
@@ -109,8 +103,6 @@ try {
|
||||
} finally {
|
||||
assert.commandWorked(second.adminCommand(
|
||||
{configureFailPoint: 'hangAfterSettingUpIndexBuildUnlocked', mode: 'off'}));
|
||||
assert.commandWorked(second.adminCommand(
|
||||
{configureFailPoint: 'hangAfterSettingUpResumableIndexBuild', mode: 'off'}));
|
||||
|
||||
// Let index build complete on primary, which replicates a commitIndexBuild to the secondary.
|
||||
IndexBuildTest.resumeIndexBuilds(primaryDB);
|
||||
|
||||
@@ -1,43 +1,164 @@
|
||||
(function() {
|
||||
'use strict';
|
||||
|
||||
load("jstests/libs/host_ipaddr.js");
|
||||
|
||||
const configuredMaxConns = 5;
|
||||
const configuredReadyAdminThreads = 3;
|
||||
let conn = MongoRunner.runMongod({
|
||||
config: "jstests/noPassthrough/libs/max_conns_override_config.yaml",
|
||||
});
|
||||
|
||||
// Use up all the maxConns with junk connections, all of these should succeed
|
||||
let maxConns = [];
|
||||
for (let i = 0; i < 5; i++) {
|
||||
maxConns.push(new Mongo(`127.0.0.1:${conn.port}`));
|
||||
let tmpDb = maxConns[maxConns.length - 1].getDB("admin");
|
||||
assert.commandWorked(tmpDb.runCommand({isMaster: 1}));
|
||||
// Get serverStatus to check that we have the right number of threads in the right places
|
||||
function getStats() {
|
||||
return assert.commandWorked(conn.getDB("admin").runCommand({serverStatus: 1}));
|
||||
}
|
||||
|
||||
// Get serverStatus to check that we have the right number of threads in the right places
|
||||
let status = conn.getDB("admin").runCommand({serverStatus: 1});
|
||||
const connectionsStatus = status["connections"];
|
||||
const reservedExecutorStatus = connectionsStatus["adminConnections"];
|
||||
const normalExecutorStatus = status["network"]["serviceExecutorTaskStats"];
|
||||
function verifyStats({exemptCount, normalCount}) {
|
||||
const totalCount = exemptCount + normalCount;
|
||||
|
||||
// Log these serverStatus sections so we can debug this easily
|
||||
print("connections status section: ", tojson(connectionsStatus));
|
||||
print("normal executor status section: ", tojson(normalExecutorStatus));
|
||||
// Verify that we have updated serverStatus.
|
||||
assert.soon(() => {
|
||||
const serverStatus = getStats();
|
||||
const executors = serverStatus.network.serviceExecutors;
|
||||
|
||||
// The number of "available" connections should be less than zero, because we've used
|
||||
// all of maxConns. We're over the limit!
|
||||
assert.lt(connectionsStatus["available"], 0);
|
||||
// The number of "current" connections should be greater than maxConns
|
||||
assert.gt(connectionsStatus["current"], configuredMaxConns);
|
||||
// The number of ready threads should be the number of readyThreads we configured, since
|
||||
// every thread spawns a new thread on startup
|
||||
assert.eq(reservedExecutorStatus["readyThreads"] + reservedExecutorStatus["startingThreads"],
|
||||
configuredReadyAdminThreads);
|
||||
// The number of running admin threads should be greater than the readyThreads, because
|
||||
// one is being used right now
|
||||
assert.gt(reservedExecutorStatus["threadsRunning"], reservedExecutorStatus["readyThreads"]);
|
||||
// The normal serviceExecutor should only be running maxConns number of threads
|
||||
assert.eq(normalExecutorStatus["threadsRunning"], configuredMaxConns);
|
||||
const currentCount = serverStatus.connections.current;
|
||||
if (currentCount != totalCount) {
|
||||
print(`Not yet at the expected count of connections: ${currentCount} != ${totalCount}`);
|
||||
return false;
|
||||
}
|
||||
|
||||
MongoRunner.stopMongod(conn);
|
||||
const readyAdminThreads =
|
||||
executors.reserved.threadsRunning - executors.reserved.clientsRunning;
|
||||
if (readyAdminThreads < configuredReadyAdminThreads) {
|
||||
print("Not enough admin threads yet: " +
|
||||
`${readyAdminThreads} < ${configuredReadyAdminThreads}`);
|
||||
return false;
|
||||
}
|
||||
|
||||
const threadedCount = serverStatus.connections.threaded;
|
||||
const threadedExecutorCount =
|
||||
executors.passthrough.clientsInTotal + executors.reserved.clientsInTotal;
|
||||
if (threadedCount != threadedExecutorCount) {
|
||||
print("Not enough running threaded clients yet: " +
|
||||
`${threadedCount} != ${threadedExecutorCount}`);
|
||||
return false;
|
||||
}
|
||||
|
||||
const totalExecutorCount = threadedExecutorCount + executors.fixed.clientsInTotal;
|
||||
if (totalCount != totalExecutorCount) {
|
||||
print(`Not enough running clients yet: ${totalCount} != ${totalExecutorCount}`);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}, "Failed to verify initial conditions", 10000);
|
||||
|
||||
const serverStatus = getStats();
|
||||
const connectionsStatus = serverStatus.connections;
|
||||
const reservedExecutorStatus = serverStatus.network.serviceExecutors.reserved;
|
||||
const fixedExecutorStatus = serverStatus.network.serviceExecutors.fixed;
|
||||
const executorStatus = serverStatus.network.serviceExecutors.passthrough;
|
||||
|
||||
// Log these serverStatus sections so we can debug this easily.
|
||||
const filteredSections = {
|
||||
connections: connectionsStatus,
|
||||
network: {
|
||||
serviceExecutors: {
|
||||
passthrough: executorStatus,
|
||||
fixed: fixedExecutorStatus,
|
||||
reserved: reservedExecutorStatus
|
||||
}
|
||||
}
|
||||
};
|
||||
print(`serverStatus: ${tojson(filteredSections)}`);
|
||||
|
||||
if (totalCount > configuredMaxConns) {
|
||||
// If we're over maxConns, there are no available connections.
|
||||
assert.lte(connectionsStatus["available"], -1);
|
||||
} else {
|
||||
assert.eq(connectionsStatus["available"], configuredMaxConns - totalCount);
|
||||
}
|
||||
|
||||
// All connections on an exempt CIDR should be marked as limitExempt.
|
||||
assert.eq(connectionsStatus["limitExempt"], exemptCount);
|
||||
|
||||
// The normal serviceExecutor should only be running at most maxConns number of threads.
|
||||
assert.lte(executorStatus["threadsRunning"], configuredMaxConns);
|
||||
|
||||
// Clients on the normal executor own their thread and cannot wait asynchronously.
|
||||
assert.eq(executorStatus["clientsRunning"], executorStatus["clientsInTotal"]);
|
||||
assert.eq(executorStatus["clientsRunning"], executorStatus["threadsRunning"]);
|
||||
assert.eq(executorStatus["clientsWaitingForData"], 0);
|
||||
|
||||
// Clients on the reserved executor run on a thread and cannot wait asynchronously.
|
||||
assert.eq(reservedExecutorStatus["clientsRunning"], reservedExecutorStatus["clientsInTotal"]);
|
||||
assert.lte(reservedExecutorStatus["clientsRunning"], reservedExecutorStatus["threadsRunning"]);
|
||||
assert.eq(reservedExecutorStatus["clientsWaitingForData"], 0);
|
||||
|
||||
// Clients on the fixed executor borrow one thread and can wait asynchronously
|
||||
assert.lte(fixedExecutorStatus["clientsRunning"], fixedExecutorStatus["clientsInTotal"]);
|
||||
assert.lte(fixedExecutorStatus["clientsRunning"], fixedExecutorStatus["threadsRunning"]);
|
||||
assert.lte(fixedExecutorStatus["clientsWaitingForData"], fixedExecutorStatus["clientsInTotal"]);
|
||||
}
|
||||
|
||||
// Use the external ip to avoid our exempt CIDR.
|
||||
let ip = get_ipaddr();
|
||||
|
||||
try {
|
||||
let adminConns = [];
|
||||
let normalConns = [];
|
||||
|
||||
// We start with one exempt control socket.
|
||||
let exemptCount = 1;
|
||||
let normalCount = 0;
|
||||
|
||||
// Do an initial verification.
|
||||
verifyStats({exemptCount: exemptCount, normalCount: normalCount});
|
||||
|
||||
for (let i = 0; i < 2 * configuredMaxConns; i++) {
|
||||
// Make some connections using the exempt CIDR and some using the normal CIDR.
|
||||
let isExempt = (i % 2 == 0);
|
||||
try {
|
||||
if (isExempt) {
|
||||
adminConns.push(new Mongo(`127.0.0.1:${conn.port}`));
|
||||
++exemptCount;
|
||||
} else {
|
||||
normalConns.push(new Mongo(`${ip}:${conn.port}`));
|
||||
++normalCount;
|
||||
}
|
||||
} catch (e) {
|
||||
print(e);
|
||||
|
||||
// If we couldn't connect, that means we've exceeded maxConns and we're using the normal
|
||||
// CIDR.
|
||||
assert(!isExempt);
|
||||
assert(i >= configuredMaxConns);
|
||||
}
|
||||
|
||||
verifyStats({exemptCount: exemptCount, normalCount: normalCount});
|
||||
}
|
||||
|
||||
// Some common sense assertions around what was admitted.
|
||||
assert.eq(exemptCount, configuredMaxConns + 1);
|
||||
assert.lte(normalCount, configuredMaxConns);
|
||||
|
||||
// Destroy all admin connections and verify assumptions.
|
||||
while (adminConns.length) {
|
||||
adminConns.pop().close();
|
||||
--exemptCount;
|
||||
|
||||
verifyStats({exemptCount: exemptCount, normalCount: normalCount});
|
||||
}
|
||||
|
||||
// Destroy all normal connections and verify assumptions.
|
||||
while (normalConns.length) {
|
||||
normalConns.pop().close();
|
||||
--normalCount;
|
||||
|
||||
verifyStats({exemptCount: exemptCount, normalCount: normalCount});
|
||||
}
|
||||
} finally {
|
||||
MongoRunner.stopMongod(conn);
|
||||
}
|
||||
})();
|
||||
|
||||
@@ -42,11 +42,7 @@ function executeTest(db, isMongos) {
|
||||
error = assert.throws(function() {
|
||||
cursor.itcount();
|
||||
}, [], "expected query to abort due to time limit");
|
||||
// TODO SERVER-32565: The error should always be MaxTimeMSExpired, but there are rare cases
|
||||
// where interrupting javascript execution on the server with a stepdown or timeout results
|
||||
// in an error code of InternalError or Interrupted instead, so we also accept those here.
|
||||
assert.commandFailedWithCode(
|
||||
error, [ErrorCodes.MaxTimeMSExpired, ErrorCodes.Interrupted, ErrorCodes.InternalError]);
|
||||
assert.commandFailedWithCode(error, ErrorCodes.MaxTimeMSExpired);
|
||||
})();
|
||||
|
||||
//
|
||||
@@ -102,11 +98,7 @@ function executeTest(db, isMongos) {
|
||||
cursor.next();
|
||||
cursor.next();
|
||||
}, [], "expected batch 2 (getmore) to abort due to time limit");
|
||||
// TODO SERVER-32565: The error should always be MaxTimeMSExpired, but there are rare cases
|
||||
// where interrupting javascript execution on the server with a stepdown or timeout results
|
||||
// in an error code of InternalError or Interrupted instead, so we also accept those here.
|
||||
assert.commandFailedWithCode(
|
||||
error, [ErrorCodes.MaxTimeMSExpired, ErrorCodes.Interrupted, ErrorCodes.InternalError]);
|
||||
assert.commandFailedWithCode(error, ErrorCodes.MaxTimeMSExpired);
|
||||
})();
|
||||
|
||||
//
|
||||
@@ -168,11 +160,7 @@ function executeTest(db, isMongos) {
|
||||
error = assert.throws(function() {
|
||||
cursor.itcount();
|
||||
}, [], "expected find() to abort due to time limit");
|
||||
// TODO SERVER-32565: The error should always be MaxTimeMSExpired, but there are rare cases
|
||||
// where interrupting javascript execution on the server with a stepdown or timeout results
|
||||
// in an error code of InternalError or Interrupted instead, so we also accept those here.
|
||||
assert.commandFailedWithCode(
|
||||
error, [ErrorCodes.MaxTimeMSExpired, ErrorCodes.Interrupted, ErrorCodes.InternalError]);
|
||||
assert.commandFailedWithCode(error, ErrorCodes.MaxTimeMSExpired);
|
||||
})();
|
||||
|
||||
//
|
||||
|
||||
@@ -57,7 +57,7 @@ function testKillOp(pipeline, comment, failpointName) {
|
||||
// Run the aggregate and ensure that it is interrupted.
|
||||
const runAggregate = `
|
||||
const testDB = db.getSiblingDB("${kDBName}");
|
||||
testDB.setSlaveOk(true);
|
||||
testDB.setSecondaryOk();
|
||||
const res = testDB.runCommand({
|
||||
aggregate: "inputColl",
|
||||
pipeline: ${tojson(pipeline)},
|
||||
|
||||
@@ -19,8 +19,8 @@ replTest.initiate(config);
|
||||
const primary = replTest.getPrimary();
|
||||
const secondary = replTest.getSecondary();
|
||||
|
||||
// Set slaveOk=true so that normal read commands would be allowed on the secondary.
|
||||
secondary.setSlaveOk(true);
|
||||
// Set secondaryOk=true so that normal read commands would be allowed on the secondary.
|
||||
secondary.setSecondaryOk();
|
||||
|
||||
// Create a test collection that we can run commands against.
|
||||
assert.commandWorked(primary.getDB(dbName)[collName].insert({_id: 0}));
|
||||
|
||||
@@ -87,7 +87,7 @@ assert.soonNoExcept(function() {
|
||||
});
|
||||
|
||||
// Confirm that the write with the oplog hold behind it is now gone (truncated) as expected.
|
||||
primary.setSlaveOk();
|
||||
primary.setSecondaryOk();
|
||||
const find = primary.getDB(dbName).getCollection(collName).findOne({_id: "writeAfterHole"});
|
||||
assert.eq(find, null);
|
||||
|
||||
|
||||
@@ -25,8 +25,8 @@ var collName = jsTest.name();
|
||||
|
||||
function runTest(host, rst, waitForPrimary) {
|
||||
// We create a new connection to 'host' here instead of passing in the original connection.
|
||||
// This to work around the fact that connections created by ReplSetTest already have slaveOk
|
||||
// set on them, but we need a connection with slaveOk not set for this test.
|
||||
// This to work around the fact that connections created by ReplSetTest already have secondaryOk
|
||||
// set on them, but we need a connection with secondaryOk not set for this test.
|
||||
var conn = new Mongo(host);
|
||||
var coll = conn.getDB(dbName).getCollection(collName);
|
||||
assert(!coll.exists());
|
||||
@@ -51,7 +51,7 @@ function runTest(host, rst, waitForPrimary) {
|
||||
} catch (e) {
|
||||
}
|
||||
|
||||
// Even though our connection doesn't have slaveOk set, we should still be able to iterate
|
||||
// Even though our connection doesn't have secondaryOk set, we should still be able to iterate
|
||||
// our cursor and kill our cursor.
|
||||
assert(cursor.hasNext());
|
||||
assert.doesNotThrow(function() {
|
||||
|
||||
@@ -87,7 +87,7 @@ for (let nodeIdx = 0; nodeIdx < 2; ++nodeIdx) {
|
||||
jsTestLog("Starting as a replica set. Both indexes should exist. Node: " + nodeIdentity);
|
||||
let conn = rst.start(nodeIdx, {startClean: false}, true);
|
||||
rst.waitForState(conn, ReplSetTest.State.SECONDARY);
|
||||
conn.setSlaveOk();
|
||||
conn.setSecondaryOk();
|
||||
IndexBuildTest.assertIndexes(getColl(conn), 2, ['_id_', 'foo_1']);
|
||||
rst.stop(nodeIdx);
|
||||
}
|
||||
|
||||
@@ -16,7 +16,9 @@ for (x = -180; x < 180; x += .5) {
|
||||
assert.commandWorked(bulk.execute());
|
||||
|
||||
var numTests = 31;
|
||||
for (var n = 0; n < numTests; n++) {
|
||||
// Reduce the amount of repetitions on live-record buildvariant
|
||||
var start = (TestData.undoRecorderPath ? 20 : 0);
|
||||
for (var n = start; n < numTests; n++) {
|
||||
t.dropIndexes();
|
||||
t.ensureIndex({loc: "2d"}, {bits: 2 + n});
|
||||
|
||||
|
||||
@@ -32,7 +32,8 @@ var checkOp = function(checkDB) {
|
||||
|
||||
var dbname = 'bgIndexSec';
|
||||
var collection = 'jstests_feh';
|
||||
var size = 100000;
|
||||
// Reduce the amount of data on live-record buildvariant
|
||||
var size = (TestData.undoRecorderPath ? 10000 : 100000);
|
||||
|
||||
// Set up replica set
|
||||
var replTest = new ReplSetTest({name: 'bgIndex', nodes: 3});
|
||||
|
||||
@@ -78,7 +78,9 @@ st.waitForBalancer(true, 60000);
|
||||
var lastMigration = sh._lastMigration(collB);
|
||||
|
||||
var bulk = collB.initializeUnorderedBulkOp();
|
||||
for (var i = 0; i < 1000000; i++) {
|
||||
// Reduce the amount of data on live-record buildvariant
|
||||
var n = (TestData.undoRecorderPath ? 100000 : 1000000);
|
||||
for (var i = 0; i < n; i++) {
|
||||
bulk.insert({_id: i, hello: "world"});
|
||||
}
|
||||
assert.commandWorked(bulk.execute());
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Test that doing slaveOk reads from secondaries hits all the secondaries evenly
|
||||
// Test that doing secondaryOk reads from secondaries hits all the secondaries evenly
|
||||
// @tags: [requires_sharding]
|
||||
|
||||
function testReadLoadBalancing(numReplicas) {
|
||||
@@ -52,7 +52,7 @@ function testReadLoadBalancing(numReplicas) {
|
||||
|
||||
for (var i = 0; i < secondaries.length * 10; i++) {
|
||||
conn = new Mongo(s._mongos[0].host);
|
||||
conn.setSlaveOk();
|
||||
conn.setSecondaryOk();
|
||||
conn.getDB('test').foo.findOne();
|
||||
connections.push(conn);
|
||||
}
|
||||
@@ -103,7 +103,7 @@ function testReadLoadBalancing(numReplicas) {
|
||||
|
||||
for (var i = 0; i < secondaries.length * 10; i++) {
|
||||
conn = new Mongo(s._mongos[0].host);
|
||||
conn.setSlaveOk();
|
||||
conn.setSecondaryOk();
|
||||
conn.getDB('test').foo.findOne();
|
||||
connections.push(conn);
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ print("try some legal and illegal reads");
|
||||
var r = primary.getDB("test").foo.findOne();
|
||||
assert.eq(r.x, 1);
|
||||
|
||||
secondary.setSlaveOk();
|
||||
secondary.setSecondaryOk();
|
||||
|
||||
function doQueryOn(p) {
|
||||
var error = assert.throws(function() {
|
||||
@@ -200,7 +200,7 @@ wait(function() {
|
||||
print("make sure it has the config, too");
|
||||
assert.soon(function() {
|
||||
for (var i in rs.nodes) {
|
||||
rs.nodes[i].setSlaveOk();
|
||||
rs.nodes[i].setSecondaryOk();
|
||||
rs.nodes[i].getDB("admin").auth("foo", "bar");
|
||||
config = rs.nodes[i].getDB("local").system.replset.findOne();
|
||||
// We expect the config version to be 3 due to the initial config and then the
|
||||
|
||||
@@ -23,7 +23,7 @@ rs.waitForState(nodes[2], ReplSetTest.State.SECONDARY);
|
||||
|
||||
// Make sure you can still authenticate a replset connection with no primary
|
||||
var conn2 = new Mongo(rs.getURL());
|
||||
conn2.setSlaveOk(true);
|
||||
conn2.setSecondaryOk();
|
||||
assert(conn2.getDB('admin').auth({user: 'admin', pwd: 'pwd', mechanism: "SCRAM-SHA-1"}));
|
||||
assert.eq(1, conn2.getDB('admin').foo.findOne().a);
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ const secondaryAdminDB = secondary.getDB("admin");
|
||||
|
||||
function runAwaitableIsMasterBeforeFCVChange(
|
||||
topologyVersionField, targetFCV, isPrimary, prevMinWireVersion, serverMaxWireVersion) {
|
||||
db.getMongo().setSlaveOk();
|
||||
db.getMongo().setSecondaryOk();
|
||||
let response = assert.commandWorked(db.runCommand({
|
||||
isMaster: 1,
|
||||
topologyVersion: topologyVersionField,
|
||||
|
||||
@@ -56,7 +56,7 @@ let waitForGetMoreToFinish = startParallelShell(() => {
|
||||
load('jstests/replsets/rslib.js');
|
||||
|
||||
const secondary = db.getMongo();
|
||||
secondary.setSlaveOk();
|
||||
secondary.setSecondaryOk();
|
||||
|
||||
const dbName = 'test';
|
||||
const collName = 'coll';
|
||||
|
||||
@@ -21,7 +21,7 @@ var primary = replTest.getPrimary().getDB(name);
|
||||
var secondaryConns = replTest.getSecondaries();
|
||||
var secondaries = [];
|
||||
for (var i in secondaryConns) {
|
||||
secondaryConns[i].setSlaveOk();
|
||||
secondaryConns[i].setSecondaryOk();
|
||||
secondaries.push(secondaryConns[i].getDB(name));
|
||||
}
|
||||
replTest.awaitReplication();
|
||||
|
||||
@@ -37,7 +37,7 @@ rst.nodes.forEach(function(node) {
|
||||
});
|
||||
|
||||
function checkOpInOplog(node, op, count) {
|
||||
node.getDB("admin").getMongo().setSlaveOk();
|
||||
node.getDB("admin").getMongo().setSecondaryOk();
|
||||
var oplog = node.getDB("local")['oplog.rs'];
|
||||
var oplogArray = oplog.find().toArray();
|
||||
assert.eq(oplog.count(op), count, "op: " + tojson(op) + ", oplog: " + tojson(oplogArray));
|
||||
|
||||
@@ -192,6 +192,8 @@ const allCommands = {
|
||||
hello: {skip: isNotAUserDataRead},
|
||||
hostInfo: {skip: isNotAUserDataRead},
|
||||
httpClientRequest: {skip: isNotAUserDataRead},
|
||||
exportCollection: {skip: isNotAUserDataRead},
|
||||
importCollection: {skip: isNotAUserDataRead},
|
||||
insert: {skip: isPrimaryOnly},
|
||||
internalRenameIfOptionsAndIndexesMatch: {skip: isAnInternalCommand},
|
||||
invalidateUserCache: {skip: isNotAUserDataRead},
|
||||
|
||||
@@ -52,16 +52,16 @@ const primaryDb = primaryDataConn.getDB("test");
|
||||
const primaryColl = primaryDb[collname];
|
||||
primaryDataConn.forceWriteMode('legacy');
|
||||
|
||||
function getNotMasterLegacyUnackWritesCounter() {
|
||||
function getNotPrimaryLegacyUnackWritesCounter() {
|
||||
return assert.commandWorked(primaryAdmin.adminCommand({serverStatus: 1}))
|
||||
.metrics.repl.network.notMasterLegacyUnacknowledgedWrites;
|
||||
.metrics.repl.network.notPrimaryLegacyUnacknowledgedWrites;
|
||||
}
|
||||
|
||||
function runStepDownTest({description, failpoint, operation}) {
|
||||
jsTestLog("Enabling failpoint to block " + description + "s");
|
||||
let failPoint = configureFailPoint(primaryAdmin, failpoint);
|
||||
|
||||
let failedLegacyUnackWritesBefore = getNotMasterLegacyUnackWritesCounter();
|
||||
let failedLegacyUnackWritesBefore = getNotPrimaryLegacyUnackWritesCounter();
|
||||
|
||||
jsTestLog("Trying legacy " + description + " on stepping-down primary");
|
||||
operation();
|
||||
@@ -77,7 +77,7 @@ function runStepDownTest({description, failpoint, operation}) {
|
||||
|
||||
// Validate the number of legacy unacknowledged writes failed due to step down resulted
|
||||
// in network disconnection.
|
||||
let failedLegacyUnackWritesAfter = getNotMasterLegacyUnackWritesCounter();
|
||||
let failedLegacyUnackWritesAfter = getNotPrimaryLegacyUnackWritesCounter();
|
||||
assert.eq(failedLegacyUnackWritesAfter, failedLegacyUnackWritesBefore + 1);
|
||||
|
||||
// Allow the primary to be re-elected, and wait for it.
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
// Test the explain command on the primary and on secondaries:
|
||||
//
|
||||
// 1) Explain of read operations should work on the secondaries iff slaveOk is set.
|
||||
// 1) Explain of read operations should work on the secondaries iff secondaryOk is set.
|
||||
//
|
||||
// 2) Explain of write operations should
|
||||
// --fail on secondaries, even if slaveOk is set,
|
||||
// --fail on secondaries, even if secondaryOk is set,
|
||||
// --succeed on primary without applying any writes.
|
||||
|
||||
var name = "explain_slaveok";
|
||||
var name = "explain_secondaryok";
|
||||
|
||||
print("Start replica set with two nodes");
|
||||
var replTest = new ReplSetTest({name: name, nodes: 2});
|
||||
@@ -16,22 +16,22 @@ var primary = replTest.getPrimary();
|
||||
|
||||
// Insert a document and let it sync to the secondary.
|
||||
print("Initial sync");
|
||||
primary.getDB("test").explain_slaveok.insert({a: 1});
|
||||
primary.getDB("test").explain_secondaryok.insert({a: 1});
|
||||
replTest.awaitReplication();
|
||||
|
||||
// Check that the document is present on the primary.
|
||||
assert.eq(1, primary.getDB("test").explain_slaveok.findOne({a: 1})["a"]);
|
||||
assert.eq(1, primary.getDB("test").explain_secondaryok.findOne({a: 1})["a"]);
|
||||
|
||||
// We shouldn't be able to read from the secondary with slaveOk off.
|
||||
// We shouldn't be able to read from the secondary with secondaryOk off.
|
||||
var secondary = replTest.getSecondary();
|
||||
secondary.getDB("test").getMongo().setSlaveOk(false);
|
||||
secondary.getDB("test").getMongo().setSecondaryOk(false);
|
||||
assert.throws(function() {
|
||||
secondary.getDB("test").explain_slaveok.findOne({a: 1});
|
||||
secondary.getDB("test").explain_secondaryok.findOne({a: 1});
|
||||
});
|
||||
|
||||
// With slaveOk on, we should be able to read from the secondary.
|
||||
secondary.getDB("test").getMongo().setSlaveOk(true);
|
||||
assert.eq(1, secondary.getDB("test").explain_slaveok.findOne({a: 1})["a"]);
|
||||
// With secondaryOk on, we should be able to read from the secondary.
|
||||
secondary.getDB("test").getMongo().setSecondaryOk();
|
||||
assert.eq(1, secondary.getDB("test").explain_secondaryok.findOne({a: 1})["a"]);
|
||||
|
||||
//
|
||||
// Test explains on primary.
|
||||
@@ -39,12 +39,12 @@ assert.eq(1, secondary.getDB("test").explain_slaveok.findOne({a: 1})["a"]);
|
||||
|
||||
// Explain a count on the primary.
|
||||
var explainOut = primary.getDB("test").runCommand(
|
||||
{explain: {count: "explain_slaveok", query: {a: 1}}, verbosity: "executionStats"});
|
||||
{explain: {count: "explain_secondaryok", query: {a: 1}}, verbosity: "executionStats"});
|
||||
assert.commandWorked(explainOut, "explain read op on primary");
|
||||
|
||||
// Explain an update on the primary.
|
||||
explainOut = primary.getDB("test").runCommand({
|
||||
explain: {update: "explain_slaveok", updates: [{q: {a: 1}, u: {$set: {a: 5}}}]},
|
||||
explain: {update: "explain_secondaryok", updates: [{q: {a: 1}, u: {$set: {a: 5}}}]},
|
||||
verbosity: "executionStats"
|
||||
});
|
||||
assert.commandWorked(explainOut, "explain write op on primary");
|
||||
@@ -57,52 +57,52 @@ assert.eq(1, stages.nWouldModify);
|
||||
|
||||
// Confirm that the document did not actually get modified on the primary
|
||||
// or on the secondary.
|
||||
assert.eq(1, primary.getDB("test").explain_slaveok.findOne({a: 1})["a"]);
|
||||
secondary.getDB("test").getMongo().setSlaveOk(true);
|
||||
assert.eq(1, secondary.getDB("test").explain_slaveok.findOne({a: 1})["a"]);
|
||||
assert.eq(1, primary.getDB("test").explain_secondaryok.findOne({a: 1})["a"]);
|
||||
secondary.getDB("test").getMongo().setSecondaryOk();
|
||||
assert.eq(1, secondary.getDB("test").explain_secondaryok.findOne({a: 1})["a"]);
|
||||
|
||||
//
|
||||
// Test explains on secondary.
|
||||
//
|
||||
|
||||
// Explain a count on the secondary with slaveOk off. Should fail because
|
||||
// slaveOk is required for explains on a secondary.
|
||||
secondary.getDB("test").getMongo().setSlaveOk(false);
|
||||
// Explain a count on the secondary with secondaryOk off. Should fail because
|
||||
// secondaryOk is required for explains on a secondary.
|
||||
secondary.getDB("test").getMongo().setSecondaryOk(false);
|
||||
explainOut = secondary.getDB("test").runCommand(
|
||||
{explain: {count: "explain_slaveok", query: {a: 1}}, verbosity: "executionStats"});
|
||||
assert.commandFailed(explainOut, "explain read op on secondary, slaveOk false");
|
||||
{explain: {count: "explain_secondaryok", query: {a: 1}}, verbosity: "executionStats"});
|
||||
assert.commandFailed(explainOut, "explain read op on secondary, secondaryOk false");
|
||||
|
||||
// Explain of count should succeed once slaveOk is true.
|
||||
secondary.getDB("test").getMongo().setSlaveOk(true);
|
||||
// Explain of count should succeed once secondaryOk is true.
|
||||
secondary.getDB("test").getMongo().setSecondaryOk();
|
||||
explainOut = secondary.getDB("test").runCommand(
|
||||
{explain: {count: "explain_slaveok", query: {a: 1}}, verbosity: "executionStats"});
|
||||
assert.commandWorked(explainOut, "explain read op on secondary, slaveOk true");
|
||||
{explain: {count: "explain_secondaryok", query: {a: 1}}, verbosity: "executionStats"});
|
||||
assert.commandWorked(explainOut, "explain read op on secondary, secondaryOk true");
|
||||
|
||||
// Explain .find() on a secondary, setting slaveOk directly on the query.
|
||||
secondary.getDB("test").getMongo().setSlaveOk(false);
|
||||
// Explain .find() on a secondary, setting secondaryOk directly on the query.
|
||||
secondary.getDB("test").getMongo().setSecondaryOk(false);
|
||||
assert.throws(function() {
|
||||
secondary.getDB("test").explain_slaveok.explain("executionStats").find({a: 1}).finish();
|
||||
secondary.getDB("test").explain_secondaryok.explain("executionStats").find({a: 1}).finish();
|
||||
});
|
||||
|
||||
secondary.getDB("test").getMongo().setSlaveOk(false);
|
||||
secondary.getDB("test").getMongo().setSecondaryOk(false);
|
||||
explainOut = secondary.getDB("test")
|
||||
.explain_slaveok.explain("executionStats")
|
||||
.explain_secondaryok.explain("executionStats")
|
||||
.find({a: 1})
|
||||
.addOption(DBQuery.Option.slaveOk)
|
||||
.finish();
|
||||
assert.commandWorked(explainOut, "explain read op on secondary, slaveOk set to true on query");
|
||||
assert.commandWorked(explainOut, "explain read op on secondary, slaveOk bit set to true on query");
|
||||
|
||||
secondary.getDB("test").getMongo().setSlaveOk(true);
|
||||
secondary.getDB("test").getMongo().setSecondaryOk();
|
||||
explainOut =
|
||||
secondary.getDB("test").explain_slaveok.explain("executionStats").find({a: 1}).finish();
|
||||
assert.commandWorked(explainOut, "explain .find() on secondary, slaveOk set to true");
|
||||
secondary.getDB("test").explain_secondaryok.explain("executionStats").find({a: 1}).finish();
|
||||
assert.commandWorked(explainOut, "explain .find() on secondary, secondaryOk set to true");
|
||||
|
||||
// Explain .find() on a secondary, setting slaveOk to false with various read preferences.
|
||||
// Explain .find() on a secondary, setting secondaryOk to false with various read preferences.
|
||||
var readPrefModes = ["secondary", "secondaryPreferred", "primaryPreferred", "nearest"];
|
||||
readPrefModes.forEach(function(prefString) {
|
||||
secondary.getDB("test").getMongo().setSlaveOk(false);
|
||||
secondary.getDB("test").getMongo().setSecondaryOk(false);
|
||||
explainOut = secondary.getDB("test")
|
||||
.explain_slaveok.explain("executionStats")
|
||||
.explain_secondaryok.explain("executionStats")
|
||||
.find({a: 1})
|
||||
.readPref(prefString)
|
||||
.finish();
|
||||
@@ -112,7 +112,7 @@ readPrefModes.forEach(function(prefString) {
|
||||
// Similarly should succeed if a read preference is set on the connection.
|
||||
secondary.setReadPref(prefString);
|
||||
explainOut =
|
||||
secondary.getDB("test").explain_slaveok.explain("executionStats").find({a: 1}).finish();
|
||||
secondary.getDB("test").explain_secondaryok.explain("executionStats").find({a: 1}).finish();
|
||||
assert.commandWorked(
|
||||
explainOut,
|
||||
"explain .find() on secondary, '" + prefString + "' read preference on connection");
|
||||
@@ -120,35 +120,36 @@ readPrefModes.forEach(function(prefString) {
|
||||
secondary.setReadPref();
|
||||
});
|
||||
|
||||
// Fail explain find() on a secondary, setting slaveOk to false with read preference set to primary.
|
||||
// Fail explain find() on a secondary, setting secondaryOk to false with read preference set to
|
||||
// primary.
|
||||
var prefStringPrimary = "primary";
|
||||
secondary.getDB("test").getMongo().setSlaveOk(false);
|
||||
secondary.getDB("test").getMongo().setSecondaryOk(false);
|
||||
explainOut = secondary.getDB("test").runCommand(
|
||||
{explain: {find: "explain_slaveok", query: {a: 1}}, verbosity: "executionStats"});
|
||||
assert.commandFailed(explainOut, "not master and slaveOk=false");
|
||||
{explain: {find: "explain_secondaryok", query: {a: 1}}, verbosity: "executionStats"});
|
||||
assert.commandFailed(explainOut, "not primary and secondaryOk=false");
|
||||
|
||||
// Similarly should fail if a read preference is set on the connection.
|
||||
secondary.setReadPref(prefStringPrimary);
|
||||
explainOut = secondary.getDB("test").runCommand(
|
||||
{explain: {find: "explain_slaveok", query: {a: 1}}, verbosity: "executionStats"});
|
||||
assert.commandFailed(explainOut, "not master and slaveOk=false");
|
||||
{explain: {find: "explain_secondaryok", query: {a: 1}}, verbosity: "executionStats"});
|
||||
assert.commandFailed(explainOut, "not primary and secondaryOk=false");
|
||||
// Unset read pref on the connection.
|
||||
secondary.setReadPref();
|
||||
|
||||
// Explain an update on the secondary with slaveOk off. Should fail because
|
||||
// slaveOk is required for explains on a secondary.
|
||||
secondary.getDB("test").getMongo().setSlaveOk(false);
|
||||
// Explain an update on the secondary with secondaryOk off. Should fail because
|
||||
// secondaryOk is required for explains on a secondary.
|
||||
secondary.getDB("test").getMongo().setSecondaryOk(false);
|
||||
explainOut = secondary.getDB("test").runCommand({
|
||||
explain: {update: "explain_slaveok", updates: [{q: {a: 1}, u: {$set: {a: 5}}}]},
|
||||
explain: {update: "explain_secondaryok", updates: [{q: {a: 1}, u: {$set: {a: 5}}}]},
|
||||
verbosity: "executionStats"
|
||||
});
|
||||
assert.commandFailed(explainOut, "explain write op on secondary, slaveOk false");
|
||||
assert.commandFailed(explainOut, "explain write op on secondary, secondaryOk false");
|
||||
|
||||
// Explain of the update should also fail with slaveOk on.
|
||||
secondary.getDB("test").getMongo().setSlaveOk(true);
|
||||
// Explain of the update should also fail with secondaryOk on.
|
||||
secondary.getDB("test").getMongo().setSecondaryOk();
|
||||
explainOut = secondary.getDB("test").runCommand({
|
||||
explain: {update: "explain_slaveok", updates: [{q: {a: 1}, u: {$set: {a: 5}}}]},
|
||||
explain: {update: "explain_secondaryok", updates: [{q: {a: 1}, u: {$set: {a: 5}}}]},
|
||||
verbosity: "executionStats"
|
||||
});
|
||||
assert.commandFailed(explainOut, "explain write op on secondary, slaveOk true");
|
||||
assert.commandFailed(explainOut, "explain write op on secondary, secondaryOk true");
|
||||
replTest.stopSet();
|
||||
|
||||
@@ -50,7 +50,7 @@ replTest.awaitReplication();
|
||||
|
||||
// Calling getPrimary also populates '_secondaries'.
|
||||
var secondaries = replTest.getSecondaries();
|
||||
secondaries[0].setSlaveOk();
|
||||
secondaries[0].setSecondaryOk();
|
||||
|
||||
assert.commandWorked(secondaries[0].getDB("admin").runCommand({fsync: 1, lock: 1}));
|
||||
var docNum = 1000;
|
||||
|
||||
@@ -36,7 +36,7 @@ doTest = function(signal) {
|
||||
assert(secondaries.length == 2, "Expected 2 secondaries but length was " + secondaries.length);
|
||||
secondaries.forEach(function(secondary) {
|
||||
// try to read from secondary
|
||||
secondary.slaveOk = true;
|
||||
secondary.setSecondaryOk();
|
||||
var count = secondary.getDB("foo").foo.find().itcount();
|
||||
printjson(count);
|
||||
assert.eq(len, count, "secondary count wrong: " + secondary);
|
||||
@@ -46,7 +46,7 @@ doTest = function(signal) {
|
||||
printjson(one);
|
||||
|
||||
print("Calling inline mr() with slaveOk=true, must succeed");
|
||||
secondary.slaveOk = true;
|
||||
secondary.setSecondaryOk();
|
||||
map = function() {
|
||||
emit(this.a, 1);
|
||||
};
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
|
||||
jsTestLog("5. Wait for new node to start cloning");
|
||||
|
||||
s.setSlaveOk();
|
||||
s.setSecondaryOk();
|
||||
var sc = s.getDB("d")["c"];
|
||||
|
||||
wait(function() {
|
||||
|
||||
@@ -44,7 +44,7 @@ const secondary = rst.add({
|
||||
rsConfig: {votes: 0, priority: 0},
|
||||
setParameter: {"numInitialSyncAttempts": 1, 'collectionClonerBatchSize': clonerBatchSize}
|
||||
});
|
||||
secondary.setSlaveOk();
|
||||
secondary.setSecondaryOk();
|
||||
const secondaryColl = secondary.getDB(dbName).getCollection(collectionName);
|
||||
|
||||
// We set the collectionClonerBatchSize low above, so we will definitely hit
|
||||
|
||||
@@ -31,7 +31,7 @@ assert.commandWorked(coll.insert({_id: 0, content: "hi"}));
|
||||
// but before copying databases.
|
||||
var secondary =
|
||||
replSet.add({setParameter: "numInitialSyncAttempts=2", rsConfig: {votes: 0, priority: 0}});
|
||||
secondary.setSlaveOk();
|
||||
secondary.setSecondaryOk();
|
||||
|
||||
let failPoint = configureFailPoint(secondary, 'initialSyncHangBeforeCopyingDatabases');
|
||||
replSet.reInitiate();
|
||||
|
||||
@@ -139,7 +139,7 @@ replTest.awaitReplication();
|
||||
jsTestLog("Initial sync completed");
|
||||
|
||||
// Make sure the secondary fetched enough transaction oplog entries.
|
||||
secondary.setSlaveOk();
|
||||
secondary.setSecondaryOk();
|
||||
const secondaryOplog = secondary.getDB("local").getCollection("oplog.rs");
|
||||
assert.eq(secondaryOplog.find({"ts": beginFetchingTs}).itcount(), 1);
|
||||
|
||||
|
||||
@@ -98,7 +98,7 @@ replTest.waitForState(secondary, ReplSetTest.State.SECONDARY);
|
||||
jsTestLog("Initial sync completed");
|
||||
|
||||
// Make sure the secondary fetched enough transaction oplog entries.
|
||||
secondary.setSlaveOk();
|
||||
secondary.setSecondaryOk();
|
||||
const secondaryOplog = secondary.getDB("local").getCollection("oplog.rs");
|
||||
assert.eq(secondaryOplog.find({"ts": beginFetchingTs}).itcount(), 1);
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ assert.commandWorked(coll.insert({a: 1}));
|
||||
|
||||
// Add a secondary node but make it hang before copying databases.
|
||||
let secondary = replSet.add({rsConfig: {votes: 0, priority: 0}});
|
||||
secondary.setSlaveOk();
|
||||
secondary.setSecondaryOk();
|
||||
|
||||
assert.commandWorked(secondary.getDB('admin').runCommand(
|
||||
{configureFailPoint: 'initialSyncHangBeforeCopyingDatabases', mode: 'alwaysOn'}));
|
||||
|
||||
@@ -41,7 +41,7 @@ assert.commandWorked(masterColl.ensureIndex({x: 1}, {unique: true}));
|
||||
// Add a secondary.
|
||||
var secondary =
|
||||
rst.add({setParameter: "numInitialSyncAttempts=1", rsConfig: {votes: 0, priority: 0}});
|
||||
secondary.setSlaveOk();
|
||||
secondary.setSecondaryOk();
|
||||
var secondaryColl = secondary.getDB("test").coll;
|
||||
|
||||
// Pause initial sync when the secondary has copied {_id: 0, x: 0} and {_id: 1, x: 1}.
|
||||
|
||||
@@ -38,7 +38,7 @@ var firstOplogEntry = getFirstOplogEntry(primary);
|
||||
|
||||
// Add a secondary node but make it hang before copying databases.
|
||||
var secondary = replSet.add();
|
||||
secondary.setSlaveOk();
|
||||
secondary.setSecondaryOk();
|
||||
|
||||
var failPoint = configureFailPoint(secondary, 'initialSyncHangBeforeCopyingDatabases');
|
||||
replSet.reInitiate();
|
||||
|
||||
@@ -24,7 +24,7 @@ assert.commandWorked(coll.insert({a: 2}));
|
||||
|
||||
// Add a secondary node but make it hang before copying databases.
|
||||
var secondary = replSet.add({rsConfig: {votes: 0, priority: 0}});
|
||||
secondary.setSlaveOk();
|
||||
secondary.setSecondaryOk();
|
||||
|
||||
var failPointBeforeCopying = configureFailPoint(secondary, 'initialSyncHangBeforeCopyingDatabases');
|
||||
var failPointBeforeFinish = configureFailPoint(secondary, 'initialSyncHangBeforeFinish');
|
||||
|
||||
@@ -47,7 +47,7 @@ function restartSecondaryAndForceSyncSource(replSet, secondary, syncSource, dbNa
|
||||
// Wait for the secondary to complete initial sync.
|
||||
waitForState(secondary, ReplSetTest.State.SECONDARY);
|
||||
// Allow for secondary reads.
|
||||
secondary.setSlaveOk();
|
||||
secondary.setSecondaryOk();
|
||||
const secondaryDB = secondary.getDB(dbName);
|
||||
|
||||
// Confirm that we have a prepared transaction in progress on the secondary.
|
||||
|
||||
@@ -108,7 +108,7 @@ let prepareTimestamp = PrepareHelpers.prepareTransaction(session);
|
||||
assert(!initialSyncTest.step());
|
||||
|
||||
secondary = initialSyncTest.getSecondary();
|
||||
secondary.setSlaveOk();
|
||||
secondary.setSecondaryOk();
|
||||
|
||||
// Make sure that we cannot read from this node yet.
|
||||
assert.commandFailedWithCode(secondary.getDB("test").runCommand({count: "foo"}),
|
||||
|
||||
@@ -39,7 +39,7 @@ function ResyncWithFailpoint(failpointName, failpointData) {
|
||||
assert.eq(primary, rst.getPrimary(), 'Primary changed after reconfig');
|
||||
|
||||
jsTestLog('Wait for new node to start cloning');
|
||||
secondary.setSlaveOk();
|
||||
secondary.setSecondaryOk();
|
||||
const secondaryDB = secondary.getDB(primaryDB.getName());
|
||||
const secondaryColl = secondaryDB[primaryColl.getName()];
|
||||
|
||||
|
||||
@@ -24,8 +24,8 @@ replTest.waitForState(replTest.nodes[0], ReplSetTest.State.PRIMARY);
|
||||
var master = replTest.getPrimary();
|
||||
var a_conn = conns[0];
|
||||
var b_conn = conns[1];
|
||||
a_conn.setSlaveOk();
|
||||
b_conn.setSlaveOk();
|
||||
a_conn.setSecondaryOk();
|
||||
b_conn.setSecondaryOk();
|
||||
var A = a_conn.getDB("test");
|
||||
var B = b_conn.getDB("test");
|
||||
var AID = replTest.getNodeId(a_conn);
|
||||
|
||||
@@ -74,7 +74,7 @@ TestData.clusterTime = clusterTimeAfterPrepare;
|
||||
|
||||
const waitForSecondaryReadBlockedOnPrepareConflictThread = startParallelShell(() => {
|
||||
// Allow for secondary reads.
|
||||
db.getMongo().setSlaveOk();
|
||||
db.getMongo().setSecondaryOk();
|
||||
const parallelTestDB = db.getSiblingDB(TestData.dbName);
|
||||
const parallelTestCollName = TestData.collName;
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ load("jstests/libs/fail_point_util.js");
|
||||
// must be called after reInitiateSetWithSecondary.
|
||||
var reInitiateSetWithSecondary = function(replSet, secondaryConfig) {
|
||||
const secondary = replSet.add(secondaryConfig);
|
||||
secondary.setSlaveOk();
|
||||
secondary.setSecondaryOk();
|
||||
|
||||
// Make the secondary hang after retrieving the last op on the sync source but before
|
||||
// copying databases.
|
||||
|
||||
@@ -7,8 +7,10 @@ const RollbackResumableIndexBuildTest = class {
|
||||
* rollback starts is specified by rollbackStartFailPointName. The phase that the index build
|
||||
* will resume from after rollback completes is specified by rollbackEndFailPointName. If
|
||||
* either of these points is in the drain writes phase, documents to insert into the side
|
||||
* writes table must be specified by sideWrites. Documents specified by insertsToBeRolledBack
|
||||
* are inserted after transitioning to rollback operations and will be rolled back.
|
||||
* writes table must be specified by sideWrites. locksYieldedFailPointName specifies a point
|
||||
* during the index build between rollbackEndFailPointName and rollbackStartFailPointName at
|
||||
* which its locks are yielded. Documents specified by insertsToBeRolledBack are inserted after
|
||||
* transitioning to rollback operations and will be rolled back.
|
||||
*/
|
||||
static run(rollbackTest,
|
||||
dbName,
|
||||
@@ -18,6 +20,7 @@ const RollbackResumableIndexBuildTest = class {
|
||||
rollbackStartFailPointData,
|
||||
rollbackEndFailPointName,
|
||||
rollbackEndFailPointData,
|
||||
locksYieldedFailPointName,
|
||||
insertsToBeRolledBack,
|
||||
sideWrites = []) {
|
||||
const originalPrimary = rollbackTest.getPrimary();
|
||||
@@ -29,6 +32,14 @@ const RollbackResumableIndexBuildTest = class {
|
||||
|
||||
rollbackTest.awaitLastOpCommitted();
|
||||
|
||||
// Set internalQueryExecYieldIterations to 0 and maxIndexBuildDrainBatchSize to 1 so that
|
||||
// the index build is guaranteed to yield its locks between the rollback end and start
|
||||
// failpoints.
|
||||
assert.commandWorked(
|
||||
originalPrimary.adminCommand({setParameter: 1, internalQueryExecYieldIterations: 0}));
|
||||
assert.commandWorked(
|
||||
originalPrimary.adminCommand({setParameter: 1, maxIndexBuildDrainBatchSize: 1}));
|
||||
|
||||
const coll = originalPrimary.getDB(dbName).getCollection(collName);
|
||||
const indexName = "rollback_resumable_index_build";
|
||||
|
||||
@@ -57,32 +68,23 @@ const RollbackResumableIndexBuildTest = class {
|
||||
|
||||
assert.commandWorked(coll.insert(insertsToBeRolledBack));
|
||||
|
||||
// Disable the failpoint in a parallel shell so that the primary can step down when the
|
||||
// rollback test is transitioning to sync source operations before rollback.
|
||||
const awaitDisableFailPointAfterContinuingInBackground = startParallelShell(
|
||||
funWithArgs(function(failPointName, buildUUID) {
|
||||
// Wait for the index build to be continue in the background.
|
||||
checkLog.containsJson(db.getMongo(), 4760400, {
|
||||
buildUUID: function(uuid) {
|
||||
return uuid["uuid"]["$uuid"] === buildUUID;
|
||||
}
|
||||
});
|
||||
|
||||
// Disable the failpoint so that stepdown can proceed.
|
||||
assert.commandWorked(
|
||||
db.adminCommand({configureFailPoint: failPointName, mode: "off"}));
|
||||
}, rollbackEndFp.failPointName, buildUUID), originalPrimary.port);
|
||||
// Move the index build forward to a point at which its locks are yielded. This allows the
|
||||
// primary to step down during the call to transitionToSyncSourceOperationsBeforeRollback()
|
||||
// below.
|
||||
const locksYieldedFp = configureFailPoint(
|
||||
originalPrimary, locksYieldedFailPointName, {namespace: coll.getFullName()});
|
||||
rollbackEndFp.off();
|
||||
locksYieldedFp.wait();
|
||||
|
||||
rollbackTest.transitionToSyncSourceOperationsBeforeRollback();
|
||||
|
||||
awaitDisableFailPointAfterContinuingInBackground();
|
||||
|
||||
// The index creation will report as having failed due to InterruptedDueToReplStateChange,
|
||||
// but it is still building in the background.
|
||||
awaitCreateIndex();
|
||||
|
||||
// Wait until the index build reaches the desired starting point so that we can start the
|
||||
// rollback.
|
||||
locksYieldedFp.off();
|
||||
rollbackStartFp.wait();
|
||||
|
||||
// We ignore the return value here because the node will go into rollback immediately upon
|
||||
|
||||
@@ -14,7 +14,7 @@ function SecondaryReadsTest(name = "secondary_reads_test") {
|
||||
let primaryDB = primary.getDB(dbName);
|
||||
let secondary = rst.getSecondary();
|
||||
let secondaryDB = secondary.getDB(dbName);
|
||||
secondaryDB.getMongo().setSlaveOk();
|
||||
secondaryDB.getMongo().setSecondaryOk();
|
||||
|
||||
let readers = [];
|
||||
let signalColl = "signalColl";
|
||||
@@ -37,7 +37,7 @@ function SecondaryReadsTest(name = "secondary_reads_test") {
|
||||
|
||||
this.startSecondaryReaders = function(nReaders, readFn) {
|
||||
let read = function() {
|
||||
db.getMongo().setSlaveOk();
|
||||
db.getMongo().setSecondaryOk();
|
||||
db = db.getSiblingDB(TestData.dbName);
|
||||
while (true) {
|
||||
readFn();
|
||||
|
||||
@@ -40,7 +40,7 @@ secondaries.forEach(function(secondary) {
|
||||
assert.eq(stats.myState, 3, "Secondary should be in recovering state.");
|
||||
|
||||
print("count should fail in recovering state...");
|
||||
secondary.slaveOk = true;
|
||||
secondary.setSecondaryOk();
|
||||
assert.commandFailed(secondary.getDB("foo").runCommand({count: "foo"}));
|
||||
|
||||
// unset maintenance mode when done
|
||||
|
||||
@@ -73,7 +73,7 @@ function runStepDownTest({description, failpoint, operation, errorCode}) {
|
||||
assert.commandWorked(primaryAdmin.adminCommand({serverStatus: 1})).metrics.repl;
|
||||
assert.eq(replMetrics.stateTransition.lastStateTransition, "stepDown");
|
||||
assert.eq(replMetrics.stateTransition.userOperationsKilled, 1);
|
||||
assert.eq(replMetrics.network.notMasterUnacknowledgedWrites, 0);
|
||||
assert.eq(replMetrics.network.notPrimaryUnacknowledgedWrites, 0);
|
||||
|
||||
// Allow the primary to be re-elected, and wait for it.
|
||||
assert.commandWorked(primaryAdmin.adminCommand({replSetFreeze: 0}));
|
||||
|
||||
@@ -5,12 +5,12 @@
|
||||
(function() {
|
||||
"use strict";
|
||||
|
||||
function getNotMasterUnackWritesCounter() {
|
||||
function getNotPrimaryUnackWritesCounter() {
|
||||
return assert.commandWorked(primaryDB.adminCommand({serverStatus: 1}))
|
||||
.metrics.repl.network.notMasterUnacknowledgedWrites;
|
||||
.metrics.repl.network.notPrimaryUnacknowledgedWrites;
|
||||
}
|
||||
|
||||
const collName = "not_master_unacknowledged_write";
|
||||
const collName = "not_primary_unacknowledged_write";
|
||||
|
||||
var rst = new ReplSetTest({nodes: [{}, {rsConfig: {priority: 0}}]});
|
||||
rst.startSet();
|
||||
@@ -22,8 +22,8 @@ var secondaryDB = secondary.getDB("test");
|
||||
var primaryColl = primaryDB[collName];
|
||||
var secondaryColl = secondaryDB[collName];
|
||||
|
||||
// Verify that reading from secondaries does not impact `notMasterUnacknowledgedWrites`.
|
||||
const preReadingCounter = getNotMasterUnackWritesCounter();
|
||||
// Verify that reading from secondaries does not impact `notPrimaryUnacknowledgedWrites`.
|
||||
const preReadingCounter = getNotPrimaryUnackWritesCounter();
|
||||
jsTestLog("Reading from secondary ...");
|
||||
[{name: "findOne", fn: () => secondaryColl.findOne()},
|
||||
{name: "distinct", fn: () => secondaryColl.distinct("item")},
|
||||
@@ -32,7 +32,7 @@ jsTestLog("Reading from secondary ...");
|
||||
assert.doesNotThrow(fn);
|
||||
assert.eq(assert.commandWorked(secondary.getDB("admin").isMaster()).ismaster, false);
|
||||
});
|
||||
const postReadingCounter = getNotMasterUnackWritesCounter();
|
||||
const postReadingCounter = getNotPrimaryUnackWritesCounter();
|
||||
assert.eq(preReadingCounter, postReadingCounter);
|
||||
|
||||
jsTestLog("Primary on port " + primary.port + " hangs up on unacknowledged writes");
|
||||
@@ -71,7 +71,7 @@ var command =
|
||||
|
||||
var awaitShell = startParallelShell(command, primary.port);
|
||||
|
||||
let failedUnackWritesBefore = getNotMasterUnackWritesCounter();
|
||||
let failedUnackWritesBefore = getNotPrimaryUnackWritesCounter();
|
||||
|
||||
jsTestLog("Beginning unacknowledged insert");
|
||||
primaryColl.insertOne({}, {writeConcern: {w: 0}});
|
||||
@@ -87,7 +87,7 @@ assert.includes(result.toString(), "network error while attempting to run comman
|
||||
|
||||
// Validate the number of unacknowledged writes failed due to step down resulted in network
|
||||
// disconnection.
|
||||
let failedUnackWritesAfter = getNotMasterUnackWritesCounter();
|
||||
let failedUnackWritesAfter = getNotPrimaryUnackWritesCounter();
|
||||
assert.eq(failedUnackWritesAfter, failedUnackWritesBefore + 1);
|
||||
|
||||
rst.stopSet();
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Verify that the plan cache and index filter commands can be run on secondaries, but only
|
||||
// if slave ok is explicitly set.
|
||||
// if secondaryOk is explicitly set.
|
||||
|
||||
var name = "plan_cache_slaveok";
|
||||
var name = "plan_cache_secondaryok";
|
||||
|
||||
function assertPlanCacheCommandsSucceed(db) {
|
||||
assert.commandWorked(db.runCommand({planCacheClear: name, query: {a: 1}}));
|
||||
@@ -50,13 +50,13 @@ assert.eq(1, primary.getDB("test")[name].findOne({a: 1})["a"]);
|
||||
// Make sure the plan cache commands succeed on the primary.
|
||||
assertPlanCacheCommandsSucceed(primary.getDB("test"));
|
||||
|
||||
// With slave ok false, the commands should fail on the secondary.
|
||||
// With secondaryOk false, the commands should fail on the secondary.
|
||||
var secondary = replTest.getSecondary();
|
||||
secondary.getDB("test").getMongo().setSlaveOk(false);
|
||||
secondary.getDB("test").getMongo().setSecondaryOk(false);
|
||||
assertPlanCacheCommandsFail(secondary.getDB("test"));
|
||||
|
||||
// With slave ok true, the commands should succeed on the secondary.
|
||||
secondary.getDB("test").getMongo().setSlaveOk(true);
|
||||
// With secondaryOk true, the commands should succeed on the secondary.
|
||||
secondary.getDB("test").getMongo().setSecondaryOk();
|
||||
assertPlanCacheCommandsSucceed(secondary.getDB("test"));
|
||||
|
||||
replTest.stopSet();
|
||||
|
||||
@@ -16,7 +16,7 @@ const runDBHashFn = (host, dbName, clusterTime, useSnapshot) => {
|
||||
const conn = new Mongo(host);
|
||||
const db = conn.getDB(dbName);
|
||||
|
||||
conn.setSlaveOk();
|
||||
conn.setSecondaryOk();
|
||||
let cmd;
|
||||
if (useSnapshot) {
|
||||
cmd = {dbHash: 1, readConcern: {level: "snapshot", atClusterTime: eval(clusterTime)}};
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
// Tests the output of db.printSecondaryReplicationInfo() for unreachable secondaries.
|
||||
|
||||
(function() {
|
||||
"use strict";
|
||||
const name = "printSecondaryReplicationInfo";
|
||||
const replSet = new ReplSetTest({name: name, nodes: 2});
|
||||
replSet.startSet();
|
||||
replSet.initiateWithHighElectionTimeout();
|
||||
|
||||
const primary = replSet.getPrimary();
|
||||
primary.getDB('test').foo.insert({a: 1});
|
||||
replSet.awaitReplication();
|
||||
|
||||
const secondary = replSet.getSecondary();
|
||||
replSet.stop(replSet.getNodeId(secondary));
|
||||
replSet.waitForState(secondary, ReplSetTest.State.DOWN);
|
||||
|
||||
const joinShell =
|
||||
startParallelShell("db.getSiblingDB('admin').printSecondaryReplicationInfo();", primary.port);
|
||||
joinShell();
|
||||
assert(
|
||||
rawMongoProgramOutput().match("no replication info, yet. State: \\(not reachable/healthy\\)"));
|
||||
|
||||
replSet.stopSet();
|
||||
})();
|
||||
@@ -48,7 +48,7 @@ function runAwaitableIsMaster(topologyVersionField) {
|
||||
}
|
||||
|
||||
function runFind() {
|
||||
db.getMongo().setSlaveOk();
|
||||
db.getMongo().setSecondaryOk();
|
||||
assert.eq(4, db.getSiblingDB("test").coll.find().itcount());
|
||||
}
|
||||
|
||||
|
||||
@@ -75,7 +75,7 @@ assert.eq(doDirtyRead(oldPrimaryColl), 'INVALID');
|
||||
assert.eq(doCommittedRead(oldPrimaryColl), 'old');
|
||||
|
||||
// Change the partitioning so that oldPrimary is isolated, and newPrimary can be elected.
|
||||
oldPrimary.setSlaveOk();
|
||||
oldPrimary.setSecondaryOk();
|
||||
oldPrimary.disconnect(arbiters);
|
||||
newPrimary.reconnect(arbiters);
|
||||
assert.soon(() => newPrimary.adminCommand('isMaster').ismaster, '', 60 * 1000);
|
||||
|
||||
@@ -38,9 +38,9 @@ replTest.initiateWithAnyNodeAsPrimary(
|
||||
var primary = replTest.getPrimary();
|
||||
var secondaries = replTest.getSecondaries();
|
||||
var healthySecondary = secondaries[0];
|
||||
healthySecondary.setSlaveOk();
|
||||
healthySecondary.setSecondaryOk();
|
||||
var noSnapshotSecondary = secondaries[1];
|
||||
noSnapshotSecondary.setSlaveOk();
|
||||
noSnapshotSecondary.setSecondaryOk();
|
||||
|
||||
// Do a write, wait for it to replicate, and ensure it is visible.
|
||||
var res = primary.getDB(name).runCommandWithMetadata( //
|
||||
|
||||
@@ -24,7 +24,7 @@ setFailPoint(rollbackNode, "rollbackHangAfterTransitionToRollback");
|
||||
setFailPoint(rollbackNode, "GetMoreHangBeforeReadLock");
|
||||
|
||||
const joinGetMoreThread = startParallelShell(() => {
|
||||
db.getMongo().setSlaveOk();
|
||||
db.getMongo().setSecondaryOk();
|
||||
const cursorID = assert.commandWorked(db.runCommand({"find": "coll", batchSize: 0})).cursor.id;
|
||||
// Make sure an outstanding read operation gets killed during rollback even though the read
|
||||
// was started before rollback. Outstanding read operations are killed during rollback and
|
||||
|
||||
@@ -113,7 +113,7 @@ assert.eq(replMetrics.stateTransition.lastStateTransition, "stepDown");
|
||||
assert.eq(replMetrics.stateTransition.userOperationsKilled, 0);
|
||||
// Should account for find and getmore commands issued before step down.
|
||||
assert.gte(replMetrics.stateTransition.userOperationsRunning, 2);
|
||||
assert.eq(replMetrics.network.notMasterUnacknowledgedWrites, 0);
|
||||
assert.eq(replMetrics.network.notPrimaryUnacknowledgedWrites, 0);
|
||||
|
||||
rst.stopSet();
|
||||
})();
|
||||
|
||||
@@ -36,10 +36,10 @@ assert.commandWorked(
|
||||
primaryColl.insert({_id: 0}, {"writeConcern": {"w": "majority"}}));
|
||||
rst.awaitReplication();
|
||||
|
||||
// It's possible for notMasterUnacknowledgedWrites to be non-zero because of mirrored reads during
|
||||
// It's possible for notPrimaryUnacknowledgedWrites to be non-zero because of mirrored reads during
|
||||
// initial sync.
|
||||
let replMetrics = assert.commandWorked(secondaryAdmin.adminCommand({serverStatus: 1})).metrics.repl;
|
||||
const startingNumNotMasterErrors = replMetrics.network.notMasterUnacknowledgedWrites;
|
||||
const startingNumNotMasterErrors = replMetrics.network.notPrimaryUnacknowledgedWrites;
|
||||
|
||||
// Open a cursor on secondary.
|
||||
const cursorIdToBeReadAfterStepUp =
|
||||
@@ -49,7 +49,7 @@ jsTestLog("2. Start blocking getMore cmd before step up");
|
||||
const joinGetMoreThread = startParallelShell(() => {
|
||||
// Open another cursor on secondary before step up.
|
||||
secondaryDB = db.getSiblingDB(TestData.dbName);
|
||||
secondaryDB.getMongo().setSlaveOk(true);
|
||||
secondaryDB.getMongo().setSecondaryOk();
|
||||
|
||||
const cursorIdToBeReadDuringStepUp =
|
||||
assert.commandWorked(secondaryDB.runCommand({"find": TestData.collName, batchSize: 0}))
|
||||
@@ -71,7 +71,7 @@ waitForCurOpByFailPoint(
|
||||
jsTestLog("2. Start blocking find cmd before step up");
|
||||
const joinFindThread = startParallelShell(() => {
|
||||
secondaryDB = db.getSiblingDB(TestData.dbName);
|
||||
secondaryDB.getMongo().setSlaveOk(true);
|
||||
secondaryDB.getMongo().setSecondaryOk();
|
||||
|
||||
// Enable the fail point for find cmd.
|
||||
assert.commandWorked(
|
||||
@@ -127,7 +127,7 @@ assert.eq(replMetrics.stateTransition.lastStateTransition, "stepUp");
|
||||
assert.eq(replMetrics.stateTransition.userOperationsKilled, 0);
|
||||
// Should account for find and getmore commands issued before step up.
|
||||
assert.gte(replMetrics.stateTransition.userOperationsRunning, 2);
|
||||
assert.eq(replMetrics.network.notMasterUnacknowledgedWrites, startingNumNotMasterErrors);
|
||||
assert.eq(replMetrics.network.notPrimaryUnacknowledgedWrites, startingNumNotMasterErrors);
|
||||
|
||||
rst.stopSet();
|
||||
})();
|
||||
|
||||
@@ -129,7 +129,7 @@ replTest.awaitSecondaryNodes();
|
||||
|
||||
jsTestLog("Initial sync completed");
|
||||
|
||||
secondary.setSlaveOk();
|
||||
secondary.setSecondaryOk();
|
||||
const secondaryColl = secondary.getDB(dbName).getCollection(collName);
|
||||
|
||||
// Make sure that while reading from the node that went through initial sync, we can't read
|
||||
|
||||
@@ -106,7 +106,7 @@ replTest.awaitSecondaryNodes();
|
||||
|
||||
jsTestLog("Initial sync completed");
|
||||
|
||||
secondary.setSlaveOk();
|
||||
secondary.setSecondaryOk();
|
||||
const secondaryColl = secondary.getDB(dbName).getCollection(collName);
|
||||
|
||||
// Make sure that while reading from the node that went through initial sync, we can't read
|
||||
|
||||
@@ -80,7 +80,7 @@ replTest.awaitSecondaryNodes();
|
||||
|
||||
jsTestLog("Initial sync completed");
|
||||
|
||||
secondary.setSlaveOk();
|
||||
secondary.setSecondaryOk();
|
||||
const secondaryColl = secondary.getDB(dbName).getCollection(collName);
|
||||
|
||||
// Make sure that while reading from the node that went through initial sync, we can't read
|
||||
|
||||
@@ -107,7 +107,7 @@ PrepareHelpers.awaitMajorityCommitted(replTest, prepareTimestamp);
|
||||
|
||||
jsTestLog("Initial sync completed");
|
||||
|
||||
secondary.setSlaveOk();
|
||||
secondary.setSecondaryOk();
|
||||
const secondaryColl = secondary.getDB(dbName).getCollection(collName);
|
||||
|
||||
jsTestLog("Checking that the transaction is properly prepared");
|
||||
|
||||
@@ -82,7 +82,7 @@ PrepareHelpers.awaitMajorityCommitted(replTest, prepareTimestamp2);
|
||||
|
||||
// Wait for the node to complete recovery before trying to read from it.
|
||||
replTest.awaitSecondaryNodes();
|
||||
secondary.setSlaveOk();
|
||||
secondary.setSecondaryOk();
|
||||
|
||||
jsTestLog("Checking that the first transaction is properly prepared");
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ replTest.awaitReplication();
|
||||
var secondary = replTest.getSecondary();
|
||||
var secondaryFoo = secondary.getDB("foo");
|
||||
|
||||
secondaryFoo.permanentColl.setSlaveOk(true);
|
||||
secondaryFoo.permanentColl.setSecondaryOk();
|
||||
|
||||
// Get the information on the secondary to ensure it was replicated correctly.
|
||||
checkCollectionTemp(secondaryFoo, "permanentColl", false);
|
||||
|
||||
@@ -104,7 +104,7 @@ var doTest = function(signal) {
|
||||
var secondaries = replTest.getSecondaries();
|
||||
assert(secondaries.length == 2, "Expected 2 secondaries but length was " + secondaries.length);
|
||||
secondaries.forEach(function(secondary) {
|
||||
secondary.setSlaveOk();
|
||||
secondary.setSecondaryOk();
|
||||
var count = secondary.getDB("bar").runCommand({count: "bar"});
|
||||
printjson(count);
|
||||
assert.eq(1000, count.n, "secondary count wrong: " + secondary);
|
||||
@@ -118,7 +118,7 @@ var doTest = function(signal) {
|
||||
var t = db.foo;
|
||||
|
||||
var ts = secondaries.map(function(z) {
|
||||
z.setSlaveOk();
|
||||
z.setSecondaryOk();
|
||||
return z.getDB("foo").foo;
|
||||
});
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ doTest = function(signal) {
|
||||
|
||||
var secondaries = replTest.getSecondaries();
|
||||
secondaries.forEach(function(secondary) {
|
||||
secondary.setSlaveOk();
|
||||
secondary.setSecondaryOk();
|
||||
});
|
||||
|
||||
// Test write concern with multiple inserts.
|
||||
|
||||
@@ -55,8 +55,8 @@ if (wcError != null) {
|
||||
}
|
||||
|
||||
var secondaries = replTest.getSecondaries();
|
||||
secondaries[0].setSlaveOk();
|
||||
secondaries[1].setSlaveOk();
|
||||
secondaries[0].setSecondaryOk();
|
||||
secondaries[1].setSecondaryOk();
|
||||
|
||||
var secondary0Count = secondaries[0].getDB(testDB).foo.find().itcount();
|
||||
assert(secondary0Count == docNum,
|
||||
|
||||
@@ -10,7 +10,7 @@ var p = rt.getPrimary();
|
||||
rt.awaitSecondaryNodes();
|
||||
var secondaries = rt.getSecondaries();
|
||||
s = secondaries[0];
|
||||
s.setSlaveOk();
|
||||
s.setSecondaryOk();
|
||||
admin = p.getDB("admin");
|
||||
|
||||
debug = function(foo) {}; // print( foo ); }
|
||||
|
||||
@@ -99,8 +99,8 @@ assert.soon(() => {
|
||||
});
|
||||
|
||||
// Observe that the old write does not exist anywhere in the set.
|
||||
syncSource.setSlaveOk();
|
||||
resyncNode.setSlaveOk();
|
||||
syncSource.setSecondaryOk();
|
||||
resyncNode.setSecondaryOk();
|
||||
assert.eq(0, syncSource.getDB(dbName)[collName].find(disappearingDoc).itcount());
|
||||
assert.eq(0, resyncNode.getDB(dbName)[collName].find(disappearingDoc).itcount());
|
||||
|
||||
|
||||
@@ -47,8 +47,8 @@ replTest.waitForState(replTest.nodes[0], ReplSetTest.State.PRIMARY);
|
||||
var master = replTest.getPrimary();
|
||||
var a_conn = conns[0];
|
||||
var b_conn = conns[1];
|
||||
a_conn.setSlaveOk();
|
||||
b_conn.setSlaveOk();
|
||||
a_conn.setSecondaryOk();
|
||||
b_conn.setSecondaryOk();
|
||||
var A = a_conn.getDB("admin");
|
||||
var B = b_conn.getDB("admin");
|
||||
var a = a_conn.getDB("test");
|
||||
|
||||
@@ -31,8 +31,8 @@ function runRollbackDirectoryTest(shouldCreateRollbackFiles) {
|
||||
var master = replTest.getPrimary();
|
||||
var a_conn = conns[0];
|
||||
var b_conn = conns[1];
|
||||
a_conn.setSlaveOk();
|
||||
b_conn.setSlaveOk();
|
||||
a_conn.setSecondaryOk();
|
||||
b_conn.setSecondaryOk();
|
||||
var A = a_conn.getDB("test");
|
||||
var B = b_conn.getDB("test");
|
||||
var Apath = replTest.getDbPath(a_conn) + '/';
|
||||
|
||||
@@ -45,10 +45,10 @@ replTest.initiate({
|
||||
replTest.waitForState(replTest.nodes[0], ReplSetTest.State.PRIMARY);
|
||||
var master = replTest.getPrimary();
|
||||
var a_conn = conns[0];
|
||||
a_conn.setSlaveOk();
|
||||
a_conn.setSecondaryOk();
|
||||
var A = a_conn.getDB("admin");
|
||||
var b_conn = conns[1];
|
||||
b_conn.setSlaveOk();
|
||||
b_conn.setSecondaryOk();
|
||||
var B = b_conn.getDB("admin");
|
||||
assert.eq(master, conns[0], "conns[0] assumed to be master");
|
||||
assert.eq(a_conn, master);
|
||||
|
||||
@@ -54,10 +54,10 @@ replTest.initiate({
|
||||
replTest.waitForState(replTest.nodes[0], ReplSetTest.State.PRIMARY);
|
||||
var master = replTest.getPrimary();
|
||||
var a_conn = conns[0];
|
||||
a_conn.setSlaveOk();
|
||||
a_conn.setSecondaryOk();
|
||||
var A = a_conn.getDB("admin");
|
||||
var b_conn = conns[1];
|
||||
b_conn.setSlaveOk();
|
||||
b_conn.setSecondaryOk();
|
||||
var B = b_conn.getDB("admin");
|
||||
assert.eq(master, conns[0], "conns[0] assumed to be master");
|
||||
assert.eq(a_conn, master);
|
||||
|
||||
@@ -13,12 +13,6 @@
|
||||
|
||||
load('jstests/replsets/libs/rollback_resumable_index_build.js');
|
||||
|
||||
// TODO(SERVER-50775): Re-enable when stepdown issues are fixed in resumable index rollback tests.
|
||||
if (true) {
|
||||
jsTestLog('Skipping test.');
|
||||
return;
|
||||
}
|
||||
|
||||
const dbName = "test";
|
||||
const rollbackStartFailPointName = "hangIndexBuildDuringBulkLoadPhase";
|
||||
const insertsToBeRolledBack = [{a: 4}, {a: 5}];
|
||||
@@ -35,8 +29,9 @@ RollbackResumableIndexBuildTest.run(rollbackTest,
|
||||
{a: 1},
|
||||
rollbackStartFailPointName,
|
||||
{iteration: 1},
|
||||
"hangAfterSettingUpIndexBuildUnlocked",
|
||||
"hangAfterSettingUpIndexBuild",
|
||||
{},
|
||||
"setYieldAllLocksHang",
|
||||
insertsToBeRolledBack);
|
||||
|
||||
// Rollback to the collection scan phase.
|
||||
@@ -47,7 +42,8 @@ RollbackResumableIndexBuildTest.run(rollbackTest,
|
||||
rollbackStartFailPointName,
|
||||
{iteration: 1},
|
||||
"hangIndexBuildDuringCollectionScanPhaseBeforeInsertion",
|
||||
{fieldsToMatch: {a: 2}},
|
||||
{iteration: 1},
|
||||
"setYieldAllLocksHang",
|
||||
insertsToBeRolledBack);
|
||||
|
||||
rollbackTest.stop();
|
||||
|
||||
@@ -13,12 +13,6 @@
|
||||
|
||||
load('jstests/replsets/libs/rollback_resumable_index_build.js');
|
||||
|
||||
// TODO(SERVER-50775): Re-enable when stepdown issues are fixed in resumable index rollback tests.
|
||||
if (true) {
|
||||
jsTestLog('Skipping test.');
|
||||
return;
|
||||
}
|
||||
|
||||
const dbName = "test";
|
||||
const rollbackStartFailPointName = "hangIndexBuildDuringCollectionScanPhaseBeforeInsertion";
|
||||
const insertsToBeRolledBack = [{a: 6}, {a: 7}];
|
||||
@@ -34,9 +28,10 @@ RollbackResumableIndexBuildTest.run(rollbackTest,
|
||||
coll.getName(),
|
||||
{a: 1},
|
||||
rollbackStartFailPointName,
|
||||
{fieldsToMatch: {a: 2}},
|
||||
"hangAfterSettingUpIndexBuildUnlocked",
|
||||
{iteration: 3},
|
||||
"hangAfterSettingUpIndexBuild",
|
||||
{},
|
||||
"setYieldAllLocksHang",
|
||||
insertsToBeRolledBack);
|
||||
|
||||
// Rollback to earlier in the collection scan phase.
|
||||
@@ -45,9 +40,10 @@ RollbackResumableIndexBuildTest.run(rollbackTest,
|
||||
coll.getName(),
|
||||
{a: 1},
|
||||
rollbackStartFailPointName,
|
||||
{iteration: 4},
|
||||
{iteration: 3},
|
||||
"hangIndexBuildDuringCollectionScanPhaseAfterInsertion",
|
||||
{iteration: 2},
|
||||
{iteration: 1},
|
||||
"setYieldAllLocksHang",
|
||||
insertsToBeRolledBack);
|
||||
|
||||
rollbackTest.stop();
|
||||
|
||||
@@ -13,12 +13,6 @@
|
||||
|
||||
load('jstests/replsets/libs/rollback_resumable_index_build.js');
|
||||
|
||||
// TODO(SERVER-50775): Re-enable when stepdown issues are fixed in resumable index rollback tests.
|
||||
if (true) {
|
||||
jsTestLog('Skipping test.');
|
||||
return;
|
||||
}
|
||||
|
||||
const dbName = "test";
|
||||
const insertsToBeRolledBack = [{a: 7}, {a: 8}];
|
||||
|
||||
@@ -32,7 +26,7 @@ RollbackResumableIndexBuildTest.runIndexBuildComplete(rollbackTest,
|
||||
dbName,
|
||||
coll.getName(),
|
||||
{a: 1},
|
||||
"hangAfterSettingUpIndexBuildUnlocked",
|
||||
"hangAfterSettingUpIndexBuild",
|
||||
{},
|
||||
insertsToBeRolledBack);
|
||||
|
||||
|
||||
@@ -13,15 +13,9 @@
|
||||
|
||||
load('jstests/replsets/libs/rollback_resumable_index_build.js');
|
||||
|
||||
// TODO(SERVER-50775): Re-enable when stepdown issues are fixed in resumable index rollback tests.
|
||||
if (true) {
|
||||
jsTestLog('Skipping test.');
|
||||
return;
|
||||
}
|
||||
|
||||
const dbName = "test";
|
||||
const rollbackStartFailPointName = "hangIndexBuildDuringDrainWritesPhase";
|
||||
const insertsToBeRolledBack = [{a: 13}, {a: 14}];
|
||||
const insertsToBeRolledBack = [{a: 18}, {a: 19}];
|
||||
|
||||
const rollbackTest = new RollbackTest(jsTestName());
|
||||
const coll = rollbackTest.getPrimary().getDB(dbName).getCollection(jsTestName());
|
||||
@@ -34,11 +28,12 @@ RollbackResumableIndexBuildTest.run(rollbackTest,
|
||||
coll.getName(),
|
||||
{a: 1},
|
||||
rollbackStartFailPointName,
|
||||
{iteration: 0},
|
||||
"hangAfterSettingUpIndexBuildUnlocked",
|
||||
{iteration: 1},
|
||||
"hangAfterSettingUpIndexBuild",
|
||||
{},
|
||||
"hangDuringIndexBuildDrainYield",
|
||||
insertsToBeRolledBack,
|
||||
[{a: 4}, {a: 5}]);
|
||||
[{a: 4}, {a: 5}, {a: 6}]);
|
||||
|
||||
// Rollback to the collection scan phase.
|
||||
RollbackResumableIndexBuildTest.run(rollbackTest,
|
||||
@@ -46,11 +41,12 @@ RollbackResumableIndexBuildTest.run(rollbackTest,
|
||||
coll.getName(),
|
||||
{a: 1},
|
||||
rollbackStartFailPointName,
|
||||
{iteration: 0},
|
||||
{iteration: 1},
|
||||
"hangIndexBuildDuringCollectionScanPhaseBeforeInsertion",
|
||||
{fieldsToMatch: {a: 2}},
|
||||
{iteration: 1},
|
||||
"hangDuringIndexBuildDrainYield",
|
||||
insertsToBeRolledBack,
|
||||
[{a: 6}, {a: 7}]);
|
||||
[{a: 7}, {a: 8}, {a: 9}]);
|
||||
|
||||
// Rollback to the bulk load phase.
|
||||
RollbackResumableIndexBuildTest.run(rollbackTest,
|
||||
@@ -58,26 +54,25 @@ RollbackResumableIndexBuildTest.run(rollbackTest,
|
||||
coll.getName(),
|
||||
{a: 1},
|
||||
rollbackStartFailPointName,
|
||||
{iteration: 0},
|
||||
{iteration: 1},
|
||||
"hangIndexBuildDuringBulkLoadPhase",
|
||||
{iteration: 1},
|
||||
"hangDuringIndexBuildDrainYield",
|
||||
insertsToBeRolledBack,
|
||||
[{a: 8}, {a: 9}]);
|
||||
[{a: 10}, {a: 11}, {a: 12}]);
|
||||
|
||||
// Rollback to earlier in the drain writes phase. We set maxIndexBuildDrainBatchSize to 1 so that
|
||||
// the primary can step down between iterations.
|
||||
assert.commandWorked(
|
||||
rollbackTest.getPrimary().adminCommand({setParameter: 1, maxIndexBuildDrainBatchSize: 1}));
|
||||
// Rollback to earlier in the drain writes phase.
|
||||
RollbackResumableIndexBuildTest.run(rollbackTest,
|
||||
dbName,
|
||||
coll.getName(),
|
||||
{a: 1},
|
||||
rollbackStartFailPointName,
|
||||
{iteration: 2},
|
||||
{iteration: 3},
|
||||
"hangIndexBuildDuringDrainWritesPhaseSecond",
|
||||
{iteration: 0},
|
||||
{iteration: 1},
|
||||
"hangDuringIndexBuildDrainYield",
|
||||
insertsToBeRolledBack,
|
||||
[{a: 10}, {a: 11}, {a: 12}]);
|
||||
[{a: 13}, {a: 14}, {a: 15}, {a: 16}, {a: 17}]);
|
||||
|
||||
rollbackTest.stop();
|
||||
})();
|
||||
|
||||
@@ -147,7 +147,7 @@ reconnect = function(conn) {
|
||||
};
|
||||
|
||||
getLatestOp = function(server) {
|
||||
server.getDB("admin").getMongo().setSlaveOk();
|
||||
server.getDB("admin").getMongo().setSecondaryOk();
|
||||
var log = server.getDB("local")['oplog.rs'];
|
||||
var cursor = log.find({}).sort({'$natural': -1}).limit(1);
|
||||
if (cursor.hasNext()) {
|
||||
@@ -157,7 +157,7 @@ getLatestOp = function(server) {
|
||||
};
|
||||
|
||||
getLeastRecentOp = function({server, readConcern}) {
|
||||
server.getDB("admin").getMongo().setSlaveOk();
|
||||
server.getDB("admin").getMongo().setSecondaryOk();
|
||||
const oplog = server.getDB("local").oplog.rs;
|
||||
const cursor = oplog.find().sort({$natural: 1}).limit(1).readConcern(readConcern);
|
||||
if (cursor.hasNext()) {
|
||||
|
||||
@@ -36,8 +36,8 @@ replSet.initiate({
|
||||
// set up common points of access
|
||||
var master = replSet.getPrimary();
|
||||
var primary = master.getDB("foo");
|
||||
replSet.nodes[1].setSlaveOk();
|
||||
replSet.nodes[2].setSlaveOk();
|
||||
replSet.nodes[1].setSecondaryOk();
|
||||
replSet.nodes[2].setSecondaryOk();
|
||||
var member2 = replSet.nodes[1].getDB("admin");
|
||||
var member3 = replSet.nodes[2].getDB("admin");
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ var secondaryConns = replTest.getSecondaries();
|
||||
var secondaries = [];
|
||||
for (var i in secondaryConns) {
|
||||
var d = secondaryConns[i].getDB(name);
|
||||
d.getMongo().setSlaveOk();
|
||||
d.getMongo().setSecondaryOk();
|
||||
secondaries.push(d);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// Test that slaveOk is implicitly allowed for queries on a secondary with a read preference other
|
||||
// than 'primary', and that queries which do have 'primary' read preference fail.
|
||||
// Test that secondaryOk is implicitly allowed for queries on a secondary with a read preference
|
||||
// other than 'primary', and that queries which do have 'primary' read preference fail.
|
||||
(function() {
|
||||
"use strict";
|
||||
|
||||
@@ -28,18 +28,18 @@ const secDB = rst.getSecondary().getDB(jsTestName());
|
||||
|
||||
for (let readMode of ["commands", "legacy"]) {
|
||||
for (let readPref of readPrefs) {
|
||||
for (let slaveOk of [true, false]) {
|
||||
const testType = {readMode: readMode, readPref: readPref, slaveOk: slaveOk};
|
||||
for (let secondaryOk of [true, false]) {
|
||||
const testType = {readMode: readMode, readPref: readPref, secondaryOk: secondaryOk};
|
||||
|
||||
secDB.getMongo().forceReadMode(readMode);
|
||||
secDB.getMongo().setSlaveOk(slaveOk);
|
||||
secDB.getMongo().setSecondaryOk(secondaryOk);
|
||||
|
||||
const cursor = (readPref ? secDB.test.find().readPref(readPref) : secDB.test.find());
|
||||
|
||||
if (readPref === "primary" || (!readPref && !slaveOk)) {
|
||||
if (readPref === "primary" || (!readPref && !secondaryOk)) {
|
||||
// Attempting to run the query throws an error of type NotPrimaryNoSecondaryOk.
|
||||
const slaveOkErr = assert.throws(() => cursor.itcount(), [], tojson(testType));
|
||||
assert.commandFailedWithCode(slaveOkErr, ErrorCodes.NotPrimaryNoSecondaryOk);
|
||||
const secondaryOkErr = assert.throws(() => cursor.itcount(), [], tojson(testType));
|
||||
assert.commandFailedWithCode(secondaryOkErr, ErrorCodes.NotPrimaryNoSecondaryOk);
|
||||
} else {
|
||||
// Succeeds for all non-primary readPrefs, and for no readPref iff slaveOk.
|
||||
const docCount = assert.doesNotThrow(() => cursor.itcount(), [], tojson(testType));
|
||||
@@ -51,7 +51,7 @@ for (let readMode of ["commands", "legacy"]) {
|
||||
|
||||
function assertNotPrimaryNoSecondaryOk(func) {
|
||||
secDB.getMongo().forceReadMode("commands");
|
||||
secDB.getMongo().setSlaveOk(false);
|
||||
secDB.getMongo().setSecondaryOk(false);
|
||||
secDB.getMongo().setReadPref("primary");
|
||||
const res = assert.throws(func);
|
||||
assert.commandFailedWithCode(res, ErrorCodes.NotPrimaryNoSecondaryOk);
|
||||
@@ -59,7 +59,7 @@ function assertNotPrimaryNoSecondaryOk(func) {
|
||||
|
||||
// Test that agg with $out/$merge and non-inline mapReduce fail with 'NotPrimaryNoSecondaryOk' when
|
||||
// directed at a secondary with "primary" read preference.
|
||||
const secondaryColl = secDB.slaveok_read_pref;
|
||||
const secondaryColl = secDB.secondaryok_read_pref;
|
||||
assertNotPrimaryNoSecondaryOk(() => secondaryColl.aggregate([{$out: "target"}]).itcount());
|
||||
assertNotPrimaryNoSecondaryOk(
|
||||
() =>
|
||||
|
||||
@@ -35,7 +35,7 @@ rst.awaitSecondaryNodes();
|
||||
|
||||
// Get the new secondary connection.
|
||||
secondary = rst.getSecondary();
|
||||
secondary.setSlaveOk(true);
|
||||
secondary.setSecondaryOk();
|
||||
|
||||
const secondaryAdminDb = secondary.getDB("admin");
|
||||
// Assert that the FCV document was cloned through initial sync on the secondary.
|
||||
|
||||
@@ -93,7 +93,7 @@ jsTestLog("Do a read that hits a prepare conflict on the old primary");
|
||||
const wTPrintPrepareConflictLogFailPoint = configureFailPoint(primary, "WTPrintPrepareConflictLog");
|
||||
|
||||
const joinReadThread = startParallelShell(() => {
|
||||
db.getMongo().setSlaveOk(true);
|
||||
db.getMongo().setSecondaryOk();
|
||||
oldPrimaryDB = db.getSiblingDB(TestData.dbName);
|
||||
|
||||
assert.commandFailedWithCode(oldPrimaryDB.runCommand({
|
||||
|
||||
@@ -154,9 +154,6 @@ configDonorsColl.createIndex({expireAt: 1}, {expireAfterSeconds: 0});
|
||||
jsTest.log("Test the case where the migration aborts");
|
||||
const migrationId = UUID();
|
||||
|
||||
let configDonorsColl = donorPrimary.getCollection(kConfigDonorsNS);
|
||||
configDonorsColl.createIndex({expireAt: 1}, {expireAfterSeconds: 0});
|
||||
|
||||
let abortFp = configureFailPoint(donorPrimary, "abortTenantMigrationAfterBlockingStarts");
|
||||
assert.commandFailedWithCode(donorPrimary.adminCommand({
|
||||
donorStartMigration: 1,
|
||||
@@ -187,6 +184,29 @@ configDonorsColl.createIndex({expireAt: 1}, {expireAfterSeconds: 0});
|
||||
testDonorForgetMigration(donorRst, recipientRst, migrationId, kDBPrefix);
|
||||
})();
|
||||
|
||||
// Drop the TTL index to make sure that the migration state is still available when the
|
||||
// donorForgetMigration command is retried.
|
||||
configDonorsColl.dropIndex({expireAt: 1});
|
||||
|
||||
(() => {
|
||||
jsTest.log("Test that donorForgetMigration can be run multiple times");
|
||||
const migrationId = UUID();
|
||||
|
||||
assert.commandWorked(donorPrimary.adminCommand({
|
||||
donorStartMigration: 1,
|
||||
migrationId: migrationId,
|
||||
recipientConnectionString: kRecipientConnString,
|
||||
databasePrefix: kDBPrefix,
|
||||
readPreference: {mode: "primary"}
|
||||
}));
|
||||
|
||||
assert.commandWorked(
|
||||
donorPrimary.adminCommand({donorForgetMigration: 1, migrationId: migrationId}));
|
||||
|
||||
assert.commandWorked(
|
||||
donorPrimary.adminCommand({donorForgetMigration: 1, migrationId: migrationId}));
|
||||
})();
|
||||
|
||||
donorRst.stopSet();
|
||||
recipientRst.stopSet();
|
||||
})();
|
||||
|
||||
@@ -27,8 +27,8 @@ replTest.initiate(config);
|
||||
const primary = replTest.getPrimary();
|
||||
const secondary = replTest.getSecondary();
|
||||
|
||||
// Set slaveOk=true so that normal read commands would be allowed on the secondary.
|
||||
secondary.setSlaveOk(true);
|
||||
// Set secondaryOk=true so that normal read commands would be allowed on the secondary.
|
||||
secondary.setSecondaryOk();
|
||||
|
||||
// Create a test collection that we can run commands against.
|
||||
const primaryDB = primary.getDB(dbName);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Tests aggregate command against mongos with slaveOk. For more tests on read preference,
|
||||
* Tests aggregate command against mongos with secondaryOk. For more tests on read preference,
|
||||
* please refer to jstests/sharding/read_pref_cmd.js.
|
||||
* @tags: [
|
||||
* requires_replication,
|
||||
@@ -21,12 +21,12 @@ var doTest = function(st, doSharded) {
|
||||
}
|
||||
|
||||
testDB.user.insert({x: 10}, {writeConcern: {w: NODES}});
|
||||
testDB.setSlaveOk(true);
|
||||
testDB.setSecondaryOk();
|
||||
|
||||
var secNode = st.rs0.getSecondary();
|
||||
secNode.getDB('test').setProfilingLevel(2);
|
||||
|
||||
// wait for mongos to recognize that the slave is up
|
||||
// wait for mongos to recognize that the secondary is up
|
||||
awaitRSClientHosts(st.s, secNode, {ok: true});
|
||||
|
||||
var res = testDB.runCommand({aggregate: 'user', pipeline: [{$project: {x: 1}}], cursor: {}});
|
||||
|
||||
@@ -39,7 +39,7 @@ jsTest.log('Config nodes up: 1 of 3, shard nodes up: 1 of 2: ' +
|
||||
'Only queries will work (no shard primary)');
|
||||
st.rs0.stop(0);
|
||||
st.restartMongos(0);
|
||||
st.s0.setSlaveOk(true);
|
||||
st.s0.setSecondaryOk();
|
||||
assert.eq([{_id: 0, count: 3}], st.s0.getDB('TestDB').TestColl.find().toArray());
|
||||
|
||||
jsTest.log('Config nodes up: 1 of 3, shard nodes up: 0 of 2: ' +
|
||||
|
||||
@@ -19,7 +19,7 @@ var testColl = testDB.user;
|
||||
// before setting up authentication
|
||||
assert.commandWorked(adminDB.runCommand({replSetGetStatus: 1}));
|
||||
|
||||
conn.setSlaveOk();
|
||||
conn.setSecondaryOk();
|
||||
assert.commandWorked(adminDB.runCommand({replSetGetStatus: 1}));
|
||||
|
||||
// Add admin user using direct connection to primary to simulate connection from remote host
|
||||
@@ -38,19 +38,19 @@ assert.eq(1, testDB.auth('a', 'a'));
|
||||
jsTest.log('Sending an authorized query that should be ok');
|
||||
assert.commandWorked(testColl.insert({x: 1}, {writeConcern: {w: nodeCount}}));
|
||||
|
||||
conn.setSlaveOk(true);
|
||||
conn.setSecondaryOk();
|
||||
doc = testColl.findOne();
|
||||
assert(doc != null);
|
||||
|
||||
doc = testColl.find().readPref('secondary').next();
|
||||
assert(doc != null);
|
||||
|
||||
conn.setSlaveOk(false);
|
||||
conn.setSecondaryOk(false);
|
||||
doc = testColl.findOne();
|
||||
assert(doc != null);
|
||||
|
||||
var queryToPriShouldFail = function() {
|
||||
conn.setSlaveOk(false);
|
||||
conn.setSecondaryOk(false);
|
||||
|
||||
assert.throws(function() {
|
||||
testColl.findOne();
|
||||
@@ -63,7 +63,7 @@ var queryToPriShouldFail = function() {
|
||||
};
|
||||
|
||||
var queryToSecShouldFail = function() {
|
||||
conn.setSlaveOk(true);
|
||||
conn.setSecondaryOk();
|
||||
|
||||
assert.throws(function() {
|
||||
testColl.findOne();
|
||||
@@ -104,7 +104,7 @@ queryToPriShouldFail();
|
||||
assert.eq(1, testDB.auth('a', 'a'));
|
||||
|
||||
// Find out the current cached secondary in the repl connection
|
||||
conn.setSlaveOk(true);
|
||||
conn.setSecondaryOk();
|
||||
var serverInfo = testColl.find().readPref('secondary').explain().serverInfo;
|
||||
var secNodeIdx = -1;
|
||||
var secPortStr = serverInfo.port.toString();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* This tests whether slaveOk reads are properly routed through mongos in
|
||||
* This tests whether secondaryOk reads are properly routed through mongos in
|
||||
* an authenticated environment. This test also includes restarting the
|
||||
* entire set, then querying afterwards.
|
||||
*
|
||||
@@ -59,11 +59,11 @@ priAdminDB.createUser({user: 'user', pwd: 'password', roles: jsTest.adminUserRol
|
||||
{w: 3, wtimeout: 30000});
|
||||
|
||||
coll.drop();
|
||||
coll.setSlaveOk(true);
|
||||
coll.setSecondaryOk();
|
||||
|
||||
/* Secondaries should be up here, but they can still be in RECOVERY
|
||||
* state, which will make the ReplicaSetMonitor mark them as
|
||||
* ok = false and not eligible for slaveOk queries.
|
||||
* ok = false and not eligible for secondaryOk queries.
|
||||
*/
|
||||
awaitRSClientHosts(mongos, replTest.getSecondaries(), {ok: true, secondary: true});
|
||||
|
||||
@@ -90,7 +90,7 @@ for (var n = 0; n < nodeCount; n++) {
|
||||
|
||||
replTest.awaitSecondaryNodes();
|
||||
|
||||
coll.setSlaveOk(true);
|
||||
coll.setSecondaryOk();
|
||||
|
||||
/* replSetMonitor does not refresh the nodes information when getting secondaries.
|
||||
* A node that is previously labeled as secondary can now be a primary, so we
|
||||
|
||||
@@ -53,7 +53,7 @@ var mongos = MongoRunner.runMongos({configdb: seedList});
|
||||
rst.stop(1);
|
||||
|
||||
var admin = mongos.getDB('admin');
|
||||
mongos.setSlaveOk(true);
|
||||
mongos.setSecondaryOk();
|
||||
assert.eq(1, admin.foo.findOne().a);
|
||||
MongoRunner.stopMongos(mongos);
|
||||
rst.stopSet();
|
||||
|
||||
@@ -44,7 +44,7 @@ var collPrimary = (new Mongo(s.s0.host)).getDB('TestDB').TestColl;
|
||||
assert.eq(2100, collPrimary.find().itcount());
|
||||
|
||||
var collSlaveOk = (new Mongo(s.s0.host)).getDB('TestDB').TestColl;
|
||||
collSlaveOk.setSlaveOk();
|
||||
collSlaveOk.setSecondaryOk();
|
||||
assert.eq(2100, collSlaveOk.find().itcount());
|
||||
|
||||
assert.commandWorked(s.s0.adminCommand({
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user