RE: BUG #19950: pg_terminate_backend rejects a positive bigint timeout as negative

From: "Hayato Kuroda (Fujitsu)" <kuroda(dot)hayato(at)fujitsu(dot)com>
To: "imchifan(at)163(dot)com" <imchifan(at)163(dot)com>
Cc: "pgsql-bugs(at)lists(dot)postgresql(dot)org" <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Subject: RE: BUG #19950: pg_terminate_backend rejects a positive bigint timeout as negative
Date: 2026-11-26 02:21:02
Message-ID: OS7PR01MB1831728B6B2F4F27016FC7E2EF5422@OS7PR01MB18317.jpnprd01.prod.outlook.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Hi Liu,

> 2147483648 is positive and is within the bigint range declared by the
> function's SQL interface, so it must not produce the diagnostic that the
> timeout is negative. Since PID 2147483647 is not a PostgreSQL backend PID,
> the call should instead report that no signal was sent.
>

I confirmed this could happen by below one-liner.

```
postgres=# SELECT pg_terminate_backend(pg_backend_pid(), 2147483648::bigint);
ERROR: "timeout" must not be negative
```

> The implementation appears to store the bigint argument in an int before
> checking whether it is negative.

Hmm. Personally, I feel nobody will input such a huge timeout value, but codes in
other parts try to accept it. PSA the fix patch.
I checked [1] but could not find reasoning that timeout should be int32 or int64.

[1]: https://www.postgresql.org/message-id/flat/CALj2ACUBpunmyhYZw-kXCYs5NM%2Bh6oG_7Df_Tn4mLmmUQifkqA%40mail.gmail.com

Best regards,
Hayato Kuroda
FUJITSU LIMITED

Attachment Content-Type Size
0001-Accept-bigint-value-in-pg_terminate_backend.patch application/octet-stream 769 bytes

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tender Wang 2026-11-26 03:56:06 Re: BUG #19929: RETURNING OLD/NEW: segfault when used only inside a hashed subplan
Previous Message Tender Wang 2026-11-26 02:06:16 Re: BUG #19942: SIGSEGV crash (and wrong results) in MERGE ... RETURNING WITH (OLD/NEW) with VIRTUAL generated colum