Re: pg13: xlogreader API adjust

From: Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com>
To: bossartn(at)amazon(dot)com
Cc: alvherre(at)2ndquadrant(dot)com, tgl(at)sss(dot)pgh(dot)pa(dot)us, pgsql-hackers(at)lists(dot)postgresql(dot)org, ah(at)cybertec(dot)at, andres(at)anarazel(dot)de
Subject: Re: pg13: xlogreader API adjust
Date: 2020-05-14 05:12:25
Message-ID: 20200514.141225.2135961559041970762.horikyota.ntt@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

At Thu, 14 May 2020 01:03:48 +0000, "Bossart, Nathan" <bossartn(at)amazon(dot)com> wrote in
> I think I've discovered a problem with 850196b6. The following steps
> can be used to trigger a segfault:
>
> # wal_level = logical
> psql postgres -c "create database testdb;"
> psql testdb -c "select pg_create_logical_replication_slot('slot', 'test_decoding');"
> psql "dbname=postgres replication=database" -c "START_REPLICATION SLOT slot LOGICAL 0/0;"
>
> From a quick glance, I think the problem starts in
> StartLogicalReplication() in walsender.c. The call to
> CreateDecodingContext() may ERROR before xlogreader is initialized in
> the next line, so the subsequent call to WalSndErrorCleanup()
> segfaults when it attempts to access xlogreader.

Good catch! That's not only for CreateDecodingContet. That happens
everywhere in the query loop in PostgresMain() until logreader is
initialized. So that also happens, for example, by starting logical
replication using invalidated slot. Checking xlogreader != NULL in
WalSndErrorCleanup is sufficient. It doesn't make actual difference,
but the attached explicitly initialize the pointer with NULL.

regards.

--
Kyotaro Horiguchi
NTT Open Source Software Center

Attachment Content-Type Size
0001-Don-t-check-uninitialized-xlog-reader-state.patch text/x-patch 1.2 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrey M. Borodin 2020-05-14 05:19:42 Re: MultiXact\SLRU buffers configuration
Previous Message Amit Langote 2020-05-14 05:09:46 Re: making update/delete of inheritance trees scale better