File tree Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -235,9 +235,10 @@ ui64 TPartition::MeteringDataSize(const TActorContext& /*ctx*/) const {
235235 // We assume that DataKyesBody contains an up-to-date set of blobs, their relevance is
236236 // maintained by the background process. However, the last block may contain several irrelevant
237237 // messages. Because of them, we throw out the size of the entire blob.
238- ui64 size = Size () - DataKeysBody[0 ].Size ;
239- Y_DEBUG_ABORT_UNLESS (size >= 0 , " Metering data size must be positive" );
240- return std::max<ui64>(size, 0 );
238+ auto size = Size ();
239+ auto lastBlobSize = DataKeysBody[0 ].Size ;
240+ Y_DEBUG_ABORT_UNLESS (size >= lastBlobSize, " Metering data size must be positive" );
241+ return size >= lastBlobSize ? size - lastBlobSize : 0 ;
241242}
242243
243244ui64 TPartition::ReserveSize () const {
@@ -257,7 +258,9 @@ ui64 TPartition::GetUsedStorage(const TActorContext& ctx) {
257258 const auto duration = now - LastUsedStorageMeterTimestamp;
258259 LastUsedStorageMeterTimestamp = now;
259260
260- ui64 size = std::max<ui64>(MeteringDataSize (ctx) - ReserveSize (), 0 );
261+ auto dataSize = MeteringDataSize (ctx);
262+ auto reservedSize = ReserveSize ();
263+ ui64 size = dataSize > reservedSize ? dataSize - reservedSize : 0 ;
261264 return size * duration.MilliSeconds () / 1000 / 1_MB; // mb*seconds
262265}
263266
You can’t perform that action at this time.
0 commit comments