From b15dd8783e77ab7932c11b7c9bc2b7093015f886 Mon Sep 17 00:00:00 2001 From: Laurence Isla Date: Thu, 21 Oct 2021 21:08:29 -0500 Subject: [PATCH] Add Retry-After header when recovering the connection --- admin.rst | 11 +++++++++++ postgrest.dict | 2 ++ releases/upcoming.rst | 3 +++ 3 files changed, 16 insertions(+) diff --git a/admin.rst b/admin.rst index 68df23052..df318e516 100644 --- a/admin.rst +++ b/admin.rst @@ -188,6 +188,17 @@ A great way to inspect incoming HTTP requests including headers and query parame The options to ngrep vary depending on the address and host on which you've bound the server. The binding is described in the :ref:`configuration` section. The ngrep output isn't particularly pretty, but it's legible. +.. _automatic_recovery: + +Automatic Connection Recovery +----------------------------- + +When PostgREST loses the connection to the database, it retries the connection using capped exponential backoff, with 32 seconds being the maximum backoff time. + +This retry behavior is triggered immediately after the connection is lost if :ref:`db-channel-enabled` is set to true (this is the default behavior), otherwise it will be activated once a request is made. + +To notify the client when the next reconnection attempt will be, PostgREST responds with ``503 Service Unavailable`` and the ``Retry-After: x`` header, where ``x`` is the number of seconds programmed for the next retry. + Database Logs ------------- diff --git a/postgrest.dict b/postgrest.dict index 396e67b5e..5a2689239 100644 --- a/postgrest.dict +++ b/postgrest.dict @@ -8,6 +8,7 @@ aud Auth auth authenticator +backoff balancer Beles Bouscal @@ -123,6 +124,7 @@ Rafaj RDS reallyreallyreallyreallyverysafe Rechkemmer +reconnection Redux refactor Remo diff --git a/releases/upcoming.rst b/releases/upcoming.rst index 9610ba27e..e5dc3541b 100644 --- a/releases/upcoming.rst +++ b/releases/upcoming.rst @@ -32,6 +32,9 @@ Added * Allow escaping inside double quotes with a backslash, e.g. ``?col=in.("Double\"Quote")``, ``?col=in.("Back\\slash")``. See :ref:`reserved-chars`. |br| -- `@steve-chavez `_ +* Add ``Retry-After`` header when recovering the connection. See :ref:`automatic_recovery`. + |br| -- `@gautam1168 `_ + * Documentation improvements + Added :ref:`nested_embedding` to the :ref:`resource_embedding` section.