Re: BUG #17789: process_pgfdw_appname() fails for autovacuum workers

From: Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>
To: Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com>
Cc: exclusion(at)gmail(dot)com, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #17789: process_pgfdw_appname() fails for autovacuum workers
Date: 2023-02-14 08:02:45
Message-ID: CAD21AoArqZMZO71jPsO7HwtzKCykpW0Qvt3vSzjR+Qo0Gvx1bg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Tue, Feb 14, 2023 at 2:05 PM Kyotaro Horiguchi
<horikyota(dot)ntt(at)gmail(dot)com> wrote:
>
> At Mon, 13 Feb 2023 05:00:01 +0000, PG Bug reporting form <noreply(at)postgresql(dot)org> wrote in
> > CREATE FOREIGN TABLE ft1 (b int) INHERITS (t1)
> > SERVER LOOPBACK OPTIONS (table_name 'anytable');
>
> Yeah, the autovacuum processes t1 and then its child foreign table
> ft1. MyProcPort is NULL on autovacuum processes. This doesn't happen
> for partitioned tables.
>
> > #5 0x0000564b2ecc55c8 in ExceptionalCondition
> > (conditionName=conditionName(at)entry=0x7fb1feb3f81e "MyProcPort != NULL",
> > errorType=errorType(at)entry=0x7fb1feb3e700 "FailedAssertion",
> > fileName=fileName(at)entry=0x7fb1feb3f75a "option.c",
> > lineNumber=lineNumber(at)entry=464) at assert.c:69
> > #6 0x00007fb1feb31b30 in process_pgfdw_appname (appname=<optimized out>) at
> > option.c:464
>
> Commit 6e0cb3dec1 overlooked the case of autovacuum analyzing foreign
> tables as an inheritance child. We thought NULL MyProcPort was
> impossible in the discussion for the patch. Using %d and %u in
> postgres_fdw.application_name we hit the bug.
>
> The following change fixes the bug.

The change seems to work fine.

>
> - Is it okay to use '-' as %u (user name) and %d (databsae name) in
> the NULL MyProcPort case?

Another idea seems to not display anything in this case, which is
consistent with what log_status_format() does.

>
> - Do we need tests for the case? They need to wait for autovacuum to run.

Not sure it's worth having tests for that as the fix is obvious.

Regards,

--
Masahiko Sawada
Amazon Web Services: https://aws.amazon.com

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message PG Bug reporting form 2023-02-14 09:33:23 BUG #17793: Query with large number of joins crashes PostgreSQL
Previous Message PG Bug reporting form 2023-02-14 07:00:01 BUG #17792: MERGE uses uninitialized pointer and crashes when target tuple is updated concurrently