Created
August 20, 2020 21:26
-
-
Save DanielHons/f6253064e0e7c58eaee323038601385b to your computer and use it in GitHub Desktop.
Exponential backoff with postgreSQL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Given a table containing at least a column for the number of errors (with no success in between) and | |
frequently calling the following select will provide the candidates for a retry using an exponential backoff. | |
*/ | |
SELECT * FROM retryable_error WHERE | |
CURRENT_TIMESTAMP > (last_retry + CAST(CONCAT(CAST(POWER(2, error_count) AS text), 's') AS INTERVAL)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment