Re: AssertLog instead of Assert in some places - Mailing list pgsql-hackers

From Andres Freund
Subject Re: AssertLog instead of Assert in some places
Date
Msg-id 20230811175723.gyxxryi5u6xc44zq@awork3.anarazel.de
Whole thread Raw
In response to AssertLog instead of Assert in some places  (Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>)
Responses Re: AssertLog instead of Assert in some places
Re: AssertLog instead of Assert in some places
List pgsql-hackers
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 cycles esp. conditions are mostly true
> like the ones we use in Assert.
> 
> 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. These elogs do not make their way to non-assert
> binary so do not make it to production like Assert.

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.

Greetings,

Andres Freund



pgsql-hackers by date:

Previous
From: Andres Freund
Date:
Subject: Re: walsender "wakeup storm" on PG16, likely because of bc971f4025c (Optimize walsender wake up logic using condition variables)
Next
From: Marcelo Juchem
Date:
Subject: Re: [PATCH] Support static linking against LLVM