Re: Diagnostic comment in LogicalIncreaseXminForSlot - Mailing list pgsql-hackers

From Andres Freund
Subject Re: Diagnostic comment in LogicalIncreaseXminForSlot
Date
Msg-id 20210807061010.2ttf2qfrneyassdg@alap3.anarazel.de
Whole thread Raw
In response to Re: Diagnostic comment in LogicalIncreaseXminForSlot  (Ashutosh Bapat <ashutosh.bapat@enterprisedb.com>)
Responses Re: Diagnostic comment in LogicalIncreaseXminForSlot
List pgsql-hackers
Hi,

On 2021-07-12 17:28:15 +0530, Ashutosh Bapat wrote:
> On Mon, Jul 12, 2021 at 8:39 AM Amit Kapila <amit.kapila16@gmail.com> wrote:
> 
> > On Mon, Jul 5, 2021 at 12:54 PM Masahiko Sawada <sawada.mshk@gmail.com>
> > Today, again looking at this patch, I don't think doing elog inside
> > spinlock is a good idea. We can either release spinlock before it or
> > use some variable to remember that we need to write such an elog and
> > do it after releasing the lock. What do you think?
> 
> 
> The elog will be effective only under DEBUG1, otherwise it will be almost a
> NOOP. I am wondering whether it's worth adding a bool assignment and move
> the elog out only for DEBUG1. Anyway, will defer it to you.

It's *definitely* not ok to do an elog() while holding a spinlock. Consider
what happens if the elog tries to format the message and runs out of
memory. Or if elog detects the stack depth is too deep. An ERROR would be
thrown, and we'd loose track of the held spinlock.

Greetings,

Andres Freund



pgsql-hackers by date:

Previous
From: Amit Kapila
Date:
Subject: Re: Diagnostic comment in LogicalIncreaseXminForSlot
Next
From: Mahendra Singh Thalor
Date:
Subject: Re: Support reset of Shared objects statistics in "pg_stat_reset" function