diff options
author | Henrik Edin <henrik.edin@mongodb.com> | 2021-12-01 19:14:38 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-12-01 19:59:11 +0000 |
commit | 77c9521d20f7a6dd0f3d115bf4f619968e440830 (patch) | |
tree | 9f54f4c2d9a1ba8e89bb1644579028eb6787e6a0 /src/mongo/db/timeseries/timeseries_stats.cpp | |
parent | 1ade782dd8414129cd483423b80be05fdf6cb303 (diff) | |
download | mongo-77c9521d20f7a6dd0f3d115bf4f619968e440830.tar.gz |
SERVER-61793 Validate decompression before committing compressed timeseries buckets
Diffstat (limited to 'src/mongo/db/timeseries/timeseries_stats.cpp')
-rw-r--r-- | src/mongo/db/timeseries/timeseries_stats.cpp | 13 |
1 files changed, 9 insertions, 4 deletions
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<CompressedBucketInfo> 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 |