Skip to content

feat(db): migrate control-plane persistence to PostgreSQL - #649

Open
liubing0806 wants to merge 30 commits into
dofastted:mainfrom
liubing0806:codex/postgresql-migration
Open

liubing0806 wants to merge 30 commits into
dofastted:mainfrom
liubing0806:codex/postgresql-migration

Conversation

@liubing0806

Copy link
Copy Markdown

Closes #647.

将控制面运行数据库从同步 SQLite 切换到 PostgreSQL 17,并提供现有数据和旧备份的离线迁移路径。运行时使用异步连接池和原生 PG SQL,SQLite 只用于读取旧快照及历史测试。

主要改动:

  • repository、认证、额度、日志、计费、调度、集群及 VM 元数据镜像调用链异步化,事务使用固定连接;写队列可在维护、恢复和退出前排空。
  • 新 PG 基线保留原业务字段和加密格式,处理 ASCII 大小写、时区、64 位计数与小数调度值。SQLite 原有 41 个迁移保持原样。
  • 离线导入保留主键、关联、密文及 sequence 高水位,逐表校验,失败整体回滚;支持旧归档显式转换。
  • pg_dump 导出快照与 VM/配置文件使用一致的暂停写入窗口;恢复校验归档范围、单事务恢复、重新加载状态,失败保持维护标记。
  • 更新 Compose、两种 Dockerfile、安装/升级预检、业务数据库角色、指标、页面、CI 和部署文档。

验证(合成数据与专用 PG 17.11):

检查 提交 结果
全量 unit 4ad444d7 3325 pass、7 fail、10 skip;失败的 2 文件/7 断言与原始 eee8f6e 相同
全量 E2E 3054bfa0 96 pass、17 fail、1 skip;失败的 11 文件/17 断言与原始提交相同,无清理超时
Node 22 4ad444d7 93/93 pass
驱动/导入/备份/恢复范围 3054bfa0 40/40 pass,含相邻 schema 后续写入保留
前端 4ad444d7 473/473 pass,生产构建通过
Go / 部署 4ad444d7 worker、api-kernel race 通过;Python 25/25;实际 PG 角色权限检查通过
amd64 镜像 6aa877de 构建及实际 HTTP、PG 指标、密钥写入、备份和恢复后状态通过

例如既有 unit 失败为实际 cache TTL 1h、预期 undefined;既有 E2E 失败含 thinking 多 display: summarized。逐断言对照和页面截图已提交在 docs/plans/evidence/postgresql/。

实现 head:cf9462d5501c323efa95c254feb3821f7cf656f0。详见 实施验证报告 和 部署迁移说明。

以 Draft 提交供迁移评审。原生 ARM64 构建运行、生产规模压测及现有部署切换未验证。VM 活凭据仍使用原有槽位/CLI-home 存储,切换必须保留这些目录和业务加密密钥。本 PR 提供共享持久化,尚不代表控制面已具备 #648 的多副本调度能力。

@liubing0806
liubing0806 marked this pull request as ready for review October 22, 2026 02:47
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-10-22T03:05:09.945377Z
We couldn’t complete this review. Comment @codex review to try again.
fcd568c Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] 数据库迁移到 PostgreSQL,支持大规模和高并发使用

1 participant