Skip to content

Commit d2622f6

Browse files
authored
[To dev/1.3] Load: Add check for reset memory size to 0 in LoadTsFileMemoryManager (#16940) #16942
(cherry picked from commit 302864a)
1 parent c2c2729 commit d2622f6

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,10 @@ public synchronized long tryAllocateFromQuery(final long sizeInBytes) {
8282
}
8383

8484
public synchronized void releaseToQuery(final long sizeInBytes) {
85+
if (sizeInBytes <= 0) {
86+
throw new IllegalArgumentException(
87+
String.format("Load: Invalid memory size %d bytes, must be positive", sizeInBytes));
88+
}
8589
if (usedMemorySizeInBytes.get() < sizeInBytes) {
8690
LOGGER.error(
8791
"Load: Attempting to release more memory ({}) than allocated ({})",
@@ -96,6 +100,10 @@ public synchronized void releaseToQuery(final long sizeInBytes) {
96100

97101
public synchronized LoadTsFileMemoryBlock allocateMemoryBlock(long sizeInBytes)
98102
throws LoadRuntimeOutOfMemoryException {
103+
if (sizeInBytes <= 0) {
104+
throw new IllegalArgumentException(
105+
String.format("Load: Invalid memory size %d bytes, must be positive", sizeInBytes));
106+
}
99107
try {
100108
forceAllocateFromQuery(sizeInBytes);
101109
if (LOGGER.isDebugEnabled()) {

0 commit comments

Comments
 (0)