This is an automated email from the ASF dual-hosted git repository. Caideyipi pushed a commit to branch patch-2094 in repository https://gitbox.apache.org/repos/asf/iotdb.git
commit 53099c667311e3ab567474b6b6fa9bfa6157fba0 Author: Weihao Li <[email protected]> AuthorDate: Thu Apr 30 11:18:33 2026 +0800 modify release Signed-off-by: Weihao Li <[email protected]> (cherry picked from commit 1cec558dfffc21dd804bc23709325c55763a37e3) (cherry picked from commit 798e76d44e4f713573e79febeff7689faf6fc888) --- .../commons/memory/AtomicLongMemoryBlock.java | 24 +++++++++++++--------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/memory/AtomicLongMemoryBlock.java b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/memory/AtomicLongMemoryBlock.java index 9663eb0e689..1a7d3c25413 100644 --- a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/memory/AtomicLongMemoryBlock.java +++ b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/memory/AtomicLongMemoryBlock.java @@ -100,16 +100,20 @@ public class AtomicLongMemoryBlock extends IMemoryBlock { @Override public long release(long sizeInByte) { - return usedMemoryInBytes.updateAndGet( - memCost -> { - if (sizeInByte > memCost) { - LOGGER.warn( - "The memory cost to be released is larger than the memory cost of memory block {}", - this); - return 0; - } - return memCost - sizeInByte; - }); + long prev; + long next; + do { + prev = usedMemoryInBytes.get(); + if (sizeInByte > prev) { + LOGGER.warn( + "The memory cost to be released is larger than the memory cost of memory block {}", + this); + next = 0; + } else { + next = prev - sizeInByte; + } + } while (!usedMemoryInBytes.compareAndSet(prev, next)); + return next; } @Override
