Skip to content

Commit aa14de7

Browse files
committed
Refresh uuidMap after applying shardCollection DDL change and add tests.
1 parent 245c104 commit aa14de7

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

pcsm/catalog.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1188,7 +1188,6 @@ func (c *Catalog) ShardCollection(
11881188

11891189
log.Ctx(ctx).Debugf("Sharded collection %s.%s", db, coll)
11901190

1191-
// update c.databases[db].collections[coll].sharded = true
11921191
c.lock.Lock()
11931192
databaseEntry := c.Databases[db]
11941193
collectionEntry := databaseEntry.Collections[coll]

pcsm/repl.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,7 @@ func (r *Repl) run(opts *options.ChangeStreamOptionsBuilder) {
573573
metrics.AddEventsApplied(1)
574574

575575
switch change.OperationType { //nolint:exhaustive
576-
case Create, Rename, Drop, DropDatabase:
576+
case Create, Rename, Drop, DropDatabase, ShardCollection:
577577
uuidMap = r.catalog.UUIDMap()
578578
}
579579
}
@@ -742,6 +742,8 @@ func (r *Repl) applyDDLChange(ctx context.Context, change *ChangeEvent) error {
742742
event.OperationDescription.ShardKey,
743743
event.OperationDescription.Unique)
744744

745+
lg.Infof("Collection %q has been sharded", change.Namespace)
746+
745747
case ReshardCollection:
746748
fallthrough
747749
case RefineCollectionShardKey:

tests/test_collections_sharded.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,13 @@ def test_create_collection_with_collation(t: Testing, phase: Runner.Phase):
5757
t.source.admin.command(
5858
"shardCollection", "db_1.coll_1", key={"name": 1}, collation={"locale": "simple"}
5959
)
60+
t.source["db_1"]["coll_1"].insert_many([{"name": "n3"}, {"name": "n2"}, {"name": "n3"}])
61+
62+
t.source["db_1"].create_collection("coll_2", collation={"locale": "en", "strength": 2})
63+
t.source.admin.command(
64+
"shardCollection", "db_1.coll_2", key={"_id": "hashed"}, collation={"locale": "simple"}
65+
)
66+
t.source["db_1"]["coll_2"].insert_many([{"_id": 11}, {"_id": 22}, {"_id": 33}])
6067

6168
t.compare_all_sharded()
6269

0 commit comments

Comments
 (0)