Skip to content

Fix NPE when fragment context is removed concurrently - #18439

Merged
JackieTien97 merged 1 commit into
apache:masterfrom
JackieTien97:ty-fix-fragment-instance-context-npe
Aug 11, 2026
Merged

JackieTien97 merged 1 commit into
apache:masterfrom
JackieTien97:ty-fix-fragment-instance-context-npe

Conversation

@JackieTien97

Copy link
Copy Markdown
Contributor

Summary

  • preserve fragment failure information before concurrent cancellation removes the fragment context
  • apply the fix to both data and schema fragment execution paths
  • add deterministic regression tests for the cancellation/planning-failure race

Root cause

cancelTask removes the FragmentInstanceContext before waiting for the in-progress instanceExecution.computeIfAbsent call. If planning then fails, the failure path returns from computeIfAbsent and looks the context up again. The lookup can return null, causing an NPE that masks the original failure, such as metadata lease fencing status 536.

Impact

The original fragment failure and status are returned instead of an unrelated NPE.

Validation

  • mvn compile -pl iotdb-core/datanode -am -DskipTests
  • mvn test -pl iotdb-core/datanode -am -Dtest=FragmentInstanceManagerTest -DfailIfNoTests=false -Dsurefire.failIfNoSpecifiedTests=false (2 tests passed)

@JackieTien97
JackieTien97 marked this pull request as ready for review August 11, 2026 06:09
@JackieTien97
JackieTien97 merged commit ab88131 into apache:master Aug 11, 2026
41 checks passed
@JackieTien97
JackieTien97 deleted the ty-fix-fragment-instance-context-npe branch August 11, 2026 06:09
VGalaxies pushed a commit to VGalaxies/iotdb that referenced this pull request Oct 26, 2026
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.

1 participant