Skip to content

Conversation

@edsavage
Copy link
Contributor

@edsavage edsavage commented Jun 13, 2023

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.

edsavage added 2 commits June 13, 2023 14:51
…dices or not.

When datafeeds send flush requests they don't require the indices to be refreshed.

First working version.
 * change naming
 * remove unnecessary logging
@edsavage edsavage added :ml Machine learning v8.9.0 labels Jun 13, 2023
edsavage added 6 commits June 13, 2023 16:37
… fix

Always refresh indices in FlushAcknowlegement instance created within integration tests. This is to ensure consistent behaviour across test runs.
@edsavage
Copy link
Contributor Author

retest

@edsavage edsavage marked this pull request as ready for review June 14, 2023 15:10
@elasticsearchmachine elasticsearchmachine added the Team:ML Meta label for the ML team label Jun 14, 2023
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/ml-core (Team:ML)


private final String id;
private final Instant lastFinalizedBucketEnd;
private final Boolean refreshRequired;

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();

Choose a reason for hiding this comment

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

Suggested change
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);

Choose a reason for hiding this comment

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

Suggested change
out.writeOptionalBoolean(refreshRequired);
out.writeBoolean(refreshRequired);

And BWC needs to be handled too.

return lastFinalizedBucketEnd;
}

public Boolean getRefreshRequired() {

Choose a reason for hiding this comment

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

Suggested change
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);

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);

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();

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() {

Choose a reason for hiding this comment

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

Suggested change
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);

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);

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);

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.

edsavage added 2 commits June 15, 2023 11:23
 * 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.
Copy link

@droberts195 droberts195 left a comment

Choose a reason for hiding this comment

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

LGTM

edsavage added 3 commits June 15, 2023 14:26
For transport versions prior to V_8_500_012 refreshRequired in FlushJobAction.Request is always set to true. Update the tests to reflect that.
@edsavage edsavage merged commit cbe8aa9 into elastic:main Jun 15, 2023
@edsavage edsavage deleted the add_internal_flag_to_flush_api branch June 15, 2023 15:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

:ml Machine learning >non-issue Team:ML Meta label for the ML team v8.9.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants