scylladb / kafka-connect-scylladb

Kafka Connect Scylladb Sink

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Connector fails : JsonConverter with schemas.enable requires "schema" and "payload" fields and may not contain additional fields.

Saikumarn78 opened this issue · comments

Hello @avelanarius @mailmahee

Following the procedure mentioned on the blog and hit with the bellow error.

Initially, the log was complaining about the JSON line which has syntax issue and after correcting the JSON we are hit with another error.

Issue 1 :

Caused by: org.apache.kafka.common.errors.SerializationException: com.fasterxml.jackson.core.JsonParseException: Unexpected character (':' (code 58)): was expecting comma to separate Array entries
at [Source: (byte[])"{"schema":{"type":"struct","fields":[{"type":"int32","optional":false,"field":"id"},{"type":"string","optional":false,"field":"name"},{"type":"string","optional":true,"field":"department"},"payload":{"id":10,"name":"John Doe10","department":"engineering"}}"; line: 1, column: 200]
Caused by: com.fasterxml.jackson.core.JsonParseException: Unexpected character (':' (code 58)): was expecting comma to separate Array entries
at [Source: (byte[])"{"schema":{"type":"struct","fields":[{"type":"int32","optional":false,"field":"id"},{"type":"string","optional":false,"field":"name"},{"type":"string","optional":true,"field":"department"},"payload":{"id":10,"name":"John Doe10","department":"engineering"}}"; line: 1, column: 200]

