Commit Graph

4 Commits

Author SHA1 Message Date
hailin 54eb472faa fix(debezium): 添加 heartbeat.action.query 防止 WAL 无限积压
问题根因:
- 5个 Debezium outbox connector 配置了 heartbeat.interval.ms=10000
  但缺少 heartbeat.action.query,导致低写入频率的数据库
  (auth/contribution/mining-wallet) 无法向 PostgreSQL 回传
  confirmed_flush_lsn 确认位点
- PostgreSQL 无法回收旧 WAL,磁盘占用持续增长至 293GB

修复方案 (参考 Debezium 创始人 Gunnar Morling 推荐):
- 使用 pg_logical_emit_message() 代替心跳表方案
- 每10秒向 WAL 写入逻辑解码消息,绕过 publication 过滤
- 无需建表、无需改 table.include.list、无需改 publication
- 不产生额外 Kafka 消息,对消费端零影响
- 要求 PostgreSQL >= 14 (当前 16.11)

影响范围: 全部5个 outbox connector 配置文件
操作方式: PUT /connectors/{name}/config 热更新,触发 task 重启

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 02:44:38 -08:00
hailin 0204f748e6 fix(debezium): outbox connector 配置支持 standalone 模式 (postgres-2)
- database.hostname 从硬编码 "postgres" 改为 ${DEBEZIUM_DB_HOST:-postgres}
- database.user/password 改为环境变量替换 ${POSTGRES_USER}/${POSTGRES_PASSWORD}
- standalone 模式设置 DEBEZIUM_DB_HOST=postgres-2
- shared 模式不设置,默认值 postgres 保持不变

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-01 23:01:45 -08:00
hailin a4e1859fd2 fix(debezium): 修复 outbox connector 配置中的数据库凭证
使用实际的用户名和密码替代环境变量占位符,
因为 envsubst 不支持带默认值的变量语法

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-12 02:13:07 -08:00
hailin 63d73af135 refactor(cdc): 统一使用 Debezium CDC 进行数据同步
1. contribution-service:
   - 添加 identity topic 订阅,全量同步 1.0 用户数据
   - 修改 fromBeginning 为 true,首次启动全量同步

2. mining-admin-service:
   - 将 Outbox 事件改为 Debezium CDC 监听 outbox_events 表
   - 修改 fromBeginning 为 true,首次启动全量同步

3. 新增 5 个 2.0 服务的 Debezium connector 配置:
   - auth-outbox-connector.json
   - contribution-outbox-connector.json
   - mining-outbox-connector.json
   - trading-outbox-connector.json
   - mining-wallet-outbox-connector.json

4. 更新 register-connectors.sh 脚本

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-11 23:19:34 -08:00