Skip to content

Commit 0ce2a5d

Browse files
committed
fix: release memory occupied by CteDataStore
1 parent 286768d commit 0ce2a5d

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/planner/CteMaterializer.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ public CteDataStore fetchCteQueryResult(Table table, Query query, MPPQueryContex
165165
"!!! Failed to materialize CTE. The main query falls back to INLINE mode !!!");
166166
}
167167
context.releaseMemoryReservedForFrontEnd(cteDataStore.getCachedBytes());
168+
cteDataStore.clear();
168169
return null;
169170
}
170171
}
@@ -179,6 +180,7 @@ public CteDataStore fetchCteQueryResult(Table table, Query query, MPPQueryContex
179180
} catch (final Throwable throwable) {
180181
if (cteDataStore != null) {
181182
context.releaseMemoryReservedForFrontEnd(cteDataStore.getCachedBytes());
183+
cteDataStore.clear();
182184
}
183185
t = throwable;
184186
} finally {

iotdb-core/datanode/src/main/java/org/apache/iotdb/db/utils/cte/CteDataStore.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,6 @@ public boolean addTsBlock(TsBlock tsBlock) {
5656
int rows = tsBlock.getPositionCount();
5757
if (bytesSize + cachedBytes >= iotConfig.getCteBufferSize()
5858
|| rows + cachedRows >= iotConfig.getMaxRowsInCteBuffer()) {
59-
cachedData.clear();
60-
cachedBytes = 0;
61-
cachedRows = 0;
6259
return false;
6360
}
6461
cachedData.add(tsBlock);
@@ -70,6 +67,7 @@ public boolean addTsBlock(TsBlock tsBlock) {
7067
public void clear() {
7168
cachedData.clear();
7269
cachedBytes = 0L;
70+
cachedRows = 0;
7371
}
7472

7573
public List<TsBlock> getCachedData() {

0 commit comments

Comments
 (0)