Skip to content

fix(dbng): bound database readiness polling - #1277

Open
WilliamK112 wants to merge 2 commits into
Scalingo:masterfrom
WilliamK112:fix/database-create-bounded-retry
Open

WilliamK112 wants to merge 2 commits into
Scalingo:masterfrom
WilliamK112:fix/database-create-bounded-retry

Conversation

@WilliamK112

Copy link
Copy Markdown
Contributor

Summary

  • replace the unbounded database readiness loop with go-utils/retry
  • keep polling transitional and not-yet-visible databases, with a 30-minute maximum wait
  • stop immediately when the database is stopped or the API returns a non-404 error
  • add focused tests for successful transitions, temporary not-found responses, terminal states, API errors, and bounded retries

Fixes #1271

Validation

  • go test ./dbng
  • go test ./...
  • go vet ./...
  • gofmt and git diff --check

The repository-equivalent golangci-lint command was also attempted locally, but the analyzer remained CPU-bound without producing output on this resource-constrained machine; PR CI will run the same official configuration.

Checklist

  • Add a changelog entry in the section "To Be Released" of CHANGELOG.md

Use the shared Scalingo retry utility to cap readiness polling at 30 minutes while preserving retries for transitional states and databases that are not visible yet. Stop immediately for stopped databases and API errors, and cover the behavior with focused tests.
@WilliamK112
WilliamK112 requested a review from a team as a code owner October 21, 2026 20:43
@WilliamK112
WilliamK112 requested review from SCedricThomas and removed request for a team October 21, 2026 20:43
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-21T20:48:35.202820Z 962c851 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 962c8515e1

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread dbng/create.go Outdated
db, err := client.Preview().DatabaseShow(ctx, appID)
retryer := retry.New(
retry.WithWaitDuration(databaseStatusPollInterval),
retry.WithMaxDuration(databaseStatusMaxWait),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Pass the polling deadline into status lookups

When a DatabaseShow call runs across the 30-minute mark, this option does not actually bound the wait: Retryer.Do creates a separate timeout context but invokes method(ctx) with the original context and returns a successful result before consulting that timeout (vendor/github.com/Scalingo/go-utils/retry/retry.go:163,177-180). Consequently, an in-flight lookup can continue past the deadline and can even report success afterward; this is significant here because Preview DatabaseShow performs a list plus per-database population requests. Derive and pass a 30-minute context to the lookup so the provisioning deadline also cancels an active poll.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in fc116ade. The 30-minute provisioning limit now creates a child context before the retry loop and passes that same context into every DatabaseShow call, so an in-flight lookup is canceled when the deadline expires. I added a regression test whose lookup blocks until the supplied context is canceled.

Validation passed:

  • go test ./dbng
  • cancellation regression test repeated 50 times
  • go test ./...
  • go vet ./...

@EtienneM
EtienneM requested review from EtienneM and removed request for SCedricThomas October 22, 2026 07:40

This branch has not been deployed

No deployments
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.

[database-create] waitForRunningDatabase should not wait endlessly

1 participant