[SERVER-39659] router should uassert that there was no writeConcern error when processing _configsvrCreateDatabase response Created: 19/Feb/19  Updated: 29/Oct/23  Resolved: 07/Jun/19

Status: Closed
Project: Core Server
Component/s: Sharding
Affects Version/s: 3.6.10, 4.0.6, 4.1.8
Fix Version/s: 4.2.0-rc5, 4.3.1

Type: Bug Priority: Major - P3
Reporter: Esha Maharishi (Inactive) Assignee: James Heppenstall (Inactive)
Resolution: Fixed Votes: 0
Labels: neweng, sharding-interns-2019, sharding-wfbf-day
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Related
Backwards Compatibility: Fully Compatible
Operating System: ALL
Backport Requested:
v4.2
Sprint: Sharding 2019-06-17
Participants:
Linked BF Score: 6

 Description   

Currently it only uasserts on the commandStatus and then tries to refresh its cache to find the new (supposedly durable) entry for the database, which can lead to commands failing with with "Database <> not found":

        ConfigsvrCreateDatabase configCreateDatabaseRequest(dbName.toString());
        configCreateDatabaseRequest.setDbName(NamespaceString::kAdminDb);
 
        auto configShard = Grid::get(opCtx)->shardRegistry()->getConfigShard();
 
        auto createDbStatus =
            uassertStatusOK(configShard->runCommandWithFixedRetryAttempts(
                                opCtx,
                                ReadPreferenceSetting(ReadPreference::PrimaryOnly),
                                "admin",
                                CommandHelpers::appendMajorityWriteConcern(
                                    configCreateDatabaseRequest.toBSON({})),
                                Shard::RetryPolicy::kIdempotent))
                .commandStatus;
 
        if (createDbStatus.isOK() || createDbStatus == ErrorCodes::NamespaceExists) {
            dbStatus = Grid::get(opCtx)->catalogCache()->getDatabase(opCtx, dbName);
        } else {
            dbStatus = createDbStatus;
        }



 Comments   
Comment by Githook User [ 03/Jul/19 ]

Author:

{'name': 'Jamie Heppenstall', 'username': 'JamesHeppenstall', 'email': 'jamie.heppenstall@mongodb.com'}

Message: SERVER-39659 Reformat createShardDatabase to return void and call uasserts on all relevant statuses

(cherry picked from commit 0863aca0c6ad060ad241b7fa75fb03db06beccb0)
Branch: v4.2
https://github.com/mongodb/mongo/commit/6792520dc6a2a0c430c11fc264faa1e061903fbd

Comment by Githook User [ 07/Jun/19 ]

Author:

{'name': 'Jamie Heppenstall', 'email': 'jamie.heppenstall@mongodb.com'}

Message: SERVER-39659 Reformat createShardDatabase to return void and call uasserts on all relevant statuses
Branch: master
https://github.com/mongodb/mongo/commit/0863aca0c6ad060ad241b7fa75fb03db06beccb0

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