Skip to content

Commit

Permalink
postgres: add exponential backoff to connection retries (dbt-labs#5503)
Browse files Browse the repository at this point in the history
add exponential backoff to postgres connection retries
  • Loading branch information
Nathaniel May authored and Axel Goblet committed Sep 16, 2022
1 parent c14e736 commit 9064f60
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .changes/unreleased/Features-20220720-171257.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
kind: Features
body: add exponential backoff to connection retries on Postgres (and Redshift)
time: 2022-07-20T17:12:57.486949-04:00
custom:
Author: nathaniel-may
Issue: "5502"
PR: "5503"
4 changes: 4 additions & 0 deletions plugins/postgres/dbt/adapters/postgres/connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,15 @@ def connect():
psycopg2.errors.OperationalError,
]

def exponential_backoff(attempt: int):
return attempt * attempt

return cls.retry_connection(
connection,
connect=connect,
logger=logger,
retry_limit=credentials.retries,
retry_timeout=exponential_backoff,
retryable_exceptions=retryable_exceptions,
)

Expand Down

0 comments on commit 9064f60

Please sign in to comment.