diff options
23 files changed, 143 insertions, 118 deletions
diff --git a/buildscripts/resmokeconfig/suites/concurrency_sharded_causal_consistency.yml b/buildscripts/resmokeconfig/suites/concurrency_sharded_causal_consistency.yml index ea27ceda2f9..bc415c66482 100644 --- a/buildscripts/resmokeconfig/suites/concurrency_sharded_causal_consistency.yml +++ b/buildscripts/resmokeconfig/suites/concurrency_sharded_causal_consistency.yml @@ -25,17 +25,6 @@ selector: - jstests/concurrency/fsm_workloads/agg_graph_lookup.js - jstests/concurrency/fsm_workloads/view_catalog_cycle_lookup.js - # Disabled due to SERVER-20057, 'Concurrent, sharded mapReduces can fail when temporary - # namespaces collide across mongos processes' - - jstests/concurrency/fsm_workloads/map_reduce_drop.js - - jstests/concurrency/fsm_workloads/map_reduce_inline.js - - jstests/concurrency/fsm_workloads/map_reduce_interrupt.js - - jstests/concurrency/fsm_workloads/map_reduce_merge.js - - jstests/concurrency/fsm_workloads/map_reduce_reduce.js - - jstests/concurrency/fsm_workloads/map_reduce_replace.js - - jstests/concurrency/fsm_workloads/map_reduce_replace_nonexistent.js - - jstests/concurrency/fsm_workloads/map_reduce_replace_remove.js - # Disabled due to MongoDB restrictions and/or workload restrictions # These workloads sometimes trigger 'Could not lock auth data update lock' diff --git a/buildscripts/resmokeconfig/suites/concurrency_sharded_causal_consistency_and_balancer.yml b/buildscripts/resmokeconfig/suites/concurrency_sharded_causal_consistency_and_balancer.yml index d9e65315211..a281dbe6b5d 100644 --- a/buildscripts/resmokeconfig/suites/concurrency_sharded_causal_consistency_and_balancer.yml +++ b/buildscripts/resmokeconfig/suites/concurrency_sharded_causal_consistency_and_balancer.yml @@ -28,17 +28,6 @@ selector: - jstests/concurrency/fsm_workloads/agg_graph_lookup.js - jstests/concurrency/fsm_workloads/view_catalog_cycle_lookup.js - # Disabled due to SERVER-20057, 'Concurrent, sharded mapReduces can fail when temporary - # namespaces collide across mongos processes' - - jstests/concurrency/fsm_workloads/map_reduce_drop.js - - jstests/concurrency/fsm_workloads/map_reduce_inline.js - - jstests/concurrency/fsm_workloads/map_reduce_interrupt.js - - jstests/concurrency/fsm_workloads/map_reduce_merge.js - - jstests/concurrency/fsm_workloads/map_reduce_reduce.js - - jstests/concurrency/fsm_workloads/map_reduce_replace.js - - jstests/concurrency/fsm_workloads/map_reduce_replace_nonexistent.js - - jstests/concurrency/fsm_workloads/map_reduce_replace_remove.js - # Disabled due to MongoDB restrictions and/or workload restrictions # These workloads sometimes trigger 'Could not lock auth data update lock' diff --git a/buildscripts/resmokeconfig/suites/concurrency_sharded_local_read_write_multi_stmt_txn.yml b/buildscripts/resmokeconfig/suites/concurrency_sharded_local_read_write_multi_stmt_txn.yml index 6f7c3828f71..2e5e957d92e 100644 --- a/buildscripts/resmokeconfig/suites/concurrency_sharded_local_read_write_multi_stmt_txn.yml +++ b/buildscripts/resmokeconfig/suites/concurrency_sharded_local_read_write_multi_stmt_txn.yml @@ -26,17 +26,6 @@ selector: - jstests/concurrency/fsm_workloads/agg_graph_lookup.js - jstests/concurrency/fsm_workloads/view_catalog_cycle_lookup.js - # Disabled due to SERVER-20057, 'Concurrent, sharded mapReduces can fail when temporary - # namespaces collide across mongos processes' - - jstests/concurrency/fsm_workloads/map_reduce_drop.js - - jstests/concurrency/fsm_workloads/map_reduce_inline.js - - jstests/concurrency/fsm_workloads/map_reduce_interrupt.js - - jstests/concurrency/fsm_workloads/map_reduce_merge.js - - jstests/concurrency/fsm_workloads/map_reduce_reduce.js - - jstests/concurrency/fsm_workloads/map_reduce_replace.js - - jstests/concurrency/fsm_workloads/map_reduce_replace_nonexistent.js - - jstests/concurrency/fsm_workloads/map_reduce_replace_remove.js - # Disabled due to MongoDB restrictions and/or workload restrictions # These workloads sometimes trigger 'Could not lock auth data update lock' diff --git a/buildscripts/resmokeconfig/suites/concurrency_sharded_local_read_write_multi_stmt_txn_with_balancer.yml b/buildscripts/resmokeconfig/suites/concurrency_sharded_local_read_write_multi_stmt_txn_with_balancer.yml index 67e6ce6cc47..246c0fa8202 100644 --- a/buildscripts/resmokeconfig/suites/concurrency_sharded_local_read_write_multi_stmt_txn_with_balancer.yml +++ b/buildscripts/resmokeconfig/suites/concurrency_sharded_local_read_write_multi_stmt_txn_with_balancer.yml @@ -26,17 +26,6 @@ selector: - jstests/concurrency/fsm_workloads/agg_graph_lookup.js - jstests/concurrency/fsm_workloads/view_catalog_cycle_lookup.js - # Disabled due to SERVER-20057, 'Concurrent, sharded mapReduces can fail when temporary - # namespaces collide across mongos processes' - - jstests/concurrency/fsm_workloads/map_reduce_drop.js - - jstests/concurrency/fsm_workloads/map_reduce_inline.js - - jstests/concurrency/fsm_workloads/map_reduce_interrupt.js - - jstests/concurrency/fsm_workloads/map_reduce_merge.js - - jstests/concurrency/fsm_workloads/map_reduce_reduce.js - - jstests/concurrency/fsm_workloads/map_reduce_replace.js - - jstests/concurrency/fsm_workloads/map_reduce_replace_nonexistent.js - - jstests/concurrency/fsm_workloads/map_reduce_replace_remove.js - # Disabled due to MongoDB restrictions and/or workload restrictions # These workloads sometimes trigger 'Could not lock auth data update lock' diff --git a/buildscripts/resmokeconfig/suites/concurrency_sharded_multi_stmt_txn.yml b/buildscripts/resmokeconfig/suites/concurrency_sharded_multi_stmt_txn.yml index 3a337cf68eb..d628ea71cc2 100644 --- a/buildscripts/resmokeconfig/suites/concurrency_sharded_multi_stmt_txn.yml +++ b/buildscripts/resmokeconfig/suites/concurrency_sharded_multi_stmt_txn.yml @@ -26,17 +26,6 @@ selector: - jstests/concurrency/fsm_workloads/agg_graph_lookup.js - jstests/concurrency/fsm_workloads/view_catalog_cycle_lookup.js - # Disabled due to SERVER-20057, 'Concurrent, sharded mapReduces can fail when temporary - # namespaces collide across mongos processes' - - jstests/concurrency/fsm_workloads/map_reduce_drop.js - - jstests/concurrency/fsm_workloads/map_reduce_inline.js - - jstests/concurrency/fsm_workloads/map_reduce_interrupt.js - - jstests/concurrency/fsm_workloads/map_reduce_merge.js - - jstests/concurrency/fsm_workloads/map_reduce_reduce.js - - jstests/concurrency/fsm_workloads/map_reduce_replace.js - - jstests/concurrency/fsm_workloads/map_reduce_replace_nonexistent.js - - jstests/concurrency/fsm_workloads/map_reduce_replace_remove.js - # Disabled due to MongoDB restrictions and/or workload restrictions # These workloads sometimes trigger 'Could not lock auth data update lock' 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 7e5e06da476..e9c2e7c6243 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 @@ -41,6 +41,7 @@ selector: - jstests/concurrency/fsm_workloads/map_reduce_replace.js - jstests/concurrency/fsm_workloads/map_reduce_replace_nonexistent.js - jstests/concurrency/fsm_workloads/map_reduce_replace_remove.js + - jstests/concurrency/fsm_workloads/map_reduce_with_chunk_migrations.js # Disabled due to MongoDB restrictions and/or workload restrictions 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 3fd5309bc2e..3b79ce60006 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 @@ -41,6 +41,7 @@ selector: - jstests/concurrency/fsm_workloads/map_reduce_replace.js - jstests/concurrency/fsm_workloads/map_reduce_replace_nonexistent.js - jstests/concurrency/fsm_workloads/map_reduce_replace_remove.js + - jstests/concurrency/fsm_workloads/map_reduce_with_chunk_migrations.js # Disabled due to MongoDB restrictions and/or workload restrictions diff --git a/buildscripts/resmokeconfig/suites/concurrency_sharded_multi_stmt_txn_with_balancer.yml b/buildscripts/resmokeconfig/suites/concurrency_sharded_multi_stmt_txn_with_balancer.yml index ca4b35b5650..5f7e2e324d1 100644 --- a/buildscripts/resmokeconfig/suites/concurrency_sharded_multi_stmt_txn_with_balancer.yml +++ b/buildscripts/resmokeconfig/suites/concurrency_sharded_multi_stmt_txn_with_balancer.yml @@ -26,17 +26,6 @@ selector: - jstests/concurrency/fsm_workloads/agg_graph_lookup.js - jstests/concurrency/fsm_workloads/view_catalog_cycle_lookup.js - # Disabled due to SERVER-20057, 'Concurrent, sharded mapReduces can fail when temporary - # namespaces collide across mongos processes' - - jstests/concurrency/fsm_workloads/map_reduce_drop.js - - jstests/concurrency/fsm_workloads/map_reduce_inline.js - - jstests/concurrency/fsm_workloads/map_reduce_interrupt.js - - jstests/concurrency/fsm_workloads/map_reduce_merge.js - - jstests/concurrency/fsm_workloads/map_reduce_reduce.js - - jstests/concurrency/fsm_workloads/map_reduce_replace.js - - jstests/concurrency/fsm_workloads/map_reduce_replace_nonexistent.js - - jstests/concurrency/fsm_workloads/map_reduce_replace_remove.js - # Disabled due to MongoDB restrictions and/or workload restrictions # These workloads sometimes trigger 'Could not lock auth data update lock' 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 f27d4b3df7c..eba68494ef9 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 @@ -31,17 +31,6 @@ selector: - jstests/concurrency/fsm_workloads/agg_graph_lookup.js - jstests/concurrency/fsm_workloads/view_catalog_cycle_lookup.js - # Disabled due to SERVER-20057, 'Concurrent, sharded mapReduces can fail when temporary - # namespaces collide across mongos processes' - - jstests/concurrency/fsm_workloads/map_reduce_drop.js - - jstests/concurrency/fsm_workloads/map_reduce_inline.js - - jstests/concurrency/fsm_workloads/map_reduce_interrupt.js - - jstests/concurrency/fsm_workloads/map_reduce_merge.js - - jstests/concurrency/fsm_workloads/map_reduce_reduce.js - - jstests/concurrency/fsm_workloads/map_reduce_replace.js - - jstests/concurrency/fsm_workloads/map_reduce_replace_nonexistent.js - - jstests/concurrency/fsm_workloads/map_reduce_replace_remove.js - # Disabled due to MongoDB restrictions and/or workload restrictions # These workloads sometimes trigger 'Could not lock auth data update lock' diff --git a/buildscripts/resmokeconfig/suites/concurrency_sharded_replication.yml b/buildscripts/resmokeconfig/suites/concurrency_sharded_replication.yml index 8b49a9667e1..022390913be 100644 --- a/buildscripts/resmokeconfig/suites/concurrency_sharded_replication.yml +++ b/buildscripts/resmokeconfig/suites/concurrency_sharded_replication.yml @@ -22,17 +22,6 @@ selector: - jstests/concurrency/fsm_workloads/agg_graph_lookup.js - jstests/concurrency/fsm_workloads/view_catalog_cycle_lookup.js - # Disabled due to SERVER-20057, 'Concurrent, sharded mapReduces can fail when temporary - # namespaces collide across mongos processes' - - jstests/concurrency/fsm_workloads/map_reduce_drop.js - - jstests/concurrency/fsm_workloads/map_reduce_inline.js - - jstests/concurrency/fsm_workloads/map_reduce_interrupt.js - - jstests/concurrency/fsm_workloads/map_reduce_merge.js - - jstests/concurrency/fsm_workloads/map_reduce_reduce.js - - jstests/concurrency/fsm_workloads/map_reduce_replace.js - - jstests/concurrency/fsm_workloads/map_reduce_replace_nonexistent.js - - jstests/concurrency/fsm_workloads/map_reduce_replace_remove.js - # Disabled due to MongoDB restrictions and/or workload restrictions # These workloads sometimes trigger 'Could not lock auth data update lock' diff --git a/buildscripts/resmokeconfig/suites/concurrency_sharded_replication_with_balancer.yml b/buildscripts/resmokeconfig/suites/concurrency_sharded_replication_with_balancer.yml index 5b8e6519f26..06f789f1c30 100644 --- a/buildscripts/resmokeconfig/suites/concurrency_sharded_replication_with_balancer.yml +++ b/buildscripts/resmokeconfig/suites/concurrency_sharded_replication_with_balancer.yml @@ -25,17 +25,6 @@ selector: - jstests/concurrency/fsm_workloads/agg_graph_lookup.js - jstests/concurrency/fsm_workloads/view_catalog_cycle_lookup.js - # Disabled due to SERVER-20057, 'Concurrent, sharded mapReduces can fail when temporary - # namespaces collide across mongos processes' - - jstests/concurrency/fsm_workloads/map_reduce_drop.js - - jstests/concurrency/fsm_workloads/map_reduce_inline.js - - jstests/concurrency/fsm_workloads/map_reduce_interrupt.js - - jstests/concurrency/fsm_workloads/map_reduce_merge.js - - jstests/concurrency/fsm_workloads/map_reduce_reduce.js - - jstests/concurrency/fsm_workloads/map_reduce_replace.js - - jstests/concurrency/fsm_workloads/map_reduce_replace_nonexistent.js - - jstests/concurrency/fsm_workloads/map_reduce_replace_remove.js - # Disabled due to MongoDB restrictions and/or workload restrictions # These workloads sometimes trigger 'Could not lock auth data update lock' diff --git a/buildscripts/resmokeconfig/suites/concurrency_sharded_with_stepdowns.yml b/buildscripts/resmokeconfig/suites/concurrency_sharded_with_stepdowns.yml index 5aac53747b7..a6a11be3b67 100644 --- a/buildscripts/resmokeconfig/suites/concurrency_sharded_with_stepdowns.yml +++ b/buildscripts/resmokeconfig/suites/concurrency_sharded_with_stepdowns.yml @@ -22,8 +22,7 @@ selector: - jstests/concurrency/fsm_workloads/agg_graph_lookup.js - jstests/concurrency/fsm_workloads/view_catalog_cycle_lookup.js - # Disabled due to SERVER-20057, 'Concurrent, sharded mapReduces can fail when temporary - # namespaces collide across mongos processes' + # Disabled pending investigation in SERVER-43251. - jstests/concurrency/fsm_workloads/map_reduce_drop.js - jstests/concurrency/fsm_workloads/map_reduce_inline.js - jstests/concurrency/fsm_workloads/map_reduce_interrupt.js diff --git a/buildscripts/resmokeconfig/suites/concurrency_sharded_with_stepdowns_and_balancer.yml b/buildscripts/resmokeconfig/suites/concurrency_sharded_with_stepdowns_and_balancer.yml index 31394bad9fc..1185566451b 100644 --- a/buildscripts/resmokeconfig/suites/concurrency_sharded_with_stepdowns_and_balancer.yml +++ b/buildscripts/resmokeconfig/suites/concurrency_sharded_with_stepdowns_and_balancer.yml @@ -25,8 +25,7 @@ selector: - jstests/concurrency/fsm_workloads/agg_graph_lookup.js - jstests/concurrency/fsm_workloads/view_catalog_cycle_lookup.js - # Disabled due to SERVER-20057, 'Concurrent, sharded mapReduces can fail when temporary - # namespaces collide across mongos processes' + # Disabled pending investigation in SERVER-43251. - jstests/concurrency/fsm_workloads/map_reduce_drop.js - jstests/concurrency/fsm_workloads/map_reduce_inline.js - jstests/concurrency/fsm_workloads/map_reduce_interrupt.js diff --git a/buildscripts/resmokeconfig/suites/concurrency_simultaneous.yml b/buildscripts/resmokeconfig/suites/concurrency_simultaneous.yml index 81e56d57edc..6df807aad19 100644 --- a/buildscripts/resmokeconfig/suites/concurrency_simultaneous.yml +++ b/buildscripts/resmokeconfig/suites/concurrency_simultaneous.yml @@ -29,6 +29,10 @@ selector: - jstests/concurrency/fsm_workloads/collmod_writeconflict.js - jstests/concurrency/fsm_workloads/reindex_writeconflict.js + # This test is not compatible with the other mapReduce FSM tests since it requires the + # 'internalQueryUseAggMapReduce' knob to be false while the other tests explicitly set it to true. + - jstests/concurrency/fsm_workloads/map_reduce_reduce.js + exclude_with_any_tags: - uses_transactions - requires_replication diff --git a/buildscripts/resmokeconfig/suites/concurrency_simultaneous_replication.yml b/buildscripts/resmokeconfig/suites/concurrency_simultaneous_replication.yml index 03a8a95756f..ce4cead3db5 100644 --- a/buildscripts/resmokeconfig/suites/concurrency_simultaneous_replication.yml +++ b/buildscripts/resmokeconfig/suites/concurrency_simultaneous_replication.yml @@ -44,6 +44,10 @@ selector: - jstests/concurrency/fsm_workloads/collmod_writeconflict.js - jstests/concurrency/fsm_workloads/reindex_writeconflict.js + # This test is not compatible with the other mapReduce FSM tests since it requires the + # 'internalQueryUseAggMapReduce' knob to be false while the other tests explicitly set it to true. + - jstests/concurrency/fsm_workloads/map_reduce_reduce.js + exclude_with_any_tags: - requires_sharding diff --git a/buildscripts/resmokeconfig/suites/concurrency_simultaneous_replication_wiredtiger_cursor_sweeps.yml b/buildscripts/resmokeconfig/suites/concurrency_simultaneous_replication_wiredtiger_cursor_sweeps.yml index 048f20abce5..0f1984ec4ff 100644 --- a/buildscripts/resmokeconfig/suites/concurrency_simultaneous_replication_wiredtiger_cursor_sweeps.yml +++ b/buildscripts/resmokeconfig/suites/concurrency_simultaneous_replication_wiredtiger_cursor_sweeps.yml @@ -44,6 +44,10 @@ selector: - jstests/concurrency/fsm_workloads/collmod_writeconflict.js - jstests/concurrency/fsm_workloads/reindex_writeconflict.js + # This test is not compatible with the other mapReduce FSM tests since it requires the + # 'internalQueryUseAggMapReduce' knob to be false while the other tests explicitly set it to true. + - jstests/concurrency/fsm_workloads/map_reduce_reduce.js + exclude_with_any_tags: - requires_sharding diff --git a/buildscripts/resmokeconfig/suites/concurrency_simultaneous_replication_wiredtiger_eviction_debug.yml b/buildscripts/resmokeconfig/suites/concurrency_simultaneous_replication_wiredtiger_eviction_debug.yml index c068ce14806..9ab48d8c9dc 100644 --- a/buildscripts/resmokeconfig/suites/concurrency_simultaneous_replication_wiredtiger_eviction_debug.yml +++ b/buildscripts/resmokeconfig/suites/concurrency_simultaneous_replication_wiredtiger_eviction_debug.yml @@ -44,6 +44,10 @@ selector: - jstests/concurrency/fsm_workloads/collmod_writeconflict.js - jstests/concurrency/fsm_workloads/reindex_writeconflict.js + # This test is not compatible with the other mapReduce FSM tests since it requires the + # 'internalQueryUseAggMapReduce' knob to be false while the other tests explicitly set it to true. + - jstests/concurrency/fsm_workloads/map_reduce_reduce.js + exclude_with_any_tags: - requires_sharding diff --git a/jstests/concurrency/fsm_workloads/map_reduce_inline.js b/jstests/concurrency/fsm_workloads/map_reduce_inline.js index 94382b1fe70..268fc1460d7 100644 --- a/jstests/concurrency/fsm_workloads/map_reduce_inline.js +++ b/jstests/concurrency/fsm_workloads/map_reduce_inline.js @@ -61,25 +61,23 @@ var $config = (function() { var transitions = {init: {mapReduce: 1}, mapReduce: {mapReduce: 1}}; - function makeDoc(keyLimit, valueLimit) { - return { - _id: new ObjectId(), - key: Random.randInt(keyLimit), - value: Random.randInt(valueLimit) - }; - } - function setup(db, collName, cluster) { var bulk = db[collName].initializeUnorderedBulkOp(); for (var i = 0; i < this.numDocs; ++i) { // TODO: this actually does assume that there are no unique indexes - var doc = makeDoc(this.numDocs / 100, this.numDocs / 10); - bulk.insert(doc); + bulk.insert({ + _id: i, + key: Random.randInt(this.numDocs / 100), + value: Random.randInt(this.numDocs / 10) + }); } var res = bulk.execute(); assertAlways.commandWorked(res); assertAlways.eq(this.numDocs, res.nInserted); + + assert.commandWorked( + db.adminCommand({setParameter: 1, internalQueryUseAggMapReduce: true})); } return { diff --git a/jstests/concurrency/fsm_workloads/map_reduce_reduce.js b/jstests/concurrency/fsm_workloads/map_reduce_reduce.js index 86d3733df9c..99207cd5832 100644 --- a/jstests/concurrency/fsm_workloads/map_reduce_reduce.js +++ b/jstests/concurrency/fsm_workloads/map_reduce_reduce.js @@ -28,6 +28,12 @@ var $config = extendWorkload($config, function($config, $super) { } $config.states.init = function init(db, collName) { + // TODO SERVER-44150: Cannot run MR with output 'reduce' in agg since the 'whenMatched' + // pipeline will always run which can cause unexpected failures in the user-specified reduce + // function. + assert.commandWorked( + db.adminCommand({setParameter: 1, internalQueryUseAggMapReduce: false})); + $super.states.init.apply(this, arguments); this.outCollName = uniqueCollectionName(prefix, this.tid); @@ -40,7 +46,6 @@ var $config = extendWorkload($config, function($config, $super) { "output collection '" + fullName + "' should exist"); var options = {finalize: this.finalizer, out: {reduce: this.outCollName}}; - var res = db[collName].mapReduce(this.mapper, this.reducer, options); assertAlways.commandWorked(res); }; diff --git a/jstests/concurrency/fsm_workloads/map_reduce_replace_remove.js b/jstests/concurrency/fsm_workloads/map_reduce_replace_remove.js index 1bd48dce230..30225fc7c0f 100644 --- a/jstests/concurrency/fsm_workloads/map_reduce_replace_remove.js +++ b/jstests/concurrency/fsm_workloads/map_reduce_replace_remove.js @@ -21,8 +21,7 @@ load('jstests/concurrency/fsm_workloads/map_reduce_replace.js'); // for $config var $config = extendWorkload($config, function($config, $super) { $config.states.remove = function remove(db, collName) { for (var i = 0; i < 20; ++i) { - var res = db[collName].remove({value: {$gte: Random.randInt(this.numDocs / 10)}}, - {justOne: true}); + var res = db[collName].remove({_id: Random.randInt(this.numDocs)}, {justOne: true}); assertAlways.commandWorked(res); assertAlways.lte(0, res.nRemoved, tojson(res)); } diff --git a/jstests/concurrency/fsm_workloads/map_reduce_with_chunk_migrations.js b/jstests/concurrency/fsm_workloads/map_reduce_with_chunk_migrations.js new file mode 100644 index 00000000000..df4cee9c472 --- /dev/null +++ b/jstests/concurrency/fsm_workloads/map_reduce_with_chunk_migrations.js @@ -0,0 +1,106 @@ +'use strict'; + +/** + * map_reduce_with_chunk_migrations.js + * + * This tests exercises mapReduce on a collection during chunk migrations. If extending this + * workload, consider overriding the following: + * + * $config.data.collWithMigrations: collection to run chunk migrations against (default is the + * input collection of the mapReduce). + * $config.state.mapReduce: function to execute the mapReduce. + * + * @tags: [ + * requires_sharding, assumes_balancer_off, + * assumes_autosplit_off, + * requires_non_retryable_writes, + * # mapReduce does not support afterClusterTime. + * does_not_support_causal_consistency + * ] + */ +load('jstests/concurrency/fsm_libs/extend_workload.js'); // for extendWorkload +load('jstests/concurrency/fsm_workloads/sharded_moveChunk_partitioned.js'); // for $config + +var $config = extendWorkload($config, function($config, $super) { + // The base setup will insert 'partitionSize' number of documents per thread, evenly + // distributing across the chunks. Documents will only have the "_id" field. + $config.data.partitionSize = 50; + $config.threadCount = 2; + $config.iterations = 100; + $config.data.numDocs = $config.data.partitionSize * $config.threadCount; + + // By default, the collection that will be sharded with concurrent chunk migrations will be the + // one that the aggregate is run against. + $config.data.collWithMigrations = $config.collName; + $config.data.resultsCollection = "map_reduce_with_chunk_migrations_out"; + + $config.transitions = { + init: {mapReduce: 1}, + mapReduce: { + moveChunk: 0.2, + mapReduce: 0.8, + }, + moveChunk: {mapReduce: 1}, + }; + + /** + * Moves a random chunk in the target collection. + */ + $config.states.moveChunk = function moveChunk(db, collName, connCache) { + $super.states.moveChunk.apply(this, [db, this.collWithMigrations, connCache]); + }; + + /** + * Executes a mapReduce with output mode "replace". + */ + $config.states.mapReduce = function mapReduce(db, collName, connCache) { + const map = function() { + emit(this._id, 1); + }; + const reduce = function(k, values) { + return Array.sum(values); + }; + + const res = db[collName].mapReduce(map, reduce, {out: {replace: this.resultsCollection}}); + assertWhenOwnColl.commandWorked(res); + + // TODO SERVER-43290 Support for cluster stats should be able to enable this check. + // assertWhenOwnColl.eq( + // this.numDocs, res.counts.output, `Expected each _id to be output once: + // ${tojson(res)}`); + }; + + /** + * Uses the base class init() to initialize this thread for both collections. + */ + $config.states.init = function init(db, collName, connCache) { + $super.states.init.apply(this, [db, collName, connCache]); + + // Init the target collection in a similar manner, if it is different than the default + // collection. + if (collName != this.collWithMigrations) { + $super.states.init.apply(this, [db, this.collWithMigrations, connCache]); + } + }; + + /** + * Initializes the aggregate collection and the target collection for chunk migrations as + * sharded with an even distribution across each thread ID. + */ + $config.setup = function setup(db, collName, cluster) { + $super.setup.apply(this, [db, collName, cluster]); + + if (collName != this.collWithMigrations) { + // Setup the target collection in a similar manner. Note that the FSM infrastructure + // will have already enabled sharded on collName, but we need to manually do it for the + // output collection. + cluster.shardCollection(db[this.collWithMigrations], this.shardKey, false); + $super.setup.apply(this, [db, this.collWithMigrations, cluster]); + } + + assert.commandWorked( + db.adminCommand({setParameter: 1, internalQueryUseAggMapReduce: true})); + }; + + return $config; +}); diff --git a/src/mongo/db/commands/map_reduce_agg_test.cpp b/src/mongo/db/commands/map_reduce_agg_test.cpp index 1f79f718038..ada484ac475 100644 --- a/src/mongo/db/commands/map_reduce_agg_test.cpp +++ b/src/mongo/db/commands/map_reduce_agg_test.cpp @@ -98,7 +98,7 @@ TEST(MapReduceAggTest, testSortWithoutLimit) { auto iter = sources.begin(); ASSERT(typeid(DocumentSourceSort) == typeid(**iter)); auto& sort = dynamic_cast<DocumentSourceSort&>(**iter++); - ASSERT_EQ(-1ll, *sort.getLimit()); + ASSERT(sort.getLimit() == boost::none); ASSERT(typeid(DocumentSourceSingleDocumentTransformation) == typeid(**iter++)); ASSERT(typeid(DocumentSourceUnwind) == typeid(**iter++)); ASSERT(typeid(DocumentSourceGroup) == typeid(**iter)); diff --git a/src/mongo/db/commands/mr_common.cpp b/src/mongo/db/commands/mr_common.cpp index e1595bea415..68ce716f0f5 100644 --- a/src/mongo/db/commands/mr_common.cpp +++ b/src/mongo/db/commands/mr_common.cpp @@ -68,7 +68,7 @@ using namespace std::string_literals; auto translateSort(boost::intrusive_ptr<ExpressionContext> expCtx, const BSONObj& sort, const boost::optional<std::int64_t>& limit) { - return DocumentSourceSort::create(expCtx, sort, limit.get_value_or(-1)); + return DocumentSourceSort::create(expCtx, sort, limit.get_value_or(0)); } auto translateMap(boost::intrusive_ptr<ExpressionContext> expCtx, std::string code) { |