From 77c9521d20f7a6dd0f3d115bf4f619968e440830 Mon Sep 17 00:00:00 2001 From: Henrik Edin Date: Wed, 1 Dec 2021 19:14:38 +0000 Subject: SERVER-61793 Validate decompression before committing compressed timeseries buckets --- src/mongo/db/timeseries/timeseries_stats.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'src/mongo/db/timeseries/timeseries_stats.cpp') diff --git a/src/mongo/db/timeseries/timeseries_stats.cpp b/src/mongo/db/timeseries/timeseries_stats.cpp index 4333bf39a7d..61aa3a968aa 100644 --- a/src/mongo/db/timeseries/timeseries_stats.cpp +++ b/src/mongo/db/timeseries/timeseries_stats.cpp @@ -44,15 +44,19 @@ const TimeseriesStats& TimeseriesStats::get(const Collection* coll) { } void TimeseriesStats::onBucketClosed(int uncompressedSize, - boost::optional compressed) const { + const CompressedBucketInfo& compressed) const { _uncompressedSize.fetchAndAddRelaxed(uncompressedSize); - if (compressed) { - _compressedSize.fetchAndAddRelaxed(compressed->size); - _compressedSubObjRestart.fetchAndAddRelaxed(compressed->numInterleaveRestarts); + if (compressed.result.isOK() && compressed.size > 0) { + _compressedSize.fetchAndAddRelaxed(compressed.size); + _compressedSubObjRestart.fetchAndAddRelaxed(compressed.numInterleaveRestarts); _numCompressedBuckets.fetchAndAddRelaxed(1); } else { _compressedSize.fetchAndAddRelaxed(uncompressedSize); _numUncompressedBuckets.fetchAndAddRelaxed(1); + + if (compressed.decompressionFailed) { + _numFailedDecompressBuckets.fetchAndAddRelaxed(1); + } } } @@ -62,6 +66,7 @@ void TimeseriesStats::append(BSONObjBuilder* builder) const { builder->appendNumber("numSubObjCompressionRestart", _compressedSubObjRestart.load()); builder->appendNumber("numCompressedBuckets", _numCompressedBuckets.load()); builder->appendNumber("numUncompressedBuckets", _numUncompressedBuckets.load()); + builder->appendNumber("numFailedDecompressBuckets", _numFailedDecompressBuckets.load()); } } // namespace mongo -- cgit v1.2.1