Re: Flush some statistics within running transactions

From: Álvaro Herrera <alvherre(at)kurilemu(dot)de>
To: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
Cc: Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com>, Sami Imseih <samimseih(at)gmail(dot)com>, Michael Paquier <michael(at)paquier(dot)xyz>, pgsql-hackers(at)lists(dot)postgresql(dot)org, Zsolt Parragi <zsolt(dot)parragi(at)percona(dot)com>, Andres Freund <andres(at)anarazel(dot)de>
Subject: Re: Flush some statistics within running transactions
Date: 2026-01-30 14:37:57
Message-ID: 202601301359.pwvtc26izo5z@alvherre.pgsql
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2026-Jan-30, Álvaro Herrera wrote:

> So apparently the first function to do this in postinit.c was added by
> commit c6dda1f48e57 -- and apparently it was mimicking
> CheckDeadLockAlert(), which at this time looked like this:

I'm now wondering if CheckDeadLockAlert() really needed to have this in
the first place, or it was just an exercise in paranoia ... it was added
by commit 6753333f55e1, with the discussion in [1], and it's not clear
to me that there was any theoretical or experimental evidence that it
was necessary; the thread didn't discuss it, and the commit message
doesn't either. Added Andres to CC as committer to this thread, maybe
he remembers.

[1] https://www.postgresql.org/message-id/flat/20150115020335.GZ5245%40awork2.anarazel.de

Just for laughs I moved the SetLatch call in handle_sig_alarm() to the
bottom, and remove the ones in handlers, on the theory that by the time
the SetLatch call is reached, all the handlers have already run and thus
the flag variables are set. Everything seems to continue to work:
https://cirrus-ci.com/build/5758839359799296

(Though to be honest, it's not clear to me why it would matter at which
point in handle_sig_alarm we call SetLatch relative to the variables
being set, given that these variables are only going to matter once the
signal handler returns to the original code and the next
CHECK_FOR_INTERRUPTS is hit.)

--
Álvaro Herrera PostgreSQL Developer — https://www.EnterpriseDB.com/
"Pensar que el espectro que vemos es ilusorio no lo despoja de espanto,
sólo le suma el nuevo terror de la locura" (Perelandra, C.S. Lewis)

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Boris Mironov 2026-01-30 14:47:54 Re: Idea to enhance pgbench by more modes to generate data (multi-TXNs, UNNEST, COPY BINARY)
Previous Message Ashutosh Bapat 2026-01-30 14:35:13 Re: Improvements and refactoring in shmem.c