{"schema":{"type":"struct","fields":[{"type":"int32","optional":false,"field":"id"},{"type":"string","optional":false,"field":"name"},{"type":"string","optional":true,"field":"department"},"payload":{"id":10,"name":"John Doe10","department":"engineering"}}

After solving the Json on issue 1 then issue 2 occurred.

[2021-05-28 02:31:08,684] INFO [Consumer clientId=connector-consumer-scylladb-sink-connector-0, groupId=connect-scylladb-sink-connector] Resetting offset for partition rndnewsix-0 to position FetchPosition{offset=0, offsetEpoch=Optional.empty, currentLeader=LeaderAndEpoch{leader=Optional[10.10.188.11:9092 (id: 0 rack: null)], epoch=0}}. (org.apache.kafka.clients.consumer.internals.SubscriptionState:396)
[2021-05-28 02:31:08,756] ERROR WorkerSinkTask{id=scylladb-sink-connector-0} Error converting message value in topic 'rndnewsix' partition 0 at offset 0 and timestamp 1622186917395: JsonConverter with schemas.enable requires "schema" and "payload" fields and may not contain additional fields. If you are trying to deserialize plain JSON data, set schemas.enable=false in your converter configuration. (org.apache.kafka.connect.runtime.WorkerSinkTask:547)
org.apache.kafka.connect.errors.DataException: JsonConverter with schemas.enable requires "schema" and "payload" fields and may not contain additional fields. If you are trying to deserialize plain JSON data, set schemas.enable=false in your converter configuration.
at org.apache.kafka.connect.json.JsonConverter.toConnectData(JsonConverter.java:370)
at org.apache.kafka.connect.storage.Converter.toConnectData(Converter.java:87)
at org.apache.kafka.connect.runtime.WorkerSinkTask.convertValue(WorkerSinkTask.java:545)
at org.apache.kafka.connect.runtime.WorkerSinkTask.lambda$convertAndTransformRecord$1(WorkerSinkTask.java:501)
at org.apache.kafka.connect.runtime.errors.RetryWithToleranceOperator.execAndRetry(RetryWithToleranceOperator.java:156)
at org.apache.kafka.connect.runtime.errors.RetryWithToleranceOperator.execAndHandleError(RetryWithToleranceOperator.java:190)
at org.apache.kafka.connect.runtime.errors.RetryWithToleranceOperator.execute(RetryWithToleranceOperator.java:132)
at org.apache.kafka.connect.runtime.WorkerSinkTask.convertAndTransformRecord(WorkerSinkTask.java:501)
at org.apache.kafka.connect.runtime.WorkerSinkTask.convertMessages(WorkerSinkTask.java:478)
at org.apache.kafka.connect.runtime.WorkerSinkTask.poll(WorkerSinkTask.java:328)
at org.apache.kafka.connect.runtime.WorkerSinkTask.iteration(WorkerSinkTask.java:232)
at org.apache.kafka.connect.runtime.WorkerSinkTask.execute(WorkerSinkTask.java:201)
at org.apache.kafka.connect.runtime.WorkerTask.doRun(WorkerTask.java:189)
at org.apache.kafka.connect.runtime.WorkerTask.run(WorkerTask.java:238)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
[2021-05-28 02:31:08,818] INFO Using data-center name 'DC1' for DCAwareRoundRobinPolicy (if this is incorrect, please provide the correct datacenter name with DCAwareRoundRobinPolicy constructor) (com.datastax.driver.core.policies.DCAwareRoundRobinPolicy:110)
[2021-05-28 02:31:08,819] INFO New Cassandra host /10.10.228.71:9042 added (com.datastax.driver.core.Cluster:1650)

configs:

[centos7 kafka]$ cat scylladb-sink-connector.properties
name=scylladb-sink-connector
connector.class=io.connect.scylladb.ScyllaDbSinkConnector
tasks.max=1
topics=rndnewsix
scylladb.contact.points=10.10.228.71
scylladb.keyspace=scylladb
key.converter=org.apache.kafka.connect.json.JsonConverter
value.converter=org.apache.kafka.connect.json.JsonConverter
key.converter.schemas.enable=true
value.converter.schemas.enable=true
transforms=createKey
transforms.createKey.fields=id
transforms.createKey.type=org.apache.kafka.connect.transforms.ValueToKey

confluent kafka : @confluent-6.1.1

Hi Team,

Even in Avro mode also we are getting the below error.

./kafka-avro-console-producer --broker-list 10.10.188.11:9092 --topic rnd --property parse.key=true --property key.schema='{"type":"record",name":"key_schema","fields":[{"name":"id","type":"int"}]}' --property "key.separator=$" --property value.schema='{"type":"record","name":"value_schema","fields":[{"name":"id","type":"int"},{"name":"firstName","type":"string"},{"name":"lastName","type":"string"}]}'{"id":1}${"id":1,"firstName":"first","lastName":"last"}
-bash: value.schema='{"type":"record","name":"value_schema","fields":[{"name":"id","type":"int"},{"name":"firstName","type":"string"},{"name":"lastName","type":"string"}]}'{"id":1}${"id":1,"firstName":"first","lastName":"last"}: bad substitution
[elasticsearch@centos7 bin]$

With Confluent 6.0.0 and the connector (configuration below), I can correctly insert the data.

Console producer (first line is the command, second line is an input):

bin/kafka-avro-console-producer --broker-list 127.0.0.1:9092 --topic rnd --property parse.key=true --property key.schema='{"type":"record","name":"key_schema","fields":[{"name":"id","type":"int"}]}' --property "key.separator=$" --property value.schema='{"type":"record","name":"value_schema","fields":[{"name":"id","type":"int"},{"name":"firstName","type":"string"},{"name":"lastName","type":"string"}]}'

{"id":1}${"id":1,"firstName":"first","lastName":"last"}

Connector configuration:

name = rndconn
connector.class = io.connect.scylladb.ScyllaDbSinkConnector
key.converter = io.confluent.connect.avro.AvroConverter
value.converter = io.confluent.connect.avro.AvroConverter
topics = rnd
scylladb.contact.points = 127.0.0.2
scylladb.port = 9042
scylladb.keyspace = ks
value.converter.schema.registry.url = http://localhost:8081
key.converter.schema.registry.url = http://localhost:8081

Before running, I created a keyspace in Scylla: CREATE KEYSPACE ks WITH REPLICATION = {'class': 'SimpleStrategy', 'replication_factor': 1}.