生产 123 万行表(9.8GB)跑批次1时磁盘满回滚(2026-08-10)。 根因二:① alembic 无 transaction_per_migration,批次1的 01+02+03 全在一个 事务,JSON→JSONB 重写空间不释放、与后续重写叠加;② 1421ea169bb6 循环逐个 ALTER 5 个日期字段 = 5 次整表重写,同一事务累积。 修复:alembic.ini 开启 transaction_per_migration(每迁移独立提交,前序空间 释放);1421ea169bb6 合并 5 列为单条 ALTER(一次重写)。 本地 DB 已在 head 不受影响,heads 仍单一头 55105f0bb1d7。
43 lines
939 B
INI
43 lines
939 B
INI
[alembic]
|
|
script_location = alembic
|
|
sqlalchemy.url = postgresql://scilit:scilit_dev@localhost:5432/scilit
|
|
# Commit each migration in its own transaction (default: whole upgrade in one).
|
|
# Rewrite-heavy migrations (JSON->JSONB / ALTER COLUMN TYPE DATE) on the
|
|
# 1.23M-row prod table peak at huge disk usage; one shared txn accumulates
|
|
# them -> disk-full (2026-08-10 batch 1 incident root cause).
|
|
# Independent commits release space early.
|
|
transaction_per_migration = true
|
|
|
|
[loggers]
|
|
keys = root,sqlalchemy,alembic
|
|
|
|
[handlers]
|
|
keys = console
|
|
|
|
[formatters]
|
|
keys = generic
|
|
|
|
[logger_root]
|
|
level = WARN
|
|
handlers = console
|
|
|
|
[logger_sqlalchemy]
|
|
level = WARN
|
|
handlers =
|
|
qualname = sqlalchemy.engine
|
|
|
|
[logger_alembic]
|
|
level = INFO
|
|
handlers =
|
|
qualname = alembic
|
|
|
|
[handler_console]
|
|
class = StreamHandler
|
|
args = (sys.stderr,)
|
|
level = NOTSET
|
|
formatter = generic
|
|
|
|
[formatter_generic]
|
|
format = %(levelname)-5.5s [%(name)s] %(message)s
|
|
datefmt = %H:%M:%S
|