Introduce reason codes for segment completion requests - #19251
Conversation
|
cc @noob-se7en |
| public static final String REASON_INDEX_CAPACITY_THRESHOLD_BREACHED = "indexCapacityThresholdBreached"; | ||
|
|
||
| public enum ReasonCode { | ||
| ROW_LIMIT(REASON_ROW_LIMIT), |
There was a problem hiding this comment.
I feel the purpose is to add an integer response code instead of a string enum
There was a problem hiding this comment.
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
nullwhen the legacy reason is absent or unrecognized, so its public return type must be marked@Nullableunder 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()returnsnullfor requests without a recognized code, but the new getter does not declare that nullable contract. Add@Nullable, matchingCommittingSegmentDescriptor.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 Report✅ All modified and coverable lines are covered by tests. 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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Fixes #12055
Summary
SegmentCompletionProtocol.ReasonCodeand send it as areasonCodequery parameter while preserving the existingreasonparameter.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=21git diff --checkNote: 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.