-
-
Notifications
You must be signed in to change notification settings - Fork 148
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add missing MongoDB sharding configuration for version vectors (#1097)
This commit adds the missing MongoDB sharding configuration for versionvectors collection introduced in PR #1047, as well as updates the related documentation to reflect these changes.
- Loading branch information
1 parent
e3045dc
commit c9a86db
Showing
4 changed files
with
61 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,46 @@ | ||
sh.addShard("shard-rs-1/shard1-1:27017") | ||
sh.addShard("shard-rs-2/shard2-1:27017") | ||
sh.addShard("shard-rs-1/shard1-1:27017"); | ||
sh.addShard("shard-rs-2/shard2-1:27017"); | ||
|
||
function findAnotherShard(shard) { | ||
if (shard == "shard-rs-1") { | ||
return "shard-rs-2" | ||
} else { | ||
return "shard-rs-1" | ||
} | ||
if (shard == "shard-rs-1") { | ||
return "shard-rs-2"; | ||
} else { | ||
return "shard-rs-1"; | ||
} | ||
} | ||
|
||
function shardOfChunk(minKeyOfChunk) { | ||
return db.getSiblingDB("config").chunks.findOne({ min: { project_id: minKeyOfChunk } }).shard | ||
return db | ||
.getSiblingDB("config") | ||
.chunks.findOne({ min: { project_id: minKeyOfChunk } }).shard; | ||
} | ||
|
||
// Shard the database for the mongo client test | ||
const mongoClientDB = "test-yorkie-meta-mongo-client" | ||
sh.enableSharding(mongoClientDB) | ||
sh.shardCollection(mongoClientDB + ".clients", { project_id: 1 }) | ||
sh.shardCollection(mongoClientDB + ".documents", { project_id: 1 }) | ||
sh.shardCollection(mongoClientDB + ".changes", { doc_id: 1 }) | ||
sh.shardCollection(mongoClientDB + ".snapshots", { doc_id: 1 }) | ||
sh.shardCollection(mongoClientDB + ".syncedseqs", { doc_id: 1 }) | ||
const mongoClientDB = "test-yorkie-meta-mongo-client"; | ||
sh.enableSharding(mongoClientDB); | ||
sh.shardCollection(mongoClientDB + ".clients", { project_id: 1 }); | ||
sh.shardCollection(mongoClientDB + ".documents", { project_id: 1 }); | ||
sh.shardCollection(mongoClientDB + ".changes", { doc_id: 1 }); | ||
sh.shardCollection(mongoClientDB + ".snapshots", { doc_id: 1 }); | ||
sh.shardCollection(mongoClientDB + ".syncedseqs", { doc_id: 1 }); | ||
sh.shardCollection(mongoClientDB + ".versionvectors", { doc_id: 1 }); | ||
|
||
// Split the inital range at `splitPoint` to allow doc_ids duplicate in different shards. | ||
const splitPoint = ObjectId("500000000000000000000000") | ||
sh.splitAt(mongoClientDB + ".documents", { project_id: splitPoint }) | ||
const splitPoint = ObjectId("500000000000000000000000"); | ||
sh.splitAt(mongoClientDB + ".documents", { project_id: splitPoint }); | ||
// Move the chunk to another shard. | ||
db.adminCommand({ moveChunk: mongoClientDB + ".documents", find: { project_id: splitPoint }, to: findAnotherShard(shardOfChunk(splitPoint)) }) | ||
db.adminCommand({ | ||
moveChunk: mongoClientDB + ".documents", | ||
find: { project_id: splitPoint }, | ||
to: findAnotherShard(shardOfChunk(splitPoint)), | ||
}); | ||
|
||
// Shard the database for the server test | ||
const serverDB = "test-yorkie-meta-server" | ||
sh.enableSharding(serverDB) | ||
sh.shardCollection(serverDB + ".clients", { project_id: 1 }) | ||
sh.shardCollection(serverDB + ".documents", { project_id: 1 }) | ||
sh.shardCollection(serverDB + ".changes", { doc_id: 1 }) | ||
sh.shardCollection(serverDB + ".snapshots", { doc_id: 1 }) | ||
sh.shardCollection(serverDB + ".syncedseqs", { doc_id: 1 }) | ||
|
||
const serverDB = "test-yorkie-meta-server"; | ||
sh.enableSharding(serverDB); | ||
sh.shardCollection(serverDB + ".clients", { project_id: 1 }); | ||
sh.shardCollection(serverDB + ".documents", { project_id: 1 }); | ||
sh.shardCollection(serverDB + ".changes", { doc_id: 1 }); | ||
sh.shardCollection(serverDB + ".snapshots", { doc_id: 1 }); | ||
sh.shardCollection(serverDB + ".syncedseqs", { doc_id: 1 }); | ||
sh.shardCollection(serverDB + ".versionvectors", { doc_id: 1 }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters