Skip to content

Fix potential NPE in tryGetFLushLock#16274

Merged
jt2594838 merged 1 commit intomasterfrom
FixLockNpe
Aug 27, 2025
Merged

Fix potential NPE in tryGetFLushLock#16274
jt2594838 merged 1 commit intomasterfrom
FixLockNpe

Conversation

@JackieTien97
Copy link
Contributor

This pull request improves the robustness of the tryGetFLushLock method in DataRegion.java by handling cases where a TsFileProcessor is null, which indicates the file is in the process of closing. The new logic introduces a busy-wait loop to check for the file's closed status before proceeding, ensuring thread safety and correctness during concurrent file operations.

Concurrency and file closing handling:

  • Added a check for tsFileProcessor == null to detect if a tsfile is being closed, and implemented a busy-wait loop that waits for the file to finish closing before proceeding. If the file closes within the wait time, the loop continues; otherwise, it clears the lock list and returns false to prevent unsafe operations. (iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/DataRegion.java)

@sonarqubecloud
Copy link

@codecov
Copy link

codecov bot commented Aug 26, 2025

Codecov Report

❌ Patch coverage is 0% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 38.89%. Comparing base (54ca825) to head (f78997f).
⚠️ Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
.../iotdb/db/storageengine/dataregion/DataRegion.java 0.00% 8 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##             master   #16274   +/-   ##
=========================================
  Coverage     38.89%   38.89%           
  Complexity      198      198           
=========================================
  Files          4894     4894           
  Lines        320486   320494    +8     
  Branches      40533    40536    +3     
=========================================
+ Hits         124664   124671    +7     
- Misses       195822   195823    +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jt2594838 jt2594838 merged commit 6a11cbe into master Aug 27, 2025
29 of 30 checks passed
@jt2594838 jt2594838 deleted the FixLockNpe branch August 27, 2025 01:40
JackieTien97 added a commit that referenced this pull request Dec 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants