| From: | Amit Kapila <amit(dot)kapila16(at)gmail(dot)com> |
|---|---|
| To: | "Hayato Kuroda (Fujitsu)" <kuroda(dot)hayato(at)fujitsu(dot)com> |
| Cc: | shihao zhong <zhong950419(at)gmail(dot)com>, Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>, Manu <manuelreyesbravo(at)gmail(dot)com>, Fujii Masao <masao(dot)fujii(at)gmail(dot)com>, "pgsql-hackers(at)lists(dot)postgresql(dot)org" <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Andres Freund <andres(at)anarazel(dot)de>, Thomas Munro <thomas(dot)munro(at)gmail(dot)com>, Noah Misch <noah(at)leadboat(dot)com> |
| Subject: | Re: [PG19] Promotion hangs behind a backend blocked on a stuck client |
| Date: | 2026-10-22 04:27:01 |
| Message-ID: | CAA4eK1LRp_JLxLC71-BH6WP+QKaFDH+94S14mOp7wp6MvfusBQ@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On Wed, Oct 21, 2026 at 2:36 PM Hayato Kuroda (Fujitsu)
<kuroda(dot)hayato(at)fujitsu(dot)com> wrote:
>
> ```
> The setting takes effect only for connections
> + established after it is configured,
> ```
>
> Hmm, is it correct?
> There is an assign hook which can update the socket option. My below experiment
> also indicated that TCP_USER_TIMEOUT can be enabled for established connections.
>
> 1. Connected via TCP connection
> $ psql -h 127.0.0.1 -U postgres
>
> 2. Set the tcp_user_timeout
>
> ```
> postgres=# SHOW tcp_user_timeout ;
> tcp_user_timeout
> ------------------
> 0
> (1 row)
>
> postgres=# SET tcp_user_timeout = '3s';
> SET
> ```
>
> 3. Sent a large amount of data to the client.
>
> ```
> postgres=# COPY (
> SELECT repeat('x', 1000000)
> FROM generate_series(1, 100000)
> ) TO STDOUT;
> ```
>
> 4. Sent a STOP signal to psql process, from another terminal
> ```
> $ kill -STOP 40049
> ```
>
> 5. After sometime the backend could be terminated due to the tcp timeout.
> According to the log:
>
> ```
> LOG: could not send data to client: Connection timed out
> STATEMENT: COPY (
> SELECT repeat('x', 1000000)
> FROM generate_series(1, 100000)
> ) TO STDOUT;
> ```
>
> Note: the backend could retain if step2 was skipped.
>
Thanks for the test but how can the user know when to set it, if not
before connection? Anyway, how about something generic as follows:
- To bound such waits in advance, set
- <varname>tcp_user_timeout</varname> on the standby, where supported by
- the operating system. The setting takes effect only for connections
- established after it is configured, and does not affect a connection
- whose backend is already blocked.
+ To bound such waits, configure <varname>tcp_user_timeout</varname> on
+ the standby ahead of time, for example in
+ <filename>postgresql.conf</filename>, where supported by the operating
+ system. Setting it after a backend is already blocked sending data has
+ no effect on that backend.
--
With Regards,
Amit Kapila.
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Suraj Kharage | 2026-10-22 04:39:26 | Re: [PATCH] Add support for INSERT ... SET syntax |
| Previous Message | Michael Paquier | 2026-10-22 04:10:27 | Re: [PATCH] Fix argument in pg_indexam_progress_phasename() |