feat: 新增 G4 热表独立双写能力

- 新增配置项以支持旧/新明细表的独立写入开关及目标表名。
- 重构 DatabaseManager,抽象通用批量 COPY 写入内核,支持不同目标表的复用。
- 新增双明细写入编排器,支持旧/新表独立执行、重试及 fallback。
- 调整 HeartbeatProcessor.processBatch(),确保 room_status 独立执行。
- 错误表仅记录新表写入失败,旧表失败不再写入错误表。
- 重新定义消费暂停策略,基于当前启用的关键 sink 判断。
- 补充按 sink 维度的统计项与启动日志。

新增 G4 热表相关的数据库规范与处理逻辑,确保系统在双写模式下的稳定性与可扩展性。
This commit is contained in:
2026-03-09 15:49:12 +08:00
parent f59000f5ef
commit 43fa7505e5
21 changed files with 2546 additions and 154 deletions

View File

@@ -43,15 +43,17 @@ describe('StatsReporter', () => {
const reporter = new StatsReporter({ redis, stats });
reporter.flushOnce();
assert.equal(calls.push.length, 4);
assert.equal(calls.push[0].level, 'info');
assert.equal(calls.push[1].level, 'info');
assert.equal(calls.push[2].level, 'info');
assert.equal(calls.push[3].level, 'info');
assert.match(calls.push[0].message, /^\[STATS\] \d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.\d{3} 数据库写入量: 7条$/);
assert.match(calls.push[1].message, /^\[STATS\] \d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.\d{3} 数据库写入失败量: 2条$/);
assert.match(calls.push[2].message, /^\[STATS\] \d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.\d{3} 数据过滤量: 8条$/);
assert.match(calls.push[3].message, /^\[STATS\] \d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.\d{3} Kafka拉取量: 9条$/);
assert.equal(calls.push.length, 9);
for (const c of calls.push) assert.equal(c.level, 'info');
assert.match(calls.push[0].message, /Legacy写入量: 7条$/);
assert.match(calls.push[1].message, /Legacy写入失败量: 2条$/);
assert.match(calls.push[2].message, /G4Hot写入量: 0条$/);
assert.match(calls.push[3].message, /G4Hot写入失败量: 0条$/);
assert.match(calls.push[4].message, /RoomStatus写入量: 0条$/);
assert.match(calls.push[5].message, /RoomStatus失败量: 0条$/);
assert.match(calls.push[6].message, /G4Hot错误表插入量: 0条$/);
assert.match(calls.push[7].message, /数据过滤量: 8条$/);
assert.match(calls.push[8].message, /Kafka拉取量: 9条$/);
});
});