BUG #17789: process_pgfdw_appname() fails for autovacuum workers

From: PG Bug reporting form <noreply(at)postgresql(dot)org>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Cc: exclusion(at)gmail(dot)com
Subject: BUG #17789: process_pgfdw_appname() fails for autovacuum workers
Date: 2023-02-13 05:00:01
Message-ID: 17789-8b31c5a4672b74d9@postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

The following bug has been logged on the website:

Bug reference: 17789
Logged by: Alexander Lakhin
Email address: exclusion(at)gmail(dot)com
PostgreSQL version: 15.2
Operating system: Ubuntu 22.04
Description:

When executing the following queries:
CREATE EXTENSION postgres_fdw;
DO $d$
BEGIN
EXECUTE $$CREATE SERVER loopback FOREIGN DATA WRAPPER
postgres_fdw
OPTIONS (dbname '$$||current_database()||$$',
port '$$||current_setting('port')||$$'
)$$;
END;
$d$;
CREATE USER MAPPING FOR CURRENT_USER SERVER loopback;
ALTER SERVER loopback OPTIONS (application_name 'postgres_fdw %d/%u');
CREATE TABLE t1 (a int);
INSERT INTO t1 SELECT * FROM generate_series(1, 66) i;
CREATE FOREIGN TABLE ft1 (b int) INHERITS (t1)
SERVER LOOPBACK OPTIONS (table_name 'anytable');
\c -
SELECT pg_sleep(60)

with the autovacuum enabled:
autovacuum = on
autovacuum_naptime = 1
autovacuum_vacuum_threshold = 1

I get an assertion failure:
Core was generated by `postgres: autovacuum worker regression
'.
Program terminated with signal SIGABRT, Aborted.

warning: Section `.reg-xstate/2522086' in core file too small.
#0 __pthread_kill_implementation (no_tid=0, signo=6,
threadid=140402663786304) at ./nptl/pthread_kill.c:44
44 ./nptl/pthread_kill.c: No such file or directory.
(gdb) bt
#0 __pthread_kill_implementation (no_tid=0, signo=6,
threadid=140402663786304) at ./nptl/pthread_kill.c:44
#1 __pthread_kill_internal (signo=6, threadid=140402663786304) at
./nptl/pthread_kill.c:78
#2 __GI___pthread_kill (threadid=140402663786304, signo=signo(at)entry=6) at
./nptl/pthread_kill.c:89
#3 0x00007fb20a30e476 in __GI_raise (sig=sig(at)entry=6) at
../sysdeps/posix/raise.c:26
#4 0x00007fb20a2f47f3 in __GI_abort () at ./stdlib/abort.c:79
#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
#7 0x00007fb1feb2ae40 in connect_pg_server
(server=server(at)entry=0x564b30b0c220, user=user(at)entry=0x564b30b0c0b0)
at connection.c:416
#8 0x00007fb1feb2b2be in make_new_connection
(entry=entry(at)entry=0x564b30b203d0, user=user(at)entry=0x564b30b0c0b0)
at connection.c:344
#9 0x00007fb1feb2b799 in GetConnection (user=0x564b30b0c0b0,
will_prep_stmt=will_prep_stmt(at)entry=false,
state=state(at)entry=0x0) at connection.c:204
#10 0x00007fb1feb34a44 in postgresAnalyzeForeignTable
(relation=0x7fb1feb4fa30, func=<optimized out>,
totalpages=0x7fff7f91b4a8) at postgres_fdw.c:4951
#11 0x0000564b2e916252 in acquire_inherited_sample_rows
(onerel=onerel(at)entry=0x7fb1feb4b940, elevel=elevel(at)entry=13,
rows=rows(at)entry=0x564b30b27750, targrows=targrows(at)entry=30000,
totalrows=totalrows(at)entry=0x7fff7f91b5b0,
totaldeadrows=totaldeadrows(at)entry=0x7fff7f91b5b8) at analyze.c:1470
#12 0x0000564b2e91983f in do_analyze_rel
(onerel=onerel(at)entry=0x7fb1feb4b940, params=params(at)entry=0x564b30aaaaa4,
va_cols=va_cols(at)entry=0x0, acquirefunc=0x564b2e91854e
<acquire_sample_rows>, relpages=1, inh=inh(at)entry=true,
in_outer_xact=false, elevel=13) at analyze.c:534
#13 0x0000564b2e91a167 in analyze_rel (relid=<optimized out>,
relation=0x564b30b07250,
params=params(at)entry=0x564b30aaaaa4, va_cols=0x0,
in_outer_xact=<optimized out>, bstrategy=<optimized out>)
at analyze.c:269
#14 0x0000564b2e9a8ec7 in vacuum (relations=0x564b30b092b8,
params=params(at)entry=0x564b30aaaaa4,
bstrategy=<optimized out>, bstrategy(at)entry=0x564b30b034a8,
isTopLevel=isTopLevel(at)entry=true) at vacuum.c:492
#15 0x0000564b2eace110 in autovacuum_do_vac_analyze
(tab=tab(at)entry=0x564b30aaaaa0,
bstrategy=bstrategy(at)entry=0x564b30b034a8) at autovacuum.c:3149
#16 0x0000564b2ead028a in do_autovacuum () at autovacuum.c:2472
#17 0x0000564b2ead07ce in AutoVacWorkerMain (argc=argc(at)entry=0,
argv=argv(at)entry=0x0) at autovacuum.c:1715
#18 0x0000564b2ead08ac in StartAutoVacWorker () at autovacuum.c:1493
#19 0x0000564b2ead8300 in StartAutovacuumWorker () at postmaster.c:5541
#20 0x0000564b2ead932f in sigusr1_handler (postgres_signal_arg=<optimized
out>) at postmaster.c:5246
#21 <signal handler called>
#22 0x00007fb20a3e774d in __GI___select (nfds=nfds(at)entry=8,
readfds=readfds(at)entry=0x7fff7f91c960,
writefds=writefds(at)entry=0x0, exceptfds=exceptfds(at)entry=0x0,
timeout=timeout(at)entry=0x7fff7f91c8d0)
at ../sysdeps/unix/sysv/linux/select.c:69
#23 0x0000564b2ead999d in ServerLoop () at postmaster.c:1770
#24 0x0000564b2eadad45 in PostmasterMain (argc=argc(at)entry=3,
argv=argv(at)entry=0x564b30a29620) at postmaster.c:1478
#25 0x0000564b2ea1f2b0 in main (argc=3, argv=0x564b30a29620) at main.c:202

(A build without asserts crashes with a segmentation fault for me.)
Observed on REL_15_STABLE..master since the process_pgfdw_appname()
introduction (6e0cb3de).
Maybe the assert should be replaced by checks for MyProcPort in cases
'd','u' for compatibility with autovacuum workers.

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Fujii Masao 2023-02-13 05:29:09 array_agg(DISTINCT) caused a segmentation fault
Previous Message David Rowley 2023-02-13 03:21:11 Re: BUG #17777: An assert failed in nodeWindowAgg.c