Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kafka Connect CDC to MS SQL sourceOffset exception

We are using Confluent MS SQL CDC connector and the connection descriptor is :

curl -X POST -H \
  "Content-Type: application/json" --data '{
    "name" : "yury-mssql-cdc1",
    "config" : {
      "connector.class" : "io.confluent.connect.cdc.mssql.MsSqlSourceConnector",
      "tasks.max" : "1",
      "initial.database" : "test2",
      "username" : "user",
      "password" : "pass",
      "server.name" : "some-server.eu-west-1.rds.amazonaws.com",
      "server.port" : "1433",
      "change.tracking.tables" : "dbo.foobar"
    }
  }' \
   http://ip-10-0-0-24.eu-west-1.compute.internal:8083/connectors

the whole infrastructure is deployed at AWS... and the exception is :

ERROR Exception thrown while querying for ChangeKey

{databaseName=test2, schemaName=dbo, tableName=foobar} (io.confluent.connect.cdc.mssql.QueryService:94) java.lang.NullPointerException: sourceOffset cannot be null.

any help would be greatly appreciated.

like image 519
Mário de Sá Vera Avatar asked May 15 '26 23:05

Mário de Sá Vera


1 Answers

I found the answer, I think the problem is the way SQL server CDC is configured. We should not use the old way of setting CDC ( EXEC sys.sp_cdc_enable_db and EXEC sys.sp_cdc_enable_table )

Instead, use the following command to configure SQL server CDC

ALTER DATABASE [db name] SET CHANGE_TRACKING = ON (CHANGE_RETENTION = 2 DAYS, AUTO_CLEANUP = ON) GO ALTER DATABASE [db name] SET ALLOW_SNAPSHOT_ISOLATION ON GO ALTER TABLE [talbe name ] ENABLE CHANGE_TRACKING WITH (TRACK_COLUMNS_UPDATED = ON) GO

like image 52
user10838797 Avatar answered May 18 '26 13:05

user10838797



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!