fix(go): keep fast writer tdengine pool safe by default

This commit is contained in:
lingniu
2026-07-03 19:33:45 +08:00
parent 06866b0fa7
commit fb34969602
4 changed files with 51 additions and 4 deletions

View File

@@ -433,6 +433,15 @@ vehicle_fast_writer_stage_duration_ms_histogram_sum{subject,stage,status}
2026-07-03 后续优化:`nats-fast-writer` 已从“Fetch batch 后逐条写 TDengine”改为“Fetch batch 后先调用 `history.Writer.AppendAllBatch` 批量写 TDengine再逐条更新 Redis 和 ack”。这样可以减少 TDengine round tripRedis/ack 仍按单条执行,避免某条实时投影失败时误 ack。
2026-07-03 后续优化:`nats-fast-writer` 的 TDengine SQL 连接池已从固定 `1` 改为可配置:
```text
FAST_WRITER_TDENGINE_MAX_OPEN_CONNS
FAST_WRITER_TDENGINE_MAX_IDLE_CONNS
```
默认 `max_open=1``max_idle=1`。原因是当前 TDengine 写入依赖启动时执行的 `USE <database>``database/sql` 连接池新建连接不会继承其他连接上的 `USE` 状态。实测默认跟随 worker 放大到 8 会导致 `[0x200] db is not specified` / `[0x2616] Database not specified`。后续只有在 TDengine DSN 或 writer SQL 改为每条连接都明确选库后,才能提高该连接池。
同时新增 batch pending gauge
```text