Skip to content

Commit 19c0b59

Browse files
committed
SERVER-42349 Write new unsharded collections to the sharding catalog under feature flag
1 parent c6c9416 commit 19c0b59

File tree

5 files changed

+663
-10
lines changed

5 files changed

+663
-10
lines changed

buildscripts/resmokeconfig/suites/sharding_continuous_config_stepdown.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ selector:
9999
- jstests/sharding/move_chunk_insert_with_write_retryability.js
100100
- jstests/sharding/move_chunk_remove_with_write_retryability.js
101101
- jstests/sharding/move_chunk_update_with_write_retryability.js
102+
- jstests/sharding/track_unsharded_collections_create_collection.js
102103
- jstests/sharding/txn_two_phase_commit_commands_basic_requirements.js
103104
- jstests/sharding/txn_two_phase_commit_coordinator_shutdown_and_restart.js
104105
- jstests/sharding/txn_two_phase_commit_failover.js

buildscripts/resmokeconfig/suites/sharding_last_stable_mongos_and_mixed_shards.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ selector:
148148
- jstests/sharding/clone_catalog_data.js
149149
- jstests/sharding/database_and_shard_versioning_all_commands.js
150150
- jstests/sharding/shard1.js
151+
- jstests/sharding/track_unsharded_collections_create_collection.js
151152
# Enable if SERVER-41813 is backported or 4.4 becomes last-stable
152153
- jstests/sharding/invalid_system_views_sharded_collection.js
153154

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
/**
2+
* Common helpers for testing operations on unsharded collections.
3+
*/
4+
5+
function getNewNs(dbName) {
6+
if (typeof getNewNs.counter == 'undefined') {
7+
getNewNs.counter = 0;
8+
}
9+
getNewNs.counter++;
10+
const collName = "ns" + getNewNs.counter;
11+
return [collName, dbName + "." + collName];
12+
}
13+
14+
function checkInStorageCatalog({dbName, collName, type, shardConn}) {
15+
const query = {name: collName, type};
16+
assert.eq(1,
17+
shardConn.getDB(dbName).getCollectionInfos(query).length,
18+
"Current contents of storage catalog on " + shardConn + ": " +
19+
tojson(shardConn.getDB(dbName).getCollectionInfos()) +
20+
", query: " + tojson(query));
21+
}
22+
23+
function checkNotInStorageCatalog({dbName, collName, shardConn}) {
24+
const query = {name: collName};
25+
assert.eq(0,
26+
shardConn.getDB(dbName).getCollectionInfos(query).length,
27+
"Current contents of storage catalog on " + shardConn + ": " +
28+
tojson(shardConn.getDB(dbName).getCollectionInfos()) +
29+
", query: " + tojson(query));
30+
}
31+
32+
function checkInShardingCatalog({ns, shardKey, unique, distributionMode, numChunks, mongosConn}) {
33+
const configDB = mongosConn.getDB("config");
34+
35+
// Check the collection entry.
36+
const collQuery = {};
37+
collQuery._id = ns;
38+
collQuery["key." + shardKey] = 1;
39+
collQuery.unique = unique;
40+
collQuery.distributionMode = distributionMode;
41+
assert.neq(null,
42+
configDB.collections.findOne(collQuery),
43+
"Current contents of config.collections: " +
44+
tojson(configDB.collections.find().toArray()) + ", query: " + tojson(collQuery));
45+
46+
// Check the chunk entries.
47+
const chunkQuery = {};
48+
chunkQuery.ns = ns;
49+
chunkQuery["min." + shardKey] = {$exists: true};
50+
chunkQuery["max." + shardKey] = {$exists: true};
51+
assert.eq(numChunks,
52+
configDB.chunks.count(chunkQuery),
53+
"Current contents of config.chunks: " + tojson(configDB.chunks.find().toArray()) +
54+
", query: " + tojson(chunkQuery));
55+
}
56+
57+
function checkNotInShardingCatalog({ns, mongosConn}) {
58+
const configDB = mongosConn.getDB("config");
59+
60+
assert.eq(
61+
null,
62+
configDB.collections.findOne({_id: ns}),
63+
"Current contents of config.collections: " + tojson(configDB.collections.find().toArray()));
64+
assert.eq(0,
65+
configDB.chunks.count({ns: ns}),
66+
"Current contents of config.chunks: " + tojson(configDB.chunks.find().toArray()));
67+
}
68+
69+
function setFailpoint(failpointName, conn) {
70+
assert.commandWorked(conn.adminCommand({
71+
configureFailPoint: failpointName,
72+
mode: "alwaysOn",
73+
}));
74+
}
75+
76+
function unsetFailpoint(failpointName, conn) {
77+
assert.commandWorked(conn.adminCommand({
78+
configureFailPoint: failpointName,
79+
mode: "off",
80+
}));
81+
}

0 commit comments

Comments
 (0)