SERVER-110842: commitTimeseriesBucketForBatch and commitTimeseriesBucketsAtomically should set the collection catalog within the scope of acquireAndValidateBucketsCollection (#45620)
Co-authored-by: Stephanie <53684987+seristof@users.noreply.github.com> GitOrigin-RevId: daeccb8cfad449fa2363a948904e6a27eeed3a0f
This commit is contained in:
parent
0d05f10f27
commit
701f29ddcc
@ -356,7 +356,7 @@ Status commitTimeseriesBucketsAtomically(OperationContext* opCtx,
|
||||
|
||||
// Explicitly hold a reference to the CollectionCatalog, such that the corresponding
|
||||
// Collection instances remain valid, and the collator is not invalidated.
|
||||
auto catalog = CollectionCatalog::get(opCtx);
|
||||
std::shared_ptr<const CollectionCatalog> catalog;
|
||||
NamespaceString nss;
|
||||
const CollatorInterface* collator = nullptr;
|
||||
|
||||
@ -371,6 +371,13 @@ Status commitTimeseriesBucketsAtomically(OperationContext* opCtx,
|
||||
CollectionAcquisitionRequest::fromOpCtx(
|
||||
opCtx, internal::ns(request), AcquisitionPrerequisites::kRead),
|
||||
MODE_IS);
|
||||
|
||||
// We want to ensure that the catalog instance after the scope of the acquisition is the
|
||||
// same as before the acquisition. Acquiring the collection involves stashing the
|
||||
// current catalog instance, so assigning the catalog in scope of the try block ensures
|
||||
// that we have a consistent catalog with the acquisition.
|
||||
catalog = CollectionCatalog::get(opCtx);
|
||||
|
||||
nss = bucketsAq.nss();
|
||||
collator = bucketsAq.getCollectionPtr()->getDefaultCollator();
|
||||
} catch (const DBException& ex) {
|
||||
@ -1044,7 +1051,7 @@ commit_result::Result commitTimeseriesBucketForBatch(
|
||||
|
||||
// Explicitly hold a reference to the CollectionCatalog, such that the corresponding
|
||||
// Collection instances remain valid, and the collator is not invalidated.
|
||||
auto catalog = CollectionCatalog::get(opCtx);
|
||||
std::shared_ptr<const CollectionCatalog> catalog;
|
||||
const CollatorInterface* collator = nullptr;
|
||||
NamespaceString nss;
|
||||
|
||||
@ -1059,6 +1066,13 @@ commit_result::Result commitTimeseriesBucketForBatch(
|
||||
CollectionAcquisitionRequest::fromOpCtx(
|
||||
opCtx, internal::ns(request), AcquisitionPrerequisites::kRead),
|
||||
MODE_IS);
|
||||
|
||||
// We want to ensure that the catalog instance after the scope of the acquisition is the
|
||||
// same as before the acquisition. Acquiring the collection involves stashing the
|
||||
// current catalog instance, so assigning the catalog in scope of the try block ensures
|
||||
// that we have a consistent catalog with the acquisition.
|
||||
catalog = CollectionCatalog::get(opCtx);
|
||||
|
||||
nss = bucketsAcq.nss();
|
||||
collator = bucketsAcq.getCollectionPtr()->getDefaultCollator();
|
||||
} catch (const DBException& ex) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user