diff options
author | Randolph Tan <randolph@10gen.com> | 2020-07-23 20:13:50 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-08-01 01:21:21 +0000 |
commit | b9353930bcb5387857620f1d45fb87b79f4a0064 (patch) | |
tree | edfb570765fe1259692ceedb00e1b9798ccc0797 /src/mongo/db | |
parent | d57c783b60d548c3173058d70343537b6df6c1e9 (diff) | |
download | mongo-b9353930bcb5387857620f1d45fb87b79f4a0064.tar.gz |
SERVER-48264 Don't invariant when task is cancelled by the executor
Diffstat (limited to 'src/mongo/db')
-rw-r--r-- | src/mongo/db/s/shard_server_catalog_cache_loader.cpp | 50 |
1 files changed, 34 insertions, 16 deletions
diff --git a/src/mongo/db/s/shard_server_catalog_cache_loader.cpp b/src/mongo/db/s/shard_server_catalog_cache_loader.cpp index 0f1b153397c..dbd1f38f8e2 100644 --- a/src/mongo/db/s/shard_server_catalog_cache_loader.cpp +++ b/src/mongo/db/s/shard_server_catalog_cache_loader.cpp @@ -896,7 +896,13 @@ void ShardServerCatalogCacheLoader::_ensureMajorityPrimaryAndScheduleCollAndChun } _executor->schedule([this, nss](auto status) { - invariant(status); + if (!status.isOK()) { + if (ErrorCodes::isCancelationError(status)) { + return; + } + + fassertFailedWithStatus(4826400, status); + } _runCollAndChunksTasks(nss); }); @@ -918,7 +924,13 @@ void ShardServerCatalogCacheLoader::_ensureMajorityPrimaryAndScheduleDbTask(Oper } _executor->schedule([this, name = dbName.toString()](auto status) { - invariant(status); + if (!status.isOK()) { + if (ErrorCodes::isCancelationError(status)) { + return; + } + + fassertFailedWithStatus(4826401, status); + } _runDbTasks(name); }); @@ -972,7 +984,12 @@ void ShardServerCatalogCacheLoader::_runCollAndChunksTasks(const NamespaceString } } - _executor->schedule([this, nss](auto status) { + _executor->schedule([this, nss](Status status) { + if (status.isOK()) { + _runCollAndChunksTasks(nss); + return; + } + if (ErrorCodes::isCancelationError(status.code())) { LOGV2(22096, "Cache loader failed to schedule a persisted metadata update task for namespace " @@ -988,11 +1005,9 @@ void ShardServerCatalogCacheLoader::_runCollAndChunksTasks(const NamespaceString stdx::lock_guard<Latch> lock(_mutex); _collAndChunkTaskLists.erase(nss); } - return; + } else { + fassertFailedWithStatus(4826402, status); } - invariant(status); - - _runCollAndChunksTasks(nss); }); } @@ -1044,26 +1059,29 @@ void ShardServerCatalogCacheLoader::_runDbTasks(StringData dbName) { } _executor->schedule([this, name = dbName.toString()](auto status) { + if (status.isOK()) { + _runDbTasks(name); + return; + } + if (ErrorCodes::isCancelationError(status.code())) { LOGV2(22099, - "Cache loader failed to schedule a persisted metadata update task for namespace " - "{namespace} due to {error}. Clearing task list so that scheduling will be " - "attempted by the next caller to refresh this namespace", + "Cache loader failed to schedule a persisted metadata update task for database " + "{database} due to {error}. Clearing task list so that scheduling will be " + "attempted by the next caller to refresh this database", "Cache loader failed to schedule a persisted metadata update task. Clearing task " "list so that scheduling will be attempted by the next caller to refresh this " - "namespace", - "namespace"_attr = name, + "database", + "database"_attr = name, "error"_attr = redact(status)); { stdx::lock_guard<Latch> lock(_mutex); _dbTaskLists.erase(name); } - return; + } else { + fassertFailedWithStatus(4826403, status); } - invariant(status); - - _runDbTasks(name); }); } |