Skip to content

Conversation

@luoluoyuyu
Copy link
Member

Description

Fix NullPointerException caused by concurrent access to insertNode field in pipe transfer.

Root Cause:

  1. TOCTOU race condition: insertNode field accessed multiple times without synchronization
  2. Reference counting gap: In batch mode, getDeviceId() called before reference count increased

Changes:

  1. Use local variable snapshots in PipeInsertNodeTabletInsertionEvent to avoid repeated mutable field access
  2. Protect event access with reference counting in PipeTransferBatchReqBuilder
  3. Add reference counting protection in WebSocketSink for toRawTabletInsertionEvents() call

Fixed methods in PipeInsertNodeTabletInsertionEvent:

  • getDeviceId(): double layer protection (node + targetPath snapshot)
  • getByteBuffer(): added null check
  • isGeneratedByPipe(), throwIfNoPrivilege(), toString(), coreReportMessage(), ramBytesUsed()

This PR has:

  • been self-reviewed.
    • concurrent read
    • concurrent write
    • concurrent read and write
  • added documentation for new or modified features or behaviors.
  • added Javadocs for most classes and all non-trivial methods.
  • added or updated version, license, or notice information
  • added comments explaining the "why" and the intent of the code wherever would not be obvious
    for an unfamiliar reader.
  • added unit tests or modified existing tests to cover new code paths, ensuring the threshold
    for code coverage.
  • added integration tests.
  • been tested in a test IoTDB cluster.

Key changed/added classes (or packages if there are too many classes) in this PR

@luoluoyuyu luoluoyuyu force-pushed the fix-npe branch 2 times, most recently from 7f22104 to ec59808 Compare December 3, 2025 03:28
@Caideyipi
Copy link
Collaborator

Better remove the stack printed at "ignored because the failure event is released", just use e.getMessage() or null if e == null

Copy link
Collaborator

@Caideyipi Caideyipi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jt2594838 jt2594838 merged commit 5bc4779 into apache:master Dec 4, 2025
38 of 39 checks passed
luoluoyuyu added a commit to luoluoyuyu/iotdb that referenced this pull request Dec 5, 2025
* fix

* fix

* fix

* fix

* fix

(cherry picked from commit 5bc4779)
jt2594838 pushed a commit that referenced this pull request Dec 5, 2025
…16872)

* fix

* fix

* fix

* fix

* fix

(cherry picked from commit 5bc4779)
JackieTien97 pushed a commit that referenced this pull request Dec 8, 2025
* fix

* fix

* fix

* fix

* fix

(cherry picked from commit 5bc4779)
@luoluoyuyu luoluoyuyu deleted the fix-npe branch December 8, 2025 08:46
JackieTien97 pushed a commit that referenced this pull request Dec 9, 2025
* fix

* fix

* fix

* fix

* fix

(cherry picked from commit 5bc4779)
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