I am testing this against SQL Server using MS JDBC driver. I am using a custom query with timestamp column (so I can rely on the Kafka Connect framework for tracking offsets). The timestamp column is of type datetime in SQL server.
The debug logs show that the connector is using the correct offset in the query so ideally there should not be any records returned by running the query (I confirmed this by executing the query directly on SQL Server using the offset value). However, subsequent entries in the log show that the connector is returning 16 records every time it polls and that's what is causing the duplicates on Kafka:
[2016-06-28 22:34:23,626] DEBUG Checking for next block of results from TimestampIncrementingTableQuerier{name='null', query='select cdc.lsn_time_mapping.tran_begin_time,cdc.dbo_users_CT.__$operation as operation,
cdc.dbo_users_CT.id,
cdc.dbo_users_CT.name,cdc.dbo_users_CT.email,cdc.dbo_users_CT.department,cdc.dbo_users_CT.modified from cdc.lsn_time_mapping join cdc.dbo_users_CT on cdc.lsn_time_mapping.start_lsn=cdc.dbo_users_CT.__$start_lsn and cdc.dbo_users_CT.__$operation != 3', topicPrefix='users1', timestampColumn='tran_begin_time', incrementingColumn='null'} (io.confluent.connect.jdbc.JdbcSourceTask:211)
[2016-06-28 22:34:23,626] DEBUG executing query select CURRENT_TIMESTAMP; to get current time from database (io.confluent.connect.jdbc.JdbcSourceTask:224)
[2016-06-28 22:34:23,628] DEBUG Executing prepared statement with timestamp value = 1467153055053 (2016-06-28 22:30:55.053) end time 2016-06-28 22:34:20.937 (io.confluent.connect.jdbc.TimestampIncrementingTableQuerier:171)
[2016-06-28 22:34:23,633] DEBUG Closing this query for TimestampIncrementingTableQuerier{name='null', query='select cdc.lsn_time_mapping.tran_begin_time,cdc.dbo_users_CT.__$operation as operation,
cdc.dbo_users_CT.id,
cdc.dbo_users_CT.name,cdc.dbo_users_CT.email,cdc.dbo_users_CT.department,cdc.dbo_users_CT.modified from cdc.lsn_time_mapping join cdc.dbo_users_CT on cdc.lsn_time_mapping.start_lsn=cdc.dbo_users_CT.__$start_lsn and cdc.dbo_users_CT.__$operation != 3', topicPrefix='users1', timestampColumn='tran_begin_time', incrementingColumn='null'} (io.confluent.connect.jdbc.JdbcSourceTask:223)
[2016-06-28 22:34:23,633] DEBUG Returning 16 records for TimestampIncrementingTableQuerier{name='null', query='select cdc.lsn_time_mapping.tran_begin_time,cdc.dbo_users_CT.__$operation as operation,
cdc.dbo_users_CT.id,
cdc.dbo_users_CT.name,cdc.dbo_users_CT.email,cdc.dbo_users_CT.department,cdc.dbo_users_CT.modified from cdc.lsn_time_mapping join cdc.dbo_users_CT on cdc.lsn_time_mapping.start_lsn=cdc.dbo_users_CT.__$start_lsn and cdc.dbo_users_CT.__$operation != 3', topicPrefix='users1', timestampColumn='tran_begin_time', incrementingColumn='null'} (io.confluent.connect.jdbc.JdbcSourceTask:236)
[2016-06-28 22:34:23,633] DEBUG About to send 16 records to Kafka (org.apache.kafka.connect.runtime.WorkerSourceTask:159)
[2016-06-28 22:34:23,634] DEBUG Nothing to send to Kafka. Polling source for additional records (org.apache.kafka.connect.runtime.WorkerSourceTask:154)
[2016-06-28 22:34:28,634] DEBUG Checking for next block of results from TimestampIncrementingTableQuerier{name='null', query='select cdc.lsn_time_mapping.tran_begin_time,cdc.dbo_users_CT.__$operation as operation,
cdc.dbo_users_CT.id,
cdc.dbo_users_CT.name,cdc.dbo_users_CT.email,cdc.dbo_users_CT.department,cdc.dbo_users_CT.modified from cdc.lsn_time_mapping join cdc.dbo_users_CT on cdc.lsn_time_mapping.start_lsn=cdc.dbo_users_CT.__$start_lsn and cdc.dbo_users_CT.__$operation != 3', topicPrefix='users1', timestampColumn='tran_begin_time', incrementingColumn='null'} (io.confluent.connect.jdbc.JdbcSourceTask:211)
[2016-06-28 22:34:28,634] DEBUG executing query select CURRENT_TIMESTAMP; to get current time from database (io.confluent.connect.jdbc.JdbcSourceTask:224)
[2016-06-28 22:34:28,636] DEBUG Executing prepared statement with timestamp value = 1467153055053 (2016-06-28 22:30:55.053) end time 2016-06-28 22:34:25.943 (io.confluent.connect.jdbc.TimestampIncrementingTableQuerier:171)
[2016-06-28 22:34:28,641] DEBUG Closing this query for TimestampIncrementingTableQuerier{name='null', query='select cdc.lsn_time_mapping.tran_begin_time,cdc.dbo_users_CT.__$operation as operation,
cdc.dbo_users_CT.id,
cdc.dbo_users_CT.name,cdc.dbo_users_CT.email,cdc.dbo_users_CT.department,cdc.dbo_users_CT.modified from cdc.lsn_time_mapping join cdc.dbo_users_CT on cdc.lsn_time_mapping.start_lsn=cdc.dbo_users_CT.__$start_lsn and cdc.dbo_users_CT.__$operation != 3', topicPrefix='users1', timestampColumn='tran_begin_time', incrementingColumn='null'} (io.confluent.connect.jdbc.JdbcSourceTask:223)
[2016-06-28 22:34:28,641] DEBUG Returning 16 records for TimestampIncrementingTableQuerier{name='null', query='select cdc.lsn_time_mapping.tran_begin_time,cdc.dbo_users_CT.__$operation as operation,
cdc.dbo_users_CT.id,
cdc.dbo_users_CT.name,cdc.dbo_users_CT.email,cdc.dbo_users_CT.department,cdc.dbo_users_CT.modified from cdc.lsn_time_mapping join cdc.dbo_users_CT on cdc.lsn_time_mapping.start_lsn=cdc.dbo_users_CT.__$start_lsn and cdc.dbo_users_CT.__$operation != 3', topicPrefix='users1', timestampColumn='tran_begin_time', incrementingColumn='null'} (io.confluent.connect.jdbc.JdbcSourceTask:236)
[2016-06-28 22:34:28,641] DEBUG About to send 16 records to Kafka (org.apache.kafka.connect.runtime.WorkerSourceTask:159)
[2016-06-28 22:34:28,648] DEBUG Nothing to send to Kafka. Polling source for additional records (org.apache.kafka.connect.runtime.WorkerSourceTask:154)
[2016-06-28 22:34:33,641] DEBUG Checking for next block of results from TimestampIncrementingTableQuerier{name='null', query='select cdc.lsn_time_mapping.tran_begin_time,cdc.dbo_users_CT.__$operation as operation,
cdc.dbo_users_CT.id,
cdc.dbo_users_CT.name,cdc.dbo_users_CT.email,cdc.dbo_users_CT.department,cdc.dbo_users_CT.modified from cdc.lsn_time_mapping join cdc.dbo_users_CT on cdc.lsn_time_mapping.start_lsn=cdc.dbo_users_CT.__$start_lsn and cdc.dbo_users_CT.__$operation != 3', topicPrefix='users1', timestampColumn='tran_begin_time', incrementingColumn='null'} (io.confluent.connect.jdbc.JdbcSourceTask:211)
[2016-06-28 22:34:33,641] DEBUG executing query select CURRENT_TIMESTAMP; to get current time from database (io.confluent.connect.jdbc.JdbcSourceTask:224)
[2016-06-28 22:34:33,644] DEBUG Executing prepared statement with timestamp value = 1467153055053 (2016-06-28 22:30:55.053) end time 2016-06-28 22:34:30.960 (io.confluent.connect.jdbc.TimestampIncrementingTableQuerier:171)
[2016-06-28 22:34:33,649] DEBUG Closing this query for TimestampIncrementingTableQuerier{name='null', query='select cdc.lsn_time_mapping.tran_begin_time,cdc.dbo_users_CT.__$operation as operation,
cdc.dbo_users_CT.id,
cdc.dbo_users_CT.name,cdc.dbo_users_CT.email,cdc.dbo_users_CT.department,cdc.dbo_users_CT.modified from cdc.lsn_time_mapping join cdc.dbo_users_CT on cdc.lsn_time_mapping.start_lsn=cdc.dbo_users_CT.__$start_lsn and cdc.dbo_users_CT.__$operation != 3', topicPrefix='users1', timestampColumn='tran_begin_time', incrementingColumn='null'} (io.confluent.connect.jdbc.JdbcSourceTask:223)
[2016-06-28 22:34:33,649] DEBUG Returning 16 records for TimestampIncrementingTableQuerier{name='null', query='select cdc.lsn_time_mapping.tran_begin_time,cdc.dbo_users_CT.__$operation as operation,
cdc.dbo_users_CT.id,
cdc.dbo_users_CT.name,cdc.dbo_users_CT.email,cdc.dbo_users_CT.department,cdc.dbo_users_CT.modified from cdc.lsn_time_mapping join cdc.dbo_users_CT on cdc.lsn_time_mapping.start_lsn=cdc.dbo_users_CT.__$start_lsn and cdc.dbo_users_CT.__$operation != 3', topicPrefix='users1', timestampColumn='tran_begin_time', incrementingColumn='null'} (io.confluent.connect.jdbc.JdbcSourceTask:236)
[2016-06-28 22:34:33,649] DEBUG About to send 16 records to Kafka (org.apache.kafka.connect.runtime.WorkerSourceTask:159)
[2016-06-28 22:34:33,657] DEBUG Nothing to send to Kafka. Polling source for additional records (org.apache.kafka.connect.runtime.WorkerSourceTask:154)
[2016-06-28 22:34:38,649] DEBUG Checking for next block of results from TimestampIncrementingTableQuerier{name='null', query='select cdc.lsn_time_mapping.tran_begin_time,cdc.dbo_users_CT.__$operation as operation,
cdc.dbo_users_CT.id,
cdc.dbo_users_CT.name,cdc.dbo_users_CT.email,cdc.dbo_users_CT.department,cdc.dbo_users_CT.modified from cdc.lsn_time_mapping join cdc.dbo_users_CT on cdc.lsn_time_mapping.start_lsn=cdc.dbo_users_CT.__$start_lsn and cdc.dbo_users_CT.__$operation != 3', topicPrefix='users1', timestampColumn='tran_begin_time', incrementingColumn='null'} (io.confluent.connect.jdbc.JdbcSourceTask:211)
[2016-06-28 22:34:38,649] DEBUG executing query select CURRENT_TIMESTAMP; to get current time from database (io.confluent.connect.jdbc.JdbcSourceTask:224)
[2016-06-28 22:34:38,652] DEBUG Executing prepared statement with timestamp value = 1467153055053 (2016-06-28 22:30:55.053) end time 2016-06-28 22:34:35.960 (io.confluent.connect.jdbc.TimestampIncrementingTableQuerier:171)
[2016-06-28 22:34:38,656] DEBUG Closing this query for TimestampIncrementingTableQuerier{name='null', query='select cdc.lsn_time_mapping.tran_begin_time,cdc.dbo_users_CT.__$operation as operation,
cdc.dbo_users_CT.id,
cdc.dbo_users_CT.name,cdc.dbo_users_CT.email,cdc.dbo_users_CT.department,cdc.dbo_users_CT.modified from cdc.lsn_time_mapping join cdc.dbo_users_CT on cdc.lsn_time_mapping.start_lsn=cdc.dbo_users_CT.__$start_lsn and cdc.dbo_users_CT.__$operation != 3', topicPrefix='users1', timestampColumn='tran_begin_time', incrementingColumn='null'} (io.confluent.connect.jdbc.JdbcSourceTask:223)
[2016-06-28 22:34:38,656] DEBUG Returning 16 records for TimestampIncrementingTableQuerier{name='null', query='select cdc.lsn_time_mapping.tran_begin_time,cdc.dbo_users_CT.__$operation as operation,
cdc.dbo_users_CT.id,
cdc.dbo_users_CT.name,cdc.dbo_users_CT.email,cdc.dbo_users_CT.department,cdc.dbo_users_CT.modified from cdc.lsn_time_mapping join cdc.dbo_users_CT on cdc.lsn_time_mapping.start_lsn=cdc.dbo_users_CT.__$start_lsn and cdc.dbo_users_CT.__$operation != 3', topicPrefix='users1', timestampColumn='tran_begin_time', incrementingColumn='null'} (io.confluent.connect.jdbc.JdbcSourceTask:236)
[2016-06-28 22:34:38,656] DEBUG About to send 16 records to Kafka (org.apache.kafka.connect.runtime.WorkerSourceTask:159)
[2016-06-28 22:34:38,657] DEBUG Nothing to send to Kafka. Polling source for additional records (org.apache.kafka.connect.runtime.WorkerSourceTask:154)
[2016-06-28 22:34:40,058] DEBUG Scavenging sessions at 1467153280058 (org.eclipse.jetty.server.session:347)
[2016-06-28 22:34:43,657] DEBUG Checking for next block of results from TimestampIncrementingTableQuerier{name='null', query='select cdc.lsn_time_mapping.tran_begin_time,cdc.dbo_users_CT.__$operation as operation,
cdc.dbo_users_CT.id,
cdc.dbo_users_CT.name,cdc.dbo_users_CT.email,cdc.dbo_users_CT.department,cdc.dbo_users_CT.modified from cdc.lsn_time_mapping join cdc.dbo_users_CT on cdc.lsn_time_mapping.start_lsn=cdc.dbo_users_CT.__$start_lsn and cdc.dbo_users_CT.__$operation != 3', topicPrefix='users1', timestampColumn='tran_begin_time', incrementingColumn='null'} (io.confluent.connect.jdbc.JdbcSourceTask:211)
[2016-06-28 22:34:43,657] DEBUG executing query select CURRENT_TIMESTAMP; to get current time from database (io.confluent.connect.jdbc.JdbcSourceTask:224)
[2016-06-28 22:34:43,659] DEBUG Executing prepared statement with timestamp value = 1467153055053 (2016-06-28 22:30:55.053) end time 2016-06-28 22:34:40.963 (io.confluent.connect.jdbc.TimestampIncrementingTableQuerier:171)
[2016-06-28 22:34:43,663] DEBUG Closing this query for TimestampIncrementingTableQuerier{name='null', query='select cdc.lsn_time_mapping.tran_begin_time,cdc.dbo_users_CT.__$operation as operation,
cdc.dbo_users_CT.id,
cdc.dbo_users_CT.name,cdc.dbo_users_CT.email,cdc.dbo_users_CT.department,cdc.dbo_users_CT.modified from cdc.lsn_time_mapping join cdc.dbo_users_CT on cdc.lsn_time_mapping.start_lsn=cdc.dbo_users_CT.__$start_lsn and cdc.dbo_users_CT.__$operation != 3', topicPrefix='users1', timestampColumn='tran_begin_time', incrementingColumn='null'} (io.confluent.connect.jdbc.JdbcSourceTask:223)
[2016-06-28 22:34:43,663] DEBUG Returning 16 records for TimestampIncrementingTableQuerier{name='null', query='select cdc.lsn_time_mapping.tran_begin_time,cdc.dbo_users_CT.__$operation as operation,
cdc.dbo_users_CT.id,
cdc.dbo_users_CT.name,cdc.dbo_users_CT.email,cdc.dbo_users_CT.department,cdc.dbo_users_CT.modified from cdc.lsn_time_mapping join cdc.dbo_users_CT on cdc.lsn_time_mapping.start_lsn=cdc.dbo_users_CT.__$start_lsn and cdc.dbo_users_CT.__$operation != 3', topicPrefix='users1', timestampColumn='tran_begin_time', incrementingColumn='null'} (io.confluent.connect.jdbc.JdbcSourceTask:236)
[2016-06-28 22:34:43,663] DEBUG About to send 16 records to Kafka (org.apache.kafka.connect.runtime.WorkerSourceTask:159)
[2016-06-28 22:34:43,664] DEBUG Nothing to send to Kafka. Polling source for additional records (org.apache.kafka.connect.runtime.WorkerSourceTask:154)
[2016-06-28 22:34:48,663] DEBUG Checking for next block of results from TimestampIncrementingTableQuerier{name='null', query='select cdc.lsn_time_mapping.tran_begin_time,cdc.dbo_users_CT.__$operation as operation,
cdc.dbo_users_CT.id,
cdc.dbo_users_CT.name,cdc.dbo_users_CT.email,cdc.dbo_users_CT.department,cdc.dbo_users_CT.modified from cdc.lsn_time_mapping join cdc.dbo_users_CT on cdc.lsn_time_mapping.start_lsn=cdc.dbo_users_CT.__$start_lsn and cdc.dbo_users_CT.__$operation != 3', topicPrefix='users1', timestampColumn='tran_begin_time', incrementingColumn='null'} (io.confluent.connect.jdbc.JdbcSourceTask:211)
[2016-06-28 22:34:48,664] DEBUG executing query select CURRENT_TIMESTAMP; to get current time from database (io.confluent.connect.jdbc.JdbcSourceTask:224)
[2016-06-28 22:34:48,666] DEBUG Executing prepared statement with timestamp value = 1467153055053 (2016-06-28 22:30:55.053) end time 2016-06-28 22:34:45.980 (io.confluent.connect.jdbc.TimestampIncrementingTableQuerier:171)
[2016-06-28 22:34:48,670] DEBUG Closing this query for TimestampIncrementingTableQuerier{name='null', query='select cdc.lsn_time_mapping.tran_begin_time,cdc.dbo_users_CT.__$operation as operation,
cdc.dbo_users_CT.id,
cdc.dbo_users_CT.name,cdc.dbo_users_CT.email,cdc.dbo_users_CT.department,cdc.dbo_users_CT.modified from cdc.lsn_time_mapping join cdc.dbo_users_CT on cdc.lsn_time_mapping.start_lsn=cdc.dbo_users_CT.__$start_lsn and cdc.dbo_users_CT.__$operation != 3', topicPrefix='users1', timestampColumn='tran_begin_time', incrementingColumn='null'} (io.confluent.connect.jdbc.JdbcSourceTask:223)
[2016-06-28 22:34:48,670] DEBUG Returning 16 records for TimestampIncrementingTableQuerier{name='null', query='select cdc.lsn_time_mapping.tran_begin_time,cdc.dbo_users_CT.__$operation as operation,
cdc.dbo_users_CT.id,
cdc.dbo_users_CT.name,cdc.dbo_users_CT.email,cdc.dbo_users_CT.department,cdc.dbo_users_CT.modified from cdc.lsn_time_mapping join cdc.dbo_users_CT on cdc.lsn_time_mapping.start_lsn=cdc.dbo_users_CT.__$start_lsn and cdc.dbo_users_CT.__$operation != 3', topicPrefix='users1', timestampColumn='tran_begin_time', incrementingColumn='null'} (io.confluent.connect.jdbc.JdbcSourceTask:236)
[2016-06-28 22:34:48,670] DEBUG About to send 16 records to Kafka (org.apache.kafka.connect.runtime.WorkerSourceTask:159)
[2016-06-28 22:34:48,672] DEBUG Nothing to send to Kafka. Polling source for additional records (org.apache.kafka.connect.runtime.WorkerSourceTask:154)
[2016-06-28 22:34:53,670] DEBUG Checking for next block of results from TimestampIncrementingTableQuerier{name='null', query='select cdc.lsn_time_mapping.tran_begin_time,cdc.dbo_users_CT.__$operation as operation,
cdc.dbo_users_CT.id,
cdc.dbo_users_CT.name,cdc.dbo_users_CT.email,cdc.dbo_users_CT.department,cdc.dbo_users_CT.modified from cdc.lsn_time_mapping join cdc.dbo_users_CT on cdc.lsn_time_mapping.start_lsn=cdc.dbo_users_CT.__$start_lsn and cdc.dbo_users_CT.__$operation != 3', topicPrefix='users1', timestampColumn='tran_begin_time', incrementingColumn='null'} (io.confluent.connect.jdbc.JdbcSourceTask:211)
[2016-06-28 22:34:53,670] DEBUG executing query select CURRENT_TIMESTAMP; to get current time from database (io.confluent.connect.jdbc.JdbcSourceTask:224)
[2016-06-28 22:34:53,672] DEBUG Executing prepared statement with timestamp value = 1467153055053 (2016-06-28 22:30:55.053) end time 2016-06-28 22:34:50.980 (io.confluent.connect.jdbc.TimestampIncrementingTableQuerier:171)
[2016-06-28 22:34:53,677] DEBUG Closing this query for TimestampIncrementingTableQuerier{name='null', query='select cdc.lsn_time_mapping.tran_begin_time,cdc.dbo_users_CT.__$operation as operation,
cdc.dbo_users_CT.id,
cdc.dbo_users_CT.name,cdc.dbo_users_CT.email,cdc.dbo_users_CT.department,cdc.dbo_users_CT.modified from cdc.lsn_time_mapping join cdc.dbo_users_CT on cdc.lsn_time_mapping.start_lsn=cdc.dbo_users_CT.__$start_lsn and cdc.dbo_users_CT.__$operation != 3', topicPrefix='users1', timestampColumn='tran_begin_time', incrementingColumn='null'} (io.confluent.connect.jdbc.JdbcSourceTask:223)
[2016-06-28 22:34:53,678] DEBUG Returning 16 records for TimestampIncrementingTableQuerier{name='null', query='select cdc.lsn_time_mapping.tran_begin_time,cdc.dbo_users_CT.__$operation as operation,
cdc.dbo_users_CT.id,
cdc.dbo_users_CT.name,cdc.dbo_users_CT.email,cdc.dbo_users_CT.department,cdc.dbo_users_CT.modified from cdc.lsn_time_mapping join cdc.dbo_users_CT on cdc.lsn_time_mapping.start_lsn=cdc.dbo_users_CT.__$start_lsn and cdc.dbo_users_CT.__$operation != 3', topicPrefix='users1', timestampColumn='tran_begin_time', incrementingColumn='null'} (io.confluent.connect.jdbc.JdbcSourceTask:236)
[2016-06-28 22:34:53,678] DEBUG About to send 16 records to Kafka (org.apache.kafka.connect.runtime.WorkerSourceTask:159)
[2016-06-28 22:34:53,679] DEBUG Nothing to send to Kafka. Polling source for additional records (org.apache.kafka.connect.runtime.WorkerSourceTask:154)
The problem seems to resolve itself after a new update to the source table.
Thanks for your help !