summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikita Lapkov <nikita.lapkov@mongodb.com>2021-10-01 12:46:37 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-10-05 08:12:39 +0000
commita73cbaa31af52f1f8de9c35f579c69bb384a9501 (patch)
treecb2106208289cd42accaa3b57d3795c5bf462fb0
parent9833bf4830fbfba67cbea4a6ae42d58bd6866a6f (diff)
downloadmongo-a73cbaa31af52f1f8de9c35f579c69bb384a9501.tar.gz
SERVER-60285 Add FSM test for deletes on a sharded time-series collection
-rw-r--r--buildscripts/resmokeconfig/suites/concurrency_sharded_multi_stmt_txn_kill_primary.yml1
-rw-r--r--buildscripts/resmokeconfig/suites/concurrency_sharded_multi_stmt_txn_terminate_primary.yml1
-rw-r--r--buildscripts/resmokeconfig/suites/concurrency_sharded_multi_stmt_txn_with_stepdowns.yml1
-rw-r--r--jstests/concurrency/fsm_workloads/random_moveChunk_timeseries_deletes.js72
4 files changed, 75 insertions, 0 deletions
diff --git a/buildscripts/resmokeconfig/suites/concurrency_sharded_multi_stmt_txn_kill_primary.yml b/buildscripts/resmokeconfig/suites/concurrency_sharded_multi_stmt_txn_kill_primary.yml
index ec618e5d03f..95c712d59dd 100644
--- a/buildscripts/resmokeconfig/suites/concurrency_sharded_multi_stmt_txn_kill_primary.yml
+++ b/buildscripts/resmokeconfig/suites/concurrency_sharded_multi_stmt_txn_kill_primary.yml
@@ -163,6 +163,7 @@ selector:
- jstests/concurrency/fsm_workloads/view_catalog.js
- jstests/concurrency/fsm_workloads/view_catalog_cycle_with_drop.js
- jstests/concurrency/fsm_workloads/view_catalog_direct_system_writes.js
+ - jstests/concurrency/fsm_workloads/random_moveChunk_timeseries_deletes.js
##
# Denylists specific to this suite
diff --git a/buildscripts/resmokeconfig/suites/concurrency_sharded_multi_stmt_txn_terminate_primary.yml b/buildscripts/resmokeconfig/suites/concurrency_sharded_multi_stmt_txn_terminate_primary.yml
index 4cf2b0f8721..5d734d13c1c 100644
--- a/buildscripts/resmokeconfig/suites/concurrency_sharded_multi_stmt_txn_terminate_primary.yml
+++ b/buildscripts/resmokeconfig/suites/concurrency_sharded_multi_stmt_txn_terminate_primary.yml
@@ -163,6 +163,7 @@ selector:
- jstests/concurrency/fsm_workloads/view_catalog.js
- jstests/concurrency/fsm_workloads/view_catalog_cycle_with_drop.js
- jstests/concurrency/fsm_workloads/view_catalog_direct_system_writes.js
+ - jstests/concurrency/fsm_workloads/random_moveChunk_timeseries_deletes.js
##
# Denylists specific to this suite
diff --git a/buildscripts/resmokeconfig/suites/concurrency_sharded_multi_stmt_txn_with_stepdowns.yml b/buildscripts/resmokeconfig/suites/concurrency_sharded_multi_stmt_txn_with_stepdowns.yml
index e65701ed958..7f22963a6c8 100644
--- a/buildscripts/resmokeconfig/suites/concurrency_sharded_multi_stmt_txn_with_stepdowns.yml
+++ b/buildscripts/resmokeconfig/suites/concurrency_sharded_multi_stmt_txn_with_stepdowns.yml
@@ -146,6 +146,7 @@ selector:
- jstests/concurrency/fsm_workloads/view_catalog.js
- jstests/concurrency/fsm_workloads/view_catalog_cycle_with_drop.js
- jstests/concurrency/fsm_workloads/view_catalog_direct_system_writes.js
+ - jstests/concurrency/fsm_workloads/random_moveChunk_timeseries_deletes.js
##
# Denylists specific to this suite
diff --git a/jstests/concurrency/fsm_workloads/random_moveChunk_timeseries_deletes.js b/jstests/concurrency/fsm_workloads/random_moveChunk_timeseries_deletes.js
new file mode 100644
index 00000000000..d1c95834941
--- /dev/null
+++ b/jstests/concurrency/fsm_workloads/random_moveChunk_timeseries_deletes.js
@@ -0,0 +1,72 @@
+/**
+ * Extends random_moveChunk_timeseries_inserts.js workload with delete stage. Tests deletes in the
+ * presence of concurrent insert and moveChunk commands.
+ * @tags: [
+ * requires_sharding,
+ * assumes_balancer_off,
+ * requires_non_retryable_writes,
+ * ]
+ */
+'use strict';
+
+load('jstests/core/timeseries/libs/timeseries.js'); // For 'TimeseriesTest' helpers.
+// Load parent workload for extending below.
+load('jstests/concurrency/fsm_workloads/random_moveChunk_timeseries_inserts.js');
+
+var $config = extendWorkload($config, function($config, $super) {
+ $config.data.generateMetaFieldValueForInitialInserts = () => {
+ let meta = {};
+ // Insert a document with a field for every thread to test concurrent deletes of the
+ // same document.
+ for (let i = 0; i < $config.threadCount; i++) {
+ meta["tid" + i] = Random.randInt($config.data.numMetaCount);
+ }
+ return meta;
+ };
+
+ $config.data.generateMetaFieldValueForInsertStage = (tid) => {
+ // After the initial stage, each thread will insert documents containing only fields with
+ // this thread's id. This ensures we do not run into concurrency issues with concurrent
+ // inserts and deletes.
+ // NOTE: This problem does not exist for the initial set of documents, since they are
+ // inserted before any delete operation is issued.
+ return {["tid" + tid]: Random.randInt($config.data.numMetaCount)};
+ };
+
+ $config.states.init = function init(db, collName, connCache) {
+ $super.states.init.call(this, db, collName, connCache);
+
+ this.featureFlagDisabled = this.featureFlagDisabled ||
+ !TimeseriesTest.timeseriesUpdatesAndDeletesEnabled(db) ||
+ !TimeseriesTest.shardedTimeseriesUpdatesAndDeletesEnabled(db);
+ if (this.featureFlagDisabled) {
+ jsTestLog(
+ "Skipping executing this test as the requisite feature flags are not enabled.");
+ }
+ };
+
+ $config.states.doDelete = function doDelete(db, collName, connCache) {
+ if (this.featureFlagDisabled) {
+ return;
+ }
+
+ const filter = {
+ m: {
+ ["tid" + this.tid]: {
+ $gte: Random.randInt($config.data.numMetaCount),
+ },
+ },
+ };
+ assertAlways.commandWorked(db[collName].deleteMany(filter));
+ assertAlways.commandWorked(db[this.nonShardCollName].deleteMany(filter));
+ };
+
+ $config.transitions = {
+ init: {insert: 1},
+ insert: {insert: 3, doDelete: 3, moveChunk: 1},
+ doDelete: {insert: 3, doDelete: 3, moveChunk: 1},
+ moveChunk: {insert: 1, doDelete: 1, moveChunk: 0},
+ };
+
+ return $config;
+});