Skip to content

Conversation

pgomulka
Copy link
Contributor

If an index was created in version 6 and contain a date field with a joda-style pattern it should still be allowed to search and insert document into it.
Those created in 6 but date pattern starts with 8, it should be considered as java style.

@pgomulka pgomulka self-assigned this Feb 20, 2020
@pgomulka pgomulka added v7.7.0 :Core/Infra/Core Core issues without another label labels Feb 20, 2020
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-core-infra (:Core/Infra/Core)

@pugnascotia
Copy link
Contributor

@pgomulka there seems to be some unrelated changes here? Are you completely up-to-date with 7.x?

@pgomulka pgomulka force-pushed the joda/enable_joda_indices branch from 9990233 to 9b79406 Compare February 20, 2020 13:26
rolling upgrade test for joda-java

support for java.style created in 6

tests passing

revert not needed changes
@pgomulka pgomulka force-pushed the joda/enable_joda_indices branch from 75b3458 to 04d376a Compare February 20, 2020 13:48
@pgomulka
Copy link
Contributor Author

@pugnascotia yes, this is probably because of file encoding and line separators on windows.. trying to fix..

@pgomulka
Copy link
Contributor Author

@elasticmachine test this please

if (hasPatternChanged || Objects.equals(builder.locale, formatter.locale()) == false) {
fieldType().setDateTimeFormatter(DateFormatter.forPattern(pattern).withLocale(locale));
DateFormatter dateTimeFormatter;
// if (Joda.isJodaStyleIndex(context,pattern) ) {
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't this be uncommented?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes - I am trying to find a good example where the test for range fields fails in 7 with joda pattern. Luckily the one with 'YYYY' passes -although the values are incorrectly parsed

@pgomulka
Copy link
Contributor Author

@elasticmachine run elasticsearch-ci/bwc

@pgomulka
Copy link
Contributor Author

pgomulka commented Mar 4, 2020

@elasticmachine update branch

@pgomulka
Copy link
Contributor Author

pgomulka commented Mar 9, 2020

it was failing the build because I forgot to use refresh when indexing docs.
passing now.
@polyfractal would you have some time to give it a look?

Copy link
Contributor

@jpountz jpountz left a comment

Choose a reason for hiding this comment

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

I left some comments, but the approach and tests make sense to me.

response = performRequest(iteratorNodeTuple, internalRequest, null);
}
return response;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

We shouldn't add this method to the REST client, it's trappy by design given how it ignores all responses but the last one?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good point, this should not be available outside tests

* Hence a skip assume section in init()
*
* @see org.elasticsearch.search.DocValueFormat.DateTime
*/
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for adding javadocs to this test suite. This isn't common practice in our code base, but is definitely useful in this case.

*
* @see org.elasticsearch.search.DocValueFormat.DateTime
*/
public class DateFieldsIT extends AbstractRollingTestCase {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you use a more specific name, something like JodaCompatibilityIT?

return options.build();
}

private void assertSearchResponse(Response searchResp) throws IOException {
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe use a different name, when I first saw the method I assumed it would check for shard failures, like ElasticsearchAssertions#assertSearchResponse, but this one actually checks the content.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

will rename

search.setOptions(ignoreWarnings());

Response searchResp = client().performRequest(search,3);
assertEquals(HttpStatus.SC_OK, searchResp.getStatusLine().getStatusCode());
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we go further and assert that the total number of shards is equal to the number of successful shards?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good idea. will do

* all shards are allocated on the same node and client is connecting to it.
* Because of this warnings assertions have to be ignored.
*
* A special flag on DocValues is used to indicate that an index was created in 6.x and has a joda pattern.
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not seeing this flag?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the flag is used during serialization of DocValueFormat.DateTime
I have reworded the javadoc


public static boolean isJodaPattern(Version version, String pattern) {
return version.before(Version.V_7_0_0)
&& version.after(Version.V_6_0_0)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you meant onOrAfter. But this makes me wonder whether we need this condition of the boolean expression, pre-6.x indices are not supported anyway in 7.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

agree - will remove && version.after(Version.V_6_0_0)
I meant to make it explicit, but I think the context in v7 is clear that pre6x is not supported

}
};

public static boolean isJodaPattern(Version version, String pattern) {
Copy link
Contributor

Choose a reason for hiding this comment

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

can you add javadocs?

isJoda = in.readBoolean();
} else {
//when received a stream from 6.0-6.latest Node it can be java if starts with 8 otherwise joda
// If a stream is from [7.0 - 7.7) it will assume (sometimes incorrectly) that the date is java
Copy link
Contributor

Choose a reason for hiding this comment

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

can you add more details about when it gets incorrect? If my understanding is correct, this happens if an index is created on 6.x and the cluster is later upgraded to 7.x (x<7)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

you are correct. added more details about this. Let me know if it is clear now

@pgomulka
Copy link
Contributor Author

pgomulka commented Mar 10, 2020

@elasticmachine run elasticsearch-ci/2
failure related to #53222

@pgomulka
Copy link
Contributor Author

@elasticmachine update branch

@pgomulka
Copy link
Contributor Author

@elasticmachine run elasticsearch-ci/packaging-sample-matrix-windows

@pgomulka pgomulka requested a review from jpountz March 11, 2020 09:38
Copy link
Contributor

@jpountz jpountz left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks for taking care of this.

);
Response resp = client().performRequest(putDoc);
assertEquals(HttpStatus.SC_CREATED, resp.getStatusLine().getStatusCode());
// flush(endpoint,true);
Copy link
Contributor

Choose a reason for hiding this comment

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

remove?

@pgomulka pgomulka merged commit 2438b89 into elastic:7.x Mar 12, 2020
pgomulka added a commit that referenced this pull request Mar 12, 2020
when upgrading from 7.7+ ES will send out a flag indicating if a pattern is of joda style. This is only used to support joda style indices in 7.x, in 8 we no longer support this. All indices in 8 should use java style pattern. Hence we can ignore this flag. Similarly when writing from v8 to v7.7+ we should always send false flag.

relates #52555
relates #53478
closes #53477
pgomulka added a commit that referenced this pull request Aug 20, 2020
Previously migration guide incorrectly stated that joda-time patterns have to be fixed before upgrading to 7.x
since (7.7) #52555 and our bwc policy 6.x created indices even with joda-time are supported
relates #60374
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Core/Infra/Core Core issues without another label v7.7.0
6 participants