Compare commits

...

63 Commits

Author SHA1 Message Date
Amirsaman Memaripour
63338e0dd6 SERVER-51690 Futurize and refactor Mongos execCommandClient 2020-11-18 00:38:58 +00:00
Amirsaman Memaripour
13bb35d34d SERVER-51690 Futurize Mongos runCommand for async command execution 2020-11-17 17:07:44 +00:00
Amirsaman Memaripour
f4373b85f0 SERVER-51690 Futurize clientCommand to support async command execution 2020-11-05 02:21:26 +00:00
Amirsaman Memaripour
51067e0952 SERVER-49108 Convert buildInfo command to async implementation 2020-11-03 16:43:16 +00:00
Amirsaman Memaripour
9262aac9e7 SERVER-51690 Futurize Mongos handleRequest for async command execution 2020-11-02 17:38:29 +00:00
Ben Caimano
5b57abab3e SERVER-51499 Track service executor statistics more thoroughly 2020-10-23 21:48:26 +00:00
Ben Caimano
907bf93c57 SERVER-49109 Move to the dedicated executor after blocking commands 2020-10-23 21:48:21 +00:00
Ben Caimano
243a506fca SERVER-49109 ServiceExecutorFixed tracks work and sessions
This commit also adds a server parameter to start on the "borrowed"
threading model and introduces an evergreen variant for it.
2020-10-23 21:47:37 +00:00
Amirsaman Memaripour
8cff99b2c4 SERVER-50452 Make destruction of ServiceExecutorFixed deterministic
This commit introduces new fail-points to allow unit-tests
deterministically examine creation and return of executor threads.
2020-10-23 21:47:37 +00:00
Ben Caimano
439730c7f4 SERVER-51279 Updating runOnDataAvailable 2020-10-20 22:06:45 +00:00
Amirsaman Memaripour
18f1d00029 SERVER-49107 Futurize migrationConflictHandler and runCommandInvocation 2020-10-19 22:44:45 +00:00
Ben Caimano
fa29e47f37 SERVER-51278 Introduced ClientStrand 2020-10-19 20:25:05 +00:00
Amirsaman Memaripour
b03c93d55b SERVER-49107 Futurize and refactor command invocation 2020-10-14 17:38:12 +00:00
Amirsaman Memaripour
1d6af89487 SERVER-49107 Futurize and refactor runCommandImpl() 2020-10-14 17:17:30 +00:00
Amirsaman Memaripour
38f350478a SERVER-49107 Futurize and refactor execCommandDatabase() 2020-09-26 01:43:36 +00:00
Amirsaman Memaripour
4c283d5c34 SERVER-49107 Futurize and refactor receivedCommands() 2020-09-25 18:16:01 +00:00
Ben Caimano
efb3f7689e SERVER-51080 Fix mongobridge startup ordering 2020-09-22 16:02:52 +00:00
Amirsaman Memaripour
66b412e165 SERVER-49107 Add support for async execution to handleRequest
This patch extends handleRequest to capture context for out-of-line
execution and makes ServiceStateMachine own the opCtx used for
command execution.
2020-09-17 17:36:35 +00:00
Ben Caimano
5f3f8d9745 SERVER-50947 Implize ServiceStateMachine 2020-09-17 02:08:00 +00:00
Amirsaman Memaripour
dabf0e0842 SERVER-49107 Allow binding clients to executor threads 2020-09-14 22:01:12 +00:00
Ben Caimano
92e7ecf4ba SERVER-49073 Track connections that are maxConn exempt or threaded 2020-09-14 04:04:35 +00:00
Ben Caimano
46b220b83e Revert "SERVER-50867 Roll back ServiceStateMachine changes temporarily"
This reverts commit 575f370475.
2020-09-14 04:01:09 +00:00
Ben Caimano
575f370475 SERVER-50867 Roll back ServiceStateMachine changes temporarily
This reverts these commits:
b039b24746: SERVER-48980
97e16187ff: SERVER-49072
0607a6c291: SERVER-49104
2020-09-11 20:22:25 +00:00
Benety Goh
6a031f67c7 SERVER-50519 index build is resumable only if commit quorum is the default (i.e. all-voters) and node is a voter 2020-09-11 18:10:28 +00:00
Gregory Wlodarek
d735d9cf70 SERVER-50704 Create exportCollection command 2020-09-11 17:41:18 +00:00
Cheahuychou Mao
8dfebbb8bc SERVER-50872 Make the OpObserver construct TenantMigrationAccessBlocker on observing insertion for state doc with state "data sync" 2020-09-11 17:16:27 +00:00
Charlie Swanson
b39aecbdf4 SERVER-50764 Fix bad merge conflict - add break; 2020-09-11 16:50:11 +00:00
Ruoxin Xu
1373280c25 SERVER-43503 Complete TODO listed in SERVER-32565 2020-09-11 16:14:54 +00:00
Mark Benvenuto
642adc7547 SERVER-50036 logd() fails with invalid format string 2020-09-11 15:53:33 +00:00
Spencer Jackson
a5f72d4b37 SERVER-50736 Make OpenSSL explicitly accept SNIs 2020-09-11 15:28:31 +00:00
David Storch
712013ffd4 SERVER-50884 Change order of SBE traverse 'from' and 'in' branches in debug output 2020-09-11 14:33:20 +00:00
Mihai Andrei
94e5a1620a SERVER-49447 Implement validation error generation for jsonSchema scalar/miscellaneous keywords 2020-09-11 14:15:15 +00:00
Milena Ivanova
a70ac5e30e SERVER-49742 ExpressionAdd in SBE should use doubleDoubleSum built-in when called with more than two operands 2020-09-11 12:21:04 +00:00
Anton Korshunov
8216b783d1 SERVER-48472 Make SBE raise a KeyNotFound error when $_resumeAfter record id is not found 2020-09-11 10:38:26 +00:00
Luke Chen
8222bf3550 Import wiredtiger: a68890f718f74cdc9e9961bf5b33f5b125e853dd from branch mongodb-4.6
ref: df168fcd37..a68890f718
for: 4.7.0

