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

Add more information on _failed_to_convert_ exception (#21946) #27034

Merged
merged 1 commit into from
Nov 6, 2017

Conversation

liketic
Copy link

@liketic liketic commented Oct 17, 2017

Close #21946

@elasticmachine
Copy link
Collaborator

Since this is a community submitted pull request, a Jenkins build has not been kicked off automatically. Can an Elastic organization member please verify the contents of this patch and then kick off a build manually?

@DaveCTurner
Copy link
Contributor

@elasticmachine please test this

@@ -62,6 +64,44 @@ public void testSlowLogParsedDocumentPrinterSourceToLog() throws IOException {
p = new SlowLogParsedDocumentPrinter(index, pd, 10, true, 3);
assertThat(p.toString(), containsString("source[{\"f]"));
assertThat(p.toString(), startsWith("[foo/123] took"));

source = new BytesReference() {
Copy link
Member

Choose a reason for hiding this comment

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

Is it possible to not implement BytesReference just to throw the exception but to actually use a "source" that will trigger some JsonParseException when creating the parser from source? I think that would be more realistic and a better test.

Copy link
Member

@cbuescher cbuescher left a comment

Choose a reason for hiding this comment

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

Thanks, I left a small suggestion for improvement. Also I think @ppf2 who raised the original issue should take a look and let us know his opinion about whether this kind of error message would improve the situation

@liketic
Copy link
Author

liketic commented Oct 28, 2017

@cbuescher Make sense! Thanks a lot! 😃

@@ -193,7 +193,9 @@ public String toString() {
String source = XContentHelper.convertToJson(doc.source(), reformat, doc.getXContentType());
sb.append(", source[").append(Strings.cleanTruncate(source, maxSourceCharsToLog)).append("]");
} catch (IOException e) {
sb.append(", source[_failed_to_convert_]");
sb.append(", source[_failed_to_convert_[").append(e.getMessage()).append("]]");
sb.append(", reformat[").append(reformat).append("]");
Copy link
Member

Choose a reason for hiding this comment

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

Looking at the issue this is trying to fix (#21946), I'm not sure if we need to include the "reformat" and the "x_content_type" in the slow log output.

Copy link
Author

Choose a reason for hiding this comment

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

I pushed 96b88d46cf59a08c9b69e8433364d0c5abc04d30 . Thanks very much! 👍

@cbuescher
Copy link
Member

@liketic thanks, I left another small question, also I'd like to get some feedback from @ppf2 if he thinks including the exception message improves the situation enough to close #21946.

@cbuescher
Copy link
Member

@elasticmachine test this please

@liketic
Copy link
Author

liketic commented Oct 31, 2017

@ppf2 Cloud you take a look at this? 😄

@cbuescher cbuescher self-assigned this Nov 1, 2017
Copy link
Member

@cbuescher cbuescher left a comment

Choose a reason for hiding this comment

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

Hi @liketic, looks like @ppf2 approved of the general way to add this error message in the original issue, I just left one comment regarding the test assertion, then I think this is ready to be merged.

pd = new ParsedDocument(new NumericDocValuesField("version", 1), SeqNoFieldMapper.SequenceIDFields.emptySeqID(), "id",
"test", null, null, source, XContentType.JSON, null);
p = new SlowLogParsedDocumentPrinter(index, pd, 10, true, 3);
assertThat(p.toString(), containsString("_failed_to_convert_[Unrecognized token 'invalid'"));
Copy link
Member

Choose a reason for hiding this comment

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

Can you change this assertion to match the whole error string? It might be a bit fragile to future changes in tests, but since we don't randomize anything here the error should stay stable for a bit and this makes it easiert to understand the whole error structure from reading the test.

Copy link
Author

Choose a reason for hiding this comment

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

Thanks! I pushed 9153b6d99567d6b1b68160d739b2656ddf537c74 . We cannot put the while error message here because the internal class org.elasticsearch.common.bytes.BytesReference$MarkSupportingStreamInputWrapper does not implement a toString() so the results of toString() are different each time.

"test", null, null, source, XContentType.JSON, null);
p = new SlowLogParsedDocumentPrinter(index, pd, 10, true, 3);

assertThat(p.toString(), containsString("_failed_to_convert_[Unrecognized token 'invalid':"
Copy link
Member

Choose a reason for hiding this comment

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

Sorry, what I meant by the previous request was to do an assertion on the whole error string (e.g. wie assertEquals), unless there are any reasons preventing this.

Copy link
Member

Choose a reason for hiding this comment

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

Right, I didn't see your comment above. Makes sense to me now, sorry for the noise.

Copy link
Member

@cbuescher cbuescher left a comment

Choose a reason for hiding this comment

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

LGTM, I will kick of the CI tests

@cbuescher
Copy link
Member

@liketic CI doesn't seem happy, although the error doesn't seem to be related to your changes, could you either rebase your branch or merge in master before I kick off another build?

@liketic
Copy link
Author

liketic commented Nov 3, 2017

@cbuescher Rebase done. Please try again.

@cbuescher
Copy link
Member

@elasticmachine test this please

Copy link
Member

@cbuescher cbuescher left a comment

Choose a reason for hiding this comment

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

Looks ready for merging.

@cbuescher cbuescher merged commit 5d661df into elastic:master Nov 6, 2017
@liketic liketic deleted the issues/21946 branch November 6, 2017 08:49
@cbuescher cbuescher added :Core/Infra/Logging Log management and logging utilities >enhancement v6.1.0 v7.0.0 labels Nov 6, 2017
martijnvg added a commit that referenced this pull request Nov 6, 2017
* 6.x:
  test: Break apart the multi type aspect of rolling upgrade tests,
  Upgrade to Jackson 2.8.10 (#27230)
  [Docs] Fix minor paragraph indentation error for multiple Indices params (#25535)
  Fix inconsistencies in the rest api specs for `tasks` (#27163)
  Adjust RestHighLevelClient method modifiers (#27238)
  Add more information on `_failed_to_convert_` exception (#27034)
  Remove ElasticsearchQueryCachingPolicy (#27190)
  Backport the size-based index rollver to v6.1.0
  Add size-based condition to the index rollover API (#27160)
  Remove the single argument Environment constructor (#27235)
  Fix RestGetAction name typo
jasontedor added a commit that referenced this pull request Nov 7, 2017
* master: (25 commits)
  Disable bwc tests in preparation of backporting #26931
  TemplateUpgradeService should only run on the master (#27294)
  Die with dignity while merging
  Fix profiling naming issues (#27133)
  Correctly encode warning headers
  Fixed references to Multi Index Syntax (#27283)
  Add an active Elasticsearch WordPress plugin link (#27279)
  Setting url parts as required to reflect the code base (#27263)
  keys in aggs percentiles need to be in quotes. (#26905)
  Align routing param type with search.json (#26958)
  Update to support bulk updates by query (#27172)
  Remove duplicated SnapshotStatus (#27276)
  add split index reference in indices.asciidoc
  Add ability to split shards (#26931)
  [Docs] Fix minor paragraph indentation error for multiple Indices params (#25535)
  Upgrade to Jackson 2.8.10 (#27230)
  Fix inconsistencies in the rest api specs for `tasks` (#27163)
  Adjust RestHighLevelClient method modifiers (#27238)
  Remove unused parameters in AnalysisRegistry (#27232)
  Add more information on `_failed_to_convert_` exception (#27034)
  ...
jasontedor added a commit to martijnvg/elasticsearch that referenced this pull request Nov 7, 2017
* ccr: (127 commits)
  Disable bwc tests in preparation of backporting elastic#26931
  TemplateUpgradeService should only run on the master (elastic#27294)
  Die with dignity while merging
  Fix profiling naming issues (elastic#27133)
  Correctly encode warning headers
  Fixed references to Multi Index Syntax (elastic#27283)
  Add an active Elasticsearch WordPress plugin link (elastic#27279)
  Setting url parts as required to reflect the code base (elastic#27263)
  keys in aggs percentiles need to be in quotes. (elastic#26905)
  Align routing param type with search.json (elastic#26958)
  Update to support bulk updates by query (elastic#27172)
  Remove duplicated SnapshotStatus (elastic#27276)
  add split index reference in indices.asciidoc
  Add ability to split shards (elastic#26931)
  [Docs] Fix minor paragraph indentation error for multiple Indices params (elastic#25535)
  Upgrade to Jackson 2.8.10 (elastic#27230)
  Fix inconsistencies in the rest api specs for `tasks` (elastic#27163)
  Adjust RestHighLevelClient method modifiers (elastic#27238)
  Remove unused parameters in AnalysisRegistry (elastic#27232)
  Add more information on `_failed_to_convert_` exception (elastic#27034)
  ...
@colings86 colings86 removed the v7.0.0 label Feb 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants