You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by "abhishekrb19 (via GitHub)" <gi...@apache.org> on 2023/04/28 06:37:22 UTC

[GitHub] [druid] abhishekrb19 opened a new pull request, #14183: Fix uncaught `ParseException` when reading Avro from Kafka

abhishekrb19 opened a new pull request, #14183:
URL: https://github.com/apache/druid/pull/14183

   <!-- Thanks for trying to help us make Apache Druid be the best it can be! Please fill out as much of the following information as is possible (where relevant, and remove it when irrelevant) to help make the intention and scope of this PR clear in order to ease review. -->
   
   <!-- Please read the doc for contribution (https://github.com/apache/druid/blob/master/CONTRIBUTING.md) before making this PR. Also, once you open a PR, please _avoid using force pushes and rebasing_ since these make it difficult for reviewers to see what you've changed in response to their reviews. See [the 'If your pull request shows conflicts with master' section](https://github.com/apache/druid/blob/master/CONTRIBUTING.md#if-your-pull-request-shows-conflicts-with-master) for more details. -->
   
   Fixes https://github.com/apache/druid/issues/13894, https://github.com/apache/druid/issues/14041.
   
   In `StreamChunkParser#parseWithInputFormat`, we call `byteEntityReader.read()` without handling a potential `ParseException`, which is thrown during this function call by the delegate `AvroStreamReader#intermediateRowIterator`. 
   A `ParseException` can be thrown if an Avro stream has corrupt data or data that doesn't conform to the schema specified or for other decoding reasons. This exception if uncaught, can cause ingestion to fail. 
   
   Primary code changes:
   - Handle `ParseException` in the call stack `StreamChunkParser`.
   - Improved the error message when the avro schema id cannot be found. 
   -  Added a new constructor to `StreamChunkParser` to facilitate unit testing. This allows dependencies to be passed in by the caller, making testing easier.
   - Fix miscellaneous typos and javadocs in the modified code.
   
   Unit test changes:
   - Add unit tests to test this exception handling behavior alongside setting maximum allowed parse exceptions to different thresholds.
   - Replace `NoopRowIngestionMeters` and a mocked `RowIngestionMeters` with a more realistic implementation, `SimpleRowIngestionMeters`, used to validate any parse exceptions.
   
   
   <!--
   In each section, please describe design decisions made, including:
    - Choice of algorithms
    - Behavioral aspects. What configuration values are acceptable? How are corner cases and error conditions handled, such as when there are insufficient resources?
    - Class organization and design (how the logic is split between classes, inheritance, composition, design patterns)
    - Method organization and design (how the logic is split between methods, parameters and return types)
    - Naming (class, method, API, configuration, HTTP endpoint, names of emitted metrics)
   -->
   
   
   <!-- It's good to describe an alternative design (or mention an alternative name) for every design (or naming) decision point and compare the alternatives with the designs that you've implemented (or the names you've chosen) to highlight the advantages of the chosen designs and names. -->
   
   <!-- If there was a discussion of the design of the feature implemented in this PR elsewhere (e. g. a "Proposal" issue, any other issue, or a thread in the development mailing list), link to that discussion from this PR description and explain what have changed in your final design compared to your original proposal or the consensus version in the end of the discussion. If something hasn't changed since the original discussion, you can omit a detailed discussion of those aspects of the design here, perhaps apart from brief mentioning for the sake of readability of this PR description. -->
   
   <!-- Some of the aspects mentioned above may be omitted for simple and small changes. -->
   
   #### Release note
   Fixes https://github.com/apache/druid/issues/13894, https://github.com/apache/druid/issues/14041.
   
   <!-- Give your best effort to summarize your changes in a couple of sentences aimed toward Druid users. 
   
   If your change doesn't have end user impact, you can skip this section.
   
   For tips about how to write a good release note, see [Release notes](https://github.com/apache/druid/blob/master/CONTRIBUTING.md#release-notes).
   
   -->
   
   
   
   <!-- Check the items by putting "x" in the brackets for the done things. Not all of these items apply to every PR. Remove the items which are not done or not relevant to the PR. None of the items from the checklist below are strictly necessary, but it would be very helpful if you at least self-review the PR. -->
   
   This PR has:
   
   - [x] been self-reviewed.
      - [ ] using the [concurrency checklist](https://github.com/apache/druid/blob/master/dev/code-review/concurrency.md) (Remove this item if the PR doesn't have any relation to concurrency.)
   - [ ] added documentation for new or modified features or behaviors.
   - [x] a release note entry in the PR description.
   - [ ] added Javadocs for most classes and all non-trivial methods. Linked related entities via Javadoc links.
   - [ ] added or updated version, license, or notice information in [licenses.yaml](https://github.com/apache/druid/blob/master/dev/license.md)
   - [ ] added comments explaining the "why" and the intent of the code wherever would not be obvious for an unfamiliar reader.
   - [x] added unit tests or modified existing tests to cover new code paths, ensuring the threshold for [code coverage](https://github.com/apache/druid/blob/master/dev/code-review/code-coverage.md) is met.
   - [ ] added integration tests.
   - [x] been tested in a test Druid cluster.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


[GitHub] [druid] abhishekrb19 commented on pull request #14183: Fix uncaught `ParseException` when reading Avro from Kafka

Posted by "abhishekrb19 (via GitHub)" <gi...@apache.org>.
abhishekrb19 commented on PR #14183:
URL: https://github.com/apache/druid/pull/14183#issuecomment-1533524113

   @gianm, thanks for the review. Added a UT to Kafka indexing as well.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


[GitHub] [druid] abhishekagarwal87 merged pull request #14183: Fix uncaught `ParseException` when reading Avro from Kafka

Posted by "abhishekagarwal87 (via GitHub)" <gi...@apache.org>.
abhishekagarwal87 merged PR #14183:
URL: https://github.com/apache/druid/pull/14183


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


[GitHub] [druid] abhishekrb19 commented on a diff in pull request #14183: Fix uncaught `ParseException` when reading Avro from Kafka

Posted by "abhishekrb19 (via GitHub)" <gi...@apache.org>.
abhishekrb19 commented on code in PR #14183:
URL: https://github.com/apache/druid/pull/14183#discussion_r1184104339


##########
extensions-core/avro-extensions/src/main/java/org/apache/druid/data/input/avro/SchemaRegistryBasedAvroBytesDecoder.java:
##########
@@ -140,7 +140,10 @@ public GenericRecord parse(ByteBuffer bytes)
       schema = parsedSchema instanceof AvroSchema ? ((AvroSchema) parsedSchema).rawSchema() : null;
     }
     catch (IOException | RestClientException ex) {
-      throw new ParseException(null, ex, "Failed to fetch Avro schema from registry: %s", id);
+      throw new ParseException(null, ex, "Failed to fetch Avro schema from registry: %s. Check if the id "
+                                         + "exists in the schema registry. Otherwise it could mean that there is "
+                                         + "malformed data in the stream or data that doesn’t conform to the schema "

Review Comment:
   Good spot! Fixed



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


[GitHub] [druid] gianm commented on a diff in pull request #14183: Fix uncaught `ParseException` when reading Avro from Kafka

Posted by "gianm (via GitHub)" <gi...@apache.org>.
gianm commented on code in PR #14183:
URL: https://github.com/apache/druid/pull/14183#discussion_r1180580658


##########
extensions-core/avro-extensions/src/main/java/org/apache/druid/data/input/avro/SchemaRegistryBasedAvroBytesDecoder.java:
##########
@@ -140,7 +140,10 @@ public GenericRecord parse(ByteBuffer bytes)
       schema = parsedSchema instanceof AvroSchema ? ((AvroSchema) parsedSchema).rawSchema() : null;
     }
     catch (IOException | RestClientException ex) {
-      throw new ParseException(null, ex, "Failed to fetch Avro schema from registry: %s", id);
+      throw new ParseException(null, ex, "Failed to fetch Avro schema from registry: %s. Check if the id "

Review Comment:
   Our log message style guide recommends bracketing interpolations, and saying what they are, like `Failed to fetch Avro schema id[%s] from registry.`



##########
extensions-core/avro-extensions/src/main/java/org/apache/druid/data/input/avro/SchemaRegistryBasedAvroBytesDecoder.java:
##########
@@ -140,7 +140,10 @@ public GenericRecord parse(ByteBuffer bytes)
       schema = parsedSchema instanceof AvroSchema ? ((AvroSchema) parsedSchema).rawSchema() : null;
     }
     catch (IOException | RestClientException ex) {
-      throw new ParseException(null, ex, "Failed to fetch Avro schema from registry: %s", id);
+      throw new ParseException(null, ex, "Failed to fetch Avro schema from registry: %s. Check if the id "
+                                         + "exists in the schema registry. Otherwise it could mean that there is "
+                                         + "malformed data in the stream or data that doesn’t conform to the schema "

Review Comment:
   Use `'` instead of `’`?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


[GitHub] [druid] abhishekrb19 commented on pull request #14183: Fix uncaught `ParseException` when reading Avro from Kafka

Posted by "abhishekrb19 (via GitHub)" <gi...@apache.org>.
abhishekrb19 commented on PR #14183:
URL: https://github.com/apache/druid/pull/14183#issuecomment-1527650670

   There is the usual flaky kafka slow IT failure unrelated to this change. Hopefully re-running should fix it:
   ```
   2023-04-28T11:19:34,972 INFO [main] org.apache.druid.security.basic.authorization.db.cache.CoordinatorPollingBasicAuthorizerCacheManager - CoordinatorPollingBasicAuthorizerCacheManager is stopping.
   2023-04-28T11:19:34,972 INFO [main] org.apache.druid.security.basic.authorization.db.cache.CoordinatorPollingBasicAuthorizerCacheManager - CoordinatorPollingBasicAuthorizerCacheManager is stopped.
   2023-04-28T11:19:34,972 INFO [main] org.apache.druid.security.basic.authentication.db.cache.CoordinatorPollingBasicAuthenticatorCacheManager - CoordinatorPollingBasicAuthenticatorCacheManager is stopping.
   2023-04-28T11:19:34,972 INFO [main] org.apache.druid.security.basic.authentication.db.cache.CoordinatorPollingBasicAuthenticatorCacheManager - CoordinatorPollingBasicAuthenticatorCacheManager is stopped.
   2023-04-28T11:19:35,014 INFO [Curator-Framework-0] org.apache.curator.framework.imps.CuratorFrameworkImpl - backgroundOperationsLoop exiting
   2023-04-28T11:19:35,134 INFO [main] org.apache.zookeeper.ZooKeeper - Session: 0x100000e65e40007 closed
   2023-04-28T11:19:35,135 INFO [main-EventThread] org.apache.zookeeper.ClientCnxn - EventThread shut down for session: 0x100000e65e40007
   2023-04-28T11:19:35,154 INFO [main] org.apache.druid.java.util.emitter.core.LoggingEmitter - {"feed":"metrics","metric":"jetty/numOpenConnections","service":"","host":"","value":0,"timestamp":"2023-04-28T11:19:35.152Z"}
   2023-04-28T11:19:35,154 INFO [main] org.apache.druid.java.util.emitter.core.LoggingEmitter - Close: started [false]
   2023-04-28T11:19:35,154 INFO [main] org.apache.druid.java.util.common.lifecycle.Lifecycle - Stopping lifecycle [module] stage [INIT]
   Error:  Tests run: 4, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 2,038.216 s <<< FAILURE! - in TestSuite
   Error:  testKafkaIndexDataWithLosingCoordinator(org.apache.druid.tests.indexer.ITKafkaIndexingServiceTransactionalSerializedTest)  Time elapsed: 234.292 s
   Error:  testKafkaIndexDataWithLosingHistorical(org.apache.druid.tests.indexer.ITKafkaIndexingServiceTransactionalSerializedTest)  Time elapsed: 192.643 s
   Error:  testKafkaIndexDataWithLosingOverlord(org.apache.druid.tests.indexer.ITKafkaIndexingServiceTransactionalSerializedTest)  Time elapsed: 189.737 s
   Error:  testQueryNilColumnBeforeAndAfterPublishingSegments(org.apache.druid.tests.indexer.ITNilColumnTest)  Time elapsed: 1,344.173 s  <<< FAILURE!
   org.apache.druid.java.util.common.ISE: Max number of retries[240] exceeded for Task[Waiting for all tasks to stop]. Failing.
   	at org.apache.druid.tests.indexer.ITNilColumnTest.testQueryNilColumnBeforeAndAfterPublishingSegments(ITNilColumnTest.java:126)
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


[GitHub] [druid] abhishekrb19 commented on a diff in pull request #14183: Fix uncaught `ParseException` when reading Avro from Kafka

Posted by "abhishekrb19 (via GitHub)" <gi...@apache.org>.
abhishekrb19 commented on code in PR #14183:
URL: https://github.com/apache/druid/pull/14183#discussion_r1184103970


##########
extensions-core/avro-extensions/src/main/java/org/apache/druid/data/input/avro/SchemaRegistryBasedAvroBytesDecoder.java:
##########
@@ -140,7 +140,10 @@ public GenericRecord parse(ByteBuffer bytes)
       schema = parsedSchema instanceof AvroSchema ? ((AvroSchema) parsedSchema).rawSchema() : null;
     }
     catch (IOException | RestClientException ex) {
-      throw new ParseException(null, ex, "Failed to fetch Avro schema from registry: %s", id);
+      throw new ParseException(null, ex, "Failed to fetch Avro schema from registry: %s. Check if the id "

Review Comment:
   Done



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org