Re: pgsql: pgstat: Bring up pgstat in BaseInit() to fix uninitialized use o - Mailing list pgsql-committers

From Masahiko Sawada
Subject Re: pgsql: pgstat: Bring up pgstat in BaseInit() to fix uninitialized use o
Date
Msg-id CAD21AoCCAa+J1-udHRo5-Hbtv=D38WdZDAaXZGDbQQ_Vg_d3bQ@mail.gmail.com
Whole thread Raw
In response to Re: pgsql: pgstat: Bring up pgstat in BaseInit() to fix uninitialized use o  (Andres Freund <andres@anarazel.de>)
Responses Re: pgsql: pgstat: Bring up pgstat in BaseInit() to fix uninitialized use o  (Amit Kapila <amit.kapila16@gmail.com>)
List pgsql-committers
Hi,

On Sun, Aug 8, 2021 at 11:24 AM Andres Freund <andres@anarazel.de> wrote:
>
> Hi,
>
> On 2021-08-07 12:01:31 -0700, Andres Freund wrote:
> > Attached is a patch showing how this could look like. Note that the PANIC
> > should likely not be that but a WARNING, but the PANIC more useful for running
> > some initial tests...
>
> I pushed a slightly evolved version of this. As the commit message noted, this
> may not be the best approach, but we can revise after further discussion.

While testing streaming logical replication, I got another assertion
failure with the current HEAD (e2ce88b58f) when the apply worker
raised an error during applying spooled changes:

TRAP: FailedAssertion("pgstat_is_initialized && !pgstat_is_shutdown",
File: "pgstat.c", Line: 4810, PID: 11084)
0   postgres                            0x000000010704fd9a
ExceptionalCondition + 234
1   postgres                            0x0000000106d41e62
pgstat_assert_is_up + 66
2   postgres                            0x0000000106d43854 pgstat_send + 20
3   postgres                            0x0000000106d4433e
pgstat_report_tempfile + 94
4   postgres                            0x0000000106df9519
ReportTemporaryFileUsage + 25
5   postgres                            0x0000000106df945a
PathNameDeleteTemporaryFile + 282
6   postgres                            0x0000000106df8c7e
unlink_if_exists_fname + 174
7   postgres                            0x0000000106df8b3a walkdir + 426
8   postgres                            0x0000000106df8982
PathNameDeleteTemporaryDir + 82
9   postgres                            0x0000000106dfe591
SharedFileSetDeleteAll + 113
10  postgres                            0x0000000106dfdf62
SharedFileSetDeleteOnProcExit + 66
11  postgres                            0x0000000106e05275
proc_exit_prepare + 325
12  postgres                            0x0000000106e050a3 proc_exit + 19
13  postgres                            0x0000000106d3ba99
StartBackgroundWorker + 649
14  postgres                            0x0000000106d54e85
do_start_bgworker + 613
15  postgres                            0x0000000106d4ef26
maybe_start_bgworkers + 486
16  postgres                            0x0000000106d4d767 sigusr1_handler + 631
17  libsystem_platform.dylib            0x00007fff736705fd _sigtramp + 29
18  ???                                 0x0000000000000000 0x0 + 0
19  postgres                            0x0000000106d4c990 PostmasterMain + 6640
20  postgres                            0x0000000106c24fa3 main + 819
21  libdyld.dylib                       0x00007fff73477cc9 start + 1

The apply worker registers SharedFileSetDeleteOnProcExit() when
creating a file set to serialize the changes. When it raises an error
due to conflict during applying the change, the callback eventually
reports the temp file statistics but pgstat already shut down,
resulting in this assertion failure.

Regards,

-- 
Masahiko Sawada
EDB:  https://www.enterprisedb.com/



pgsql-committers by date:

Previous
From: Daniel Gustafsson
Date:
Subject: pgsql: Remove unused regression test certificate server-ss
Next
From: Daniel Gustafsson
Date:
Subject: pgsql: Add alternative output for OpenSSL 3 without legacy loaded