Skip to content

Commit 79e8901

Browse files
jordistEvergreen Agent
authored andcommitted
SERVER-82810 dropAggTempCollections should accept NamespaceNotFound errors due to the db having been dropped
1 parent b979bb2 commit 79e8901

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

jstests/noPassthrough/out_cleans_up_temp_collections_sharding.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ function failFn_killOp() {
6060
adminDB.killOp(curOps[0].opid);
6161
}
6262

63+
function failFn_dropDbAndSigKill() {
64+
testDB.dropDatabase();
65+
failFn_sigkill();
66+
}
67+
6368
function testFn(timeseries, failFn) {
6469
assert.eq(0, getTempCollections().length);
6570

@@ -105,6 +110,10 @@ function testFn(timeseries, failFn) {
105110
jsTest.log("Running test with normal collection and SIGKILL");
106111
testFn(false, failFn_sigkill);
107112

113+
jsTest.log("Running test with normal collection and dropDbAndSigKill");
114+
testFn(false, failFn_dropDbAndSigKill);
115+
assert.commandWorked(sourceColl.insert({x: 1}));
116+
108117
jsTest.log("Running test with normal collection and killOp");
109118
testFn(false, failFn_killOp);
110119

src/mongo/db/s/drop_agg_temp_collections.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,15 @@ void dropAggTempCollections(OperationContext* opCtx) {
9292

9393
try {
9494
dropTempCollection(opCtx.get(), nss);
95+
} catch (const ExceptionFor<ErrorCodes::NamespaceNotFound>&) {
96+
// The database might have been dropped by a different operation, so the temp
97+
// collection does no longer exist.
9598
} catch (const DBException& ex) {
9699
LOGV2(8144400,
97100
"Failed to drop temporary aggregation collection",
98101
logAttrs(nss),
99102
"error"_attr = redact(ex.toString()));
103+
// Do not remove the temporary collection entry.
100104
continue;
101105
}
102106

0 commit comments

Comments
 (0)