Compare commits

...

11 Commits

Author SHA1 Message Date
Esha Maharishi
f17ad42fb5 SERVER-41417 Transaction coordinator should only delete durable state if two-phase commit completed successfully 2019-06-04 13:55:51 -04:00
Mathew Robinson
960e89726f SERVER-41302 Lift restriction on publishing embedded SDKs from the 4.2 branch 2019-06-04 12:40:57 -04:00
Kaloian Manassiev
0d26400300 SERVER-41468 Only shut down the LogicalSessionsCache if it has been created
(cherry picked from commit 5e998f021f)
2019-06-04 11:29:01 -04:00
Lingzhi Deng
aeb8148c54 SERVER-40386: replace commitTransaction() used in jstests with commitTransaction_forTesting()
(cherry picked from commit 603d97f23f)
2019-06-04 11:23:20 -04:00
Lingzhi Deng
84f1ba4d33 SERVER-40386: replace abortTransaction() used in jstests with abortTransaction_forTesting()
(cherry picked from commit f41d1675fc)
2019-06-04 11:20:32 -04:00
Judah Schvimer
e2e5dc658a SERVER-39293 Correct string literals for oplog collection namespace
(cherry picked from commit 4156b6a9a7)
2019-06-04 10:10:48 -04:00
Judah Schvimer
6484628232 SERVER-41427 Bind the isKilledSessionCode return value to a global variable
(cherry picked from commit 5e652e3b25)
2019-06-04 10:09:00 -04:00
Benety Goh
777d16318b Revert "SERVER-41014 extract helper functions from runCreateIndexes()"
This reverts commit 47ca83f447.
2019-06-04 10:00:23 -04:00
Max Hirschhorn
c710c8429d SERVER-41393 Identify devices by their UUID in /etc/fstab.
This ensures they are automatically mounted following a machine reboot.

(cherry picked from commit 79091ef290)
2019-06-03 18:54:59 -04:00
Brian Samek
6ac1954e5b SERVER-41233 Add drivers nightly testing to 4.2 branch 2019-06-03 15:53:35 -04:00
tycho garen
4c25ec3f60 SERVER-41225: update evergreen configuration for 4.2 branch 2019-06-03 15:25:20 -04:00
92 changed files with 1022 additions and 404 deletions

View File

