现象:共享桶部署下网关启动即报 gateway_auditor_key_required,残留过期 审计文件则每次 Execute 报 gateway_exclusive_writer_evidence_unverified; 用户已改为“停目标写入容器→更新→启动”的维护式更新。 根因:Gateway.Ready 强制 Isolation.Verify,main 强制 Ed25519 公钥,等于 把整桶独占证明当作发布前置;这与共享桶、沿用原 AK 的实际部署矛盾。 取舍:删除审计校验与相关 env 依赖,保留 journal、治理 PG 只读 authority、 plan/owner/attempt/epoch 绑定、intent-before-send、单次写与精确版本回滚。 create 仅在精确版本读回且仍为 current 时提交;发现外部 latest 只返回冲突, 不在 confirm 阶段删除(journal create intent 已提交,删除会变成无 delete intent/receipt 的未记账副作用并让 intent 永久 held)。同 key 不自动合并。 证据:真实二进制无审计/残留审计两环境通过;kg-pgtest-writeset 一次性库 + 随机 MinIO 桶跑 14 个网关用例(含共享桶共存写者、同 key 既有对象拒绝、 精确回滚)全过;umask 022 下 make verify 本地必需项全 success。
This commit is contained in:
@@ -20,17 +20,18 @@ type Gateway struct {
|
||||
Pool *pgxpool.Pool
|
||||
Scope string
|
||||
Backend Backend
|
||||
Isolation IsolationVerifier
|
||||
MaxBytes int64
|
||||
}
|
||||
|
||||
// Ready gates admission on the local journal and the object backend only. A
|
||||
// shared bucket is the supported deployment shape: unrelated writers on other
|
||||
// keys do not need to be drained, and no whole-bucket exclusivity evidence is
|
||||
// required. Per-key competition is handled at execute time, not by a global
|
||||
// "only writer" attestation.
|
||||
func (g *Gateway) Ready(ctx context.Context) error {
|
||||
if g.Pool == nil || g.Scope == "" || g.Backend == nil || g.MaxBytes < 1 {
|
||||
return ErrPersistence
|
||||
}
|
||||
if g.Isolation == nil || g.Isolation.Verify(ctx) != nil {
|
||||
return ErrIsolation
|
||||
}
|
||||
var sync, fsync, full string
|
||||
if g.Pool.QueryRow(ctx, "SELECT current_setting('synchronous_commit'), current_setting('fsync'), current_setting('full_page_writes')").Scan(&sync, &fsync, &full) != nil || sync != "on" || fsync != "on" || full != "on" {
|
||||
return ErrPersistence
|
||||
@@ -249,13 +250,9 @@ func (g *Gateway) execute(ctx context.Context, r Request, body []byte, authoriza
|
||||
if exists {
|
||||
return g.finish(ctx, r, "rejected", Version{})
|
||||
}
|
||||
v, err := g.Backend.Put(ctx, r.Key, body, r.token())
|
||||
v, err := sendCreate(ctx, g.Backend, r, body)
|
||||
if err != nil {
|
||||
return Receipt{}, ErrHeld
|
||||
}
|
||||
exact, exists, err := g.Backend.Observe(ctx, r.Key, v.ID)
|
||||
if err != nil || !exists || !r.matches(exact) || v != exact {
|
||||
return Receipt{}, ErrHeld
|
||||
return Receipt{}, err
|
||||
}
|
||||
return g.finish(ctx, r, "committed", v)
|
||||
}
|
||||
@@ -322,5 +319,15 @@ func (g *Gateway) Reconcile(ctx context.Context, r Request) (Receipt, error) {
|
||||
if err != nil || !exists || exact != found[0] {
|
||||
return Receipt{}, ErrHeld
|
||||
}
|
||||
latest, current, err := g.Backend.Observe(ctx, r.Key, "")
|
||||
if err != nil || !current {
|
||||
return Receipt{}, ErrHeld
|
||||
}
|
||||
if latest.ID != exact.ID {
|
||||
// Another writer owns the current version of this key. Do not delete
|
||||
// anything during reconcile and do not report a committed create for a
|
||||
// key this plan no longer controls.
|
||||
return Receipt{}, ErrConflict
|
||||
}
|
||||
return g.finish(ctx, r, "committed", exact)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user