WT-6592       Avoid marking errors for skipped Python tests due to not-built extension
WT-6653       Rollback/Restart txn before retry in RTS test
2020-09-11 07:31:12 +00:00
Gregory Wlodarek
f10e0ad7ca SERVER-29418 Create a storage-engine agnostic checkpointing thread 2020-09-10 23:41:14 +00:00
Gregory Noma
b68df4e87d SERVER-49215 Differentiate internal idents used for resumable index build information from other internal idents 2020-09-10 22:22:32 +00:00
Gregory Noma
4ff797fa43 SERVER-50775 Use failpoint for yielding index build locks in RollbackResumableIndexBuildTest 2020-09-10 21:13:14 +00:00
Ali Mir
0927e74e9d SERVER-50417 Change notMasterUnacknowledgedWrites to notPrimaryUnacknowledgedWrites in serverStatus 2020-09-10 18:44:30 +00:00
Louis Williams
11c68393df SERVER-48452 Internal readers should default to reading without a timestamp
Removes ReadSource::kUnset in favor of kNoTimestamp as the default

Makes the following behavioral changes to AutoGetCollectionForRead:
* Removes special early-return handling for kNoTimestamp
* Only user or DBDirectClient operations are eligible to read at
  kLastApplied.
* Operations only read at kLastApplied when in the SECONDARY state, nothing
  else. This means most internal operations that use DBDirectClient do not need
  to use a ReadSourceScope to ensure they read at kNoTimestamp.
2020-09-10 18:15:18 +00:00
A. Jesse Jiryu Davis
ce0487190c SERVER-49858 Add Command::acceptsAnyApiVersionParameters 2020-09-10 17:20:46 +00:00
Lingzhi Deng
93a5cd255c SERVER-50705: Create importCollection command 2020-09-10 16:14:55 +00:00
James Wahlin
3e453b013e SERVER-50557 Remove unused ExpressionContext::jsFnTimeoutMillis member var 2020-09-10 15:09:02 +00:00
Ali Mir
759787fd5a SERVER-50416 Change notMasterLegacyUnacknowledgedWrites to notPrimaryLegacyUnacknowledgedWrites in serverStatus 2020-09-10 14:12:01 +00:00
Pierlauro Sciarelli
9dac088a96 SERVER-50853 Enable retries of getShardAndCollectionVersion on the config server 2020-09-10 08:23:25 +00:00
Mikhail Shchatko
57cb74336b SERVER-50313 Add standalone tasks to live-record buildvariant 2020-09-10 07:27:00 +00:00
Billy Donahue
0ce948778c SERVER-50228 ThreadPool predicate condvar wait
- Switch std::vector to std::list to enable node splicing.
 - fmt::format
 - ThreadPool::Impl
 - check for uncallable onCreate in ServiceExecutorFixed
 - _workerThreadBody can be member of ThreadPool. Threads don't detach anymore
2020-09-10 07:09:32 +00:00
Luke Chen
c7efb504fd Import wiredtiger: df168fcd373a4afc719f6134f6911a1685178041 from branch mongodb-4.6
ref: bb92ab603f..df168fcd37
for: 4.7.0

WT-6650       Coverity: Null dereferences in session::close
2020-09-10 06:42:15 +00:00
Justin Seyster
09ba65f429 SERVER-50622 Add logging for 'mr_killop_test_fp' failpoint 2020-09-10 04:55:36 +00:00
A. Jesse Jiryu Davis
74c76f296c SERVER-50375 Ensure mongos forwards API params to shards 2020-09-10 00:34:29 +00:00
Ali Mir
2b5dc35f01 SERVER-50581 Replace setSlaveOk and getSlaveOk occurrences in jstests 2020-09-09 23:29:23 +00:00
Cheahuychou Mao
ee106b978c SERVER-50837 Make sure that donorForgetMigration command can be retried 2020-09-09 23:10:22 +00:00
Adam Cooper
4b2be90987 SERVER-50725 Remove "Upstream Version" from README.third_party.md for 4.7 2020-09-09 22:44:08 +00:00
Marcos José Grillo Ramírez
377b8fe439 SERVER-46199 Make the collection CatalogCache support causal consistency
This change implements the collection CatalogCache on top of the
ReadThroughCache, giving it the ability to support causal consistency.
As part of this change, the 'forceRefreshFromThisThread' flag has been
removed from the shard's refresh methods.

