I'm trying to use Kafka Connect in a local Docker container (using the official Confluent image) in order to push DB2 data to a Kafka cluster on Openshift (on AWS). I'm using the Confluent JDBC connector with my DB2 JDBC-Jar. I have different connector configs since I use SMT with "transforms.createKey" (to create my key) and the key columns in my tables have different names.
Here are my steps:
- create topics for Kafka Connect for config, offset and status
- start/create Kafka Connect container (with env vars see below)
- create the first JDBC connector via post call to my Connect container (config see below)
So far everything works well and I can see my data being pushed to the cluster. However as soon as the I add a second JDBC connector via post call, the first connector stops pushing data to the cluster while the second starts and continues to load and push data. There is a short time where it seems that both connectors push data to the cluster, but I'm assuming that this might be data from connector 1 that are still flushed. The problem is that a) even trace logs do not show an error that's meaningful (to me at least) and b) the errors that are shown differ between tries (I've always deleted all topics and the container).
I'm assuming this is not a bug but rather a combination of configs that need to be set appropriately and/or I'm lacking understanding of some basic Kafka Connect core functionalities. I've already tried to add and change various configs but unfortunately nothing has worked out so far. I've given it a good number of tries not but no luck. I've attached the logs of my two most recent tries as well as the configs.
Does anyone have an idea which config I could adapt or what to look into in order to fix this? Any help is appreciated - thanks!
Kafka: 2.0.0
Docker image: confluentinc/cp-kafka-connect:5.0.0
DB2: 10.5
JDBC Jar: db2jcc4.jar with version 4.19.76
Logs 1st try:
[2018-12-17 13:09:15,683] ERROR Invalid call to OffsetStorageWriter flush() while already flushing, the framework should not allow this (org.apache.kafka.connect.storage.OffsetStorageWriter)
[2018-12-17 13:09:15,684] ERROR WorkerSourceTask{id=db2-jdbc-source-0} Task threw an uncaught and unrecoverable exception (org.apache.kafka.connect.runtime.WorkerTask)
org.apache.kafka.connect.errors.ConnectException: OffsetStorageWriter is already flushing
at org.apache.kafka.connect.storage.OffsetStorageWriter.beginFlush(OffsetStorageWriter.java:110)
at org.apache.kafka.connect.runtime.WorkerSourceTask.commitOffsets(WorkerSourceTask.java:409)
at org.apache.kafka.connect.runtime.WorkerSourceTask.execute(WorkerSourceTask.java:238)
at org.apache.kafka.connect.runtime.WorkerTask.doRun(WorkerTask.java:175)
at org.apache.kafka.connect.runtime.WorkerTask.run(WorkerTask.java:219)
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)
[2018-12-17 13:09:15,686] ERROR WorkerSourceTask{id=db2-jdbc-source-0} Task is being killed and will not recover until manually restarted (org.apache.kafka.connect.runtime.WorkerTask)
[2018-12-17 13:09:15,686] INFO [Producer clientId=producer-4] Closing the Kafka producer with timeoutMillis = 30000 ms. (org.apache.kafka.clients.producer.KafkaProducer)
[2018-12-17 13:09:20,682] ERROR Graceful stop of task db2-jdbc-source-0 failed. (org.apache.kafka.connect.runtime.Worker)
[2018-12-17 13:09:20,682] INFO Finished stopping tasks in preparation for rebalance (org.apache.kafka.connect.runtime.distributed.DistributedHerder)
Logs 2nd try:
[2018-12-17 14:01:31,658] INFO Stopping task db2-jdbc-source-0 (org.apache.kafka.connect.runtime.Worker)
[2018-12-17 14:01:31,689] INFO Stopped connector db2-jdbc-source (org.apache.kafka.connect.runtime.Worker)
[2018-12-17 14:01:31,784] INFO WorkerSourceTask{id=db2-jdbc-source-0} Committing offsets (org.apache.kafka.connect.runtime.WorkerSourceTask)
[2018-12-17 14:01:31,784] INFO WorkerSourceTask{id=db2-jdbc-source-0} flushing 20450 outstanding messages for offset commit (org.apache.kafka.connect.runtime.WorkerSourceTask)
[2018-12-17 14:01:36,733] ERROR Graceful stop of task db2-jdbc-source-0 failed. (org.apache.kafka.connect.runtime.Worker)
[2018-12-17 14:01:36,733] INFO Finished stopping tasks in preparation for rebalance (org.apache.kafka.connect.runtime.distributed.DistributedHerder)
screenshot of incoming messages per second in the Kafka cluster
Kafka Connect Docker env variables:
-e CONNECT_BOOTSTRAP_SERVERS=my_kafka_cluster:443 \
-e CONNECT_PRODUCER_BOOTSTRAP_SERVERS="my_kafka_cluster:443" \
-e CONNECT_REST_ADVERTISED_HOST_NAME="kafka-connect" \
-e CONNECT_REST_PORT=8083 \
-e CONNECT_GROUP_ID="kafka-connect-group" \
-e CONNECT_CONFIG_STORAGE_REPLICATION_FACTOR=3 \
-e CONNECT_CONFIG_STORAGE_TOPIC="kafka-connect-config" \
-e CONNECT_OFFSET_STORAGE_REPLICATION_FACTOR=3 \
-e CONNECT_OFFSET_STORAGE_TOPIC="kafka-connect-offset" \
-e CONNECT_OFFSET_FLUSH_INTERVAL_MS=15000 \
-e CONNECT_OFFSET_FLUSH_TIMEOUT_MS=60000 \
-e CONNECT_STATUS_STORAGE_REPLICATION_FACTOR=3 \
-e CONNECT_STATUS_STORAGE_TOPIC="kafka-connect-status" \
-e CONNECT_KEY_CONVERTER="io.confluent.connect.avro.AvroConverter" \
-e CONNECT_KEY_CONVERTER_SCHEMA_REGISTRY_URL=http://url_to_schemaregistry \
-e CONNECT_VALUE_CONVERTER="io.confluent.connect.avro.AvroConverter" \
-e CONNECT_VALUE_CONVERTER_SCHEMA_REGISTRY_URL=http://url_to_schemaregistry \
-e CONNECT_INTERNAL_KEY_CONVERTER="org.apache.kafka.connect.json.JsonConverter" \
-e CONNECT_INTERNAL_KEY_CONVERTER_SCHEMAS_ENABLE="false" \
-e CONNECT_INTERNAL_VALUE_CONVERTER="org.apache.kafka.connect.json.JsonConverter" \
-e CONNECT_INTERNAL_VALUE_CONVERTER_SCHEMAS_ENABLE="false" \
-e CONNECT_PLUGIN_PATH=/usr/share/java \
-e CONNECT_PRODUCER_BUFFER_MEMORY="8388608" \
-e CONNECT_SECURITY_PROTOCOL="SSL" \
-e CONNECT_PRODUCER_SECURITY_PROTOCOL="SSL" \
-e CONNECT_SSL_TRUSTSTORE_LOCATION="/usr/share/kafka.client.truststore.jks" \
-e CONNECT_PRODUCER_SSL_TRUSTSTORE_LOCATION="/usr/share/kafka.client.truststore.jks" \
-e CONNECT_SSL_TRUSTSTORE_PASSWORD="my_ts_pw" \
-e CONNECT_PRODUCER_SSL_TRUSTSTORE_PASSWORD="my_ts_pw" \
-e CONNECT_LOG4J_LOGGERS=org.apache.kafka.connect.runtime.rest=WARN,org.reflections=ERROR \
-e CONNECT_LOG4J_ROOT_LOGLEVEL=INFO \
-e HOSTNAME=kafka-connect \
JDBC connectors (only the tables and key columns vary):
{
"name": "db2-jdbc-source",
"config":
{
"mode":"timestamp",
"debug":"true",
"batch.max.rows":"50",
"poll.interval.ms":"10000",
"timestamp.delay.interval.ms":"60000",
"timestamp.column.name":"IBMSNAP_LOGMARKER",
"connector.class":"io.confluent.connect.jdbc.JdbcSourceConnector" ,
"connection.url":"jdbc:db2://myip:myport/mydb:currentSchema=myschema;",
"connection.password":"mypw",
"connection.user":"myuser",
"connection.backoff.ms":"60000",
"dialect.name": "Db2DatabaseDialect",
"table.types": "TABLE",
"table.poll.interval.ms":"60000",
"table.whitelist":"MYTABLE1",
"tasks.max":"1",
"topic.prefix":"db2_",
"key.converter":"io.confluent.connect.avro.AvroConverter",
"key.converter.schema.registry.url":"http://url_to_schemaregistry",
"value.converter":"io.confluent.connect.avro.AvroConverter",
"value.converter.schema.registry.url":"http://url_to_schemaregistry",
"transforms":"createKey",
"transforms.createKey.type":"org.apache.kafka.connect.transforms.ValueToKey",
"transforms.createKey.fields":"MYKEY1"
}
}