Postgres table 中的某些行可以生成 CDC,而其他行则不能

Some rows in the Postgres table can generate CDC while others cannot

我有一个带有 CDC 设置的 Postgres 数据库。

我通过

为 Postgres 数据库部署了 Kafka Debezium 连接器 1.8。0.Final

POST http://localhost:8083/connectors

与 body:

{
    "name": "postgres-kafkaconnector",
    "config": {
        "connector.class": "io.debezium.connector.postgresql.PostgresConnector",
        "tasks.max": "1",
        "database.hostname": "example.com",
        "database.port": "5432",
        "database.dbname": "my_db",
        "database.user": "xxx",
        "database.password": "xxx",
        "database.server.name": "postgres_server",
        "table.include.list": "public.products",
        "plugin.name": "pgoutput"
    }
}

我注意到一些奇怪的事情。

在同一个table中,当我更新行时,一些行可以生成CDC,但其他行不能生成CDC。

这些行非常相似,除了 ididentifier 不同。

-- Updating this row can generate CDC
UPDATE public.products
SET identifier = 'GET /api/accounts2'
WHERE id = '90c21719-ce41-4523-8ad1-ed6b21ecfaf1';

-- Updating this row cannot generate CDC
UPDATE public.products
SET identifier = 'GET /api/notworking/accounts2'
WHERE id = '22f5ebf3-9594-493d-8aa6-649d9fbcefd2';

我检查了我的 Kafka Connect 容器日志,也没有错误。

有什么想法吗?

找到问题了!这是因为我的 Kafka Connector postgres-kafkaconnector 最初指向一个 DB (stage1),然后我通过更新

切换到另一个 DB (stage2)
"database.hostname": "example.com",
"database.port": "5432",
"database.dbname": "my_db",
"database.user": "xxx",
"database.password": "xxx",

但是,他们在我最开始部署的 Kafka Connect 中使用相同的配置属性:

config.storage.topic
offset.storage.topic
status.storage.topic

由于此连接器与不同的数据库配置共享相同的上述 Kafka 配置属性,并且数据库 table 架构相同,

由于共享相同的 Kafka 偏移量,它变得一团糟。

一个简单的修复方法是在部署 Kafka 连接器以在不同的数据库上进行测试时,使用不同的名称(例如 postgres-kafkaconnector-stage1postgres-kafkaconnector-stage2 以避免 Kafka 主题偏移混乱。