summaryrefslogtreecommitdiff
path: root/src/mongo/db/timeseries/bucket_catalog/bucket_catalog.cpp
diff options
context:
space:
mode:
authorFaustoleyva54 <fausto.leyva@mongodb.com>2023-02-10 12:51:18 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2023-02-10 13:44:21 +0000
commit32220e43865e7e4a8a47093d55b89312d0a6f4af (patch)
treebb9241a2e070a043442f7ae75db5ec3064372f25 /src/mongo/db/timeseries/bucket_catalog/bucket_catalog.cpp
parentce925dfbbc9459f65b1ad6f91a2d85c02ab69ca4 (diff)
downloadmongo-32220e43865e7e4a8a47093d55b89312d0a6f4af.tar.gz
SERVER-72838 Prevent concurrent direct writes from unsetting kPendingDirectWrite flag
Diffstat (limited to 'src/mongo/db/timeseries/bucket_catalog/bucket_catalog.cpp')
-rw-r--r--src/mongo/db/timeseries/bucket_catalog/bucket_catalog.cpp12
1 files changed, 4 insertions, 8 deletions
diff --git a/src/mongo/db/timeseries/bucket_catalog/bucket_catalog.cpp b/src/mongo/db/timeseries/bucket_catalog/bucket_catalog.cpp
index 57c569e7d31..37cbf1d7935 100644
--- a/src/mongo/db/timeseries/bucket_catalog/bucket_catalog.cpp
+++ b/src/mongo/db/timeseries/bucket_catalog/bucket_catalog.cpp
@@ -449,16 +449,14 @@ void BucketCatalog::directWriteStart(const NamespaceString& ns, const OID& oid)
BucketId{ns, oid},
[](boost::optional<BucketState> input, std::uint64_t) -> boost::optional<BucketState> {
if (input.has_value()) {
- return input.value().setFlag(BucketStateFlag::kPendingDirectWrite);
+ return input.value().addDirectWrite();
}
// The underlying bucket isn't tracked by the catalog, but we need to insert a state
// here so that we can conflict reopening this bucket until we've completed our write
// and the reader has refetched.
- return BucketState{}
- .setFlag(BucketStateFlag::kPendingDirectWrite)
- .setFlag(BucketStateFlag::kUntracked);
+ return BucketState{}.setFlag(BucketStateFlag::kUntracked).addDirectWrite();
});
- if (result && result.value().isPrepared()) {
+ if (result.has_value() && result.value().isPrepared()) {
hangTimeseriesDirectModificationBeforeWriteConflict.pauseWhileSet();
throwWriteConflictException("Prepared bucket can no longer be inserted into.");
}
@@ -483,9 +481,7 @@ void BucketCatalog::directWriteFinish(const NamespaceString& ns, const OID& oid)
// state.
return boost::none;
}
- return input.value()
- .unsetFlag(BucketStateFlag::kPendingDirectWrite)
- .setFlag(BucketStateFlag::kCleared);
+ return input.value().removeDirectWrite();
});
}