rwadurian/backend/services/wallet-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
..
docs refactor(mpc-system): migrate to party-driven architecture with PartyID-based routing 2025-12-05 08:11:28 -08:00
prisma fix(cdc): 添加 Debezium heartbeat 机制防止 WAL 堆积 2026-01-19 17:42:41 -08:00
scripts feat(admin-web): 仪表板改用 planting-service 源数据 2026-01-06 10:47:44 -08:00
src fix(wallet): 统一使用 accountSequence 查询钱包,修复转账余额不足问题 2026-01-15 23:00:40 -08:00
test 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
.gitignore refactor(mpc-system): migrate to party-driven architecture with PartyID-based routing 2025-12-05 08:11:28 -08:00
Dockerfile perf(docker): 优化Dockerfile构建,避免最后chown整个目录 2025-12-21 19:31:58 -08:00
deploy.sh fix: convert deploy.sh CRLF to LF and add executable permission 2025-12-07 07:01:13 -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.json fix(backend): 修复构建错误并添加 TOTP 数据库迁移 2025-12-15 05:29:29 -08:00
tsconfig.build.json refactor(mpc-system): migrate to party-driven architecture with PartyID-based routing 2025-12-05 08:11:28 -08:00
tsconfig.json refactor(mpc-system): migrate to party-driven architecture with PartyID-based routing 2025-12-05 08:11:28 -08:00