Re: AssertLog instead of Assert in some places

2023-08-14 Thread Ashutosh Bapat
On Sat, Aug 12, 2023 at 12:56 AM Andres Freund wrote: > On 2023-08-11 11:56:27 -0700, Peter Geoghegan wrote: > > On Fri, Aug 11, 2023 at 11:23 AM Andres Freund wrote: > > > > Couldn't you say the same thing about defensive "can't happen" ERRORs? > > > > They are essentially a form of assertion th

Re: AssertLog instead of Assert in some places

2023-08-14 Thread Ashutosh Bapat
On Fri, Aug 11, 2023 at 11:27 PM Andres Freund wrote: > > > > Attached patch combines Assert and elog(ERROR, ) so that when an > > Assert is triggered in assert-enabled binary, it will throw an error > > while keeping the backend intact. Thus it does not affect gdb session > > or psql session. The

Re: AssertLog instead of Assert in some places

2023-08-11 Thread Peter Geoghegan
On Fri, Aug 11, 2023 at 2:04 PM Andres Freund wrote: > Where supported, a crash (distinguishing from assertion failures) will now > report something like: > > process with pid: 2900527 received signal: SIGSEGV, si_code: 1, si_addr: > 0xdeadbeef > [0x5628ec45212f] pg_fatalsig_handler+0x20f

Re: AssertLog instead of Assert in some places

2023-08-11 Thread Andres Freund
Hi, On 2023-08-11 13:19:34 -0700, Peter Geoghegan wrote: > On Fri, Aug 11, 2023 at 12:26 PM Andres Freund wrote: > > > For example, dealing with core dumps left behind by the regression > > > tests can be annoying. > > > > Hm. I don't have a significant problem with that. But I can see it being >

Re: AssertLog instead of Assert in some places

2023-08-11 Thread Peter Geoghegan
On Fri, Aug 11, 2023 at 12:26 PM Andres Freund wrote: > > For example, dealing with core dumps left behind by the regression > > tests can be annoying. > > Hm. I don't have a significant problem with that. But I can see it being > problematic. Unfortunately, short of preventing core dumps from hap

Re: AssertLog instead of Assert in some places

2023-08-11 Thread Andres Freund
Hi, On 2023-08-11 11:56:27 -0700, Peter Geoghegan wrote: > On Fri, Aug 11, 2023 at 11:23 AM Andres Freund wrote: > > > Couldn't you say the same thing about defensive "can't happen" ERRORs? > > > They are essentially a form of assertion that isn't limited to > > > assert-enabled builds. > > > > Y

Re: AssertLog instead of Assert in some places

2023-08-11 Thread Peter Geoghegan
On Fri, Aug 11, 2023 at 11:23 AM Andres Freund wrote: > > Couldn't you say the same thing about defensive "can't happen" ERRORs? > > They are essentially a form of assertion that isn't limited to > > assert-enabled builds. > > Yes. A lot of them I hate them with the passion of a thousand suns ;).

Re: AssertLog instead of Assert in some places

2023-08-11 Thread Andres Freund
Hi, On 2023-08-11 11:14:34 -0700, Peter Geoghegan wrote: > On Fri, Aug 11, 2023 at 10:57 AM Andres Freund wrote: > > I am quite strongly against this. This will lead to assertions being hit in > > tests without that being noticed, e.g. because they happen in a background > > process that just res

Re: AssertLog instead of Assert in some places

2023-08-11 Thread Peter Geoghegan
On Fri, Aug 11, 2023 at 10:57 AM Andres Freund wrote: > I am quite strongly against this. This will lead to assertions being hit in > tests without that being noticed, e.g. because they happen in a background > process that just restarts. Couldn't you say the same thing about defensive "can't hap

Re: AssertLog instead of Assert in some places

2023-08-11 Thread Andres Freund
Hi, On 2023-08-11 17:59:37 +0530, Ashutosh Bapat wrote: > Most of the Asserts are recoverable by rolling back the transaction > without crashing the backend. So an elog(ERROR, ) is enough. But just > by themselves elogs are compiled into non-debug binary and the > condition check can waste CPU cyc

AssertLog instead of Assert in some places

2023-08-11 Thread Ashutosh Bapat
Hi All, PostgreSQL code uses Assert() as a way to 1. document the assumption or conditions which must be true at a given place in code 2. make sure that some bug elsewhere does not break these assumptions or rules 3. conditions which can not be (easily) induced by user actions E.g. following condi