Skip to content

[Robustness] revoke が分散トランザクションでなく、成功不明時に local と remote の状態が分岐する #66

Description

@somasekimoto

背景

PR #56 のディープレビュー指摘 (B56-6)。PR #56 で per-content の process 内 mutex を入れ、単一 gateway プロセス内の同時 revoke は直列化されたが、プロセスをまたぐ場合と部分失敗時の分岐は残っている。

問題

1. 複数 gateway プロセスからの同時 revoke

mutex は process 内のものなので、gateway が複数プロセス / 複数インスタンスで動く場合は直列化されない。

2. remote commit 後の event publish 失敗で local が rollback する

これが最も影響が大きい。

  • state node は CRDT commit 後の event publish 失敗をリクエスト全体の error にする
  • SDK はその error を「remote に commit されなかった」と解釈して local snapshot を restore する
  • 結果、remote は新 ciphertext を持ち、local は旧 CEK を持つ状態になり、以後復号できない

3. invalidate 成功後に後段が失敗すると、成功した部分を caller へ返せない

token_invalidated_at は取れているのに、後続処理の失敗で error response になるため caller に伝わらない。

4. relay 経由の invalidate が member の実 cutoff を返さない

relay ノードの概算時刻を返しており、member 側が実際に設定した min_valid_issued_at ではない。

あるべき修正

  • revoke を versioned / idempotent な saga として設計する
  • remote mutation ID と結果を照会可能にし、timeout 後に commit 有無を reconcile できるようにする
  • Share / CEK / ciphertext に CAS version を導入する
  • 「invalidate は成功した」という partial outcome を、error response であっても caller へ返す

関連

🤖 Generated with Claude Code

https://claude.ai/code/session_01S8xhYR7ZuFkiFMS91NUW6c

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions