Skip to content
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

DateFormat incompatibility between 6.x and 7.x #40913

Closed
ywelsch opened this issue Apr 5, 2019 · 9 comments
Closed

DateFormat incompatibility between 6.x and 7.x #40913

ywelsch opened this issue Apr 5, 2019 · 9 comments
Labels
>bug :Core/Infra/Core Core issues without another label :Search Foundations/Mapping Index mappings, including merging and defining field types Team:Search Foundations Meta label for the Search Foundations team in Elasticsearch

Comments

@ywelsch
Copy link
Contributor

ywelsch commented Apr 5, 2019

QA testing of ML functionality in an upgrade from 6.7.1 to 7.0.0-rc2 revealed an issue where moving shards from 6.7.1 to 7.0.0-rc2 nodes were getting stuck in the translog phase. The reason for this was that the 7.0.0-rc2 would not be able to parse the documents from the 6.7.1 node, internally throwing a MapperParsingException of the form failed to parse field [@timestamp] of type [date] in document with id 'AVr3KgpQqy1yzebk-FVk'. This would in turn make the peer recovery hang, as the node with the MapperParsingException would indefinitely wait for a cluster state update with an updated mapping. This issue does not only present a problem for rolling upgrades, but also does not allow any peer recovery of that index in a pure 7.x cluster unless the translog with the corresponding documents is completely purged.

The problematic dateformat field in the mappings of the index looked as follows:

  "@timestamp" : {
    "type" : "date",
    "format" : "yyyy-MM-dd'T'HH:mm:ss.SSSZ"
  }, ...

The documents were of the form

{"@timestamp":"2013-01-25T20:16:55.000Z", ...}

The problem seems to be an incompatibility between 6.x and 7.x when it comes to date format parsing, possibly related to #27330

The following test illustrates the problem on 7.x:

    // put this in DateFieldMapperTests
    public void testFormat() throws Exception {
        String mapping = Strings.toString(XContentFactory.jsonBuilder().startObject().startObject("type")
            .startObject("properties").startObject("@timestamp").field("type", "date")
            .field("format", "yyyy-MM-dd'T'HH:mm:ss.SSSZ").endObject().endObject()
            .endObject().endObject());
        DocumentMapper mapper = parser.parse("type", new CompressedXContent(mapping));
        ParsedDocument doc = mapper.parse(new SourceToParse("test", "type", "1", BytesReference
            .bytes(XContentFactory.jsonBuilder()
                .startObject()
                .field("@timestamp", "2013-01-25T20:16:55.000Z")
                .endObject()),
            XContentType.JSON));
        assertNotNull(doc);
    }

and the corresponding test on 6.x passes:

    public void testFormat() throws Exception {
        String mapping = Strings.toString(XContentFactory.jsonBuilder().startObject().startObject("type")
            .startObject("properties").startObject("@timestamp").field("type", "date")
            .field("format", "yyyy-MM-dd'T'HH:mm:ss.SSSZ").endObject().endObject()
            .endObject().endObject());
        DocumentMapper mapper = parser.parse("type", new CompressedXContent(mapping));
        ParsedDocument doc = mapper.parse(SourceToParse.source("test", "type", "1", BytesReference
                .bytes(XContentFactory.jsonBuilder()
                    .startObject()
                    .field("@timestamp", "2013-01-25T20:16:55.000Z")
                    .endObject()),
            XContentType.JSON));
        assertNotNull(doc);
    }

Involved in this investigation: @pheyos and @dolaru (ML QA), @joegallo (Cloud, where rolling upgrades got stuck), @dnhatn (ES debugging + tests)

@ywelsch ywelsch added >bug :Core/Infra/Core Core issues without another label labels Apr 5, 2019
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-core-infra

@pgomulka
Copy link
Contributor

pgomulka commented Apr 6, 2019

Should the pattern before the upgrade from 6.x to 7.x be prefixed with 8 and in java-time format?
if the pattern in a test in 6.x is prefixed with 8 it will fail the same (as it would use JavaDateFormatter)

how about patterns like these?
8yyyy-MM-dd'T'HH:mm:ss.SSSXX in 6.x and yyyy-MM-dd'T'HH:mm:ss.SSSXX in 7.x?