Co-authored-by: Tommaso Tocci <tommaso.tocci@mongodb.com>
Co-authored-by: Pierlauro Sciarelli <pierlauro.sciarelli@mongodb.com>
Co-authored-by: Kaloian Manassiev <kaloian.manassiev@mongodb.com>
2020-09-09 22:27:23 +00:00
Billy Donahue
f9d4a15397 SERVER-50835 Add .clangd/ to the .gitignore file 2020-09-09 21:56:28 +00:00
Spencer T Brody
10ecbbca34 SERVER-50700 Allow constructing a FailPointEnableBlock from a pointer to the FailPoint 2020-09-09 21:39:22 +00:00
Spencer T Brody
4e6da58756 SERVER-49242 Add serverStatus counters for number of running PrimaryOnlyService instances 2020-09-09 20:30:47 +00:00
Huayu Ouyang
1327ea6366 SERVER-19823 rs.printSlaveReplicationInfo() syncedTo field displays the epoch for unreachable secondaries 2020-09-09 20:12:42 +00:00
Cheahuychou Mao
2795d76c63 SERVER-48318 Make snapshot window equal to max of minSnapshotHistoryWindowInSeconds and transactionLifetimeLimitSeconds 2020-09-09 19:09:10 +00:00
Louis Williams
067c84541c SERVER-50703 Create global resource consumption structure 2020-09-09 17:13:17 +00:00
Louis Williams
705f35bfd7 SERVER-50702 Create feature flag for measuring operation resource consumption 2020-09-09 16:19:13 +00:00
Zakhar Kleyman
5665906d24 SERVER-50724 Update signing key to 4.8 in master 2020-09-09 11:23:37 -04:00
Robert Guo
700e7a60b0 SERVER-50722 Create new MSI upgrade codes for 4.8.0Dev.x/4.8.0.x 2020-09-09 10:24:35 -04:00
343 changed files with 9613 additions and 4909 deletions

3
.gitignore vendored
View File

@@ -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

View File

@@ -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

View File

@@ -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,

View File

@@ -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:

View File

@@ -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

View File

@@ -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();

View File

@@ -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);
});

View 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);
})();

View File

@@ -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");

View File

@@ -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},

View File

@@ -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.

View File

@@ -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"}}

View File

@@ -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 =

View File

@@ -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);

View File

@@ -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({

View File

@@ -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);

View File

@@ -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);
}
})();

View File

@@ -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);
})();
//

View File

@@ -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)},

View File

@@ -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}));

View File

@@ -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);

View File

@@ -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() {

View File

@@ -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);
}

View File

@@ -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});

View File

@@ -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});

View File

@@ -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());

View File

@@ -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);
}

View File

@@ -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

View File

@@ -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);

View File

@@ -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,

View File

@@ -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';

View File

@@ -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();

View File

@@ -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));

View File

@@ -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},

View File

@@ -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.

View File

@@ -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();

View File

@@ -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;

View File

@@ -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);
};

View File

@@ -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() {

View File

@@ -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

View File

@@ -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();

View File

@@ -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);

View File

@@ -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);

View File

@@ -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'}));

View File

@@ -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}.

View File

@@ -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();

View File

@@ -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');

View File

@@ -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.

View File

@@ -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"}),

View File

@@ -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()];

View File

@@ -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);

View File

@@ -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;

View File

@@ -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.

View File

@@ -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

View File

@@ -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();

View File

@@ -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

View File

@@ -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}));

View File

@@ -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();

View File

@@ -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();

View File

@@ -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)}};

View File

@@ -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();
})();

View File

@@ -48,7 +48,7 @@ function runAwaitableIsMaster(topologyVersionField) {
}
function runFind() {
db.getMongo().setSlaveOk();
db.getMongo().setSecondaryOk();
assert.eq(4, db.getSiblingDB("test").coll.find().itcount());
}

View File

@@ -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);

View File

@@ -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( //

View File

@@ -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

View File

@@ -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();
})();

View File

@@ -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();
})();

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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");

View File

@@ -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");

View File

@@ -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);

View File

@@ -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;
});

View File

@@ -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.

View File

@@ -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,

View File

@@ -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 ); }

View File

@@ -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());

View File

@@ -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");

View File

@@ -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) + '/';

View File

@@ -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);

View File

@@ -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);

View File

@@ -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();

View File

@@ -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();

View File

@@ -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);

View File

@@ -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();
})();

View File

@@ -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()) {

View File

@@ -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");

View File

@@ -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);
}

View File

@@ -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(
() =>

View File

@@ -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.

View File

@@ -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({

View File

@@ -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();
})();

View File

@@ -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);

View File

@@ -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: {}});

View File

@@ -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: ' +

View File

@@ -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();

View File

@@ -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

View File

@@ -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();

View File

@@ -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