Skip to content

[fix](publish) Avoid NPE for force-finished publish task#63069

Open
deardeng wants to merge 2 commits intoapache:masterfrom
deardeng:fix-publish-npe-master
Open

[fix](publish) Avoid NPE for force-finished publish task#63069
deardeng wants to merge 2 commits intoapache:masterfrom
deardeng:fix-publish-npe-master

Conversation

@deardeng
Copy link
Copy Markdown
Collaborator

@deardeng deardeng commented May 8, 2026

FE publish can loop on:

java.lang.NullPointerException: Cannot invoke
"java.util.Map.containsKey(Object)" because the return value of
"PublishVersionTask.getSuccTablets()" is null
at DatabaseTransactionMgr.checkReplicaContinuousVersionSucc(...)
at DatabaseTransactionMgr.finishCheckQuorumReplicas(...)
at DatabaseTransactionMgr.finishTransaction(...)

PublishVersionTask starts with succTablets == null, but
AgentTaskCleanupDaemon.removeInactiveBeAgentTasks can force-finish an
in-flight task with setFinished(true) without ever calling setSuccTablets.
That leaves a finished task whose getSuccTablets() still returns null.

MasterImpl.finishPublishVersion is only a theoretical source here:
BE task_worker_pool.cpp unconditionally sets succ_tablets on the finish
request, so that path currently receives at worst an empty map.

Fix this on both sides:

  • default PublishVersionTask.succTablets to an empty map and coerce null
  • guard the call site before containsKey(tabletId)

Add FE unit coverage and a regression suite for BE-down publish cleanup.

What problem does this PR solve?

Issue Number: close #xxx

Related PR: #xxx

Problem Summary:

Release note

None

Check List (For Author)

  • Test

    • Regression test
    • Unit Test
    • Manual test (add detailed scripts or steps below)
    • No need to test or manual test. Explain why:
      • This is a refactor/code format and no logic has been changed.
      • Previous test can cover this change.
      • No code files have been changed.
      • Other reason
  • Behavior changed:

    • No.
    • Yes.
  • Does this need documentation?

    • No.
    • Yes.

Check List (For Reviewer who merge this PR)

  • Confirm the release note
  • Confirm test cases
  • Confirm document
  • Add branch pick label

@hello-stephen
Copy link
Copy Markdown
Contributor

Thank you for your contribution to Apache Doris.
Don't know what should be done next? See How to process your PR.

Please clearly describe your PR:

  1. What problem was fixed (it's best to include specific error reporting information). How it was fixed.
  2. Which behaviors were modified. What was the previous behavior, what is it now, why was it modified, and what possible impacts might there be.
  3. What features were added. Why was this function added?
  4. Which code was refactored and why was this part of the code refactored?
  5. Which functions were optimized and what is the difference before and after the optimization?

@deardeng deardeng changed the title [fix](publish) Avoid NPE in checkReplicaContinuousVersionSucc when PublishVersionTask is force-finished without succTablets [fix](publish) Avoid NPE for force-finished publish task May 8, 2026
@deardeng
Copy link
Copy Markdown
Collaborator Author

deardeng commented May 8, 2026

run buildall

deardeng and others added 2 commits May 8, 2026 14:46
FE publish can loop on:

  java.lang.NullPointerException: Cannot invoke
  "java.util.Map.containsKey(Object)" because the return value of
  "PublishVersionTask.getSuccTablets()" is null
  at DatabaseTransactionMgr.checkReplicaContinuousVersionSucc(...)
  at DatabaseTransactionMgr.finishCheckQuorumReplicas(...)
  at DatabaseTransactionMgr.finishTransaction(...)

PublishVersionTask starts with succTablets == null, but
AgentTaskCleanupDaemon.removeInactiveBeAgentTasks can force-finish an
in-flight task with setFinished(true) without ever calling setSuccTablets.
That leaves a finished task whose getSuccTablets() still returns null.

MasterImpl.finishPublishVersion is only a theoretical source here:
BE task_worker_pool.cpp unconditionally sets succ_tablets on the finish
request, so that path currently receives at worst an empty map.

Fix this on both sides:
- default PublishVersionTask.succTablets to an empty map and coerce null
- guard the call site before containsKey(tabletId)

Add FE unit coverage and a regression suite for BE-down publish cleanup.
@deardeng deardeng force-pushed the fix-publish-npe-master branch from dfec873 to 479a4a0 Compare May 8, 2026 07:19
@deardeng
Copy link
Copy Markdown
Collaborator Author

deardeng commented May 8, 2026

run buildall

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants