Uploaded image for project: 'Debezium'
  1. Debezium
  2. DBZ-9091

SQL Server connector doesn't properly handle special characters in database object names

XMLWordPrintable

    • False
    • Hide

      None

      Show
      None
    • False

      In order to make your issue reports as actionable as possible, please provide the following information, depending on the issue type.

      Bug report

      For bug reports, provide this information, please:

      What Debezium connector do you use and what version?

      v3.1.1.Final

      What is the connector configuration?

      Integration tests

      What is the captured database version and mode of deployment?

      Irrelevant

      What behavior do you expect?

      All databases, schemas and tables are handled correctly regardless of their names.

      What behavior do you see?

      Debezium doesn't handle the tables with one of the following characters in the name: [, ] and potentially others.

      If the table name contains ] (e.g. UAT WAG CZ$Fixed Asset ['1']), the connector will fail to lock the table:

      org.apache.kafka.connect.errors.RetriableException: An exception occurred in the change event producer. This connector will be restarted.
          at io.debezium.pipeline.ErrorHandler.setProducerThrowable(ErrorHandler.java:63)
          at io.debezium.pipeline.ChangeEventSourceCoordinator.lambda$start$0(ChangeEventSourceCoordinator.java:150)
          at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:572)
          at java.base/java.util.concurrent.FutureTask.run$$$capture(FutureTask.java:317)
          at java.base/java.util.concurrent.FutureTask.run(FutureTask.java)
          at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
          at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
          at java.base/java.lang.Thread.run(Thread.java:1583)
      Caused by: io.debezium.DebeziumException: com.microsoft.sqlserver.jdbc.SQLServerException: Unclosed quotation mark after the character string 'UAT WAG CZ$Fixed Asset ['1'] WITH (TABLOCKX)'.
          at io.debezium.pipeline.source.AbstractSnapshotChangeEventSource.execute(AbstractSnapshotChangeEventSource.java:105)
          at io.debezium.pipeline.ChangeEventSourceCoordinator.doSnapshot(ChangeEventSourceCoordinator.java:294)
          at io.debezium.pipeline.ChangeEventSourceCoordinator.doSnapshot(ChangeEventSourceCoordinator.java:278)
          at io.debezium.connector.sqlserver.SqlServerChangeEventSourceCoordinator.executeChangeEventSources(SqlServerChangeEventSourceCoordinator.java:84)
          at io.debezium.pipeline.ChangeEventSourceCoordinator.lambda$start$0(ChangeEventSourceCoordinator.java:143)
          ... 6 common frames omitted
      Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: Unclosed quotation mark after the character string 'UAT WAG CZ$Fixed Asset ['1'] WITH (TABLOCKX)'.
          at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:259)
          at com.microsoft.sqlserver.jdbc.SQLServerStatement.getNextResult(SQLServerStatement.java:1695)
          at com.microsoft.sqlserver.jdbc.SQLServerStatement.doExecuteStatement(SQLServerStatement.java:920)
          at com.microsoft.sqlserver.jdbc.SQLServerStatement$StmtExecCmd.doExecute(SQLServerStatement.java:814)
          at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:7675)
          at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:4137)
          at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeCommand(SQLServerStatement.java:272)
          at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeStatement(SQLServerStatement.java:246)
          at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeQuery(SQLServerStatement.java:736)
          at io.debezium.connector.sqlserver.SqlServerSnapshotChangeEventSource.lockTablesForSchemaSnapshot(SqlServerSnapshotChangeEventSource.java:126)
          at io.debezium.relational.RelationalSnapshotChangeEventSource.doExecute(RelationalSnapshotChangeEventSource.java:156)
          at io.debezium.pipeline.source.AbstractSnapshotChangeEventSource.execute(AbstractSnapshotChangeEventSource.java:96)
          ... 10 common frames omitted
      

       

      If the table contains an opening square bracket, the connector will fail to introspect its schema:

      Unable to find relational table model for 'testDB1.dbo.UAT WAG CZ$Fixed Asset [1', there may be an issue with your include/exclude list configuration.
          at io.debezium.relational.RelationalSnapshotChangeEventSource.createSchemaChangeEventsForTables(RelationalSnapshotChangeEventSource.java:439)
          at io.debezium.relational.RelationalSnapshotChangeEventSource.doExecute(RelationalSnapshotChangeEventSource.java:168)
          at io.debezium.pipeline.source.AbstractSnapshotChangeEventSource.execute(AbstractSnapshotChangeEventSource.java:96)
          ... 10 common frames omitted
      

      Additionally, the test helper won't be able to enable CDC for a table that contains a single quote in its name.

       

      I will update SpecialCharsInNamesIT to demonstrate the issues.

      Do you see the same behaviour using the latest released Debezium version?

      Yes, tested on the main branch.

              Unassigned Unassigned
              sergeimorozov Sergei Morozov
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: