Skip to content

fix(master): bump the cooldown failure count with a compare-and-swap - #270

Merged
beinan merged 1 commit into
lance-format:mainfrom
beinan:fix/cooldown-cas
Sep 26, 2026
Merged

beinan merged 1 commit into
lance-format:mainfrom
beinan:fix/cooldown-cas

Conversation

@beinan

@beinan beinan commented Sep 26, 2026

Copy link
Copy Markdown
Collaborator

Problem

record_failure (#267) bumped the per-target failure count with a plain get → +1 → put. Several masters finish a failing task for the same target within seconds of one another (they all swept it at the same instant), so two could read the same count and both write count+1 — a lost update. Staging showed three masters failing the same store at 10:34:49/:51/:52 with the record under-counting; a broken store then takes an extra window or two to reach the threshold.

Fix

get_cooldown_versioned returns the key's mod_revision; record_failure writes the new record in a Txn conditioned on Compare::mod_revision == observed, and on conflict revokes its lease, backs off 5–25 ms with jitter, and retries (up to 64 attempts — contention is bounded by the master count, a handful). The success path is unchanged.

Verification

New etcd-backed test concurrent_failure_records_are_not_lost: 12 concurrent record_failure calls on one target, asserts failures == 12. Under the pre-fix get/put it lost updates; with CAS but a tight 8-retry loop it exhausted retries; with jittered backoff all 12 land. Master suite 28/28 etcd-backed + 42 default, clippy clean.

Refs #266, #267, #269.

🤖 Generated with Claude Code

Several masters finish a failing task for the same target within seconds
of one another because they all swept it at the same instant. The count
was bumped with a plain get/put, so two of them could read the same value
and both write count+1, losing a failure and delaying the cooldown. On
staging three masters failed the same store within 3.4 s and the record
showed fewer failures than tasks.

Read the key's mod_revision, write the new record in a Txn conditioned on
it, and retry with a short jittered backoff on conflict. A 12-way
concurrent test now records exactly 12.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@beinan
beinan merged commit be86f49 into lance-format:main Sep 26, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant