-
Type: Task
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: None
-
Fully Compatible
-
Sharding EMEA 2023-02-20, Sharding EMEA 2023-03-06, Sharding EMEA 2023-03-20, Sharding EMEA 2023-04-03
-
135
The CollectionWriter (and it's sibling AutoGetCollection::getWritableCollection) paradigms are really an attempt to provide a "see your own catalog writes" semantics for catalog changes performed while holding an AutoGetCollection. This ticket is proposing to implement a proper utility which ensures that all collection acquisitions held by an operation automatically see any catalog writes performed by the code path on which they have been placed.
The semantics of this utility will be:
- It must be instantiated only within a WUOU and its lifetime must be smaller than that of the WUOW
- Must must be instantiated only by passing a ScopedCollectionOrViewAcquisition obtained with at least MODE_X lock on the collection
- On construction must invalidate the ScopedCollectionOrViewAcquisition to guarantee that it is not used while the underlying state is being modified
- On destruction must make visible all the changes made (uncommitted, since within a WUOW) to the ScopedCollectionOrViewAcquisition
- On rollback of the WUOW, must bring the respective AcquiredCollection to the old state (which means any active ScopedCollectionOrViewAcquisitions will start seeing the old state)
- (FUTURE) On commit must ensure that the committed state presented doesn't advance beyond the Sharding's Placement timestamp
Context
The AutoGetXXX utilities and the CollectionPtr are really caches of a particular collection from the CollectionCatalog, which itself is a cache of the persistent WT state on disk. The CollectionWriter utility serves two purposes:
- Provide a programmatic C++ way to remove the constness of a CollectionPtr
- Establish a "release"-barrier after which any caches of the CollectionCatalog (namely AutoGetCollection(s)) will reflect the changes that were made to the local catalog, pertaining to that collection
The ScopedCollectionOrView acquisition class is really a more complete cache of the entire catalog information for a collection (sharding + local) and at the end of PM-2144, no code paths should be interacting with the catalog outside of ScopedCollectionOrView. The ScopedLocalCatalogWriter described in this ticket will provide the release semantics described above, without dangling memory bugs like SERVER-73755, because it will operate on the TransactionResources' collection acquisitions rather than on stack variables.
- depends on
-
SERVER-73238 Introduce the shard_role_api library
- Closed
- is depended on by
-
SERVER-73298 Thread-through `ScopedCollectionOrViewAcquisition` on the insert code path
- Closed
-
SERVER-73756 Thread-through `ScopedCollectionOrViewAcquisition` on the drop indexes code path
- Closed
- related to
-
SERVER-75286 Coverity analysis defect 135887: Uninitialized pointer field
- Closed
-
SERVER-75157 Complete TODO listed in SERVER-73766
- Blocked