rwadurian/backend/services/referral-service
hailin 8326f8c35c fix(cdc): 添加 Debezium heartbeat 机制防止 WAL 堆积
问题背景:
- PostgreSQL pg_wal 目录从 80MB 膨胀到 60.4GB,导致磁盘使用率达到 96%
- 根因: wallet/planting/referral 三个数据库的业务表长期无写入
- 虽然 Debezium 有 heartbeat 配置,但未配置 heartbeat.action.query
- 导致 replication slot 的 restart_lsn 无法推进,WAL 文件无法被清理

解决方案:
1. 在 wallet/planting/referral 三个服务中添加 debezium_heartbeat 表
2. 配置 Debezium connector 的 heartbeat.action.query
3. 每 60 秒自动执行 UPDATE 语句推进 restart_lsn

修改内容:
- wallet-service/prisma/schema.prisma: 添加 DebeziumHeartbeat model
- planting-service/prisma/schema.prisma: 添加 DebeziumHeartbeat model
- referral-service/prisma/schema.prisma: 添加 DebeziumHeartbeat model
- scripts/debezium/wallet-connector.json: 添加 heartbeat.action.query 配置
- scripts/debezium/planting-connector.json: 添加 heartbeat.action.query 配置
- scripts/debezium/referral-connector.json: 添加 heartbeat.action.query 配置
- 新增三个服务的 Prisma migration 文件

效果:
- pg_wal 从 60.4GB 降至 80.2MB
- 磁盘使用率从 96% 降至 40%
- replication slot lag 从 51-60GB 降至 KB 级别

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-19 17:42:41 -08:00
..
prisma fix(cdc): 添加 Debezium heartbeat 机制防止 WAL 堆积 2026-01-19 17:42:41 -08:00
scripts refactor(mpc-system): migrate to party-driven architecture with PartyID-based routing 2025-12-05 08:11:28 -08:00
src fix(referral-service): 修复 Kafka 消费异常被吞掉的问题 2026-01-07 18:47:05 -08:00
test fix(authorization): 修复团队升级竞态条件,改用事件链模式 2025-12-24 00:13:39 -08:00
.dockerignore refactor(mpc-system): migrate to party-driven architecture with PartyID-based routing 2025-12-05 08:11:28 -08:00
.env.development refactor(mpc-system): migrate to party-driven architecture with PartyID-based routing 2025-12-05 08:11:28 -08:00
.env.example refactor(mpc-system): migrate to party-driven architecture with PartyID-based routing 2025-12-05 08:11:28 -08:00
.eslintrc.js refactor(mpc-system): migrate to party-driven architecture with PartyID-based routing 2025-12-05 08:11:28 -08:00
.gitignore chore: 添加 tsbuildinfo 到 .gitignore 2025-12-21 04:34:26 -08:00
.prettierrc refactor(mpc-system): migrate to party-driven architecture with PartyID-based routing 2025-12-05 08:11:28 -08:00
DEVELOPMENT_GUIDE.md refactor: 多项UI优化和品牌更名 2025-12-15 01:43:47 -08:00
Dockerfile fix: 添加 -m 参数创建用户home目录 2025-12-21 18:01:19 -08:00
Dockerfile.test refactor(mpc-system): migrate to party-driven architecture with PartyID-based routing 2025-12-05 08:11:28 -08:00
Makefile refactor(mpc-system): migrate to party-driven architecture with PartyID-based routing 2025-12-05 08:11:28 -08:00
deploy.sh fix: convert deploy.sh CRLF to LF and add executable permission 2025-12-07 07:01:13 -08:00
docker-compose.test.yml refactor(mpc-system): migrate to party-driven architecture with PartyID-based routing 2025-12-05 08:11:28 -08:00
nest-cli.json refactor(mpc-system): migrate to party-driven architecture with PartyID-based routing 2025-12-05 08:11:28 -08:00
package-lock.json Revert "fix(mpc-service): don't block startup on Kafka consumer rebalance" 2025-12-09 03:26:05 -08:00
package.json feat: 添加 GENESIS 系统种子用户用于初始推荐码 2025-12-21 04:09:39 -08:00
tsconfig.build.json fix: 修复 referral-service 编译配置以支持 prisma seed.ts 2025-12-21 04:30:35 -08:00
tsconfig.json refactor(mpc-system): migrate to party-driven architecture with PartyID-based routing 2025-12-05 08:11:28 -08:00