How to tell Druid to skip bad kafka records during ingestion with schema registry?

My Kafka topics sometimes contains bad (corrupted) records. I would like to skip them while ingesting data, becauese now an error appears while ingesting. I have found the maxParseExceptions parameter but it is set to a big number by default (2147483647) and the error still happens.

  • I configured Druid to ingest data from kafka with schema_registry successfully. Everything works as expected (records are parsed well and loaded into the DataSource.
  • It works well until Druid hits, at some offset, a bad record which doesn’t have valid data because it’s corrupted. If I look into task logs, I can find an error message with an exception saying that the schema id is not found in the schema registry (see logs below). That’s because the first bytes of that record are corrupted and doesn’t contain a correct schema id, but just noise.
  • When that happens, the ingestion stops and starts again after some time. When it is restarde, the same happens. it keeps doing that in a loop.

Because of that, I cant load kafka messages after the bad one. I would like to skip all corrupted messages from being ingested and ignore them.

Things I've tried
  • I have played with maxParseExceptions with no luck.

maxParseExceptions parameter is defined here:


This is the error I get during ingestion:

2022-03-14T13:46:03,647 ERROR [task-runner-0-priority-0] org.apache.druid.indexing.seekablestream.SeekableStreamIndexTaskRunner - Encountered exception while running task. Failed to get Avro schema: 1786271608
    at ~[?:?]
    at ~[?:?]
    at ~[druid-core-0.22.1.jar:0.22.1]
    at ~[druid-processing-0.22.1.jar:0.22.1]
    at ~[druid-indexing-service-0.22.1.jar:0.22.1]
    at org.apache.druid.indexing.seekablestream.StreamChunkParser.parseWithInputFormat( ~[druid-indexing-service-0.22.1.jar:0.22.1]
    at org.apache.druid.indexing.seekablestream.StreamChunkParser.parse( ~[druid-indexing-service-0.22.1.jar:0.22.1]
    at org.apache.druid.indexing.seekablestream.SeekableStreamIndexTaskRunner.runInternal( ~[druid-indexing-service-0.22.1.jar:0.22.1]
    at [druid-indexing-service-0.22.1.jar:0.22.1]
    at [druid-indexing-service-0.22.1.jar:0.22.1]
    at org.apache.druid.indexing.overlord.SingleTaskBackgroundRunner$ [druid-indexing-service-0.22.1.jar:0.22.1]
    at org.apache.druid.indexing.overlord.SingleTaskBackgroundRunner$ [druid-indexing-service-0.22.1.jar:0.22.1]
    at [?:1.8.0_275]
    at java.util.concurrent.ThreadPoolExecutor.runWorker( [?:1.8.0_275]
    at java.util.concurrent.ThreadPoolExecutor$ [?:1.8.0_275]
    at [?:1.8.0_275]
Caused by: Schema not found; error code: 40403
    at ~[?:?]
    at ~[?:?]
    at ~[?:?]
    at ~[?:?]
    at io.confluent.kafka.schemaregistry.client.CachedSchemaRegistryClient.getSchemaByIdFromRegistry( ~[?:?]
    at io.confluent.kafka.schemaregistry.client.CachedSchemaRegistryClient.getSchemaBySubjectAndId( ~[?:?]
    at io.confluent.kafka.schemaregistry.client.CachedSchemaRegistryClient.getSchemaById( ~[?:?]
    at ~[?:?]
    ... 15 more

This is the configuration spec for the ingestion:

  "type": "kafka",
  "spec": {
    "dataSchema": {
      "dataSource": "",
      "timestampSpec": {
        "column": "lastOperationTime",
        "format": "millis",
        "missingValue": null
      "dimensionsSpec": {
        "dimensions": [     
            ... (ommited) ...           
        "dimensionExclusions": [
      "metricsSpec": [],
      "granularitySpec": {
        "type": "uniform",
        "segmentGranularity": "DAY",
        "queryGranularity": {
          "type": "none"
        "rollup": false,
        "intervals": []
      "transformSpec": {
        "filter": null,
        "transforms": []
    "ioConfig": {
      "topic": "",
      "inputFormat": {
        "type": "avro_stream",
        "flattenSpec": {
          "useFieldDiscovery": true,
          "fields": [
            ... (ommited) ...
        "avroBytesDecoder": {
          "type": "schema_registry",
          "url": "http://schema_registry_host:port",
          "capacity": 2147483647,
          "urls": null,
          "config": null,
          "headers": null
        "binaryAsString": true,
        "extractUnionsByType": false
      "replicas": 1,
      "taskCount": 1,
      "taskDuration": "PT3600S",
      "consumerProperties": {
        "bootstrap.servers": "bootstrap servers ips and ports"
      "pollTimeout": 100,
      "startDelay": "PT5S",
      "period": "PT30S",
      "useEarliestOffset": true,
      "completionTimeout": "PT1800S",
      "lateMessageRejectionPeriod": null,
      "earlyMessageRejectionPeriod": null,
      "lateMessageRejectionStartDateTime": null,
      "stream": "",
      "useEarliestSequenceNumber": true,
      "autoscalerConfig": null,
      "type": "kafka"
    "tuningConfig": {
      "type": "kafka",
      "appendableIndexSpec": {
        "type": "onheap"
      "maxRowsInMemory": 1000000,
      "maxBytesInMemory": 0,
      "skipBytesInMemoryOverheadCheck": false,
      "maxRowsPerSegment": 5000000,
      "maxTotalRows": null,
      "intermediatePersistPeriod": "PT10M",
      "basePersistDirectory": "/opt/druid/var/tmp/druid-realtime-persist349032434046494455",
      "maxPendingPersists": 0,
      "indexSpec": {
        "bitmap": {
          "type": "roaring",
          "compressRunOnSerialization": true
        "dimensionCompression": "lz4",
        "metricCompression": "lz4",
        "longEncoding": "longs",
        "segmentLoader": null
      "indexSpecForIntermediatePersists": {
        "bitmap": {
          "type": "roaring",
          "compressRunOnSerialization": true
        "dimensionCompression": "lz4",
        "metricCompression": "lz4",
        "longEncoding": "longs",
        "segmentLoader": null
      "reportParseExceptions": false,
      "handoffConditionTimeout": 0,
      "resetOffsetAutomatically": false,
      "segmentWriteOutMediumFactory": null,
      "workerThreads": null,
      "chatThreads": null,
      "chatRetries": 8,
      "httpTimeout": "PT10S",
      "shutdownTimeout": "PT80S",
      "offsetFetchPeriod": "PT30S",
      "intermediateHandoffPeriod": "P2147483647D",
      "logParseExceptions": true,
      "maxParseExceptions": 2147483647,
      "maxSavedParseExceptions": 10,
      "skipSequenceNumberAvailabilityCheck": false,
      "repartitionTransitionDuration": "PT120S"

Relates to Apache Druid 0.22.1

Welcome @Dani! Thank you for including the logs. I’m wondering if it might be an Avro issue?

Hi @Mark_Herrera. Thank you for your quick answer.

What do you mean by Avro issue? From Avro point of view there’s no much. The data in the failing Kafka message contains just corrupt data with no sense, just noise. If I parse the first bytes (where schema id is located) of the corrupt message into an integer, you get the id that it’s logged: 1786271608. Since the id is got from noise, it has no sense and that’s why it druid fails from getting it from the schema registry (it doesn’t exists).

So the error being logged is correct. What I want is just to ignore these errors, skip these bad data, and keep consuming next messages. But the ingestion stops with that error. How can I configure druid to skip messages if an error occurs?

Hi Dani,

This is a known issue with Parser and parseSpec and they are deprecated. I see that you are using the Avro Stream Input Format instead which is the recommended approach. I wonder if it is a bug.

1 Like

I think this discussion might be of interest to you:

1 Like

Hi Vijeth_Sagar.

Thank you for your response.

I am pretty sure that this is what is happening to me, and the proposed change will correct my issue.

Do you know if it will be included in next release? Is there any roadmap or schadule? Can I contribute somehow, for instance, creating an issue?

Thank you very much

@petermarshallio @Sergio_Ferragut

Do we know the answer to this?

Hi @Dani,

The PR is merged into master, so it should make it into a release relatively soon.

You can get release announcements and/or get involved in the release planning by joining the Druid dev mailing list.

1 Like

Thank you very much, Sergio.

Hey @Dani and @Sergio_Ferragut I’ve pinged this over into the developer slack to see if we get any view from the devs :slight_smile: