Skip to content

fix(oauth): default a leader-lock follower's wait to the lease so its takeover can land - #9546

Merged
waleedlatif1 merged 1 commit into
stagingfrom
fix/leader-lock-default-wait
Nov 1, 2026
Merged

waleedlatif1 merged 1 commit into
stagingfrom
fix/leader-lock-default-wait

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

Summary

  • withLeaderLock lets a follower take over a lease once its wait ends with nothing (fix(oauth): take over a lapsed refresh lease, share overlapping service-account key reads, and label unsearched accounts #9537), but with the default options that takeover could never land:
    • the follower waited 3s;
    • the lease lasts 10s;
    • so the follower tried the lock while a dead leader's lease was still live, and gave up.
  • A follower's wait now defaults to the lease TTL, so its takeover try comes after a dead leader's lease has lapsed. DEFAULT_MAX_WAIT_MS is gone.
  • An explicit shorter wait is still honoured. It can still take over a lease that was released, but not one held by a dead leader. The option's doc says so.
  • No production behaviour changes: the only caller, the OAuth refresh in credential-service, already passes a wait equal to its lease TTL.

Type of Change

  • Bug fix

Testing

  • New test: a follower using the defaults, behind a dead leader's 10s lease (Redis SET NX EX modelled on fake time), waits it out and takes over. It fails on staging (the follower returns null).
  • lib/concurrency and lib/oauth pass (390 tests).
  • bun run lint, block registry check, check:audits and type-check pass.
  • The full suite runs in CI.

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing (new tests pass the test-audit authoring gate)
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel

vercel Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
docs Skipped Skipped Nov 1, 2026 5:18am UTC

Request Review

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 2 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Turn on auto-fix | Re-trigger cubic

@greptile-apps

greptile-apps Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Low impact] The PR appears safe to merge.

Summary

withLeaderLock now defaults a follower’s wait to ttlSec * 1000, allowing its takeover attempt to reach an expired lease.

  • Default lock followers wait through the lease before trying takeover.

Reviews (1) · Last reviewed commit: "fix(oauth): default a leader-lock follow..." · Reviewed by Greptile

@waleedlatif1
waleedlatif1 merged commit 425f9a4 into staging Nov 1, 2026
129 of 131 checks passed
@waleedlatif1
waleedlatif1 deleted the fix/leader-lock-default-wait branch November 1, 2026 07:14

This branch was previously deployed

1 inactive deployment
Preview — d073065f Deployed Nov 1, 2026 by vercel[bot]
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