@jimczi jimczi added the :Search Foundations/Mapping Index mappings, including merging and defining field types label Apr 8, 2019
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-search

@jaredmcqueen
Copy link
Contributor

jaredmcqueen commented Apr 22, 2019

I have discovered this too.

in 6.x this worked:
2019-04-09T00:34:10+00:00
yyyy-MM-dd'T'HH:mm:ssZZ

in 7.x it fails - but the work around I found is changing the ZZ to zz

So in 7.x this works:
2019-04-09T00:34:10+00:00
yyyy-MM-dd'T'HH:mm:sszz

not sure why the two lowercase z's fix it.

dnhatn added a commit that referenced this issue Apr 24, 2019
A stuck peer recovery in #40913 reveals that we indefinitely retry on
new cluster states if indexing translog operations hits a mapper
exception. We should not wait and retry if the mapping on the target is
as recent as the mapping that the primary used to index the replaying
operations.

Relates #40913
dnhatn added a commit to dnhatn/elasticsearch that referenced this issue Apr 27, 2019
A stuck peer recovery in elastic#40913 reveals that we indefinitely retry on
new cluster states if indexing translog operations hits a mapper
exception. We should not wait and retry if the mapping on the target is
as recent as the mapping that the primary used to index the replaying
operations.

Relates elastic#40913
akhil10x5 pushed a commit to akhil10x5/elasticsearch that referenced this issue May 2, 2019
A stuck peer recovery in elastic#40913 reveals that we indefinitely retry on
new cluster states if indexing translog operations hits a mapper
exception. We should not wait and retry if the mapping on the target is
as recent as the mapping that the primary used to index the replaying
operations.

Relates elastic#40913
@pgomulka
Copy link
Contributor

pgomulka commented May 6, 2019

@jaredmcqueen on what scenario was this failing for you? Was this the ML upgrade too?

you can use 'zz' pattern for this example, this will use java's OffsetIdPrinterParser with (+HH:MM:ss and Z as default.
The 'z' is intended for zone names (like GMT, PST, UTC etc. ) but can fall back to parsing with offset as well (like in your example)

You can use 'XXX' pattern if you want to allow ONLY +HH:MM:ss and Z

@pgomulka pgomulka self-assigned this May 7, 2019
@jaredmcqueen
Copy link
Contributor

jaredmcqueen commented May 24, 2019

The scenario it was failing was general index mappings. I was trying to index ISO 8601 datetimes.

gurkankaymak pushed a commit to gurkankaymak/elasticsearch that referenced this issue May 27, 2019
A stuck peer recovery in elastic#40913 reveals that we indefinitely retry on
new cluster states if indexing translog operations hits a mapper
exception. We should not wait and retry if the mapping on the target is
as recent as the mapping that the primary used to index the replaying
operations.

Relates elastic#40913
@ITzhangqiang
Copy link

I have discovered this too.

in 6.x this worked:
2019-04-09T00:34:10+00:00
yyyy-MM-dd'T'HH:mm:ssZZ

in 7.x it fails - but the work around I found is changing the ZZ to zz

So in 7.x this works:
2019-04-09T00:34:10+00:00
yyyy-MM-dd'T'HH:mm:sszz

not sure why the two lowercase z's fix it.

NB,bro

@pgomulka
Copy link
Contributor

@ywelsch are you ok if I close this issue? This problem occurred because the incorrect pattern was used - missing 8 prefix and Z instead of X
as per my comment here #40913 (comment)
and it seems like it is being linked to other time related issues, different then the problem described in the first comment.
I would personally prefer if there is a new date related problem, a new issue to be opened.

@ywelsch
Copy link
Contributor Author

ywelsch commented Dec 13, 2019

Yes, you can close the issue if you think this is resolved.

@javanna javanna added the Team:Search Foundations Meta label for the Search Foundations team in Elasticsearch label Jul 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>bug :Core/Infra/Core Core issues without another label :Search Foundations/Mapping Index mappings, including merging and defining field types Team:Search Foundations Meta label for the Search Foundations team in Elasticsearch
Projects
None yet
Development

No branches or pull requests

7 participants