[SERVER-84368] CreateIndex fails with StaleConfig if run from a stale mongos against a sharded non-empty collection Created: 21/Dec/23  Updated: 30/Jan/24  Resolved: 25/Jan/24

Status: Closed
Project: Core Server
Component/s: Sharding
Affects Version/s: None
Fix Version/s: 8.0.0-rc0

Type: Bug Priority: Major - P3
Reporter: Enrico Golfieri Assignee: Marcos José Grillo Ramirez
Resolution: Fixed Votes: 0
Labels: car-qw, investigation
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Depends
is depended on by SERVER-81190 Support tracking "simple" unsharded c... Closed
Related
related to SERVER-69776 Increase test coverage for concurrent... Open
Assigned Teams:
Catalog and Routing
Backwards Compatibility: Fully Compatible
Operating System: ALL
Backport Requested:
v7.3, v7.0, v6.0, v5.0
Steps To Reproduce:

const dbName = 'testDB';
const collName = 'testColl';
const bucketsCollName = 'system.buckets.' + collName;
const timeField = 'time';
const metaField = 'hostid';
// Connections.
 
const st = new ShardingTest({mongos: 2, shards: 2, rs: {nodes: 2}});
const mongos0 = st.s0.getDB(dbName);
const mongos1 = st.s1.getDB(dbName);
const shard0DB = st.shard0.getDB(dbName);
const shard1DB = st.shard1.getDB(dbName);
 
// Insert some dummy data using 'mongos1' as the router, so that the cache is
// initialized on the mongos while the collection is unsharded.
assert.commandWorked(
mongos1.adminCommand({shardCollection: `${dbName}.${collName}`, key: {_id: 1}}));
assert.commandWorked(mongos1.getCollection(collName).insert({_id: "aaa"}));
 
// Drop and shard the collection with 'mongos0' as the router.
assert(mongos0.getCollection(collName).drop());
 
const shardKey =

{ [metaField]: 1 }

;
assert.commandWorked(mongos0.adminCommand({
shardCollection: `${dbName}.${collName}`,
key: shardKey,
timeseries: {timeField: timeField, metaField: metaField}
}));
 
let cmdObj = {createIndexes: collName, indexes: [{key:

{[timeField]: 1}

, name: "index_on_time"}]};
assert.commandWorked(mongos1.runCommand(cmdObj));
 
st.stop();

Sprint: CAR Team 2024-01-22, CAR Team 2024-02-05
Participants:
Story Points: 2

 Description   

Currently spotted a bug where given 2 mongos:

  • mongos1 : create a non-empty sharded collection
  • mongos2: drop the collection and shards it as timeseries

in case mongos1 (which is now stale) runs createIndex it will fail 10 times without trying a refresh. 

I attached a test to reproduce the error which is unclear.
The goal of the ticket is to investigate what is causing this issue.

Important notes:

  • the issue does not happen if mongos1 creates an empty sharded collection (skip the insert)
  • the issue does not happen if mongos2 creates a non-timeseries sharded collection
  • the issue only happens because mongos1 does not refresh, but attempts again with the same version for 10 times

The ticket is necessary for track unsharded collection since after SERVER-81190 it will happen even if mongos1 just runs a insert. 

Once the ticket is done, please fix the TODO



 Comments   
Comment by Githook User [ 24/Jan/24 ]

Author:

{'name': 'Marcos Grillo', 'email': 'marcos.grillo@mongodb.com', 'username': 'm4nti5'}

Message: SERVER-84368 Invalidate catalog cache original nss if staleInfo exception is received for timeseries collection (#18004)

SERVER-84368 Invalidate catalog cache original nss if staleInfo
exception is received for timeseries collection

Co-authored-by: Allison Easton <allison.easton@mongodb.com>
GitOrigin-RevId: b5f58d8cc3853c3bdecba44bf3fdf419fa200cf8
Branch: master
https://github.com/mongodb/mongo/commit/c10df9849621573d5bdf470b2ea69a6253a36521

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