-
Notifications
You must be signed in to change notification settings - Fork 142
Implemented resilient startup #415
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR implements resilient startup for PostgreSqlStorage, allowing the application to gracefully handle transient database connectivity issues during initialization. The key changes introduce retry logic with exponential backoff, configurable degraded mode, and lazy initialization on first use.
Key Changes:
- Added retry mechanism with exponential backoff for database connection during storage initialization
- Introduced degraded mode that allows applications to start even when the database is temporarily unavailable
- Implemented lazy initialization that re-attempts connection on first storage use
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
src/Hangfire.PostgreSql/PostgreSqlStorageOptions.cs |
Added configuration properties for resilient startup including retry limits, backoff delays, and degraded mode flag |
src/Hangfire.PostgreSql/PostgreSqlStorage.cs |
Refactored initialization logic to support retries, exponential backoff, and lazy initialization with proper thread safety |
tests/Hangfire.PostgreSql.Tests/PostgreSqlStorageOptionsFacts.cs |
Added tests verifying default resilient startup options and computed property behavior |
tests/Hangfire.PostgreSql.Tests/PostgreSqlStorageFacts.cs |
Added tests for retry behavior and degraded mode scenarios |
tests/Hangfire.PostgreSql.Tests/Utils/DelegateConnectionFactory.cs |
Added test utility to simulate connection failures |
README.md |
Added comprehensive documentation explaining resilient startup feature, configuration options, and usage examples |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Updated [Hangfire.PostgreSql](https://github.com/frankhommers/Hangfire.PostgreSql) from 1.20.12 to 1.20.13. <details> <summary>Release notes</summary> _Sourced from [Hangfire.PostgreSql's releases](https://github.com/frankhommers/Hangfire.PostgreSql/releases)._ ## 1.20.13 ## What's Changed * Use EXECUTE for index creation for compatibility with older PostgreSQL versions. by @sake12 in hangfire-postgres/Hangfire.PostgreSql#405 * Implemented resilient startup by @azygis in hangfire-postgres/Hangfire.PostgreSql#415 ## New Contributors * @sake12 made their first contribution in hangfire-postgres/Hangfire.PostgreSql#405 **Full Changelog**: hangfire-postgres/Hangfire.PostgreSql@1.20.12...1.20.13 Commits viewable in [compare view](hangfire-postgres/Hangfire.PostgreSql@1.20.12...1.20.13). </details> [](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) --- <details> <summary>Dependabot commands and options</summary> <br /> You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show <dependency name> ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore <dependency name> major version` will close this group update PR and stop Dependabot creating any more for the specific dependency's major version (unless you unignore this specific dependency's major version or upgrade to it yourself) - `@dependabot ignore <dependency name> minor version` will close this group update PR and stop Dependabot creating any more for the specific dependency's minor version (unless you unignore this specific dependency's minor version or upgrade to it yourself) - `@dependabot ignore <dependency name>` will close this group update PR and stop Dependabot creating any more for the specific dependency (unless you unignore this specific dependency or upgrade to it yourself) - `@dependabot unignore <dependency name>` will remove all of the ignore conditions of the specified dependency - `@dependabot unignore <dependency name> <ignore condition>` will remove the ignore condition of the specified dependency and ignore conditions </details> Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Added support for resilient startup in
PostgreSqlStorage, introducing retry logic with exponential backoff and configurable degraded mode when connecting to the database during initialization. The storage can now optionally allow the application to start even if the database is temporarily unavailable, and will re-attempt initialization on first use.Fixes #414.