Re: [PR] [Load] Isolate reused TsFile parser memory from Pipe pool [iotdb]

2026-08-09 Thread via GitHub


jt2594838 merged PR #18419:
URL: https://github.com/apache/iotdb/pull/18419


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] [Load] Isolate reused TsFile parser memory from Pipe pool [iotdb]

2026-08-07 Thread via GitHub


Caideyipi commented on code in PR #18419:
URL: https://github.com/apache/iotdb/pull/18419#discussion_r3734758363


##
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/load/memory/LoadTsFileParserMemoryManager.java:
##
@@ -0,0 +1,120 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iotdb.db.storageengine.load.memory;
+
+import org.apache.iotdb.db.i18n.StorageEngineMessages;
+import 
org.apache.iotdb.db.pipe.event.common.tsfile.parser.TsFileInsertionEventParserMemoryBlock;
+import 
org.apache.iotdb.db.pipe.event.common.tsfile.parser.TsFileInsertionEventParserMemoryManager;
+
+/**
+ * Allocates the working memory of TsFile parsers reused by Load from the 
query engine memory pool.
+ */
+public class LoadTsFileParserMemoryManager implements 
TsFileInsertionEventParserMemoryManager {
+
+  private static final LoadTsFileMemoryManager LOAD_MEMORY_MANAGER =
+  LoadTsFileMemoryManager.getInstance();
+
+  private LoadTsFileParserMemoryManager() {}
+
+  public static LoadTsFileParserMemoryManager getInstance() {
+return LoadTsFileParserMemoryManagerHolder.INSTANCE;
+  }
+
+  @Override
+  public TsFileInsertionEventParserMemoryBlock forceAllocateForTabletWithRetry(
+  final long sizeInBytes) {
+return new LoadParserMemoryBlock(sizeInBytes);
+  }
+
+  @Override
+  public TsFileInsertionEventParserMemoryBlock forceAllocate(final long 
sizeInBytes) {
+return new LoadParserMemoryBlock(sizeInBytes);
+  }
+
+  private static class LoadParserMemoryBlock implements 
TsFileInsertionEventParserMemoryBlock {
+
+private LoadTsFileMemoryBlock delegate;
+private long memoryUsageInBytes;
+private boolean isClosed;
+
+private LoadParserMemoryBlock(final long sizeInBytes) {
+  checkNonNegative(sizeInBytes);
+  if (sizeInBytes > 0) {
+delegate = LOAD_MEMORY_MANAGER.allocateMemoryBlock(sizeInBytes);
+  }
+  memoryUsageInBytes = sizeInBytes;
+}
+
+@Override
+public synchronized long getMemoryUsageInBytes() {
+  return memoryUsageInBytes;
+}
+
+@Override
+public synchronized void forceResize(final long newSizeInBytes) {
+  checkNonNegative(newSizeInBytes);
+  if (isClosed || memoryUsageInBytes == newSizeInBytes) {
+return;
+  }
+
+  resizeDelegate(newSizeInBytes);
+  memoryUsageInBytes = newSizeInBytes;
+}
+
+private void resizeDelegate(final long newSizeInBytes) {
+  if (newSizeInBytes == 0) {
+delegate.close();
+delegate = null;

Review Comment:
   Thanks for checking. The first resize to 0 closes the delegate and sets the 
tracked usage to 0; a second resize to 0 returns before dereferencing the null 
delegate because the usage is unchanged. I added a regression assertion for the 
repeated zero-size resize in 277e61e1ac3.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] [Load] Isolate reused TsFile parser memory from Pipe pool [iotdb]

2026-08-07 Thread via GitHub


sonarqubecloud[bot] commented on PR #18419:
URL: https://github.com/apache/iotdb/pull/18419#issuecomment-5215223031

   ## [![Quality Gate 
Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png
 'Quality Gate 
Passed')](https://sonarcloud.io/dashboard?id=apache_iotdb&pullRequest=18419) 
**Quality Gate passed**  
   Issues  
   
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png
 '') [29 New 
issues](https://sonarcloud.io/project/issues?id=apache_iotdb&pullRequest=18419&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
  
   
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png
 '') [0 Accepted 
issues](https://sonarcloud.io/project/issues?id=apache_iotdb&pullRequest=18419&issueStatuses=ACCEPTED)
   
   Measures  
   
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png
 '') [0 Security 
Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_iotdb&pullRequest=18419&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
  
   
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png
 '') [0.0% Coverage on New 
Code](https://sonarcloud.io/component_measures?id=apache_iotdb&pullRequest=18419&metric=new_coverage&view=list)
  
   
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png
 '') [1.9% Duplication on New 
Code](https://sonarcloud.io/component_measures?id=apache_iotdb&pullRequest=18419&metric=new_duplicated_lines_density&view=list)
  
 
   
   [See analysis details on SonarQube 
Cloud](https://sonarcloud.io/dashboard?id=apache_iotdb&pullRequest=18419)
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] [Load] Isolate reused TsFile parser memory from Pipe pool [iotdb]

2026-08-07 Thread via GitHub


jt2594838 commented on code in PR #18419:
URL: https://github.com/apache/iotdb/pull/18419#discussion_r3734208137


##
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/load/memory/LoadTsFileParserMemoryManager.java:
##
@@ -0,0 +1,120 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iotdb.db.storageengine.load.memory;
+
+import org.apache.iotdb.db.i18n.StorageEngineMessages;
+import 
org.apache.iotdb.db.pipe.event.common.tsfile.parser.TsFileInsertionEventParserMemoryBlock;
+import 
org.apache.iotdb.db.pipe.event.common.tsfile.parser.TsFileInsertionEventParserMemoryManager;
+
+/**
+ * Allocates the working memory of TsFile parsers reused by Load from the 
query engine memory pool.
+ */
+public class LoadTsFileParserMemoryManager implements 
TsFileInsertionEventParserMemoryManager {
+
+  private static final LoadTsFileMemoryManager LOAD_MEMORY_MANAGER =
+  LoadTsFileMemoryManager.getInstance();
+
+  private LoadTsFileParserMemoryManager() {}
+
+  public static LoadTsFileParserMemoryManager getInstance() {
+return LoadTsFileParserMemoryManagerHolder.INSTANCE;
+  }
+
+  @Override
+  public TsFileInsertionEventParserMemoryBlock forceAllocateForTabletWithRetry(
+  final long sizeInBytes) {
+return new LoadParserMemoryBlock(sizeInBytes);
+  }
+
+  @Override
+  public TsFileInsertionEventParserMemoryBlock forceAllocate(final long 
sizeInBytes) {
+return new LoadParserMemoryBlock(sizeInBytes);
+  }
+
+  private static class LoadParserMemoryBlock implements 
TsFileInsertionEventParserMemoryBlock {
+
+private LoadTsFileMemoryBlock delegate;
+private long memoryUsageInBytes;
+private boolean isClosed;
+
+private LoadParserMemoryBlock(final long sizeInBytes) {
+  checkNonNegative(sizeInBytes);
+  if (sizeInBytes > 0) {
+delegate = LOAD_MEMORY_MANAGER.allocateMemoryBlock(sizeInBytes);
+  }
+  memoryUsageInBytes = sizeInBytes;
+}
+
+@Override
+public synchronized long getMemoryUsageInBytes() {
+  return memoryUsageInBytes;
+}
+
+@Override
+public synchronized void forceResize(final long newSizeInBytes) {
+  checkNonNegative(newSizeInBytes);
+  if (isClosed || memoryUsageInBytes == newSizeInBytes) {
+return;
+  }
+
+  resizeDelegate(newSizeInBytes);
+  memoryUsageInBytes = newSizeInBytes;
+}
+
+private void resizeDelegate(final long newSizeInBytes) {
+  if (newSizeInBytes == 0) {
+delegate.close();
+delegate = null;

Review Comment:
   If resized twice with size 0, will an NPE be triggered?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] [Load] Isolate reused TsFile parser memory from Pipe pool [iotdb]

2026-08-06 Thread via GitHub


codecov[bot] commented on PR #18419:
URL: https://github.com/apache/iotdb/pull/18419#issuecomment-521655

   ## 
[Codecov](https://app.codecov.io/gh/apache/iotdb/pull/18419?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
 Report
   :x: Patch coverage is `83.48624%` with `18 lines` in your changes missing 
coverage. Please review.
   :white_check_mark: Project coverage is 43.62%. Comparing base 
([`7e2c453`](https://app.codecov.io/gh/apache/iotdb/commit/7e2c453fbd1880e977c4da50395881a36edc1898?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache))
 to head 
([`a35e8a4`](https://app.codecov.io/gh/apache/iotdb/commit/a35e8a42a6e324fad9111a327cf4bda52655eec6?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
   
   | [Files with missing 
lines](https://app.codecov.io/gh/apache/iotdb/pull/18419?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
 | Patch % | Lines |
   |---|---|---|
   | 
[...ine/load/memory/LoadTsFileParserMemoryManager.java](https://app.codecov.io/gh/apache/iotdb/pull/18419?src=pr&el=tree&filepath=iotdb-core%2Fdatanode%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fiotdb%2Fdb%2Fstorageengine%2Fload%2Fmemory%2FLoadTsFileParserMemoryManager.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-aW90ZGItY29yZS9kYXRhbm9kZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvaW90ZGIvZGIvc3RvcmFnZWVuZ2luZS9sb2FkL21lbW9yeS9Mb2FkVHNGaWxlUGFyc2VyTWVtb3J5TWFuYWdlci5qYXZh)
 | 89.74% | [4 Missing :warning: 
](https://app.codecov.io/gh/apache/iotdb/pull/18419?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
 |
   | 
[...mmon/tsfile/parser/TsFileInsertionEventParser.java](https://app.codecov.io/gh/apache/iotdb/pull/18419?src=pr&el=tree&filepath=iotdb-core%2Fdatanode%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fiotdb%2Fdb%2Fpipe%2Fevent%2Fcommon%2Ftsfile%2Fparser%2FTsFileInsertionEventParser.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-aW90ZGItY29yZS9kYXRhbm9kZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvaW90ZGIvZGIvcGlwZS9ldmVudC9jb21tb24vdHNmaWxlL3BhcnNlci9Uc0ZpbGVJbnNlcnRpb25FdmVudFBhcnNlci5qYXZh)
 | 57.14% | [3 Missing :warning: 
](https://app.codecov.io/gh/apache/iotdb/pull/18419?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
 |
   | 
[.../parser/query/TsFileInsertionEventQueryParser.java](https://app.codecov.io/gh/apache/iotdb/pull/18419?src=pr&el=tree&filepath=iotdb-core%2Fdatanode%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fiotdb%2Fdb%2Fpipe%2Fevent%2Fcommon%2Ftsfile%2Fparser%2Fquery%2FTsFileInsertionEventQueryParser.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-aW90ZGItY29yZS9kYXRhbm9kZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvaW90ZGIvZGIvcGlwZS9ldmVudC9jb21tb24vdHNmaWxlL3BhcnNlci9xdWVyeS9Uc0ZpbGVJbnNlcnRpb25FdmVudFF1ZXJ5UGFyc2VyLmphdmE=)
 | 62.50% | [3 Missing :warning: 
](https://app.codecov.io/gh/apache/iotdb/pull/18419?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
 |
   | 
[.../parser/table/TsFileInsertionEventTableParser.java](https://app.codecov.io/gh/apache/iotdb/pull/18419?src=pr&el=tree&filepath=iotdb-core%2Fdatanode%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fiotdb%2Fdb%2Fpipe%2Fevent%2Fcommon%2Ftsfile%2Fparser%2Ftable%2FTsFileInsertionEventTableParser.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-aW90ZGItY29yZS9kYXRhbm9kZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvaW90ZGIvZGIvcGlwZS9ldmVudC9jb21tb24vdHNmaWxlL3BhcnNlci90YWJsZS9Uc0ZpbGVJbnNlcnRpb25FdmVudFRhYmxlUGFyc2VyLmphdmE=)
 | 72.72% | [3 Missing :warning: 
](https://app.codecov.io/gh/apache/iotdb/pull/18419?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
 |
   | 
[...e/load/converter/LoadTreeTsFileTabletIterator.java](https://app.codecov.io/gh/apache/iotdb/pull/18419?src=pr&el=tree&filepath=iotdb-core%2Fdatanode%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fiotdb%2Fdb%2Fstorageengine%2Fload%2Fconverter%2FLoadTreeTsFileTabletIterator.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-aW90ZGItY29yZS9kYXRhbm9kZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvaW90ZGIvZGIvc3RvcmFnZWVuZ2luZS9sb2FkL2NvbnZlcnRlci9Mb2FkVHJlZVRzRmlsZVRhYmxldEl0ZXJhdG9yLmphdmE=)
 | 50.00% | [3 Missing :warning: 
](https://app.codecov.io/gh/apache/iotdb/pull/18419?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
 |
   | 

Re: [PR] [Load] Isolate reused TsFile parser memory from Pipe pool [iotdb]

2026-08-06 Thread via GitHub


sonarqubecloud[bot] commented on PR #18419:
URL: https://github.com/apache/iotdb/pull/18419#issuecomment-5211828408

   ## [![Quality Gate 
Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png
 'Quality Gate 
Passed')](https://sonarcloud.io/dashboard?id=apache_iotdb&pullRequest=18419) 
**Quality Gate passed**  
   Issues  
   
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png
 '') [29 New 
issues](https://sonarcloud.io/project/issues?id=apache_iotdb&pullRequest=18419&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
  
   
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png
 '') [0 Accepted 
issues](https://sonarcloud.io/project/issues?id=apache_iotdb&pullRequest=18419&issueStatuses=ACCEPTED)
   
   Measures  
   
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png
 '') [0 Security 
Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_iotdb&pullRequest=18419&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
  
   
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png
 '') [0.0% Coverage on New 
Code](https://sonarcloud.io/component_measures?id=apache_iotdb&pullRequest=18419&metric=new_coverage&view=list)
  
   
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png
 '') [1.9% Duplication on New 
Code](https://sonarcloud.io/component_measures?id=apache_iotdb&pullRequest=18419&metric=new_duplicated_lines_density&view=list)
  
 
   
   [See analysis details on SonarQube 
Cloud](https://sonarcloud.io/dashboard?id=apache_iotdb&pullRequest=18419)
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



[PR] [Load] Isolate reused TsFile parser memory from Pipe pool [iotdb]

2026-08-06 Thread via GitHub


Caideyipi opened a new pull request, #18419:
URL: https://github.com/apache/iotdb/pull/18419

   ## Description
   
   ### Problem
   Load reuses TsFile insertion parsers, whose tablet, chunk, page, and 
modifications blocks were hard-coded to PipeDataNodeResourceManager.memory(). A 
large Pipe tablet backlog could therefore consume the Pipe pool and prevent 
Load from acquiring query memory.
   
   ### Fix
   - Inject a parser memory owner through 
TsFileInsertionEventParserMemoryManager.
   - Keep existing parser constructors on the Pipe pool for Pipe callers.
   - Route Load tree scan/query and table parsing through 
LoadTsFileParserMemoryManager, backed by LoadTsFileMemoryManager and the query 
operator pool.
   - Propagate LoadRuntimeOutOfMemoryException during parser initialization 
instead of treating it as TsFile corruption and falling back.
   
   ### Tests
   - LoadTsFileParserPipeMemoryIsolationTest: 
PipeDataNodeResourceManager.memory() throws if accessed; the real Load scan 
parser still reads the TsFile, records query-pool usage, and releases it.
   - 
LoadTreeStatementDataTypeConvertExecutionVisitorTest#testLoadScanParserUsesQueryMemoryPoolInsteadOfPipeMemory:
 query-pool usage increases while Pipe usage is unchanged.
   - LoadTsFileMemoryManagerTest and TsFileInsertionEventParserTest pass; 
Spotless/checkstyle pass.
   - The latest incremental compile is additionally blocked by pre-existing 
stale cross-module Subscription/Thrift generated APIs, unrelated to this change.
   
   ### Scope note
   The existing Load conversion semaphore only reads Pipe capacity to size 
permits; this change removes parser working-memory allocations from the Pipe 
pool.
   
   
   
   This PR has:
   - [x] been self-reviewed.
   - [x] added comments explaining the ownership boundary.
   - [x] added or updated unit tests for the new code paths.
   - [ ] added integration tests (not applicable to this unit-level memory 
ownership fix).
   
   
   
   # Key changed/added classes
   - TsFileInsertionEventParserMemoryBlock / 
TsFileInsertionEventParserMemoryManager
   - LoadTsFileParserMemoryManager
   - TsFileInsertionEventParser, scan/query/table parser implementations
   - LoadTreeTsFileTabletIterator and 
LoadTableStatementDataTypeConvertExecutionVisitor
   - Load memory/parser isolation tests


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]