diff options
author | Haley Connelly <haley.connelly@mongodb.com> | 2023-05-10 09:36:29 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2023-05-10 11:23:37 +0000 |
commit | 42feb6abe211d0e071b794db8e7566ff8bdd4c42 (patch) | |
tree | 8438c260dded4587aca4e534c9f435ee0354f73f /src/mongo/db/change_stream_pre_images_truncate_markers.h | |
parent | 118b6f998ca8ceb1b6392071f49efa3649cbe4e1 (diff) | |
download | mongo-42feb6abe211d0e071b794db8e7566ff8bdd4c42.tar.gz |
SERVER-75005 Integrate pre-image collection removal with new truncate mechanism
Diffstat (limited to 'src/mongo/db/change_stream_pre_images_truncate_markers.h')
-rw-r--r-- | src/mongo/db/change_stream_pre_images_truncate_markers.h | 37 |
1 files changed, 29 insertions, 8 deletions
diff --git a/src/mongo/db/change_stream_pre_images_truncate_markers.h b/src/mongo/db/change_stream_pre_images_truncate_markers.h index c71f33140fb..2b1e4b643e8 100644 --- a/src/mongo/db/change_stream_pre_images_truncate_markers.h +++ b/src/mongo/db/change_stream_pre_images_truncate_markers.h @@ -32,22 +32,43 @@ #include "mongo/db/storage/collection_truncate_markers.h" /** - * Implementation of truncate markers for the pre-images collection. + * There is up to one 'config.system.preimages' collection per tenant. This pre-images + * collection contains pre-images for every collection UUID with pre-images enabled on the tenant. + * The pre-images collection is ordered by collection UUID, so that pre-images belonging to a given + * collection are grouped together. Additionally, pre-images for a given collection UUID are stored + * in timestamp order, which makes range truncation possible. + * + * Implementation of truncate markers for pre-images associated with a single collection UUID within + * a pre-images collection. */ namespace mongo { -class PreImagesTruncateMarkers final : public CollectionTruncateMarkersWithPartialExpiration { + +class PreImagesTruncateMarkersPerCollection final + : public CollectionTruncateMarkersWithPartialExpiration { public: - PreImagesTruncateMarkers(boost::optional<TenantId> tenantId, - std::deque<Marker> markers, - int64_t leftoverRecordsCount, - int64_t leftoverRecordsBytes, - int64_t minBytesPerMarker); + PreImagesTruncateMarkersPerCollection(boost::optional<TenantId> tenantId, + std::deque<Marker> markers, + int64_t leftoverRecordsCount, + int64_t leftoverRecordsBytes, + int64_t minBytesPerMarker); + + /** + * Creates an initial set of markers for pre-images from 'nsUUID'. + */ + static CollectionTruncateMarkers::InitialSetOfMarkers createTruncateMarkersByScanning( + OperationContext* opCtx, + RecordStore* rs, + const UUID& nsUUID, + RecordId& highestSeenRecordId, + Date_t& highestSeenWallTime); private: - friend class PreImagesTruncateMarkersTest; + friend class PreImagesTruncateMarkersPerCollectionTest; bool _hasExcessMarkers(OperationContext* opCtx) const override; + bool _hasPartialMarkerExpired(OperationContext* opCtx) const override; + /** * When initialized, indicates this is a serverless environment. */ |