cluster: a runner that lost its shard lock can still write replies and messages for that shard
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 初心者へのやさしさ
- 35/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- postgresql, typescript
調査の方向性
Start with SqlMessageStorage and SqlRunnerStorage in effect/cluster, then read the shard reset and write paths named in the issue: resetShards, saveReply, saveRequest, saveEnvelope, clearReplies and clearAddress. Run the linked repro against the current code to confirm stale writes after lock loss. Done means shard writes from an old owner are rejected after a new owner resets the shard, while client writes without a fence still work.
索引モデルが issue の本文から書いたものです。
説明
Base: effect 4.0.6 (effect/cluster, SqlMessageStorage + SqlRunnerStorage on PostgreSQL advisory locks). main has the same code.
What happens. Shard ownership is a session advisory lock. A runner checks it every shardLockRefreshInterval.
Between two checks, the runner can lose the lock (its lock session ended, or it was paused) while another runner
acquires the shard, runs resetShards, and starts the same entities. The old runner does not know yet. Its handlers
finish and call saveReply, saveRequest, saveEnvelope, clearReplies and clearAddress. None of these check
who owns the shard, so the writes succeed.
Results:
- A persisted request gets two replies, or the old owner's reply wins over the new owner's.
- A
clearRepliesorclearAddressfrom the old owner deletes what the new owner just wrote. - With a duplicate primary key, the write is deduplicated with no error, so nobody sees it.
Repro (two runners believe they own one shard):
const cluster = yield* make({ backend: "pg", entities: HoldEntityLayer }) // persisted RPC that waits on a gate
const [stale] = yield* cluster.start(1)
const reply = yield* client("held").Hold(new Request({ id: "fenced" })).pipe(Effect.forkChild)
// handler has started on `stale`
yield* cluster.freeze(stale) // stale stops refreshing
yield* cluster.dropLockSessions // pg_terminate_backend on its lock session
const [owner] = yield* cluster.start(1) // owner acquires the shard and re-runs the request
assert(stale.sharding.hasShardId(shard)) // stale still believes it owns it
openGate(stale) // stale's handler finishes first
// 4.0.6: stale's reply is stored and returned to the caller.
// Expected: stale's saveReply fails; only owner's reply is stored.
Expected. Each shard acquisition gets an epoch. Every write on behalf of a shard carries the epoch the writer
acquired with, and storage rejects it in the same transaction if the shard's epoch has moved on. The rejection is a
typed error, logged at Error, and the entity on the stale runner stops.
Proposed fix (implemented on a fork, PR available).
SqlMessageStoragemigration0004_shard_epochsadds<prefix>_shards (shard_id, epoch).resetShardsraises the epoch of each shard it resets and returns aShardFenceper shard.MessageStorage.CurrentShardFencecarries the fence to the write.saveRequest,saveEnvelope,saveReply,
clearRepliesandclearAddressread the shard's epoch with a shared row lock (FOR SHARE,LOCK IN SHARE MODE,
HOLDLOCK) inside the write's transaction, and fail withShardFencedif it differs.resetShardstakes the
exclusive lock on the same row, so a stale write either commits before the new owner's reset or fails.- Writes by a client (sending to a shard it does not own) carry no fence and are not checked.
- An entity whose reply is fenced is stopped.
Shardingreleases a shard whose reset fails.
Runnable repro (real runner processes, fails on 4.0.6 and on main at 837e906): https://github.com/heyimcarlos/effect-cluster-repro, issue 3 in the README table.
- 主要言語
- TypeScript
- スター
- 16.7k
- フォーク
- 808
- 平均マージ
- 10時間 17分
- マージ済み PR(30日)
- 850
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
Effect-TS/effect のほかの issue
-
[email protected]: crypto declarations require a global CryptoKey type, breaking Node-only type-checks with @types/node 22 and 24対応中かも @effect-bot が今日担当しました。 オープンbug
Effect-TS/effect#10196 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
OpenApi.fromApi (4.1.0) emits duplicate component schemas with a _1 suffix when the encoded side differs再び着手できるかも このイシューのプルリクエストはマージされずにクローズされました。 オープン
難易度 3/5 1〜2日 初心者へのやさしさ 35/100
メンテナーはふだん 1 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 47/100
メンテナーはふだん 1 日以内に返信
-
`fromJsonSchemaDocument`: import open `patternProperties`対応中かも @effect-bot が 2 日前に担当しました。 オープン
Effect-TS/effect#10048 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
`fromJsonSchemaDocument`: import `dependentRequired` (draft-07 `dependencies`)対応中かも @effect-bot が 2 日前に担当しました。 オープン
Effect-TS/effect#10046 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
Effect-TS/effect の issue をすべて見る
似ている issue
-
Replace discontinued crypto-js in the theme対応中かも @aelmanaa が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
PaloAltoNetworks/docusaurus-openapi-docs#1689 ·
メンテナーはふだん 2 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
solana-foundation/solana-web3.js#4015 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
メンテナーはふだん 1 日以内に返信
-
documentation
難易度 1/5 1〜3時間 初心者へのやさしさ 90/100
ivopogace/opencode-courier#422 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
chapel-lang/chapel-vscode#158 ·
メンテナーはふだん 1 日以内に返信