[SERVER-83403] createView fails with StaleConfig if a sharded collection already exists with the same namespace Created: 17/Nov/23  Updated: 27/Nov/23  Resolved: 27/Nov/23

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: 7.0.0, 7.2.0-rc0, 7.3.0-rc0
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Enrico Golfieri Assignee: Backlog - Catalog and Routing
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates SERVER-82791 createView fails with StaleConfig if ... Closed
Problem/Incident
is caused by SERVER-67633 Serialise explicit/implicit createCol... Closed
Assigned Teams:
Catalog and Routing
Operating System: ALL
Participants:
Story Points: 2

 Description   

repro:

 

[direct: mongos] test> sh.shardCollection('test.foo', {x: 1})
{
collectionsharded: 'test.foo',
ok: 1,
'$clusterTime': {
clusterTime: Timestamp(
{ t: 1700234597, i: 41 }
),
signature: {
hash: Binary(Buffer.from("0000000000000000000000000000000000000000", "hex"), 0),
keyId: Long("0")
}
},
operationTime: Timestamp({ t: 1700234597, i: 41 })
}
[direct: mongos] test> db.createView('foo', 'bar', [])
MongoServerError: got stale shardVersion response from shard _unknown_name_-rs0 at host ip-10-122-2-11:20000 :: caused by :: stale config in runCommand :: caused by :: timestamp mismatch detected for test.foo
[direct: mongos] test> db.createView('foo', 'bar', [])
MongoServerError: got stale shardVersion response from shard _unknown_name_-rs0 at host ip-10-122-2-11:20000 :: caused by :: stale config in runCommand :: caused by :: timestamp mismatch detected for test.foo

 

_createView checks the shardVersion for the nss. In case the collection is sharded, we expect a shardVersion which is never present. The {create} command runs always against the primary shard and only carries the dbVersion. We should check that the namespace already exists before checking the version as already done for timeseries


Generated at Thu Feb 08 06:52:05 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.