feat(log): drop empty old-month PG partitions during cleanup

系统垃圾清理任务删除过期日志后,顺带清理旧月份空分区表:
PostgreSQL 按月分区的访问日志表(节点/用户)在数据删除后若该月
分区已无数据,则自动删除对应分区表,避免历史分区表无限累积。

- 仅删除「当前月之前」且为空的月份分区,当月/未来月及仍有数据的分区保留
- ClickHouse/SQLite 为 no-op(CH 分区随数据删除自动消失)
- 修复既有集成测试 pg_inherits 查询(inhrelid → inhparent)
- 新增单元测试与 PG 集成测试
This commit is contained in:
ryan
2026-08-09 09:33:59 +08:00
parent 34a0896ff8
commit 08d28c2c8e
7 changed files with 237 additions and 2 deletions
@@ -434,6 +434,11 @@ func (s *clickhouseLogStore) EnsurePartitions(_ context.Context, _, _ time.Time)
return nil
}
// DropEmptyPartitions 是 CH 分支 no-op(CH 分区随数据删除自动消失,无独立分区表)。
func (s *clickhouseLogStore) DropEmptyPartitions(_ context.Context, _ time.Time) error {
return nil
}
// chMigrationRange 查询 CH 表时间列 MIN/MAX;空表(NULL)返回零值。
func chMigrationRange(ctx context.Context, table, column string) (time.Time, time.Time, error) {
if err := chConnErr(); err != nil {