From 1e12522f0c9ca1f46cea0c0c04159c92a2728ddd Mon Sep 17 00:00:00 2001 From: wangbo Date: Fri, 31 Jul 2026 08:49:37 +0800 Subject: [PATCH] =?UTF-8?q?perf(worker):=20=E8=A7=A3=E8=80=A6=E5=BC=82?= =?UTF-8?q?=E6=AD=A5=E7=AD=89=E5=BE=85=E7=99=BB=E8=AE=B0=E4=B8=8E=E8=B7=A8?= =?UTF-8?q?=E5=9F=8E=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 媒体突发中的等待准入行是已同步持久化任务的可恢复派生状态,却逐条等待跨城同步提交并串行占用全局容量锁。\n\n仅对异步等待登记事务设置 synchronous_commit=off;任务实体、素材、执行准入、River job、租约、状态与账务继续同步提交。主备切换若命中极小窗口,由既有 queued-task 恢复器重建等待登记。\n\n验证:临时 PostgreSQL 18 跨 Store 分布式准入集成测试通过;Go 全量测试、go vet、gofmt 通过。 --- apps/api/internal/store/admission_queue.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/apps/api/internal/store/admission_queue.go b/apps/api/internal/store/admission_queue.go index 21426ed..0392c0c 100644 --- a/apps/api/internal/store/admission_queue.go +++ b/apps/api/internal/store/admission_queue.go @@ -151,6 +151,16 @@ func (s *Store) queueTaskAdmissionOnce( return TaskAdmission{}, err } defer rollbackTransaction(tx) + // The task itself was synchronously committed before this derived FIFO + // registration. Do not serialize a large media burst on one cross-region + // synchronous commit per waiting row: PostgreSQL still writes this WAL + // locally, and generic queued-task recovery reconstructs a registration + // after failover if the small asynchronous-commit window is hit. Admission, + // River job, execution lease, task state, and billing commits stay fully + // synchronous. + if _, err := tx.Exec(ctx, `SET LOCAL synchronous_commit = off`); err != nil { + return TaskAdmission{}, err + } if err := tryAdmissionTransactionLock(ctx, tx, "task-admission:"+input.TaskID); err != nil { return TaskAdmission{}, err