Postgres表中的某些行可以生成CDC,而其他行则不能 [英] Some rows in the Postgres table can generate CDC while others cannot

查看:22
本文介绍了Postgres表中的某些行可以生成CDC,而其他行则不能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个安装了CDC的Postgres数据库。

我部署了Kafka Debezium连接器1.8.0。Postgres DB的最终版本

发布http://localhost:8083/connectors

正文:

{
    "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"
    }
}

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

在同一张表中,我更新行时,有些行可以生成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连接器postgres-kafkaconnector最初指向一个数据库(阶段1),然后通过更新

切换到另一个数据库(阶段2)
"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

由于该连接器具有不同的DB配置,在Kafka配置属性上共享相同,因此数据库表架构相同,

由于共享相同的Kafka偏移量而变得混乱。

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

这篇关于Postgres表中的某些行可以生成CDC,而其他行则不能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