From 0b9634b74cbe4e698be364ffdcc4dfd28e86de98 Mon Sep 17 00:00:00 2001 From: wangbo Date: Fri, 31 Jul 2026 18:42:46 +0800 Subject: [PATCH] =?UTF-8?q?fix(postgres):=20=E4=BF=AE=E6=AD=A3=E8=B7=A8?= =?UTF-8?q?=E5=9C=B0=E5=9F=9F=20WAL=20=E5=BD=92=E6=A1=A3=E5=B8=A6=E5=AE=BD?= =?UTF-8?q?=E9=A2=84=E7=AE=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 将生产 archive_timeout 从 60 秒调整为 5 分钟,避免 16 MiB WAL 段在当前宁波香港链路上持续产生高于复制吞吐的空闲流量。\n\n同步复制保持开启,双库健康时 RPO 仍为 0;单库降级时对象存储归档 RPO 保持在 5 分钟目标内。补充发布回归门禁,防止配置退回无法追平的 60 秒。\n\n验证:kubectl kustomize、bash -n、ShellCheck、manual-release-test。 --- deploy/kubernetes/production/database.yaml | 6 +++++- docs/operations/k3s-ha-runbook.md | 2 +- tests/release/manual-release-test.sh | 5 +++++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/deploy/kubernetes/production/database.yaml b/deploy/kubernetes/production/database.yaml index 4b17793..99e831e 100644 --- a/deploy/kubernetes/production/database.yaml +++ b/deploy/kubernetes/production/database.yaml @@ -119,7 +119,11 @@ spec: number: 1 dataDurability: preferred parameters: - archive_timeout: 60s + # A 16 MiB WAL segment every 60 seconds requires at least 2.24 Mbit/s + # of continuous cross-region throughput even while the database is idle. + # The certified Ningbo/Hong Kong path is below that floor, so keep the + # object-storage RPO within five minutes without starving sync replay. + archive_timeout: 5min max_connections: "200" shared_buffers: 512MB wal_compression: "on" diff --git a/docs/operations/k3s-ha-runbook.md b/docs/operations/k3s-ha-runbook.md index 882fa31..614c199 100644 --- a/docs/operations/k3s-ha-runbook.md +++ b/docs/operations/k3s-ha-runbook.md @@ -10,7 +10,7 @@ CloudNativePG;洛杉矶只作为 K3s server/etcd 仲裁节点,并带 [生产同构验收模式与高媒体压力测试](production-acceptance.md)。 - 健康双库:同步复制,RPO=0。 -- 单库降级:`dataDurability: preferred` 保持写入,`archive_timeout=60s`,灾难 RPO 目标不超过 5 分钟。 +- 单库降级:`dataDurability: preferred` 保持写入,`archive_timeout=5min`,灾难 RPO 目标不超过 5 分钟。生产 WAL 段为 16 MiB;禁止把该值降到 60 秒,否则仅空闲切段就要求跨地域链路持续承载至少 2.24 Mbit/s,会使同步副本在当前带宽下永久追不平。 - 数据库故障 RTO:不超过 5 分钟。 - 应用发布:香港验收后再滚动宁波,计划内零停机。 - 公网入口:双 NGINX 加人工 AliDNS 切换。接入带健康检查的 GTM 前,不宣称公网入口自动高可用。 diff --git a/tests/release/manual-release-test.sh b/tests/release/manual-release-test.sh index a4458ec..ef337a0 100755 --- a/tests/release/manual-release-test.sh +++ b/tests/release/manual-release-test.sh @@ -290,5 +290,10 @@ grep -Fq 'gateway_tasks' "$root/deploy/manual/easyai-ai-gateway-release" grep -Fq 'gateway_task_attempts' "$root/deploy/manual/easyai-ai-gateway-release" grep -Fq 'gateway_task_events' "$root/deploy/manual/easyai-ai-gateway-release" grep -Fq 'production_changed=false' "$root/scripts/publish-release-images.sh" +grep -Fq 'archive_timeout: 5min' "$root/deploy/kubernetes/production/database.yaml" +if grep -Fq 'archive_timeout: 60s' "$root/deploy/kubernetes/production/database.yaml"; then + echo 'production archive timeout would exceed the certified cross-region bandwidth floor' >&2 + exit 1 +fi echo 'manual_release_tests=PASS'