# JDBC sink connector - multiple workers

**URL:** <https://forum.confluent.io/t/jdbc-sink-connector-multiple-workers/6288>\
**Category:** Kafka Connect\
**Created:** [14 October 2022 14:44 UTC](https://forum.confluent.io/t/jdbc-sink-connector-multiple-workers/6288 "2022-10-14T14:44:57Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![rgurskis](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.confluent.io/rgurskis/32/2475_2.png) [@rgurskis](https://forum.confluent.io/u/rgurskis)\
**Post date:** [14 October 2022 14:44 UTC](https://forum.confluent.io/t/jdbc-sink-connector-multiple-workers/6288/1 "2022-10-14T14:44:57Z")

</div>

Hi all,  
We have replication solution using Kafka Connect Data is being read using Debezium MS SQL connector into multiple topics, and then written to PostgreSQL using JDBC sink connector. Each topic/table has dedicated sink. Using “pk.mode”: “record\_value” , which generates UPSERTs. Topic has 10 partitions. There are 2 workers in Kafka Connect cluster.

For now we are using “tasks.max”: “1” in the sink, which means that all writes for given table are done by single worker in single thread.  
As JBDC connector supports multiple threads, should we be using more than 2 task in this scenario? Are there any best practices or recommendations in this matter?

I see a couple of potential issues here:

1. Parallel writes might cause locking on DB side. I saw at least one issue when deadlocks occurred using multiple tasks ([Multiple tasks in kafka-connect-jdbc sink causing deadlock · Issue #385 · confluentinc/kafka-connect-jdbc · GitHub](https://github.com/confluentinc/kafka-connect-jdbc/issues/385))
2. Can we ensure that changes are applied in the same order? For example, we have a backlog CDC changes for database record id =1:

```auto
id=1, value='A'
id=1, value='B'
id=1, value='C'

```

Is is possible that these messages will be distributed across multiple workers, and then UPSERT’s applied in the wrong order?

Any thoughts or suggestions?  
Thanks

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex019/uploads/confluentcommunity/original/1X/c49438c90c9df282e9996fdf6971be890c71b65a.svg) [@system](https://forum.confluent.io/u/system)\
**Post date:** [13 November 2022 14:45 UTC](https://forum.confluent.io/t/jdbc-sink-connector-multiple-workers/6288/2 "2022-11-13T14:45:53Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
