rwadurian/backend
hailin 2a725af83e fix: Debezium CDC 全面安全加固 (1.0 + 2.0)
问题背景:
  - 1.0 生产环境发现 6 个孤儿 replication slot, WAL 积压 8.6GB (已清理)
  - 1.0 使用 Debezium 2.4, 存在 DBZ-7316 (WAL 无限积压) bug
  - 1.0 和 2.0 均无 max_slot_wal_keep_size 安全阀 (已在线设置 10GB)
  - 2.0 outbox connector 使用 pg_logical_emit_message 心跳, 不经 publication
  - 2.0 outbox connector RegexRouter regex=".*" 导致 heartbeat 污染消费者

修复内容:

[docker-compose.yml - 1.0 基础设施]
  - Debezium: 2.4 → 2.5.4.Final (修复 DBZ-7316)
  - PostgreSQL: 添加 max_slot_wal_keep_size=10GB
  - Debezium REST API: 端口绑定 127.0.0.1 (防 SSRF 注入)
  - PostgreSQL: 端口绑定 127.0.0.1 (防公网直连)
  - Kafka Connect: 添加 OFFSET_FLUSH_INTERVAL_MS=10s

[docker-compose.2.0.yml - 2.0 基础设施]
  - Debezium: 2.5 → 2.5.4.Final (锁定精确版本)
  - PostgreSQL: 添加 max_slot_wal_keep_size=10GB
  - Kafka Connect: 添加 OFFSET_FLUSH_INTERVAL_MS=10s

[1.0 Connector 配置 - identity/authorization]
  - 添加 heartbeat.action.query (INSERT INTO debezium_heartbeat TABLE 方式)
  - 之前只有 heartbeat.interval.ms 无 action.query, 心跳不生效

[2.0 Outbox Connector 配置 - 5个全部更新]
  - heartbeat: pg_logical_emit_message → INSERT INTO debezium_heartbeat TABLE 方式
    (TABLE 方式经过 publication → Debezium 消费 → 推进 confirmed_flush_lsn)
  - RegexRouter: regex ".*" → ".*outbox_events" (只路由 outbox 事件, heartbeat 走默认 topic)
  - table.include.list: 添加 debezium_heartbeat (确保心跳变更生成 Kafka 消息)
  - publication.autocreate.mode: filtered → disabled (使用预创建的 publication)
  - auth/contribution: 添加 signal channel 配置 (支持增量快照数据重放)

经验总结:
  1. pg_logical_emit_message 写 WAL 但不经 publication, 无法推进 confirmed_flush_lsn
  2. RegexRouter regex=".*" 把所有变更(含 heartbeat)路由到 outbox topic, 污染消费者
  3. 删除 Kafka Connect connector 不会自动清理 PostgreSQL replication slot
  4. max_slot_wal_keep_size 是 sighup 级参数, 可在线 ALTER SYSTEM + pg_reload_conf

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 07:32:13 -08:00
..
.claude refactor: simplify mpc-service to gateway mode 2025-12-06 17:16:14 -08:00
api-gateway feat(customer-service): 客服联系方式从硬编码改为后台可配置 2026-02-05 05:00:25 -08:00
infrastructure chore(docker): 为 mpc-system、api-gateway、infrastructure 添加时区配置 2025-12-23 18:35:09 -08:00
mpc-system fix(service-party-android): 修复导入钱包签名时 'party not registered' 错误 2026-02-02 03:24:14 -08:00
scripts fix(scripts): 修正容器名为 rwa-blockchain-service 2025-12-15 10:34:25 -08:00
services fix: Debezium CDC 全面安全加固 (1.0 + 2.0) 2026-02-15 07:32:13 -08:00
.env.windows fix(referral): 修复 getMyReferralInfo 使用 userId 而不是 accountSequence 的问题 2025-12-14 05:05:03 -08:00
docker-compose.windows.yml fix(mining-service): Redis DB 11 冲突修复,迁移至 DB 16 2026-01-30 02:22:20 -08:00