Skip to content

Introduce reason codes for segment completion requests - #19251

Open
akg268 wants to merge 2 commits into
apache:masterfrom
akg268:pinot-12055-reason-codes
Open

Introduce reason codes for segment completion requests#19251
akg268 wants to merge 2 commits into
apache:masterfrom
akg268:pinot-12055-reason-codes

Conversation

@akg268

@akg268 akg268 commented Aug 13, 2026

Copy link
Copy Markdown

Fixes #12055

Summary

  • Add a typed SegmentCompletionProtocol.ReasonCode and send it as a reasonCode query parameter while preserving the existing reason parameter.
  • Send reason codes from the realtime server for known stop reasons.
  • Use reason codes in controller segment-completion decisions, with fallback to the legacy reason string for older servers and safe handling for unknown future codes.
  • Add compatibility and controller behavior tests for known codes, unknown codes, legacy fallback, winner selection, and force-commit threshold handling.

Testing

  • ./mvnw -pl pinot-common -am -Dtest=SegmentCompletionProtocolTest -Dsurefire.failIfNoSpecifiedTests=false -DfailIfNoTests=false -Denforcer.skip=true -Djdk.version=21 test
  • ./mvnw -pl pinot-controller checkstyle:check -Denforcer.skip=true -Djdk.version=21
  • ./mvnw -pl pinot-core checkstyle:check -Denforcer.skip=true -Djdk.version=21
  • git diff --check

Note: Local machine has JDK 21, so these local runs skip the JDK enforcer. CI should run with Pinot's required JDK.

cc @Jackie-Jiang @krishan1390 @krishna-st for review.

@Jackie-Jiang Jackie-Jiang added enhancement Improvement to existing functionality ingestion Related to data ingestion pipeline real-time Related to realtime table ingestion and serving labels Aug 13, 2026
@Jackie-Jiang
Jackie-Jiang requested a balanced review from Copilot August 13, 2026 20:40
@Jackie-Jiang

Copy link
Copy Markdown
Contributor

cc @noob-se7en

public static final String REASON_INDEX_CAPACITY_THRESHOLD_BREACHED = "indexCapacityThresholdBreached";

public enum ReasonCode {
ROW_LIMIT(REASON_ROW_LIMIT),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I feel the purpose is to add an integer response code instead of a string enum

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds typed reason codes to realtime segment-completion requests while preserving legacy reason-string compatibility.

Changes:

  • Defines and serializes ReasonCode.
  • Uses codes in server/controller completion decisions.
  • Adds compatibility and force-commit tests.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
RealtimeSegmentDataManager.java Emits typed stop reasons.
SegmentCompletionProtocol.java Defines reason-code protocol support.
SegmentCompletionProtocolTest.java Tests serialization and fallback behavior.
LLCSegmentCompletionHandlers.java Accepts reason-code parameters.
SegmentCompletionManager.java Passes typed reasons to the FSM.
SegmentCompletionFSM.java Updates the consumed-message contract.
BlockingSegmentCompletionFSM.java Uses codes for winner selection.
CommittingSegmentDescriptor.java Retains commit reason codes.
SizeBasedSegmentFlushThresholdComputer.java Handles coded force commits.
SegmentCompletionTest.java Tests controller decisions and compatibility.
SizeBasedSegmentFlushThresholdComputerTest.java Tests coded force-commit thresholds.
Suppressed comments (2)

pinot-common/src/main/java/org/apache/pinot/common/protocols/SegmentCompletionProtocol.java:187

  • This method also returns null when the legacy reason is absent or unrecognized, so its public return type must be marked @Nullable under the non-null-by-default contract.
    public static ReasonCode fromReason(String reason) {

pinot-common/src/main/java/org/apache/pinot/common/protocols/SegmentCompletionProtocol.java:405

  • getReasonCode() returns null for requests without a recognized code, but the new getter does not declare that nullable contract. Add @Nullable, matching CommittingSegmentDescriptor.getStopReasonCode(), to avoid exposing a misleading non-null API.
      public ReasonCode getReasonCode() {

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

return this == ROW_LIMIT || this == END_OF_PARTITION_GROUP;
}

public static ReasonCode fromCode(String reasonCode) {
private long _lastLogTime = 0;
private int _lastConsumedCount = 0;
private String _stopReason = null;
private SegmentCompletionProtocol.ReasonCode _stopReasonCode = null;
@codecov-commenter

codecov-commenter commented Aug 13, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (cd95aef) to head (c44c204).
⚠️ Report is 2 commits behind head on master.

Additional details and impacted files
@@              Coverage Diff               @@
##             master    #19251       +/-   ##
==============================================
+ Coverage     66.97%   100.00%   +33.02%     
+ Complexity     1423         6     -1417     
==============================================
  Files          3453         3     -3450     
  Lines        218927         6   -218921     
  Branches      34798         0    -34798     
==============================================
- Hits         146619         6   -146613     
+ Misses        60588         0    -60588     
+ Partials      11720         0    -11720     
Flag Coverage Δ
integration 100.00% <ø> (ø)
integration1 100.00% <ø> (ø)
integration2 0.00% <ø> (?)
java-25 100.00% <ø> (+33.02%) ⬆️
lane-a 100.00% <ø> (ø)
lane-b 0.00% <ø> (ø)
temurin 100.00% <ø> (+33.02%) ⬆️
unittests ?
unittests1 ?
unittests2 ?

Flags with carried forward coverage won't be shown. Click here to find out more.

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

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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

Labels

enhancement Improvement to existing functionality ingestion Related to data ingestion pipeline real-time Related to realtime table ingestion and serving

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Introduce reason codes in server http requests to controller

4 participants