Skip to content

Commit bb2fe80

Browse files
committed
fix: throw exception for invalid memory size in releaseToQuery
Change releaseToQuery to throw IllegalArgumentException when sizeInBytes <= 0, instead of silently returning. This makes it consistent with allocateMemoryBlock and helps detect programming errors early.
1 parent 05c3b4c commit bb2fe80

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/load/memory/LoadTsFileMemoryManager.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ public synchronized long tryAllocateFromQuery(final long sizeInBytes) {
8383

8484
public synchronized void releaseToQuery(final long sizeInBytes) {
8585
if (sizeInBytes <= 0) {
86-
return;
86+
throw new IllegalArgumentException(
87+
String.format("Load: Invalid memory size %d bytes, must be positive", sizeInBytes));
8788
}
8889
if (usedMemorySizeInBytes.get() < sizeInBytes) {
8990
LOGGER.error(
@@ -129,7 +130,8 @@ synchronized void forceResize(LoadTsFileMemoryBlock memoryBlock, long newSizeInB
129130
throws LoadRuntimeOutOfMemoryException {
130131
if (newSizeInBytes < 0) {
131132
throw new IllegalArgumentException(
132-
String.format("Load: Invalid memory size %d bytes, must be non-negative", newSizeInBytes));
133+
String.format(
134+
"Load: Invalid memory size %d bytes, must be non-negative", newSizeInBytes));
133135
}
134136
if (memoryBlock.getTotalMemorySizeInBytes() == newSizeInBytes) {
135137
return;

0 commit comments

Comments
 (0)