debezium postgres kafka连接器检测信号未提交lsn

p4rjhz4m  于 2021-06-04  发布在  Kafka
关注(0)|答案(1)|浏览(633)

我有一个在awsrds上的postgres数据库和一个kafka连接连接器(debeziumpostgres)在一张table上监听。连接器的配置:

{
  "name": "my-connector",
  "config": {
    "connector.class": "io.debezium.connector.postgresql.PostgresConnector",
    "database.dbname": "my_db",
    "database.user": "my_user",
    "max.queue.size": "32000",
    "slot.name": "my_slot",
    "tasks.max": "1",
    "publication.name": "my_publication",
    "database.server.name": "postgres",
    "heartbeat.interval.ms": "1000",
    "database.port": "my_port",
    "include.schema.changes": "false",
    "plugin.name": "pgoutput",
    "table.whitelist": "public.my_table",
    "tombstones.on.delete": "false",
    "database.hostname": "my_host",
    "database.password": "my_password",
    "name": "my-connector",
    "max.batch.size": "10000",
    "database.whitelist": "my_db",
    "snapshot.mode": "never"
  },
  "tasks": [
    {
      "connector": "my-connector",
      "task": 0
    }
  ],
  "type": "source"
}

该表不像其他表那样频繁更新,这最初会导致如下复制延迟:

SELECT slot_name,
  pg_size_pretty(pg_wal_lsn_diff(pg_current_wal_lsn(), restart_lsn)) as replicationSlotLag,
  pg_size_pretty(pg_wal_lsn_diff(pg_current_wal_lsn(), confirmed_flush_lsn)) as confirmedLag,
  active
FROM pg_replication_slots;
           slot_name           | replicationslotlag | confirmedlag | active
-------------------------------+--------------------+--------------+--------
 my_slot                       | 1664 MB            | 1664 MB      | t

它会变得如此之大,以至于可能会耗尽所有的磁盘空间。
我添加了心跳,如果我登录到kafka代理并设置如下控制台使用者: ./kafka-console-consumer.sh --bootstrap-server my.broker.address:9092 --topic __debezium-heartbeat.postgres --from-beginning --consumer.config=/etc/kafka/consumer.properties 它将转储所有心跳消息,然后每1000毫秒显示一条新消息。
但是,插槽的大小仍在不断增长。如果我在表中插入一个虚拟记录,它会将插槽设置回一个小的延迟,这样就可以了。
不过,我想用心跳来做这件事。我不想插入定期消息,因为这听起来像是增加了复杂性。为什么心跳没有减少插槽大小?

nkkqxpd9

nkkqxpd91#

请看一看https://debezium.io/documentation/reference/1.0/connectors/postgresql.html#wal-磁盘空间
你真的需要发出周期性的信息,但现在有一个帮助-https://issues.redhat.com/browse/dbz-1815

相关问题