-
Notifications
You must be signed in to change notification settings - Fork 25.6k
[ML] Add internal flag to flush api to control whether or not to flush indices #96803
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
[ML] Add internal flag to flush api to control whether or not to flush indices #96803
Conversation
…dices or not. When datafeeds send flush requests they don't require the indices to be refreshed. First working version.
…d_internal_flag_to_flush_api
…d_internal_flag_to_flush_api
…d_internal_flag_to_flush_api
… fix Always refresh indices in FlushAcknowlegement instance created within integration tests. This is to ensure consistent behaviour across test runs.
…d_internal_flag_to_flush_api
…d_internal_flag_to_flush_api
|
retest |
…d_internal_flag_to_flush_api
|
Pinging @elastic/ml-core (Team:ML) |
|
|
||
| private final String id; | ||
| private final Instant lastFinalizedBucketEnd; | ||
| private final Boolean refreshRequired; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be boolean, and always set, because the constructor sets it to refreshRequired == null || refreshRequired.
| public FlushAcknowledgement(StreamInput in) throws IOException { | ||
| id = in.readString(); | ||
| lastFinalizedBucketEnd = in.readOptionalInstant(); | ||
| refreshRequired = in.readOptionalBoolean(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| refreshRequired = in.readOptionalBoolean(); | |
| refreshRequired = in.readBoolean(); |
Also, needs BWC protection.
| public void writeTo(StreamOutput out) throws IOException { | ||
| out.writeString(id); | ||
| out.writeOptionalInstant(lastFinalizedBucketEnd); | ||
| out.writeOptionalBoolean(refreshRequired); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| out.writeOptionalBoolean(refreshRequired); | |
| out.writeBoolean(refreshRequired); |
And BWC needs to be handled too.
| return lastFinalizedBucketEnd; | ||
| } | ||
|
|
||
| public Boolean getRefreshRequired() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| public Boolean getRefreshRequired() { | |
| public boolean getRefreshRequired() { |
| return Objects.equals(id, other.id) && Objects.equals(lastFinalizedBucketEnd, other.lastFinalizedBucketEnd); | ||
| return Objects.equals(id, other.id) | ||
| && Objects.equals(lastFinalizedBucketEnd, other.lastFinalizedBucketEnd) | ||
| && Objects.equals(refreshRequired, other.refreshRequired); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be a simple comparison after switching to boolean.
| out.writeOptionalString(advanceTime); | ||
| out.writeOptionalString(skipTime); | ||
| out.writeBoolean(waitForNormalization); | ||
| out.writeBoolean(refreshRequired); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs BWC protection. Please read the JavaDocs in TransportVersion.java to see how to do it now.
| advanceTime = in.readOptionalString(); | ||
| skipTime = in.readOptionalString(); | ||
| waitForNormalization = in.readBoolean(); | ||
| refreshRequired = in.readBoolean(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs BWC protection.
| return waitForNormalization; | ||
| } | ||
|
|
||
| public Boolean refreshRequired() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| public Boolean refreshRequired() { | |
| public boolean refreshRequired() { |
* use boolean in preference to Boolean * BWC guards
| PARSER.declareString(Request::setEnd, END); | ||
| PARSER.declareString(Request::setAdvanceTime, ADVANCE_TIME); | ||
| PARSER.declareString(Request::setSkipTime, SKIP_TIME); | ||
| PARSER.declareBoolean(Request::setRefreshRequired, REFRESH_REQUIRED); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just thinking about this a bit more, we said we wanted this to be internal-only, so it shouldn't be available in the JSON parser. (Like waitForNormalization isn't in this block.)
| if (skipTime != null) { | ||
| builder.field(SKIP_TIME.getPreferredName(), skipTime); | ||
| } | ||
| builder.field(REFRESH_REQUIRED.getPreferredName(), refreshRequired); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similarly, it shouldn't be included in the JSON representation. (Like waitForNormalization is not mentioned in this method.)
| static { | ||
| PARSER.declareString(ConstructingObjectParser.constructorArg(), ID); | ||
| PARSER.declareLong(ConstructingObjectParser.optionalConstructorArg(), LAST_FINALIZED_BUCKET_END); | ||
| PARSER.declareBoolean(ConstructingObjectParser.optionalConstructorArg(), REFRESH_REQUIRED); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here it is correct to include the internal field in the parser, as this is for internal communications with our C++ code.
* Do not parse "refreshRequired" flag in FlushJobAction
* For backwards compatibility it must be possible to construct FlushAcknowledgement without refreshRequired, i.e. refreshRequired must be nullable. * Added missing comparisons in FlushParams equals and hashCode methods.
droberts195
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
…d_internal_flag_to_flush_api
For transport versions prior to V_8_500_012 refreshRequired in FlushJobAction.Request is always set to true. Update the tests to reflect that.
When datafeeds send flush requests they don't require the indices to be refreshed (and in fact may be detrimentally expensive in the case of small bucket sizes).
This change adds an (internal) flag to control whether or not a refresh is required when flushing.