Re: Flush some statistics within running transactions - Mailing list pgsql-hackers

From Álvaro Herrera
Subject Re: Flush some statistics within running transactions
Date
Msg-id 202601301136.kvw5jklzhkru@alvherre.pgsql
Whole thread Raw
In response to Re: Flush some statistics within running transactions  (Álvaro Herrera <alvherre@kurilemu.de>)
Responses Re: Flush some statistics within running transactions
List pgsql-hackers
On 2026-Jan-30, Álvaro Herrera wrote:

> Interesting.  Bertrand asked me about this.  He says[1] he diagnosed this
> down to SetLatch being called immediately after the handler runs, and I
> wonder if it's correct that other timeout handler functions used for
> RegisterTimeout are doing SetLatch().  The SIGALRM handler
> handle_sig_alarm() that calls the specific handler function already has
> a SetLatch call, so why do we need another one here?

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:

void
CheckDeadLockAlert(void)
{
    int         save_errno = errno;

    got_deadlock_timeout = true;

    /*
     * Have to set the latch again, even if handle_sig_alarm already did. Back
     * then got_deadlock_timeout wasn't yet set... It's unlikely that this
     * ever would be a problem, but setting a set latch again is cheap.
     */
    SetLatch(MyLatch);
    errno = save_errno;
}


I wonder if it would work to move the SetLatch() that's currently at the
top of handle_sig_alarm() to the bottom, after we have called all the
specific handlers, and remove the ones that are there.

-- 
Álvaro Herrera               48°01'N 7°57'E  —  https://www.EnterpriseDB.com/



pgsql-hackers by date:

Previous
From: Jim Jones
Date:
Subject: Re: Change default of jit to off
Next
From: Laurenz Albe
Date:
Subject: Re: Change default of jit to off