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

Supply of message.key.columns disables primary keys.

    Details

    • Steps to Reproduce:
      Hide
      • Create two tables in source database.
      • Change keys of the first table with the message.key.columns.
      • Start up connector.
      • First table has overridden columns as key in kafka messages.
      • Other table now has no key at all.
      Show
      Create two tables in source database. Change keys of the first table with the message.key.columns . Start up connector. First table has overridden columns as key in kafka messages. Other table now has no key at all.

      Description

      According to the documentation, if you supply a message.key.columns setting any unmatched tables are supposed to use their current primary key columns:

      For any table without an explicit key configuration the table's primary key column(s) will be used as message key.

      This is not currently happening, and if you match any table in message.key.columns then any non-matching tables have no message key at all.

      We are currently using the following patch to rectify this behaviour.

      
      --- debezium-core/src/main/java/io/debezium/relational/Key.java    (revision 26cdc58efcf15e3d263dcf89bd4fff03b2cc7bf9)
      +++ debezium-core/src/main/java/io/debezium/relational/Key.java    (date 1582503668926)
      @@ -118,13 +118,17 @@
                   Predicate<ColumnId> delegate = Predicates.includes(regexes, ColumnId::toString);
      
                   return (table) -> {
      -                return table.columns()
      +                List<Column> columns = table.columns()
                               .stream()
                               .filter(c -> {
                                   final TableId tableId = table.id();
                                   return delegate.test(new ColumnId(tableId.catalog(), tableId.schema(), tableId.table(), c.name()));
                               })
                               .collect(Collectors.toList());
      +                if (columns.size() > 0) {
      +                    return columns;
      +                }
      +                return table.primaryKeyColumns();
                   };
               }
           }
      

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                jpechanec Jiri Pechanec
                Reporter:
                norganna Ken Allan
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: