Skip to content

retries for alembic migration for authn on startup - #1446

Open
swelborn wants to merge 3 commits into
bluesky:mainfrom
swelborn:fix-thundering-herd-authn-startup
Open

retries for alembic migration for authn on startup #1446
swelborn wants to merge 3 commits into
bluesky:mainfrom
swelborn:fix-thundering-herd-authn-startup

Conversation

@swelborn

@swelborn swelborn commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

added this retry code to startup to try and try again if we have many replicas on startup. this should mitigate having to bootstrap a cluster manually with 1 replica on, then spinning up more.

not sure if the code is in the right place. tried conforming to lazy imports, but moved function outside of deeply nested app startup code. since that is tough to read.

Checklist

  • Add a Changelog entry
  • Add the ticket number which this PR closes to the comment section

@swelborn swelborn changed the title fix-thundering-herd-authn-startup retries for alembic migration for authn on startup Jul 21, 2026
@swelborn

Copy link
Copy Markdown
Contributor Author

closes #1447

@swelborn
swelborn force-pushed the fix-thundering-herd-authn-startup branch from dd353bd to 8cec6c6 Compare July 23, 2026 14:50
@danielballan

Copy link
Copy Markdown
Member

Thanks for moving it outside the app startup code; I agree that that has overgrown and become hard to read.

I wonder if, instead of retries, we should aim for CREATE TABLE IF NOT EXISTS. The first to open the transaction will do the work, and the rest will wait their turn and then discover that there is nothing left to do.

@swelborn

Copy link
Copy Markdown
Contributor Author

good morning dan

do you mean to move the subprocess in-process? trying to think about which replica grabs the lock to do the table creation + alembic upgrade + role creation + stamp version, and how the lock is held thru that process, without some exception handling like we have in this retry code

Sam Welborn added 3 commits July 29, 2026 13:25
this fix mitigates thundering herd problem when bringing up multiple replicas of the server. we could do this with a lock, but we want to make sure sqlite and other dialects work. so we add a retry mechanism for when things fail
@swelborn
swelborn force-pushed the fix-thundering-herd-authn-startup branch from 8cec6c6 to 00dd73b Compare July 29, 2026 17:28
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.

2 participants