-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Retry segment publish task actions without holding locks #17816
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
03404fa
f346537
e648b00
6cb009d
eedd423
212e06d
93b330e
a9e7936
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,7 +22,7 @@ | |
| import com.fasterxml.jackson.annotation.JsonCreator; | ||
| import com.fasterxml.jackson.annotation.JsonProperty; | ||
| import com.google.common.base.Preconditions; | ||
| import com.google.common.collect.ImmutableSet; | ||
| import org.apache.druid.java.util.common.StringUtils; | ||
| import org.apache.druid.metadata.PendingSegmentRecord; | ||
| import org.apache.druid.segment.SegmentUtils; | ||
| import org.apache.druid.timeline.DataSegment; | ||
|
|
@@ -34,59 +34,59 @@ | |
| import java.util.Set; | ||
|
|
||
| /** | ||
| * Result of an operation that attempts to publish segments. Indicates the set of segments actually published | ||
| * and whether or not the transaction was a success. | ||
| * | ||
| * If "success" is false then the segments set will be empty. | ||
| * | ||
| * It's possible for the segments set to be empty even if "success" is true, since the segments set only | ||
| * includes segments actually published as part of the transaction. The requested segments could have been | ||
| * published by a different transaction (e.g. in the case of replica sets) and this one would still succeed. | ||
| * Result of a segment publish operation. | ||
| */ | ||
| public class SegmentPublishResult | ||
| { | ||
| private final Set<DataSegment> segments; | ||
| private final boolean success; | ||
| @Nullable | ||
| private final boolean retryable; | ||
| private final String errorMsg; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The errorMsg was Nullable before and is not Nullable now. Is this expected ?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, this particular annotation doesn't do much. Just causes unnecessary warnings in the IDE. The constructor arg and the getter are still marked as |
||
| @Nullable | ||
| private final List<PendingSegmentRecord> upgradedPendingSegments; | ||
|
|
||
| public static SegmentPublishResult ok(Set<DataSegment> segments) | ||
| { | ||
| return new SegmentPublishResult(segments, true, null); | ||
| return new SegmentPublishResult(segments, true, false, null); | ||
| } | ||
|
|
||
| public static SegmentPublishResult ok(Set<DataSegment> segments, List<PendingSegmentRecord> upgradedPendingSegments) | ||
| { | ||
| return new SegmentPublishResult(segments, true, null, upgradedPendingSegments); | ||
| return new SegmentPublishResult(segments, true, false, null, upgradedPendingSegments); | ||
| } | ||
|
|
||
| public static SegmentPublishResult fail(String errorMsg) | ||
| public static SegmentPublishResult fail(String errorMsg, Object... args) | ||
| { | ||
| return new SegmentPublishResult(ImmutableSet.of(), false, errorMsg); | ||
| return new SegmentPublishResult(Set.of(), false, false, StringUtils.format(errorMsg, args), null); | ||
| } | ||
|
|
||
| public static SegmentPublishResult retryableFailure(String errorMsg, Object... args) | ||
| { | ||
| return new SegmentPublishResult(Set.of(), false, true, StringUtils.format(errorMsg, args), null); | ||
| } | ||
|
|
||
| @JsonCreator | ||
| private SegmentPublishResult( | ||
| @JsonProperty("segments") Set<DataSegment> segments, | ||
| @JsonProperty("success") boolean success, | ||
| @JsonProperty("retryable") boolean retryable, | ||
| @JsonProperty("errorMsg") @Nullable String errorMsg | ||
| ) | ||
| { | ||
| this(segments, success, errorMsg, null); | ||
| this(segments, success, retryable, errorMsg, null); | ||
| } | ||
|
|
||
| private SegmentPublishResult( | ||
| Set<DataSegment> segments, | ||
| boolean success, | ||
| @Nullable String errorMsg, | ||
| boolean retryable, | ||
| @Nullable String errorMsg, | ||
| List<PendingSegmentRecord> upgradedPendingSegments | ||
| ) | ||
| { | ||
| this.segments = Preconditions.checkNotNull(segments, "segments"); | ||
| this.success = success; | ||
| this.errorMsg = errorMsg; | ||
| this.retryable = retryable; | ||
| this.upgradedPendingSegments = upgradedPendingSegments; | ||
|
|
||
| if (!success) { | ||
|
|
@@ -98,6 +98,12 @@ private SegmentPublishResult( | |
| } | ||
| } | ||
|
|
||
| /** | ||
| * Set of segments published successfully. | ||
| * | ||
| * @return Empty set if the publish operation failed or if all the segments had | ||
| * already been published by a different transaction. | ||
| */ | ||
| @JsonProperty | ||
| public Set<DataSegment> getSegments() | ||
| { | ||
|
|
@@ -117,6 +123,12 @@ public String getErrorMsg() | |
| return errorMsg; | ||
| } | ||
|
|
||
| @JsonProperty | ||
| public boolean isRetryable() | ||
| { | ||
| return retryable; | ||
| } | ||
|
|
||
| @Nullable | ||
| public List<PendingSegmentRecord> getUpgradedPendingSegments() | ||
| { | ||
|
|
@@ -134,14 +146,15 @@ public boolean equals(Object o) | |
| } | ||
| SegmentPublishResult that = (SegmentPublishResult) o; | ||
| return success == that.success && | ||
| retryable == that.retryable && | ||
| Objects.equals(segments, that.segments) && | ||
| Objects.equals(errorMsg, that.errorMsg); | ||
| } | ||
|
|
||
| @Override | ||
| public int hashCode() | ||
| { | ||
| return Objects.hash(segments, success, errorMsg); | ||
| return Objects.hash(segments, success, errorMsg, retryable); | ||
| } | ||
|
|
||
| @Override | ||
|
|
@@ -150,6 +163,7 @@ public String toString() | |
| return "SegmentPublishResult{" + | ||
| "segments=" + SegmentUtils.commaSeparatedIdentifiers(segments) + | ||
| ", success=" + success + | ||
| ", retryable=" + retryable + | ||
| ", errorMsg='" + errorMsg + '\'' + | ||
| '}'; | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.