@@ -147,15 +147,24 @@ function mount_drive {
/sbin/mdadm --detail --scan > /etc/mdadm.conf
/sbin/blockdev --setra 32 $device_name
else
device_name=$devices
device_name="/dev/$device_names"
fi
# Mount the $root_dir drive(s)
/sbin/mkfs.$fs_type $mount_options -f $device_name
echo "$device_name /$root_dir auto noatime 0 0" | tee -a /etc/fstab
# We add an entry for the device to /etc/fstab so it is automatically mounted following a
# machine reboot. The device is not guaranteed to be assigned the same name across restarts so
# we use its UUID in order to identify it.
#
# We also specify type=$fs_type in the /etc/fstab entry because specifying type=auto on
# Amazon Linux AMI 2018.03 leads to the drive not being mounted automatically following a
# machine reboot.
device_uuid=$(blkid -o value -s UUID "$device_name")
echo "Adding entry to /etc/fstab for device '$device_name' with UUID '$device_uuid'"
echo "UUID=$device_uuid /$root_dir $fs_type noatime 0 0" | tee -a /etc/fstab
mkdir /$root_dir || true
chmod 777 /$root_dir
mount -t $fs_type $device_name /$root_dir
mount -t $fs_type "UUID=$device_uuid" /$root_dir
for sub_dir in $sub_dirs
do
mkdir -p /$root_dir/$sub_dir

717
etc/drivers_nightly.yml Normal file
View File

@@ -0,0 +1,717 @@
#####################################################
# Drivers Nightly Tests #
#####################################################
### Instructions for Adding a Driver ###
# The Major sections are:
# VARIABLES
# FUNCTIONS (MongoDB and Drivers)
# TASKS (MongoDB and Drivers)
# AXES (Drivers)
# MODULES (MongoDB and Drivers)
# BUILDVARIANTS (MongoDB and Drivers)
# The Major sections of this config file have a space that handles the Mongodb setup, compile and test.
# And a section that handles the same for drivers after MongoDB and compiled, tested, and pushed.
# To Add a Driver:
# Add your repo to the MODULES section
# Add your Driver-specific AXES and variables
# Add your Driver-specific Matrix at the bottom of this file
# Update the Driver-specific variables in the 'run driver tests' function if needed
stepback: true
command_type: system
# Files that match an ignore-list pattern will not trigger a build, if they're the only modified
# files in the patch.
ignore:
- ".*"
- "!.clang-format"
- "!.eslintrc.yml"
- "*.md"
- "*.rst"
- "*.txt"
- "/distsrc/**"
- "/docs/**"
- "/etc/*.yml"
- "!/etc/drivers_nightly.yml"
- "README"
#######################################
# VARIABLES #
#######################################
variables:
# Used when the tests it runs depend only on mongod, mongos, the mongo shell and the tools.
- &task_template
name: template
depends_on:
- name: compile
commands:
- func: "do setup"
- func: "run mongo tests"
vars:
resmoke_args: --help
run_multiple_jobs: false
max_jobs: 0 # If set in combination with run_multiple_jobs, will cap the number of jobs used.
# Used to list modules to retrieve from GitHub and apply patches if necessary.
- &git_get_project
command: git.get_project
params:
directory: src
revisions: # for each module include revision as <module_name> : ${<module_name>_rev}
enterprise: ${enterprise_rev}
mongo-java-driver: ${mongo-java-driver_rev}
mongo-python-driver: ${mongo-python-driver_rev}
drivers-evergreen-tools: ${drivers-evergreen-tools_rev}
- &generate_compile_expansions
command: shell.exec
params:
working_dir: src
script: |
set -o errexit
set -o verbose
# We get the raw version string (r1.2.3-45-gabcdef) from git
MONGO_VERSION=$(git describe)
# If this is a patch build, we add the patch version id to the version string so we know
# this build was a patch, and which evergreen task it came from
if [ "${is_patch|}" = "true" ]; then
MONGO_VERSION="$MONGO_VERSION-patch-${version_id}"
fi
# This script converts the generated version string into a sanitized version string for
# use by scons and uploading artifacts as well as information about for the scons cache.
MONGO_VERSION=$MONGO_VERSION SCONS_CACHE_MODE=${scons_cache_mode|nolinked} USE_SCONS_CACHE=${use_scons_cache|false} ${python|/opt/mongodbtoolchain/v2/bin/python2} buildscripts/generate_compile_expansions.py --out compile_expansions.yml
- &apply_compile_expansions
command: expansions.update
params:
file: src/compile_expansions.yml
#######################################
# FUNCTIONS #
#######################################
### MONGODB COMPILE & TEST FUNCTIONS ###
functions:
"fetch and extract binaries" : &fetch_extract_binaries
command: shell.exec
params:
working_dir: src
script: |
set -o errexit
set -o verbose
curl -s https://s3.amazonaws.com/mciuploads/drivers-nightly/${platform}/${revision}/binaries/mongo-${revision}.${ext} --output mongodb-binaries.${ext}
# When we call git_get_project and check out our source code, it creates a directory called 'mongo',
# this isn't needed and interferes with our shell binary 'mongo' when we try to copy it.
# To prevent this, we just remove the 'mongo' directory first, then we do our copy.
mv mongo mongo-old || true
${decompress} mongodb-binaries.${ext|tgz}
chmod +x mongodb*/bin/*
mv mongodb*/bin/* .
"get buildnumber" : &get_buildnumber
command: keyval.inc
params:
key: "v4.2"
destination: "builder_num"
"setup credentials" : &setup_credentials
command: shell.exec
params:
working_dir: src
silent: true
script: |
cat > mci.buildlogger <<END_OF_CREDS
slavename='${slave}'
passwd='${passwd}'
builder='MCI_${build_variant}'
build_num=${builder_num}
build_phase='${task_name}_${execution}'
END_OF_CREDS
"do setup" :
- *git_get_project
- *fetch_extract_binaries
- *get_buildnumber
- *setup_credentials
### FOR MONGODB TESTS ###
"set up virtualenv" :
command: shell.exec
type: test
params:
working_dir: src
script: |
# exit immediately if virtualenv is not found
set -o errexit
set -o verbose
virtualenv --system-site-packages ./venv
"run mongo tests" :
command: shell.exec
type: test
params:
working_dir: src
script: |
set -o errexit
set -o verbose
# check if virtualenv is set up
if [ -d "venv" ]; then
if [ "Windows_NT" = "$OS" ]; then
. ./venv/Scripts/activate
else
. ./venv/bin/activate
fi
fi
extra_args=""
processor_architecture=$(uname -m)
num_jobs_available=${num_jobs_available|1}
if [ ${max_jobs|0} -gt 0 ] && [ ${max_jobs|0} -lt $num_jobs_available ]; then
extra_args="$extra_args --jobs=${max_jobs}"
else
extra_args="$extra_args --jobs=$num_jobs_available"
fi
${rlp_environment} \
${python|/opt/mongodbtoolchain/v2/bin/python2} buildscripts/resmoke.py ${resmoke_args} $extra_args ${test_flags} --log=buildlogger --reportFile=report.json
"cleanup environment" :
command: shell.exec
params:
script: |
set -o errexit
set -o verbose
rm -rf src /data/db/* mongo-diskstats* mongo-coredumps.tgz ~/.aws
pkill -9 orchest
### DRIVERS FUNCTIONS ###
"bootstrap mongo-orchestration":
- command: shell.exec
params:
script: |
${PREPARE_SHELL}
echo "{ \"releases\": { \"default\": \"$MONGODB_BINARIES\" }}" > $MONGO_ORCHESTRATION_HOME/orchestration.config
MONGODB_VERSION="nightly" MONGODB_DOWNLOAD_URL=${MONGODB_DOWNLOAD_URL} TOPOLOGY=${TOPOLOGY} AUTH=${AUTH} SSL=${SSL} sh ${DRIVERS_TOOLS}/.evergreen/run-orchestration.sh
# run-orchestration generates expansion file with the MONGODB_URI for the cluster
- command: expansions.update
params:
file: mo-expansion.yml
"run driver tests":
- command: shell.exec
type: test
params:
working_dir: "src"
script: |
cd ${DRIVER_WORKING_DIRECTORY}
${PREPARE_SHELL}
echo $DRIVERS_TOOLS
echo $MONGO_ORCHESTRATION_HOME
echo $MONGODB_BINARIES
echo $UPLOAD_BUCKET
echo $PROJECT_DIRECTORY
echo $TMPDIR
echo $PATH
echo $PROJECT
# If there are extra dependencies, we set them up here first
file="${PROJECT_DIRECTORY}/.evergreen/install-dependencies.sh"
# Don't use ${file} syntax here because evergreen treats it as an empty expansion.
[ -f "$file" ] && sh $file || echo "$file not available, skipping"
### DRIVER-SPECIFIC VARIABLES HERE
PYTHON_BINARY="${PYTHON_BINARY}" \
JDK="${JDK}" \
AUTH="${AUTH}" SSL="${SSL}" MONGODB_URI="${MONGODB_URI}" TOPOLOGY="${TOPOLOGY}" .evergreen/run-tests.sh
"fix absolute paths":
- command: shell.exec
params:
script: |
${PREPARE_SHELL}
for filename in $(find ${DRIVERS_TOOLS} -name \*.json); do
perl -p -i -e "s|ABSOLUTE_PATH_REPLACEMENT_TOKEN|${DRIVERS_TOOLS}|g" $filename
done
"windows fix":
- command: shell.exec
params:
script: |
# Make sure we are on Windows, otherwise don't run
if [ "Windows_NT" == "$OS" ]; then # Magic variable in cygwin
${PREPARE_SHELL}
for i in $(find ${DRIVERS_TOOLS}/.evergreen ${PROJECT_DIRECTORY}/.evergreen -name \*.sh); do
cat $i | tr -d '\r' > $i.new
mv $i.new $i
done
# Copy client certificate because symlinks do not work on Windows.
cp ${DRIVERS_TOOLS}/.evergreen/x509gen/client.pem ${MONGO_ORCHESTRATION_HOME}/lib/client.pem
fi
"make files executable":
- command: shell.exec
params:
script: |
${PREPARE_SHELL}
for i in $(find ${DRIVERS_TOOLS}/.evergreen ${PROJECT_DIRECTORY}/.evergreen -name \*.sh); do
chmod +x $i
done
"init test-results":
- command: shell.exec
params:
script: |
${PREPARE_SHELL}
echo '{"results": [{ "status": "FAIL", "test_file": "Build", "log_raw": "No test-results.json found was created" } ]}' > ${PROJECT_DIRECTORY}/test-results.json
"upload xml test results":
- command: attach.xunit_results
params:
file: "${DRIVER_TEST_UPLOAD_DIRECTORY}"
### UPLOAD MONGODB AND ORCHESTRATION LOGS ###
"upload mo artifacts":
- command: shell.exec
params:
script: |
${PREPARE_SHELL}
find $MONGO_ORCHESTRATION_HOME -name \*.log | xargs tar czf ${PROJECT_DIRECTORY}/mongodb-logs.tar.gz
- command: s3.put
params:
aws_key: ${aws_key}
aws_secret: ${aws_secret}
local_file: ${PROJECT_DIRECTORY}/mongodb-logs.tar.gz
remote_file: ${UPLOAD_BUCKET}/${build_variant}/${revision}/${version_id}/${build_id}/logs/${task_id}-${execution}-mongodb-logs.tar.gz
bucket: mciuploads
permissions: public-read
content_type: ${content_type|application/x-gzip}
display_name: "mongodb-logs.tar.gz"
- command: s3.put
params:
aws_key: ${aws_key}
aws_secret: ${aws_secret}
local_file: ${DRIVERS_TOOLS}/.evergreen/orchestration/server.log
remote_file: ${UPLOAD_BUCKET}/${build_variant}/${revision}/${version_id}/${build_id}/logs/${task_id}-${execution}-orchestration.log
bucket: mciuploads
permissions: public-read
content_type: ${content_type|text/plain}
display_name: "orchestration.log"
"setup drivers environment":
- command: shell.exec
params:
working_dir: "src"
script: |
cd ${DRIVER_WORKING_DIRECTORY}
# Get the current unique version of this checkout
if [ "${is_patch}" = "true" ]; then
CURRENT_VERSION=$(git describe)-patch-${version_id}
else
CURRENT_VERSION=latest
fi
export DRIVERS_TOOLS="$(pwd)/../drivers-evergreen-tools"
# Python has cygwin path problems on Windows. Detect prospective mongo-orchestration home directory
if [ "Windows_NT" == "$OS" ]; then # Magic variable in cygwin
export DRIVERS_TOOLS=$(cygpath -m $DRIVERS_TOOLS)
fi
echo "TESTING PLATFORM ${PLATFORM}"
export MONGO_ORCHESTRATION_HOME="$DRIVERS_TOOLS/.evergreen/orchestration"
export MONGODB_BINARIES="$DRIVERS_TOOLS/mongodb/bin"
export UPLOAD_BUCKET="${project}"
export PROJECT_DIRECTORY="$(pwd)"
export MONGODB_DOWNLOAD_URL="https://s3.amazonaws.com/mciuploads/drivers-nightly/${PLATFORM}/${revision}/binaries/mongo-${revision}.${FILE_EXT}"
cat <<EOT > expansion.yml
CURRENT_VERSION: "$CURRENT_VERSION"
DRIVERS_TOOLS: "$DRIVERS_TOOLS"
MONGO_ORCHESTRATION_HOME: "$MONGO_ORCHESTRATION_HOME"
MONGODB_BINARIES: "$MONGODB_BINARIES"
UPLOAD_BUCKET: "$UPLOAD_BUCKET"
PROJECT_DIRECTORY: "$PROJECT_DIRECTORY"
MONGODB_DOWNLOAD_URL: "$MONGODB_DOWNLOAD_URL"
PREPARE_SHELL: |
set -o errexit
set -o xtrace
export DRIVERS_TOOLS="$DRIVERS_TOOLS"
export MONGO_ORCHESTRATION_HOME="$MONGO_ORCHESTRATION_HOME"
export MONGODB_BINARIES="$MONGODB_BINARIES"
export UPLOAD_BUCKET="$UPLOAD_BUCKET"
export PROJECT_DIRECTORY="$PROJECT_DIRECTORY"
export MONGODB_DOWNLOAD_URL="$MONGODB_DOWNLOAD_URL"
export TMPDIR="$MONGO_ORCHESTRATION_HOME/db"
export PATH="$MONGODB_BINARIES:$PATH"
export PROJECT="${project}"
EOT
# See what we've done
cat expansion.yml
# Load the expansion file to make an evergreen variable with the current unique version
- command: expansions.update
params:
file: src/${DRIVER_WORKING_DIRECTORY}/expansion.yml
### PRE ###
pre:
- func: "cleanup environment"
### POST ###
post:
- command: attach.results
params:
file_location: src/report.json
- func: "upload mo artifacts"
- func: "upload xml test results"
# Cleanup steps.
- command: shell.exec
params:
working_dir: src
script: |
# removes files from the (local) scons cache when it's over a
# threshold, to the $prune_ratio percentage. Ideally override
# these default values in the distro config in evergreen.
if [ -d "${scons_cache_path}" ]; then
${python|python} buildscripts/scons_cache_prune.py --cache-dir '${scons_cache_path}' --cache-size ${scons_cache_size|200} --prune-ratio ${scons_prune_ratio|0.8}
fi
- func: "cleanup environment"
#######################################
# TASKS #
#######################################
tasks:
### MONGO COMPILE & TEST TASKS ###
- name: compile
depends_on: []
commands:
- command: manifest.load
- *git_get_project
- func: "get buildnumber"
- func: "setup credentials"
- *generate_compile_expansions
# Then we load the generated version data into the agent so we can use it in task definitions
- *apply_compile_expansions
- command: shell.exec
type: test
params:
working_dir: src
script: |
set -o errexit
set -o verbose
rm -rf ${install_directory|/data/mongo-install-directory}
${compile_env|} ${python|/opt/mongodbtoolchain/v2/bin/python2} ./buildscripts/scons.py ${compile_flags|} ${scons_cache_args|} core unittests MONGO_VERSION=${version}
# Pack up the binaries
mkdir -p mongodb-binaries/bin
if [ `which strip` ]; then
echo "found strip"
find . -maxdepth 1 -type f -iname "mongo*" -exec strip {} \;
fi
find . -maxdepth 1 -type f -iname "mongo*" -exec mv {} ./mongodb-binaries/bin/ \;
${compress} mongodb-binaries.${ext|tgz} mongodb-binaries/
### Run the unittests after the compile
- func: "run mongo tests"
vars:
resmoke_args: --suites=unittests
run_multiple_jobs: true
- command: s3.put
params:
aws_key: ${aws_key}
aws_secret: ${aws_secret}
local_file: src/mongodb-binaries.${ext|tgz}
remote_file: drivers-nightly/${platform}/${revision}/binaries/mongo-${revision}.${ext|tgz}
bucket: mciuploads
permissions: public-read
content_type: ${content_type|application/x-gzip}
display_name: Binaries
- <<: *task_template
name: jsCore_WT
commands:
- func: "do setup"
- func: "run mongo tests"
vars:
resmoke_args: --suites=core --storageEngine=wiredTiger
run_multiple_jobs: true
### DRIVER TEST TASKS ###
- name: "test-nightly-standalone"
depends_on:
- variant: ".compile-variant"
name: "jsCore_WT"
tags: ["nightly", "standalone"]
commands:
- *git_get_project
- func: "setup drivers environment"
vars:
VERSION: "nightly"
TOPOLOGY: "server"
- func: "windows fix"
- func: "fix absolute paths"
- func: "init test-results"
- func: "make files executable"
- func: "bootstrap mongo-orchestration"
- func: "run driver tests"
- name: "test-nightly-replica_set"
depends_on:
- variant: ".compile-variant"
name: "jsCore_WT"
tags: ["nightly", "replica_set"]
commands:
- *git_get_project
- func: "setup drivers environment"
vars:
VERSION: "nightly"
TOPOLOGY: "replica_set"
- func: "windows fix"
- func: "fix absolute paths"
- func: "init test-results"
- func: "make files executable"
- func: "bootstrap mongo-orchestration"
- func: "run driver tests"
- name: "test-nightly-sharded_cluster"
depends_on:
- variant: ".compile-variant"
name: "jsCore_WT"
tags: ["nightly", "sharded_cluster"]
commands:
- *git_get_project
- func: "setup drivers environment"
vars:
VERSION: "nightly"
TOPOLOGY: "sharded_cluster"
- func: "windows fix"
- func: "fix absolute paths"
- func: "init test-results"
- func: "make files executable"
- func: "bootstrap mongo-orchestration"
- func: "run driver tests"
#######################################
# AXES #
#######################################
axes:
### GENERAL FOR ALL DRIVERS TESTS ###
- id: os
display_name: OS
values:
- id: "rhel62"
display_name: "RHEL 6.2"
run_on: rhel62-test
variables:
PLATFORM: "linux"
FILE_EXT: "tgz"
- id: "windows64"
display_name: "Windows 64"
run_on: windows-64-vs2015-test
variables:
PLATFORM: "windows64"
FILE_EXT: "zip"
- id: auth
display_name: Authentication
values:
- id: "auth"
display_name: Auth
variables:
AUTH: "auth"
- id: "noauth"
display_name: NoAuth
variables:
AUTH: "noauth"
- id: ssl
display_name: SSL
values:
- id: "ssl"
display_name: SSL
variables:
SSL: "ssl"
- id: "nossl"
display_name: NoSSL
variables:
SSL: "nossl"
### DRIVER-SPECIFIC AXES ###
### DRIVERS TEAM, ADD YOUR AXES VARIABLES HERE ###
### Java ###
- id: jdk
display_name: JDK
values:
- id: "jdk8"
display_name: JDK8
variables:
JDK: "jdk8"
DRIVER_WORKING_DIRECTORY: "mongo-java-driver"
DRIVER_TEST_UPLOAD_DIRECTORY: "src/mongo-java-driver/*/build/test-results/TEST-*.xml"
### Python ###
- id: python-linux
display_name: "Python"
values:
- id: "2.6"
display_name: "Python 2.6"
variables:
PYTHON_BINARY: "/opt/python/2.6/bin/python"
DRIVER_WORKING_DIRECTORY: "mongo-python-driver"
DRIVER_TEST_UPLOAD_DIRECTORY: "src/mongo-python-driver/xunit-results/TEST-*.xml"
- id: "2.7"
display_name: "Python 2.7"
variables:
PYTHON_BINARY: "/opt/python/2.7/bin/python"
DRIVER_WORKING_DIRECTORY: "mongo-python-driver"
- id: python-windows
display_name: "Windows Visual Studio 2010 Python"
values:
- id: "3.6"
display_name: "Python 3.6"
variables:
PYTHON_BINARY: "/cygdrive/c/python/Python36/python.exe"
DRIVER_WORKING_DIRECTORY: "mongo-python-driver"
DRIVER_TEST_UPLOAD_DIRECTORY: "src/mongo-python-driver/xunit-results/TEST-*.xml"
#######################################
# MODULES #
#######################################
# If a module is added it must be added to the manifest
# be sure to add the module to 'git.get_project' revisions parameter
# DRIVERS add your own git repo / branch here and add up top in 'git.get_project'
modules:
- name: enterprise
repo: git@github.com:10gen/mongo-enterprise-modules.git
prefix: src/mongo/db/modules
branch: v4.2
# Shared by all drivers projects
- name: drivers-evergreen-tools
repo: git@github.com:mongodb-labs/drivers-evergreen-tools.git
branch: master
### DRIVER REPOS ###
### DRIVERS ADD YOUR GIT REPO HERE ###
- name: mongo-java-driver
repo: git@github.com:mongodb/mongo-java-driver.git
branch: master
- name: mongo-python-driver
repo: git@github.com:mongodb/mongo-python-driver.git
branch: master
#######################################
# BUILDVARIANTS #
#######################################
buildvariants:
### MONGO COMPILE VARIANTS ###
### Linux Compile Variant ###
- name: rhel62
display_name: RHEL 6.2 MongoDB Compile
modules:
- enterprise
run_on:
- rhel62-small
expansions:
rlp_environment: MONGOD_UNITTEST_RLP_LANGUAGE_TEST_BTROOT=/opt/basis
platform: linux
compile_flags: --ssl MONGO_DISTMOD=rhel62 -j$(grep -c ^processor /proc/cpuinfo) --release --variables-files=etc/scons/mongodbtoolchain_gcc.vars CPPPATH="/opt/basis/rlp/rlp/include /opt/basis/rlp/utilities/include"
multiversion_platform_arch: "rhel62"
multiversion_edition: "targeted"
num_jobs_available: $(grep -c ^processor /proc/cpuinfo)
use_scons_cache: true
### build_mongoreplay: true
ext: tgz
tags: ["compile-variant"]
tasks:
- name: compile
distros:
- rhel62-large
- name: jsCore_WT
### Windows compile variant ###
- name: enterprise-windows-64
display_name: "Enterprise Windows MongoDB Compile"
modules:
- enterprise
run_on:
- windows-64-vs2015-compile
expansions:
platform: "windows64"
exe: ".exe"
content_type: application/zip
compile_flags: --ssl MONGO_DISTMOD=windows-64 --release CPPPATH="c:/openssl/include c:/sasl/include c:/snmp/include c:/curl/include" LIBPATH="c:/openssl/lib c:/sasl/lib c:/snmp/lib c:/curl/lib" -j$(( $(grep -c ^processor /proc/cpuinfo) / 4 )) --dynamic-windows --win-version-min=ws08r2 VARIANT_DIR=win32
num_jobs_available: $(grep -c ^processor /proc/cpuinfo)
ext: zip
use_scons_cache: true
python: python
tags: ["compile-variant"]
tasks:
- name: compile
distros:
- windows-64-vs2015-large
- name: jsCore_WT
### DRIVER Test Variants
### DRIVERS add your matrix or test variant here
### Python Matrix Linux
- matrix_name: "python-driver-linux"
matrix_spec: {auth: "*", ssl: "*", os: "rhel62", python-linux: "2.6" }
display_name: "Python Driver ${os} ${python-linux} ${auth} ${ssl}"
modules: [ "mongo-python-driver", "drivers-evergreen-tools" ]
tasks:
- name: "test-nightly-replica_set"
- name: "test-nightly-sharded_cluster"
- name: "test-nightly-standalone"
### Python Matrix Windows
- matrix_name: "python-driver-windows"
matrix_spec: {auth: "*", ssl: "*", os: "windows64", python-windows: "3.6" }
display_name: "Python Driver ${os} ${python-windows} ${auth} ${ssl}"
modules: [ "mongo-python-driver", "drivers-evergreen-tools" ]
tasks:
- name: "test-nightly-replica_set"
- name: "test-nightly-sharded_cluster"
- name: "test-nightly-standalone"
### Java Matrix Linux
- matrix_name: "java-driver-linux"
matrix_spec: {auth: "*", ssl: "*", os: "rhel62", jdk: "jdk8" }
display_name: "Java Driver ${os} ${jdk} ${auth} ${ssl}"
modules: [ "mongo-java-driver", "drivers-evergreen-tools" ]
tasks:
- name: "test-nightly-replica_set"
- name: "test-nightly-sharded_cluster"
- name: "test-nightly-standalone"

View File

@@ -261,7 +261,6 @@ variables:
- func: "get buildnumber"
- func: "set up credentials"
- func: "fetch and build OpenSSL"
- func: "use WiredTiger develop" # noop if ${use_wt_develop} is not "true"
- func: "generate compile expansions"
teardown_group:
- func: "scons cache pruning"
@@ -392,7 +391,6 @@ variables:
- enterprise-windows-64-2k8-nopush-template
- enterprise-windows-64-2k8-openssl
- enterprise-windows-64-2k8-required
- enterprise-windows-64-2k8-wtdevelop
- ubuntu1804-debug-asan
- ubuntu1804-debug-ubsan
- ubuntu1804-debug-aubsan-lite
@@ -449,7 +447,6 @@ functions:
directory: ${git_project_directory|src}
revisions: # for each module include revision as <module_name> : ${<module_name>_rev}
enterprise: ${enterprise_rev}
wtdevelop: ${wtdevelop_rev}
"fetch artifacts": &fetch_artifacts
command: s3.get
@@ -528,7 +525,7 @@ functions:
"get buildnumber": &get_buildnumber
command: keyval.inc
params:
key: "${build_variant}_master"
key: "${build_variant}_v4.2"
destination: "builder_num"
"run diskstats": &run_diskstats
@@ -780,21 +777,6 @@ functions:
bash buildscripts/fetch_and_build_openssl.sh "${python|python3}" "${openssl_make_flags|}" "${openssl_config_flags|}"
fi
"use WiredTiger develop":
command: shell.exec
params:
working_dir: src
script: |
set -o errexit
set -o verbose
if [ "${use_wt_develop|}" = "true" ]; then
cd src/third_party
for wtdir in dist examples ext lang src test tools ; do
rm -rf wiredtiger/$wtdir
mv wtdevelop/$wtdir wiredtiger/
done
fi
"setup gradle signing keys":
command: shell.exec
params:
@@ -4496,9 +4478,6 @@ tasks:
set -o errexit
set -o verbose
echo "Releases disabled on master."
exit 0
if [ "${is_release|false}" != "true" ]; then
echo "Not a release build"
exit 0
@@ -4585,7 +4564,6 @@ tasks:
- func: "set up virtualenv"
- func: "get buildnumber"
- func: "set up credentials"
- func: "use WiredTiger develop" # noop if ${use_wt_develop} is not "true"
- func: "generate compile expansions"
# Then we load the generated version data into the agent so we can use it in task definitions
- func: "apply compile expansions"
@@ -8014,12 +7992,7 @@ modules:
- name: enterprise
repo: git@github.com:10gen/mongo-enterprise-modules.git
prefix: src/mongo/db/modules
branch: master
- name: wtdevelop
repo: git@github.com:wiredtiger/wiredtiger.git
prefix: src/third_party
branch: develop
branch: v4.2
#######################################
# Buildvariants #
@@ -8118,20 +8091,6 @@ buildvariants:
- name: sharding_gen
- name: .stitch
- <<: *linux-64-debug-template
name: linux-64-debug-wtdevelop
display_name: "~ Linux DEBUG WiredTiger develop"
batchtime: 1440 # 1 day
modules:
- wtdevelop
expansions:
use_wt_develop: true
resmoke_jobs_factor: 0.5 # Avoid starting too many mongod's
compile_flags: --dbg=on --opt=on -j$(grep -c ^processor /proc/cpuinfo) --variables-files=etc/scons/mongodbtoolchain_v3_gcc.vars --enable-free-mon=off --enable-http-client=off
use_scons_cache: true
build_mongoreplay: true
test_flags: --excludeWithAnyTags=requires_http_client
- name: linux-64-duroff
display_name: Linux (No Journal)
run_on:
@@ -9148,17 +9107,6 @@ buildvariants:
distros:
- rhel70-small
- <<: *enterprise-windows-64-2k8-nopush-template
name: enterprise-windows-64-2k8-wtdevelop
display_name: "~ Enterprise Windows 2008R2 WiredTiger develop"
batchtime: 1440 # 1 day
modules:
- enterprise
- wtdevelop
expansions:
<<: *enterprise-windows-64-2k8-nopush-expansions-template
use_wt_develop: true
- <<: *enterprise-windows-64-2k8-nopush-template
name: enterprise-windows-64-2k8-compile-all
display_name: "* Enterprise Windows 2008R2 compile_all"

View File

@@ -49,7 +49,7 @@
assert.commandWorked(sessionColl.deleteOne({_id: kDeletedDocumentId}));
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
// Do applyOps on the collection that we care about. This is an "external" applyOps, though
// (not run as part of a transaction) so its entries should be skipped in the change

View File

@@ -43,7 +43,7 @@
assert.commandWorked(sessionColl.updateOne({_id: 1}, {$inc: {a: 1}}));
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
// Now insert another document, not part of a transaction.
assert.commandWorked(coll.insert({_id: 3, a: 123}));

View File

@@ -1,6 +1,6 @@
'use strict';
var {withTxnAndAutoRetry} = (function() {
var {withTxnAndAutoRetry, isKilledSessionCode} = (function() {
/**
* Calls 'func' with the print() function overridden to be a no-op.
@@ -145,14 +145,15 @@ var {withTxnAndAutoRetry} = (function() {
} catch (e) {
if (!hasCommitTxnError) {
// Use the version of abortTransaction() that ignores errors. We ignore the
// error from abortTransaction because the transaction may have implicitly
// been aborted by the server already and will therefore return a
// NoSuchTransaction error response.
// We need to call abortTransaction() in order to update the mongo shell's
// state such that it agrees no transaction is currently in progress on this
// session.
session.abortTransaction();
// We need to call abortTransaction_forTesting() in order to update the mongo
// shell's state such that it agrees no transaction is currently in progress on
// this session.
// The transaction may have implicitly been aborted by the server or killed by
// the kill_session helper and will therefore return a
// NoSuchTransaction/Interrupted error code.
assert.commandWorkedOrFailedWithCode(
session.abortTransaction_forTesting(),
[ErrorCodes.NoSuchTransaction, ErrorCodes.Interrupted]);
}
if (shouldRetryEntireTxnOnError(e, hasCommitTxnError, retryOnKilledSession)) {

View File

@@ -114,7 +114,8 @@ var $config = (function() {
do {
try {
shouldJoin = false;
quietly(() => this.session.commitTransaction());
quietly(() =>
assert.commandWorked(this.session.commitTransaction_forTesting()));
} catch (e) {
if (e.code === ErrorCodes.TransactionTooOld ||
e.code === ErrorCodes.TransactionCommitted ||

View File

@@ -94,7 +94,7 @@
assert.eq(countRes.length, 1, tojson(countRes));
assert.eq(countRes[0].count, 2, tojson(countRes));
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
jsTestLog("Transaction committed.");
// Perform aggregations with non-cursor initial sources and assert that they are not supported

View File

@@ -27,7 +27,7 @@
assert.docEq({_id: "insert-1"}, sessionColl.findOne({_id: "insert-1"}));
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
session.endSession();
}());

View File

@@ -27,7 +27,7 @@
// Implicit creation.
assert.commandWorked(db.runCommand({insert: "c", documents: [{x: 2}]}));
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
rst.stopSet();
})();

View File

@@ -41,7 +41,7 @@
assert.commandWorked(testColl.insert({_id: 2}, {writeConcern: {w: "majority"}}));
assertSameMembers([{_id: 0}]);
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
assertSameMembers([{_id: 0}, {_id: 1}, {_id: 2}]);
session.endSession();

View File

@@ -26,7 +26,7 @@
// This only requires database IX lock.
assert.commandWorked(db.runCommand({drop: "b"}));
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
rst.stopSet();
})();

View File

@@ -48,7 +48,7 @@
"Test that we can't call prepareTransaction if the most recent transaction was committed");
session.startTransaction();
assert.commandWorked(sessionColl.insert({_id: 1}));
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
assert.commandFailedWithCode(sessionDB.adminCommand({
prepareTransaction: 1,

View File

@@ -22,7 +22,7 @@
session.startTransaction();
assert.commandWorked(sessionColl.insert(doc));
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
const txnNumber = NumberLong(session.getTxnNumber_forTesting());

View File

@@ -36,7 +36,7 @@
assert.sameMembers(docs, [{_id: 0, a: 0}, {_id: 1, a: 1}, {_id: 2, a: 2}]);
// Commit the transaction.
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
/***********************************************************************************************
* Do a non-matching find-and-modify with update.
@@ -52,7 +52,7 @@
assert.sameMembers(docs, [{_id: 0, a: 0}, {_id: 1, a: 1}, {_id: 2, a: 2}]);
// Commit the transaction.
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
/***********************************************************************************************
* Do a matching find-and-modify with remove.
@@ -68,7 +68,7 @@
assert.sameMembers(docs, [{_id: 1, a: 1}, {_id: 2, a: 2}]);
// Commit the transaction.
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
/***********************************************************************************************
* Do a matching find-and-modify with update, requesting the old doc.
@@ -83,7 +83,7 @@
assert.sameMembers(docs, [{_id: 1, a: 101}, {_id: 2, a: 2}]);
// Commit the transaction.
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
/***********************************************************************************************
* Do a matching find-and-modify with update, requesting the new doc.
@@ -98,7 +98,7 @@
assert.sameMembers(docs, [{_id: 1, a: 101}, {_id: 2, a: 102}]);
// Commit the transaction.
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
/***********************************************************************************************
* Do a matching find-and-modify with upsert, requesting the new doc.
@@ -114,7 +114,7 @@
assert.sameMembers(docs, [{_id: 1, a: 101}, {_id: 2, a: 202}]);
// Commit the transaction.
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
/***********************************************************************************************
* Do a non-matching find-and-modify with upsert, requesting the old doc.
@@ -129,7 +129,7 @@
assert.sameMembers(docs, [{a: 103}]);
// Commit the transaction.
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
/***********************************************************************************************
* Do a non-matching find-and-modify with upsert, requesting the new doc.
@@ -146,6 +146,6 @@
assert.sameMembers(docs, [newdoc]);
// Commit the transaction.
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
session.endSession();
}());

View File

@@ -23,7 +23,7 @@
assert(res.hasOwnProperty("cursor"), tojson(res));
assert(res.cursor.hasOwnProperty("id"), tojson(res));
assert.commandWorked(sessionDb.runCommand({killCursors: collName, cursors: [res.cursor.id]}));
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
jsTest.log("Test that the killCursors cannot be the first operation in a transaction.");
res = assert.commandWorked(sessionDb.runCommand({find: collName, batchSize: 2}));
@@ -69,7 +69,7 @@
// killCursors does not block behind the pending MODE_X lock.
assert.commandWorked(sessionDb.runCommand({killCursors: collName, cursors: [res.cursor.id]}));
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
// Once the transaction has committed, the drop can proceed.
awaitDrop();

View File

@@ -20,7 +20,7 @@
let res = assert.commandWorked(sessionDb.runCommand({find: collName, batchSize: 2}));
assert(res.hasOwnProperty("cursor"), tojson(res));
assert(res.cursor.hasOwnProperty("id"), tojson(res));
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
assert.commandWorked(sessionDb.runCommand({killCursors: collName, cursors: [res.cursor.id]}));
jsTest.log("Test that cursors created in transactions may be kill outside of the session.");
@@ -28,7 +28,7 @@
res = assert.commandWorked(sessionDb.runCommand({find: collName, batchSize: 2}));
assert(res.hasOwnProperty("cursor"), tojson(res));
assert(res.cursor.hasOwnProperty("id"), tojson(res));
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
assert.commandWorked(testDB.runCommand({killCursors: collName, cursors: [res.cursor.id]}));
session.endSession();

View File

@@ -55,7 +55,7 @@
assert.commandWorked(sessionColl.insert({_id: 4}));
jsTest.log("Commit transaction.");
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
assert.sameMembers([{_id: 0}, {_id: 1}, {_id: 2}, {_id: 3}, {_id: 4}],
sessionColl.find().toArray());

View File

@@ -54,7 +54,7 @@ var WriteConflictHelpers = (function() {
assert(!res.hasOwnProperty("writeErrors"));
assert.commandFailedWithCode(res, ErrorCodes.WriteConflict);
session1.commitTransaction();
assert.commandWorked(session1.commitTransaction_forTesting());
assert.commandFailedWithCode(session2.commitTransaction_forTesting(),
ErrorCodes.NoSuchTransaction);
}
@@ -83,7 +83,7 @@ var WriteConflictHelpers = (function() {
assert.commandWorked(session1Coll.runCommand({find: collName})); // Start T1 with a no-op.
assert.commandWorked(session2Coll.runCommand(txn2Op));
session2.commitTransaction();
assert.commandWorked(session2.commitTransaction_forTesting());
const res = session1Coll.runCommand(txn1Op);
// Not a writeError but a total command failure

View File

@@ -38,6 +38,6 @@
assert(collObj.hasOwnProperty("info") == !nameOnly, tojson(collObj));
}
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
session.endSession();
}());

View File

@@ -31,7 +31,7 @@
res = sessionColl.find({});
assert.sameMembers(res.toArray(), [{_id: 0, a: 0}, {_id: 1, a: 0}, {_id: 2, a: 1}]);
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
jsTest.log("Do a single-result multi-delete.");
session.startTransaction({writeConcern: {w: "majority"}});
@@ -42,7 +42,7 @@
res = sessionColl.find({});
assert.sameMembers(res.toArray(), [{_id: 0, a: 0}, {_id: 1, a: 0}]);
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
jsTest.log("Do a multiple-result multi-delete.");
session.startTransaction({writeConcern: {w: "majority"}});
@@ -53,7 +53,7 @@
res = sessionColl.find({});
assert.sameMembers(res.toArray(), []);
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
// Collection should be empty.
assert.eq(0, testColl.find().itcount());

View File

@@ -49,7 +49,7 @@
assert.eq(null, testColl.findOne({_id: "insert-2"}));
// Commit the transaction.
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
// Read with default read concern sees the committed transaction.
assert.eq({_id: "insert-1"}, testColl.findOne({_id: "insert-1"}));
@@ -83,7 +83,7 @@
assert.eq({_id: "update-2", a: 0}, testColl.findOne({_id: "update-2"}));
// Commit the transaction.
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
// Read with default read concern sees the committed transaction.
assert.eq({_id: "update-1", a: 2}, testColl.findOne({_id: "update-1"}));
@@ -113,7 +113,7 @@
assert.sameMembers([{_id: "doc-1", a: 1}, {_id: "doc-2", a: 1}], docs);
// Commit the transaction.
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
// Read with default read concern sees the committed transaction.
assert.eq({_id: "doc-1", a: 1}, testColl.findOne({_id: "doc-1"}));
@@ -148,7 +148,7 @@
assert.sameMembers([], docs);
// Commit the transaction.
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
// Read with default read concern sees the commmitted transaction.
assert.eq(null, testColl.findOne({_id: "doc-1"}));

View File

@@ -34,7 +34,7 @@
session.startTransaction({readConcern: {level: "snapshot"}, writeConcern: {w: "majority"}});
// Successfully call commitTransaction.
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
jsTestLog("Run CRUD ops, read ops, and commit transaction.");
session.startTransaction({readConcern: {level: "snapshot"}, writeConcern: {w: "majority"}});
@@ -67,7 +67,7 @@
assert.docEq({_id: "insert-1", a: 1}, cursor.next());
assert(!cursor.hasNext());
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
// Make sure the correct documents exist after committing the transaciton.
assert.eq({_id: "insert-1", a: 1}, sessionColl.findOne({_id: "insert-1"}));
@@ -93,7 +93,7 @@
bulk.find({_id: "bulk-1"}).updateOne({$set: {status: "bulk"}});
bulk.find({_id: "bulk-2"}).updateOne({$set: {status: "bulk"}});
assert.commandWorked(bulk.execute());
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
assert.eq({_id: "bulk-1", status: "bulk"}, sessionColl.findOne({_id: "bulk-1"}));
assert.eq({_id: "bulk-2", status: "bulk"}, sessionColl.findOne({_id: "bulk-2"}));
@@ -105,7 +105,7 @@
bulk.find({_id: "bulk-1"}).removeOne();
bulk.find({_id: "bulk-2"}).removeOne();
assert.commandWorked(bulk.execute());
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
assert.eq(null, sessionColl.findOne({_id: "bulk-1"}));
assert.eq(null, sessionColl.findOne({_id: "bulk-2"}));

View File

@@ -40,7 +40,8 @@
throw e;
}
} finally {
session.abortTransaction();
assert.commandFailedWithCode(session.abortTransaction_forTesting(),
ErrorCodes.NoSuchTransaction);
}
}

View File

@@ -31,7 +31,7 @@
res = sessionColl.find({});
assert.sameMembers(res.toArray(), [{_id: 0, a: 0}, {_id: 1, a: 0}, {_id: 2, a: 1}]);
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
jsTest.log("Do a single-result multi-update.");
session.startTransaction({writeConcern: {w: "majority"}});
@@ -42,7 +42,7 @@
res = sessionColl.find({});
assert.sameMembers(res.toArray(), [{_id: 0, a: 0}, {_id: 1, a: 0}, {_id: 2, a: 1, b: 1}]);
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
jsTest.log("Do a multiple-result multi-update.");
session.startTransaction({writeConcern: {w: "majority"}});
@@ -54,7 +54,7 @@
assert.sameMembers(res.toArray(),
[{_id: 0, a: 0, b: 2}, {_id: 1, a: 0, b: 2}, {_id: 2, a: 1, b: 1}]);
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
jsTest.log("Do a multiple-query multi-update.");
session.startTransaction({writeConcern: {w: "majority"}});
@@ -71,7 +71,7 @@
res.toArray(),
[{_id: 0, a: 0, b: 2, c: 1}, {_id: 1, a: 0, b: 2, c: 1}, {_id: 2, a: 1, b: 1, c: 2}]);
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
jsTest.log("Do a multi-update with upsert.");
session.startTransaction({writeConcern: {w: "majority"}});
@@ -87,5 +87,5 @@
{_id: 3, d: 1}
]);
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
}());

View File

@@ -24,7 +24,7 @@
session.startTransaction({writeConcern: {w: "majority"}});
sessionColl.insert({_id: "doc"});
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
assert.eq({_id: "doc"}, testColl.findOne({_id: "doc"}));
// Insert fails when the collection does not exist.
@@ -47,7 +47,7 @@
session.startTransaction({writeConcern: {w: "majority"}});
sessionColl.update({_id: "doc"}, {$set: {updated: true}}, {upsert: true});
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
assert.eq({_id: "doc", updated: true}, testColl.findOne({_id: "doc"}));
// Update with upsert=true fails when the collection does not exist.
@@ -67,7 +67,7 @@
session.startTransaction({writeConcern: {w: "majority"}});
assert.commandWorked(
sessionColl.update({_id: "doc"}, {$set: {updated: true}}, {upsert: false}));
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
assert.eq(null, testColl.findOne({_id: "doc"}));
jsTest.log("Cannot implicitly create a collection in a transaction using findAndModify.");
@@ -80,7 +80,7 @@
let res = sessionColl.findAndModify(
{query: {_id: "doc"}, update: {$set: {updated: true}}, upsert: true});
assert.eq(null, res);
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
assert.eq({_id: "doc", updated: true}, testColl.findOne({_id: "doc"}));
// findAndModify with upsert=true fails when the collection does not exist.
@@ -101,7 +101,7 @@
res = sessionColl.findAndModify(
{query: {_id: "doc"}, update: {$set: {updated: true}}, upsert: false});
assert.eq(null, res);
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
assert.eq(null, testColl.findOne({_id: "doc"}));
session.endSession();

View File

@@ -21,7 +21,7 @@
session.startTransaction();
assert.writeOK(sessionColl.update({}, {$set: {a: [1, 2, 3]}}));
assert.eq(1, sessionColl.find({}, {_id: 0, a: 1}).sort({a: 1}).itcount());
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
assert.eq(1,
db.getSiblingDB(dbName)

View File

@@ -29,7 +29,7 @@
db.adminCommand({renameCollection: "test.a", to: "test.b", dropTarget: true}));
assert.commandWorked(db.adminCommand({renameCollection: "test.b", to: "test.c"}));
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
rst.stopSet();
})();

View File

@@ -50,7 +50,7 @@
assert.sameMembers(expectedDocs, sessionColl.find().toArray());
jsTestLog("Committing the second transaction.");
session2.commitTransaction();
assert.commandWorked(session2.commitTransaction_forTesting());
jsTestLog(
"Committed changes from the second transaction should still not be visible to the first.");
@@ -65,7 +65,7 @@
assert.sameMembers(expectedDocs, sessionColl.find().toArray());
jsTestLog("Committing first transaction.");
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
// Make sure the correct documents exist after committing the second transaction.
assert.sameMembers([{_id: 0}, {_id: 1, a: 1}, {_id: 3}, {_id: 4}],

View File

@@ -36,7 +36,7 @@
simulatePrompt();
assert.commandWorked(coll.insert(doc));
simulatePrompt();
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
assert.docEq(doc, coll.findOne());
coll.drop({writeConcern: {w: "majority"}});

View File

@@ -99,10 +99,10 @@
checkReads(defaultSession, [{_id: 0}, {_id: 1}], [{_id: "a"}]);
jsTestLog("Committing transactions.");
snapshotSession.commitTransaction();
majoritySession.commitTransaction();
localSession.commitTransaction();
defaultSession.commitTransaction();
assert.commandWorked(snapshotSession.commitTransaction_forTesting());
assert.commandWorked(majoritySession.commitTransaction_forTesting());
assert.commandWorked(localSession.commitTransaction_forTesting());
assert.commandWorked(defaultSession.commitTransaction_forTesting());
jsTestLog("A new local read must see all committed writes.");
checkReads(defaultSession, [{_id: 0}, {_id: 1}], [{_id: "a"}, {_id: "b"}]);

View File

@@ -41,7 +41,7 @@
// Insert a doc within a transaction.
assert.commandWorked(sessionColl.insert({_id: "insert-2"}));
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
// Read with default read concern sees the committed transaction.
assert.eq({_id: "insert-1"}, coll.findOne({_id: "insert-1"}));

View File

@@ -19,7 +19,7 @@
jsTestLog("Test that we cannot abort or commit a nonexistant transaction.");
// Cannot abort or commit a nonexistant transaction.
try {
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
} catch (e) {
assert.eq(e.message, "There is no active transaction to commit on this session.");
}
@@ -51,11 +51,11 @@
// At this point, the transaction is still 'active'. We will commit this transaction and test
// that calling commitTransaction again should work while calling abortTransaction should not.
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
jsTestLog("Test that we can commit a transaction more than once.");
// The transaction state is 'committed'. We can call commitTransaction again in this state.
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
jsTestLog("Test that we cannot abort a transaction that has already been committed");
// We cannot call abortTransaction on a transaction that has already been committed.
@@ -75,7 +75,7 @@
jsTestLog("Test that we cannot commit a transaction that has already been aborted.");
// We cannot call commitTransaction on a transaction that has already been aborted.
try {
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
} catch (e) {
assert.eq(e.message, "Cannot call commitTransaction after calling abortTransaction.");
}
@@ -94,11 +94,11 @@
session.startTransaction();
assert.commandWorked(sessionColl.insert({_id: "insert-3"}));
// The transaction state should be changed to 'committed'.
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
// The transaction state should be changed to 'inactive'.
assert.commandWorked(sessionColl.insert({_id: "normal-insert"}));
try {
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
} catch (e) {
assert.eq(e.message, "There is no active transaction to commit on this session.");
}

View File

@@ -158,7 +158,7 @@
assert.eq(profileObj.nModified, 1, tojson(profileObj));
jsTestLog("Committing transaction.");
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
jsTestLog("Test delete with a write conflict.");
assert.commandWorked(sessionColl.insert({_id: "delete-doc"}, {writeConcern: {w: "majority"}}));

View File

@@ -64,7 +64,7 @@
assert.sameMembers(
[{_id: "doc"}],
sessionColl.find({$where: "sleep(1000); return true;"}).comment("read failure").toArray());
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
assert.commandWorked(testDB.killOp(opId));
lockShell();
@@ -97,7 +97,7 @@
"since the transaction already has an IX DB lock.");
assert.commandWorked(sessionColl.update(
{$where: "sleep(1000); return true;"}, {$inc: {good: 1}}, {collation: {locale: "fr"}}));
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
assert.commandWorked(testDB.killOp(opId));
lockShell();

View File

@@ -55,6 +55,6 @@
assert.eq(view.distinct("_id"), ["kyle"]);
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
jsTestLog("Transaction committed.");
}());

View File

@@ -84,7 +84,7 @@
// single doc write should get serialized after the transaction, we expect it to fail with a
// duplicate key error.
jsTestLog("Commit the multi-document transaction.");
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
thread.join();
assert.commandFailedWithCode(thread.returnData(), ErrorCodes.DuplicateKey);

View File

@@ -127,13 +127,15 @@
// both modify and replacement updates
session.startTransaction();
assert.writeError(sessionDB.foo.update({x: 80}, {$set: {x: 100}}));
session.abortTransaction();
assert.commandFailedWithCode(session.abortTransaction_forTesting(),
ErrorCodes.NoSuchTransaction);
session.startTransaction();
assert.throws(function() {
sessionDB.foo.findAndModify({query: {x: 80}, update: {x: 100}});
});
session.abortTransaction();
assert.commandFailedWithCode(session.abortTransaction_forTesting(),
ErrorCodes.NoSuchTransaction);
mongos.getDB(kDbName).foo.drop();

View File

@@ -151,7 +151,7 @@
assertNoChanges(changeStreamCursor);
// Transition the second transaction to prepared. We skip capturing the prepare
// timestamp it is not required for abortTransaction().
// timestamp it is not required for abortTransaction_forTesting().
PrepareHelpers.prepareTransaction(session2);
assertNoChanges(changeStreamCursor);
@@ -164,7 +164,7 @@
//
// Abort second transaction.
//
session2.abortTransaction();
assert.commandWorked(session2.abortTransaction_forTesting());
assertWriteVisibleWithCapture(
changeStreamCursor, "insert", {_id: "no-txn-doc-4"}, changeList);
assertNoChanges(changeStreamCursor);

View File

@@ -60,7 +60,7 @@
sessionColl.insert([{shard: 0, _id: "txn1-doc-6"}, {shard: 1, _id: "txn1-doc-7"}]));
// Commit the transaction.
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
// Read the stream of events, capture them in 'changeList', and confirm that all events occurred
// at or later than the clusterTime of the first event. Unfortunately, we cannot guarantee that

View File

@@ -27,7 +27,7 @@
assert.eq(db.view.find().toArray().length, 1);
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
rst.stopSet();
})();

View File

@@ -40,7 +40,7 @@
sessionDb.runCommand({find: collName, sort: sort, singleBatch: true}));
assert.eq(expected, response.cursor.firstBatch);
});
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
}
// insert

View File

@@ -21,7 +21,7 @@
const prepareTimestamp = PrepareHelpers.prepareTransaction(session);
PrepareHelpers.commitTransaction(session, prepareTimestamp);
} else {
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
}
}

View File

@@ -21,7 +21,7 @@
assert.commandFailedWithCode(dropDB.runCommand({dropDatabase: 1, maxTimeMS: 100}),
ErrorCodes.MaxTimeMSExpired);
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
session.endSession();
})();
@@ -56,7 +56,7 @@
// This should timeout.
dropDatabaseShell();
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
session.endSession();
})();

View File

@@ -79,7 +79,7 @@
return true;
});
session.abortTransaction();
assert.commandWorked(session.abortTransaction_forTesting());
st.stop();
})();

View File

@@ -66,7 +66,7 @@
// commands are counted towards the "commands" counter.
session.startTransaction();
assert.commandWorked(sessionColl.insert({_id: "insert-1"}));
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
lastHistogram = checkHistogramDiff(lastHistogram,
getHistogramStats(),
{"reads": 0, "writes": 1, "commands": 2, "transactions": 1});
@@ -99,7 +99,7 @@
assert.commandWorked(sessionColl.insert({_id: "insert-3"}));
assert.commandWorked(sessionColl.insert({_id: "insert-4"}));
assert.eq(sessionColl.find({_id: "insert-1"}).itcount(), 1);
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
lastHistogram = checkHistogramDiff(lastHistogram,
getHistogramStats(),
{"reads": 1, "writes": 2, "commands": 2, "transactions": 1});
@@ -111,7 +111,7 @@
session.startTransaction();
assert.eq(sessionColl.find({_id: "insert-1"}).itcount(), 1);
sleep(sleepTime);
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
lastHistogram = checkHistogramLatencyDiff(lastHistogram, getHistogramStats(), sleepTime);
}

View File

@@ -19,7 +19,7 @@
// Run a transaction so the 'config.transactions' collection is implicitly created.
session.startTransaction();
assert.writeOK(primaryDB.getCollection(collName).insert({x: 2}));
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
// Run a predicate query that would fail if we did not ignore the 'notablescan' flag.
assert.eq(configDB.transactions.find({any_nonexistent_field: {$exists: true}}).itcount(),

View File

@@ -43,7 +43,7 @@ function _getClusterTime(rst) {
// 'atClusterTime' can be used with readConcern level 'snapshot'.
session.startTransaction({readConcern: {level: "snapshot", atClusterTime: clusterTime}});
assert.commandWorked(sessionDb.runCommand({find: collName}));
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
// 'atClusterTime' cannot be greater than the current cluster time.
const futureClusterTime = new Timestamp(clusterTime.getTime() + 1000, 1);
@@ -130,7 +130,7 @@ function _getClusterTime(rst) {
session.startTransaction(
{readConcern: {level: "snapshot", atClusterTime: _getClusterTime(rst)}});
assert.commandWorked(sessionDb.runCommand({find: collName}));
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
session.endSession();
rst.stopSet();
@@ -144,7 +144,7 @@ function _getClusterTime(rst) {
session.startTransaction(
{readConcern: {level: "snapshot", atClusterTime: _getClusterTime(rst)}});
assert.commandWorked(sessionDb.runCommand({find: collName}));
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
session.endSession();
rst.stopSet();
}

View File

@@ -81,7 +81,7 @@
assert.commandFailedWithCode(toRSSession.abortTransaction_forTesting(),
ErrorCodes.NoSuchTransaction);
} else {
toRSSession.commitTransaction();
assert.commandWorked(toRSSession.commitTransaction_forTesting());
}
const toRSOpTime = getLastOpTime(toRS.getPrimary()).ts;

View File

@@ -54,7 +54,7 @@
primarySession.startTransaction(
{readConcern: {level: "snapshot", atClusterTime: clusterTimePrimaryBefore}});
res = assert.commandWorked(primaryDB.runCommand({find: collName}));
primarySession.commitTransaction();
assert.commandWorked(primarySession.commitTransaction_forTesting());
assert.eq(res.cursor.firstBatch.length, 1, printjson(res));
assert.eq(res.cursor.firstBatch[0]._id, "before", printjson(res));
@@ -80,7 +80,7 @@
// Restart replication on one of the secondaries.
restartServerReplication(secondaryConn1);
// This time the transaction should commit.
primarySession.commitTransaction();
assert.commandWorked(primarySession.commitTransaction_forTesting());
// Restart replication on the lagged secondary.
restartServerReplication(secondaryConn0);

View File

@@ -62,7 +62,7 @@
session.startTransaction({writeConcern: {w: "majority"}, readConcern: {level: "snapshot"}});
assert.commandWorked(sessionDb.coll.insert({}));
assert.commandWorked(sessionDb.runCommand({find: collName}));
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
// readConcern 'snapshot' is allowed with 'afterClusterTime'.
session.startTransaction();
@@ -73,7 +73,7 @@
find: collName,
readConcern: {level: "snapshot", afterClusterTime: pingRes.$clusterTime.clusterTime}
}));
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
// readConcern 'snapshot' is not allowed with 'afterOpTime'.
session.startTransaction(
@@ -90,7 +90,7 @@
session.startTransaction(
{readConcern: {level: "snapshot", afterClusterTime: pingRes.$clusterTime.clusterTime}});
assert.commandWorked(sessionDb.runCommand({find: collName}));
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
session.endSession();
rst.stopSet();

View File

@@ -206,7 +206,7 @@
const sessionDb = session.getDatabase("test");
session.startTransaction({readConcern: {level: "snapshot"}});
const res = assert.commandWorked(sessionDb.runCommand({find: "coll", filter: {x: 1}}));
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
assert.eq(res.cursor.firstBatch.length, TestData.numDocs, tojson(res));
}, {"command.filter": {x: 1}});
@@ -226,7 +226,7 @@
{configureFailPoint: "setInterruptOnlyPlansCheckForInterruptHang", mode: "alwaysOn"}));
const res = assert.commandWorked(sessionDb.runCommand(
{getMore: NumberLong(cursorId), collection: "coll", batchSize: TestData.numDocs}));
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
assert.eq(
res.cursor.nextBatch.length, TestData.numDocs - initialFindBatchSize, tojson(res));
}, {"cursor.originatingCommand.filter": {x: 1}});
@@ -238,7 +238,7 @@
session.startTransaction({readConcern: {level: "snapshot"}});
const res = assert.commandWorked(
sessionDb.runCommand({aggregate: "coll", pipeline: [{$match: {x: 1}}], cursor: {}}));
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
assert.eq(res.cursor.firstBatch.length, TestData.numDocs, tojson(res));
}, {"command.pipeline": [{$match: {x: 1}}]});
@@ -259,7 +259,7 @@
{configureFailPoint: "setInterruptOnlyPlansCheckForInterruptHang", mode: "alwaysOn"}));
const res = assert.commandWorked(
sessionDb.runCommand({getMore: NumberLong(cursorId), collection: "coll"}));
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
assert.eq(
res.cursor.nextBatch.length, TestData.numDocs - initialFindBatchSize, tojson(res));
}, {"cursor.originatingCommand.filter": {x: 1}});
@@ -270,7 +270,7 @@
const sessionDb = session.getDatabase("test");
session.startTransaction({readConcern: {level: "snapshot"}});
const res = assert.commandWorked(sessionDb.runCommand({distinct: "coll", key: "_id"}));
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
assert(res.hasOwnProperty("values"));
assert.eq(res.values.length, 4, tojson(res));
}, {"command.distinct": "coll"});
@@ -285,7 +285,7 @@
updates:
[{q: {}, u: {$set: {updated: true}}}, {q: {new: 1}, u: {$set: {updated: true}}}]
}));
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
// Only update one existing doc committed before the transaction.
assert.eq(res.n, 1, tojson(res));
assert.eq(res.nModified, 1, tojson(res));
@@ -298,7 +298,7 @@
session.startTransaction({readConcern: {level: "snapshot"}});
const res = assert.commandWorked(sessionDb.runCommand(
{delete: "coll", deletes: [{q: {}, limit: 1}, {q: {new: 1}, limit: 1}]}));
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
// Only remove one existing doc committed before the transaction.
assert.eq(res.n, 1, tojson(res));
}, {op: "remove"}, true);
@@ -310,7 +310,7 @@
session.startTransaction({readConcern: {level: "snapshot"}});
const res = assert.commandWorked(sessionDb.runCommand(
{findAndModify: "coll", query: {new: 1}, update: {$set: {findAndModify: 1}}}));
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
assert(res.hasOwnProperty("lastErrorObject"));
assert.eq(res.lastErrorObject.n, 0, tojson(res));
assert.eq(res.lastErrorObject.updatedExisting, false, tojson(res));
@@ -322,7 +322,7 @@
session.startTransaction({readConcern: {level: "snapshot"}});
const res = assert.commandWorked(sessionDb.runCommand(
{findAndModify: "coll", query: {new: 1}, update: {$set: {findAndModify: 1}}}));
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
assert(res.hasOwnProperty("lastErrorObject"));
assert.eq(res.lastErrorObject.n, 0, tojson(res));
assert.eq(res.lastErrorObject.updatedExisting, false, tojson(res));

View File

@@ -80,7 +80,7 @@
initialStatus.transactions, newStatus.transactions, "currentInactive", 1);
// Compare server status after the transaction commit with the server status before.
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
newStatus = assert.commandWorked(testDB.adminCommand({serverStatus: 1}));
verifyServerStatusFields(newStatus);
verifyServerStatusChange(initialStatus.transactions, newStatus.transactions, "totalStarted", 1);
@@ -180,7 +180,7 @@
session.startTransaction({readConcern: {level: 'snapshot'}});
assert.commandWorked(sessionColl.update({}, {"update-1": 2}));
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
};
const transactionProcess = startParallelShell(transactionFn, primary.port);

View File

@@ -157,7 +157,7 @@
// Verify the total prepared and aborted transaction counters are updated after an abort and the
// current prepared counter is decremented.
session.abortTransaction();
assert.commandWorked(session.abortTransaction_forTesting());
newStatus = assert.commandWorked(testDB.adminCommand({serverStatus: 1}));
verifyServerStatusFields(newStatus);
verifyServerStatusChange(

View File

@@ -74,7 +74,7 @@
// getMore tests snapshot isolation across multiple getMore invocations.
res = assert.commandWorked(
sessionDb.runCommand({getMore: cursor.id, collection: collName, batchSize: 20}));
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
// The cursor has been exhausted.
cursor = parseCursor(res);
@@ -89,7 +89,7 @@
session.startTransaction({readConcern: readConcern});
res = assert.commandWorked(
sessionDb.runCommand({find: collName, sort: {_id: 1}, batchSize: 20}));
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
// The cursor has been exhausted.
cursor = parseCursor(res);

View File

@@ -33,7 +33,7 @@
// Execute a transaction that should succeed.
session.startTransaction();
assert.commandWorked(sessionDb[collName].insert({x: 1}));
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
session.endSession();
replTest.stopSet();

View File

@@ -59,7 +59,7 @@
assert.writeOK(sessionColl.update({_id: i}, {$inc: {i: 1}}));
}
}
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
session.endSession();
jsTestLog('Applying updates on secondary ' + secondary.host);

View File

@@ -134,7 +134,7 @@
newSession.startTransaction({writeConcern: {w: 3}});
const secondDoc = {_id: "second-doc"};
assert.commandWorked(newSession.getDatabase(dbName).getCollection(collName).insert(secondDoc));
newSession.commitTransaction();
assert.commandWorked(newSession.commitTransaction_forTesting());
assert.docEq(testDB.getCollection(collName).find().toArray(), [secondDoc]);
assert.docEq(newTestDB.getCollection(collName).find().toArray(), [secondDoc]);

View File

@@ -84,7 +84,7 @@
return true;
}, () => "Failed to find create collection in currentOp() output: " + tojson(db.currentOp()));
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
threadCaptruncCmd.join();
threadDBHash.join();

View File

@@ -159,7 +159,7 @@
assert(initialSyncTest.step(), "Expected initial sync to have completed, but it did not");
// Abort transaction so that the data consistency checks in stop() can run.
session.abortTransaction();
assert.commandWorked(session.abortTransaction_forTesting());
// Issue a w:2 write to make sure the secondary has replicated the abortTransaction oplog entry.
assert.commandWorked(primary.getDB("otherDB").otherColl.insert({x: 1}, {writeConcern: {w: 2}}));
@@ -174,4 +174,4 @@
// Do data consistency checks at the end.
initialSyncTest.stop();
})();
})();

View File

@@ -66,7 +66,7 @@
secondSession.startTransaction({writeConcern: {w: "majority"}});
assert.commandWorked(
secondSession.getDatabase(dbName).getCollection(collName).insert({_id: "second-doc"}));
secondSession.commitTransaction();
assert.commandWorked(secondSession.commitTransaction_forTesting());
// Unfreeze the original primary so that it can stand for election again for the next test.
assert.commandWorked(primary.adminCommand({replSetFreeze: 0}));

View File

@@ -26,7 +26,7 @@
session.startTransaction();
assert.commandWorked(sessionColl.insert({_id: 1}));
assert.commandWorked(sessionColl.insert({_id: 2}));
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
session.endSession();
};

View File

@@ -22,7 +22,7 @@
assert.commandWorked(sessionColl1.insert({a: 1}));
session1.startTransaction();
assert.commandWorked(sessionColl1.insert({b: 1}));
session1.commitTransaction();
assert.commandWorked(session1.commitTransaction_forTesting());
rollbackTest.awaitLastOpCommitted();
assert.commandWorked(
@@ -33,20 +33,20 @@
const sessionColl2 = sessionDb2[collName];
session2.startTransaction();
assert.commandWorked(sessionColl2.insert({c: 1}));
session2.commitTransaction();
assert.commandWorked(session2.commitTransaction_forTesting());
rollbackTest.transitionToRollbackOperations();
session2.startTransaction();
assert.commandWorked(sessionColl2.insert({d: 1}));
session2.commitTransaction();
assert.commandWorked(session2.commitTransaction_forTesting());
const session3 = primary.startSession();
const sessionDb3 = session3.getDatabase(dbName);
const sessionColl3 = sessionDb3[collName];
session3.startTransaction();
assert.commandWorked(sessionColl3.insert({e: 1}));
session3.commitTransaction();
assert.commandWorked(session3.commitTransaction_forTesting());
assert.eq(sessionColl1.find().itcount(), 5);

View File

@@ -50,7 +50,7 @@
jsTestLog("Starting non-majority commit transaction");
session.startTransaction({readConcern: {level: "snapshot"}, writeConcern: {w: 1}});
assert.eq(sessionColl.findOne({_id: 0}), {_id: 0, x: 1});
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
// This transaction should not complete because it uses snapshot read concern, majority
// write concern and the commit point is not advancing.

View File

@@ -42,7 +42,7 @@
assert.commandWorked(sessionColl.update({_id: 0}, {$set: {x: 1}}));
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
// The document should be updated on the local snapshot.
assert.eq(coll.findOne({_id: 0}), {_id: 0, x: 1});
@@ -67,7 +67,7 @@
// Within the transaction, we should not see the out-of-transaction update.
assert.eq(sessionColl.findOne({_id: 1}), {_id: 1});
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
// The document should be updated on the local snapshot.
assert.eq(coll.findOne({_id: 0}), {_id: 0, x: 2});
@@ -108,7 +108,7 @@
// Update it one more time.
assert.commandWorked(sessionColl.update({_id: 0}, {$inc: {x: 1}}));
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
// The document should be updated on the local snapshot.
assert.eq(coll.findOne({_id: 0}), {_id: 0, x: 3});

View File

@@ -29,7 +29,7 @@
session.startTransaction();
assert.writeOK(coll.insert({_id: 0}));
assert.writeOK(coll.insert({_id: 1}));
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
const opTime = session.getOperationTime();
const txnNum = session.getTxnNumber_forTesting();
jsTestLog('Successfully committed transaction at operation time ' + tojson(opTime) +

View File

@@ -99,7 +99,7 @@
// Make sure we read the updated data correctly.
assert.docEq(sessionColl.find().sort({_id: 1}).toArray(),
[{_id: 0, syncSource: 0, inTxn: 1}, {_id: 2}]);
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
// Make sure data is visible after commit.
assert.docEq(sessionColl.find().sort({_id: 1}).toArray(),
@@ -110,7 +110,7 @@
session.startTransaction();
assert.docEq(sessionColl.find().sort({_id: 1}).toArray(), [{_id: 0}]);
assert.commandWorked(sessionColl.update({_id: 0}, {$set: {inTxn: 1}}));
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
// Make sure data is visible after commit.
assert.docEq(sessionColl.find().sort({_id: 1}).toArray(), [{_id: 0, inTxn: 1}]);

View File

@@ -108,22 +108,22 @@
primarySession.startTransaction();
assert.commandWorked(
primarySessionDb.runCommand({find: collName, $readPreference: {mode: "primary"}}));
primarySession.commitTransaction();
assert.commandWorked(primarySession.commitTransaction_forTesting());
primarySession.startTransaction();
assert.commandWorked(
primarySessionDb.runCommand({find: collName, $readPreference: {mode: "primaryPreferred"}}));
primarySession.commitTransaction();
assert.commandWorked(primarySession.commitTransaction_forTesting());
primarySession.startTransaction();
assert.commandWorked(primarySessionDb.runCommand(
{find: collName, $readPreference: {mode: "secondaryPreferred"}}));
primarySession.commitTransaction();
assert.commandWorked(primarySession.commitTransaction_forTesting());
primarySession.startTransaction();
assert.commandWorked(
primarySessionDb.runCommand({find: collName, $readPreference: {mode: "nearest"}}));
primarySession.commitTransaction();
assert.commandWorked(primarySession.commitTransaction_forTesting());
primarySession.endSession();

View File

@@ -161,7 +161,7 @@
// Commit first transaction and confirm that the change stream sees the changes expected
// from each shard.
session1.commitTransaction();
assert.commandWorked(session1.commitTransaction_forTesting());
assertWritesVisibleWithCapture(changeStreamCursor,
[
{operationType: "insert", _id: "no-txn-doc-3"},
@@ -183,7 +183,7 @@
// Abort second transaction and confirm that the change stream sees only the previous
// non-transaction write.
session2.abortTransaction();
assert.commandWorked(session2.abortTransaction_forTesting());
assertWritesVisibleWithCapture(changeStreamCursor,
[],
[{operationType: "insert", _id: "no-txn-doc-4"}],

View File

@@ -70,16 +70,14 @@
};
// Simulate the upsert that is performed by a config server on addShard.
var shardIdentityQuery = {
_id: shardIdentityDoc._id,
shardName: shardIdentityDoc.shardName,
clusterId: shardIdentityDoc.clusterId,
};
var shardIdentityUpdate = {
$set: {configsvrConnectionString: shardIdentityDoc.configsvrConnectionString}
};
assert.writeOK(mongodConn.getDB('admin').system.version.update(
shardIdentityQuery, shardIdentityUpdate, {upsert: true}));
{
_id: shardIdentityDoc._id,
shardName: shardIdentityDoc.shardName,
clusterId: shardIdentityDoc.clusterId,
},
{$set: {configsvrConnectionString: shardIdentityDoc.configsvrConnectionString}},
{upsert: true}));
var res = mongodConn.getDB('admin').runCommand({shardingState: 1});
@@ -146,20 +144,19 @@
var st = new ShardingTest({shards: 1});
var mongod = MongoRunner.runMongod({shardsvr: ''});
{
var mongod = MongoRunner.runMongod({shardsvr: ''});
runTest(mongod, st.configRS.getURL());
MongoRunner.stopMongod(mongod);
}
runTest(mongod, st.configRS.getURL());
MongoRunner.stopMongod(mongod);
var replTest = new ReplSetTest({nodes: 1});
replTest.startSet({shardsvr: ''});
replTest.initiate();
runTest(replTest.getPrimary(), st.configRS.getURL());
replTest.stopSet();
{
var replTest = new ReplSetTest({nodes: 1});
replTest.startSet({shardsvr: ''});
replTest.initiate();
runTest(replTest.getPrimary(), st.configRS.getURL());
replTest.stopSet();
}
st.stop();
})();

View File

@@ -39,7 +39,7 @@
// Start a transaction and verify that it succeeds.
session.startTransaction();
assert.commandWorked(sessionColl.insert({_id: 0}));
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
assert.eq({_id: 0}, sessionColl.findOne({_id: 0}));

View File

@@ -79,7 +79,7 @@
session.startTransaction();
assert.commandWorked(sessionColl.update({_id: 1}, {$inc: {x: 1}}));
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
// Confirm that the results of the transaction are based on what the primary's data was when we
// started the transaction.

View File

@@ -238,7 +238,7 @@
assert(res.cursor.hasOwnProperty("nextBatch"));
assert.eq(4, res.cursor.nextBatch.length);
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
// Perform a second snapshot read under a new transaction.
session.startTransaction({writeConcern: {w: "majority"}});
@@ -256,7 +256,7 @@
// Remove the 11th document to preserve the collection for the next command.
assert.writeOK(mainDb[collName].remove({_id: 10}, {writeConcern: {w: "majority"}}));
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
session.endSession();
}

View File

@@ -65,7 +65,7 @@
"sharded transaction with read concern " + tojson(readConcern) +
" did not see expected document");
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
// Clean up for the next iteration.
assert.commandWorked(

View File

@@ -172,7 +172,8 @@
res = startTransaction(mongosSession, dbName, collName);
checkMongosResponse(res, ErrorCodes.WriteConflict, "TransientTransactionError", null);
turnOffFailCommand(st.rs0);
mongosSession.abortTransaction();
assert.commandFailedWithCode(mongosSession.abortTransaction_forTesting(),
ErrorCodes.NoSuchTransaction);
// statements prior to commit network error
failCommandWithError(
@@ -181,7 +182,8 @@
res = startTransaction(mongosSession, dbName, collName);
checkMongosResponse(res, ErrorCodes.HostUnreachable, "TransientTransactionError", null);
turnOffFailCommand(st.rs0);
mongosSession.abortTransaction();
assert.commandFailedWithCode(mongosSession.abortTransaction_forTesting(),
ErrorCodes.NoSuchTransaction);
// commitTransaction for single-shard transaction (mongos sends commitTransaction)
runCommitTests("commitTransaction");

View File

@@ -75,7 +75,7 @@
]);
// Commit the transaction and verify the write was successful.
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
if (isUpdate) {
assert.sameMembers(st.getDB(dbName)[collName].find().toArray(),
[

View File

@@ -63,7 +63,7 @@
" did not see expected number of documents, sessionOptions: " +
tojson(sessionOptions));
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
// Clean up for the next iteration.
assert.writeOK(sessionDB[collName].remove({_id: 5}));

View File

@@ -66,7 +66,7 @@
session.startTransaction({readConcern: {level: "snapshot"}});
assert.commandWorked(sessionDB.runCommand(commandBody));
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
unsetFailCommandOnEachShard(st, numShardsToError);
@@ -84,7 +84,7 @@
session.startTransaction({readConcern: {level: "snapshot"}});
assert.commandWorked(sessionDB.runCommand(commandBody));
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
unsetFailCommandOnEachShard(st, numShardsToError);

View File

@@ -31,7 +31,7 @@
// No database versioned requests have been sent to Shard0, so it is stale.
assert.commandWorked(sessionDB.runCommand({distinct: collName, key: "_id", query: {_id: 0}}));
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
//
// Stale database version on second command to a shard should fail.
@@ -88,7 +88,7 @@
assert.commandWorked(
sessionOtherDB.runCommand({distinct: otherCollName, key: "_id", query: {_id: 0}}));
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
//
// The final StaleDbVersion error should be returned if the router exhausts its retries.

View File

@@ -76,7 +76,7 @@
// Targets Shard1, which is stale.
assert.commandWorked(sessionDB.runCommand({find: collName, filter: {_id: 5}}));
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
//
// Stale shard version on second command to a shard should fail.
@@ -128,7 +128,7 @@
// Targets Shard0 for the other ns, which is stale.
assert.commandWorked(sessionDB.runCommand({find: otherCollName, filter: {_id: 5}}));
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
//
// Stale mongos aborts on old shard.
@@ -147,7 +147,7 @@
// stale but should succeed.
assert.commandWorked(sessionDB.runCommand({find: collName, filter: {_id: 5}}));
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
// Verify there is no in-progress transaction on Shard1.
res = assert.commandFailedWithCode(st.rs1.getPrimary().getDB(dbName).runCommand({
@@ -178,7 +178,7 @@
// Targets all shards, two of which are stale.
assert.commandWorked(sessionDB.runCommand({find: collName}));
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
//
// Can retry a stale write on the first statement.
@@ -194,7 +194,7 @@
// Targets Shard1, which is stale.
assert.commandWorked(sessionDB.runCommand({insert: collName, documents: [{_id: 6}]}));
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
//
// Cannot retry a stale write past the first statement.

View File

@@ -97,7 +97,7 @@
1,
"expected to find document in second chunk, cmd: " + cmdName);
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
// Move the chunk back to Shard1 for the next iteration.
assert.commandWorked(

View File

@@ -80,7 +80,7 @@
function readFromViewOnFirstParticipantStatement(session, view, viewFunc, numDocsExpected) {
session.startTransaction();
assert.eq(viewFunc(view), numDocsExpected);
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
}
// Unsharded view.
@@ -124,7 +124,7 @@
session.startTransaction();
assert.eq(view.aggregate({$match: {}}).itcount(), numDocsExpected);
assert.eq(viewFunc(view), numDocsExpected);
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
}
// Unsharded view.
@@ -229,7 +229,7 @@
assert.eq(view.aggregate({$match: {_id: -1}}).itcount(), 1);
// Targets the primary first, but the resolved retry only targets Shard1.
assert.eq(viewFunc(view), numDocsExpected);
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
}
// This is only possible against sharded views.
@@ -262,7 +262,7 @@
session.startTransaction();
const resArray = coll.aggregate(pipeline).toArray();
assert(arrayEq(resArray, expected), tojson({got: resArray, expected: expected}));
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
}
// Set up an unsharded collection to use for $lookup. We cannot lookup into sharded collections.

View File

@@ -84,7 +84,7 @@
));
assert.eq(err.code, ErrorCodes.InvalidOptions, err);
session.abortTransaction();
assert.commandWorked(session.abortTransaction_forTesting());
// Insert some data outside of a transaction.
assert.commandWorked(sessionColl.insert([{_id: -1}, {_id: 0}, {_id: 1}]));
@@ -96,7 +96,7 @@
sessionColl
.aggregate([{$_internalSplitPipeline: {mergeType: "primaryShard"}}, {$sort: {_id: 1}}])
.toArray());
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
// Move all of the data to shard 1.
assert.commandWorked(
@@ -111,7 +111,7 @@
// chunks for the collection.
session.startTransaction();
assert.eq([{_id: -1}, {_id: 0}, {_id: 1}], sessionColl.aggregate(pipeline).toArray());
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
st.stop();
})();

View File

@@ -68,7 +68,7 @@
}));
// Commit the transaction, which will execute two-phase commit.
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
jsTest.log("Verify that the transaction was committed on all shards.");
// Use assert.soon(), because although coordinateCommitTransaction currently blocks

View File

@@ -41,7 +41,7 @@ load('./jstests/libs/chunk_manipulation_util.js');
assert.eq({_id: 'updateMe'}, recipientColl.findOne({_id: 'updateMe'}));
assert.eq({_id: 'deleteMe'}, recipientColl.findOne({_id: 'deleteMe'}));
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
unpauseMoveChunkAtStep(st.shard0, moveChunkStepNames.reachedSteadyState);
joinMoveChunk();

View File

@@ -76,7 +76,7 @@
assert.eq(doc.matches.length, kUnshardedCollOriginalSize);
}
session.abortTransaction();
assert.commandWorked(session.abortTransaction_forTesting());
};
// Run the test once, with all of the data on shard 1. This means that the merging shard (shard

View File

@@ -158,7 +158,7 @@
// The above upsert works with transactions.
session.startTransaction();
assertUpdateWorkedWithNoMatchingDoc({x: 4, y: 0, z: 0}, updateDoc, true, true);
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
assert.eq(1, st.s.getDB(kDbName).coll.find(updateDoc).itcount());
// Full shard key not specified in query.
@@ -259,7 +259,7 @@
// The above upsert works with transactions.
session.startTransaction();
assertUpdateWorkedWithNoMatchingDoc({x: 4, y: 0, z: 0, opStyle: true}, update, true, true);
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
assert.eq(1, st.s.getDB(kDbName).coll.find(update["$set"]).itcount());
// Full shard key not specified in query.
@@ -392,7 +392,7 @@
}
}],
true);
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
assert.eq(
1, st.s.getDB(kDbName).coll.find({x: 2111, y: 55, z: 3, pipelineUpdate: true}).itcount());

View File

@@ -723,7 +723,7 @@
assert.commandWorked(sessionDB.foo.update({"x": 500}, {"$set": {"x": 400}}));
assert.commandWorked(sessionDB.foo.update({"x": 400}, {"x": 600, "_id": id}));
assert.commandWorked(sessionDB.foo.update({"x": 4}, {"$set": {"x": 30}}));
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
assert.eq(0, mongos.getDB(kDbName).foo.find({"x": 500}).itcount());
assert.eq(0, mongos.getDB(kDbName).foo.find({"x": 400}).itcount());
@@ -742,7 +742,7 @@
assert.commandWorked(sessionDB.foo.update({"x": 500}, {"$inc": {"a": 1}}));
assert.commandWorked(sessionDB.foo.update({"x": 500}, {"$set": {"x": 400}}));
assert.commandWorked(sessionDB.foo.update({"x": 500}, {"$inc": {"a": 1}}));
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
assert.eq(0, mongos.getDB(kDbName).foo.find({"x": 500}).itcount());
assert.eq(1, mongos.getDB(kDbName).foo.find({"x": 400}).itcount());
@@ -757,7 +757,7 @@
session.startTransaction();
sessionDB.foo.findAndModify({query: {"x": 500}, update: {$set: {"x": 600}}});
assert.commandWorked(sessionDB.foo.update({"x": 600}, {"$inc": {"a": 1}}));
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
assert.eq(0, mongos.getDB(kDbName).foo.find({"x": 500}).itcount());
assert.eq(1, mongos.getDB(kDbName).foo.find({"x": 600}).itcount());
@@ -773,7 +773,7 @@
session.startTransaction();
sessionDB.foo.findAndModify({query: {"x": 4}, update: {$set: {"x": 20}}});
assert.commandWorked(sessionDB.foo.update({"x": 20}, {$set: {"x": 1}}));
session.commitTransaction();
assert.commandWorked(session.commitTransaction_forTesting());
assert.eq(0, mongos.getDB(kDbName).foo.find({"x": 4}).itcount());
assert.eq(0, mongos.getDB(kDbName).foo.find({"x": 20}).itcount());

View File

@@ -297,108 +297,6 @@ void checkUniqueIndexConstraints(OperationContext* opCtx,
shardKeyPattern.isUniqueIndexCompatible(newIdxKey));
}
/**
* Fills in command result with number of indexes when there are no indexes to add.
*/
void fillCommandResultWithIndexesAlreadyExistInfo(int numIndexes, BSONObjBuilder* result) {
result->append("numIndexesBefore", numIndexes);
result->append("numIndexesAfter", numIndexes);
result->append("note", "all indexes already exist");
};
/**
* Before potentially taking an exclusive database or collection lock, check if all indexes
* already exist while holding an intent lock.
*
* Returns true, after filling in the command result, if the index creation can return early.
*/
bool indexesAlreadyExist(OperationContext* opCtx,
const NamespaceString& ns,
const std::vector<BSONObj>& specs,
BSONObjBuilder* result) {
AutoGetCollection autoColl(opCtx, ns, MODE_IX);
auto collection = autoColl.getCollection();
if (!collection) {
return false;
}
auto specsCopy = resolveDefaultsAndRemoveExistingIndexes(opCtx, collection, specs);
if (specsCopy.size() > 0) {
return false;
}
auto numIndexes = collection->getIndexCatalog()->numIndexesTotal(opCtx);
fillCommandResultWithIndexesAlreadyExistInfo(numIndexes, result);
return true;
}
/**
* Opens or creates database for index creation.
* On database creation, the lock will be made exclusive.
*/
Database* getOrCreateDatabase(OperationContext* opCtx, StringData dbName, Lock::DBLock* dbLock) {
auto databaseHolder = DatabaseHolder::get(opCtx);
if (auto db = databaseHolder->getDb(opCtx, dbName)) {
return db;
}
// Temporarily release the Database lock while holding a Global IX lock. This prevents
// replication state from changing. Abandon the current snapshot to see changed metadata.
opCtx->recoveryUnit()->abandonSnapshot();
dbLock->relockWithMode(MODE_X);
return databaseHolder->openDb(opCtx, dbName);
}
/**
* Checks database sharding state. Throws exception on error.
*/
void checkDatabaseShardingState(OperationContext* opCtx, Database* db) {
auto& dss = DatabaseShardingState::get(db);
auto dssLock = DatabaseShardingState::DSSLock::lock(opCtx, &dss);
dss.checkDbVersion(opCtx, dssLock);
}
/**
* Gets or creates collection to hold indexes.
* Appends field to command result to indicate if the collection already exists.
*/
Collection* getOrCreateCollection(OperationContext* opCtx,
Database* db,
const NamespaceString& ns,
const BSONObj& cmdObj,
std::string* errmsg,
BSONObjBuilder* result) {
if (auto collection = db->getCollection(opCtx, ns)) {
result->appendBool(kCreateCollectionAutomaticallyFieldName, false);
return collection;
}
result->appendBool(kCreateCollectionAutomaticallyFieldName, true);
if (ViewCatalog::get(db)->lookup(opCtx, ns.ns())) {
*errmsg = "Cannot create indexes on a view";
uasserted(ErrorCodes::CommandNotSupportedOnView, *errmsg);
}
uassertStatusOK(userAllowedCreateNS(ns.db(), ns.coll()));
CollectionOptions options;
options.uuid = UUID::gen();
return writeConflictRetry(opCtx, kCommandName, ns.ns(), [&] {
WriteUnitOfWork wunit(opCtx);
auto collection = db->createCollection(opCtx, ns, options);
invariant(collection,
str::stream() << "Failed to create collection " << ns.ns()
<< " during index creation: "
<< redact(cmdObj));
wunit.commit();
return collection;
});
}
bool runCreateIndexes(OperationContext* opCtx,
const std::string& dbname,
const BSONObj& cmdObj,
@@ -427,13 +325,40 @@ bool runCreateIndexes(OperationContext* opCtx,
str::stream() << "Not primary while creating indexes in " << ns.ns());
}
if (indexesAlreadyExist(opCtx, ns, specs, &result)) {
const auto indexesAlreadyExist = [&result](int numIndexes) {
result.append("numIndexesBefore", numIndexes);
result.append("numIndexesAfter", numIndexes);
result.append("note", "all indexes already exist");
return true;
};
// Before potentially taking an exclusive database or collection lock, check if all indexes
// already exist while holding an intent lock.
{
AutoGetCollection autoColl(opCtx, ns, MODE_IX);
if (auto collection = autoColl.getCollection()) {
auto specsCopy = resolveDefaultsAndRemoveExistingIndexes(opCtx, collection, specs);
if (specsCopy.size() == 0) {
return indexesAlreadyExist(collection->getIndexCatalog()->numIndexesTotal(opCtx));
}
}
}
auto db = getOrCreateDatabase(opCtx, ns.db(), &dbLock);
auto databaseHolder = DatabaseHolder::get(opCtx);
auto db = databaseHolder->getDb(opCtx, ns.db());
if (!db) {
// Temporarily release the Database lock while holding a Global IX lock. This prevents
// replication state from changing. Abandon the current snapshot to see changed metadata.
opCtx->recoveryUnit()->abandonSnapshot();
dbLock.relockWithMode(MODE_X);
db = databaseHolder->openDb(opCtx, ns.db());
}
checkDatabaseShardingState(opCtx, db);
{
auto& dss = DatabaseShardingState::get(db);
auto dssLock = DatabaseShardingState::DSSLock::lock(opCtx, &dss);
dss.checkDbVersion(opCtx, dssLock);
}
opCtx->recoveryUnit()->abandonSnapshot();
boost::optional<Lock::CollectionLock> exclusiveCollectionLock(
@@ -443,7 +368,24 @@ bool runCreateIndexes(OperationContext* opCtx,
// final drain phase conflicts with prepared transactions.
opCtx->recoveryUnit()->setIgnorePrepared(true);
auto collection = getOrCreateCollection(opCtx, db, ns, cmdObj, &errmsg, &result);
Collection* collection = db->getCollection(opCtx, ns);
bool createCollectionAutomatically = collection == nullptr;
result.appendBool("createdCollectionAutomatically", createCollectionAutomatically);
if (createCollectionAutomatically) {
if (ViewCatalog::get(db)->lookup(opCtx, ns.ns())) {
errmsg = "Cannot create indexes on a view";
uasserted(ErrorCodes::CommandNotSupportedOnView, errmsg);
}
uassertStatusOK(userAllowedCreateNS(ns.db(), ns.coll()));
writeConflictRetry(opCtx, kCommandName, ns.ns(), [&] {
WriteUnitOfWork wunit(opCtx);
collection = db->createCollection(opCtx, ns, CollectionOptions());
invariant(collection);
wunit.commit();
});
}
// Use AutoStatsTracker to update Top.
boost::optional<AutoStatsTracker> statsTracker;
@@ -461,8 +403,7 @@ bool runCreateIndexes(OperationContext* opCtx,
const int numIndexesBefore = collection->getIndexCatalog()->numIndexesTotal(opCtx);
if (specs.size() == 0) {
fillCommandResultWithIndexesAlreadyExistInfo(numIndexesBefore, &result);
return true;
return indexesAlreadyExist(numIndexesBefore);
}
result.append("numIndexesBefore", numIndexesBefore);
@@ -555,11 +496,13 @@ bool runCreateIndexes(OperationContext* opCtx,
exclusiveCollectionLock.emplace(opCtx, ns, MODE_X);
}
auto databaseHolder = DatabaseHolder::get(opCtx);
db = databaseHolder->getDb(opCtx, ns.db());
invariant(db->getCollection(opCtx, ns));
checkDatabaseShardingState(opCtx, db);
{
auto& dss = DatabaseShardingState::get(db);
auto dssLock = DatabaseShardingState::DSSLock::lock(opCtx, &dss);
dss.checkDbVersion(opCtx, dssLock);
}
// Perform the third and final drain while holding the exclusive collection lock.
uassertStatusOK(indexer.drainBackgroundWrites(opCtx));

View File

@@ -388,14 +388,18 @@ MONGO_REGISTER_SHIM(waitForLinearizableReadConcern)
"No longer primary when waiting for linearizable read concern"};
}
writeConflictRetry(opCtx, "waitForLinearizableReadConcern", "local.rs.oplog", [&opCtx] {
WriteUnitOfWork uow(opCtx);
opCtx->getClient()->getServiceContext()->getOpObserver()->onOpMessage(
opCtx,
BSON("msg"
<< "linearizable read"));
uow.commit();
});
writeConflictRetry(
opCtx,
"waitForLinearizableReadConcern",
NamespaceString::kRsOplogNamespace.ns(),
[&opCtx] {
WriteUnitOfWork uow(opCtx);
opCtx->getClient()->getServiceContext()->getOpObserver()->onOpMessage(
opCtx,
BSON("msg"
<< "linearizable read"));
uow.commit();
});
}
WriteConcernOptions wc = WriteConcernOptions(
WriteConcernOptions::kMajority, WriteConcernOptions::SyncMode::UNSET, readConcernTimeout);

View File

@@ -186,19 +186,10 @@ TransactionCoordinator::TransactionCoordinator(ServiceContext* serviceContext,
MONGO_UNREACHABLE;
};
})
.onCompletion([this](Status s) {
// Do a best-effort attempt to delete the coordinator document from disk, regardless of
// the success of the commit sequence.
LOG(3) << "Two-phase commit completed for " << _lsid.getId() << ':' << _txnNumber;
return txn::deleteCoordinatorDoc(*_scheduler, _lsid, _txnNumber)
.onCompletion([ this, chainStatus = std::move(s) ](Status deleteDocStatus) {
if (_participantsDurable) {
LOG(0) << redact(deleteDocStatus);
}
return chainStatus;
});
.then([this] {
// Do a best-effort attempt (i.e., writeConcern w:1) to delete the coordinator's durable
// state.
return txn::deleteCoordinatorDoc(*_scheduler, _lsid, _txnNumber);
})
.onCompletion([ this, deadlineFuture = std::move(deadlineFuture) ](Status s) mutable {
// Interrupt this coordinator's scheduler hierarchy and join the deadline task's future

View File

@@ -190,7 +190,9 @@ void cleanupTask(ServiceContext* serviceContext) {
Client& client = cc();
// Join the logical session cache before the transport layer
LogicalSessionCache::get(serviceContext)->joinOnShutDown();
if (auto lsc = LogicalSessionCache::get(serviceContext)) {
lsc->joinOnShutDown();
}
// Shutdown the TransportLayer so that new connections aren't accepted
if (auto tl = serviceContext->getTransportLayer()) {
@@ -396,7 +398,7 @@ private:
};
ExitCode runMongosServer(ServiceContext* serviceContext) {
Client::initThread("mongosMain");
ThreadClient tc("mongosMain", serviceContext);
printShardingVersionInfo(false);
initWireSpec();
@@ -447,13 +449,13 @@ ExitCode runMongosServer(ServiceContext* serviceContext) {
quickExit(EXIT_BADOPTIONS);
}
auto opCtx = cc().makeOperationContext();
LogicalClock::set(serviceContext, stdx::make_unique<LogicalClock>(serviceContext));
auto logicalClock = stdx::make_unique<LogicalClock>(opCtx->getServiceContext());
LogicalClock::set(opCtx->getServiceContext(), std::move(logicalClock));
auto opCtxHolder = tc->makeOperationContext();
auto const opCtx = opCtxHolder.get();
{
Status status = initializeSharding(opCtx.get());
Status status = initializeSharding(opCtx);
if (!status.isOK()) {
if (status == ErrorCodes::CallbackCanceled) {
invariant(globalInShutdownDeprecated());
@@ -464,15 +466,15 @@ ExitCode runMongosServer(ServiceContext* serviceContext) {
return EXIT_SHARDING_ERROR;
}
Grid::get(opCtx.get())
Grid::get(serviceContext)
->getBalancerConfiguration()
->refreshAndCheck(opCtx.get())
->refreshAndCheck(opCtx)
.transitional_ignore();
}
startMongoSFTDC();
Status status = AuthorizationManager::get(serviceContext)->initialize(opCtx.get());
Status status = AuthorizationManager::get(serviceContext)->initialize(opCtx);
if (!status.isOK()) {
error() << "Initializing authorization data failed: " << status;
return EXIT_SHARDING_ERROR;
@@ -486,17 +488,17 @@ ExitCode runMongosServer(ServiceContext* serviceContext) {
clusterCursorCleanupJob.go();
UserCacheInvalidator cacheInvalidatorThread(AuthorizationManager::get(serviceContext));
{
cacheInvalidatorThread.initialize(opCtx.get());
cacheInvalidatorThread.go();
}
cacheInvalidatorThread.initialize(opCtx);
cacheInvalidatorThread.go();
PeriodicTask::startRunningPeriodicTasks();
// Set up the periodic runner for background job execution
auto runner = makePeriodicRunner(serviceContext);
runner->startup();
serviceContext->setPeriodicRunner(std::move(runner));
{
auto runner = makePeriodicRunner(serviceContext);
runner->startup();
serviceContext->setPeriodicRunner(std::move(runner));
}
SessionKiller::set(serviceContext,
std::make_shared<SessionKiller>(serviceContext, killSessionsRemote));