Session in aborted transaction misses effective_wal_level change - Mailing list pgsql-hackers

From Sergei Patiakin
Subject Session in aborted transaction misses effective_wal_level change
Date
Msg-id CANE55rApeNAFaqxLWrvm-NC0Y5gkrBFZFVaHVYP89AGS2SYMcA@mail.gmail.com
Whole thread
List pgsql-hackers
For an aborted transaction, there is today a gap between the
AtEOXact_LogicalCtl call and the XID being cleared. If an
effective_wal_level change occurs during that gap, the change will be
missed. That means the next transaction on that session will not be
logically decoded.

Attaching a reproducer bash script that demonstrates the missing decoded change.
Attaching a fix that moves the AtEOXact_LogicalCtl call later, closing the gap.

The issue was observed on master (b69356cd789) and REL_19_STABLE
(67c01b84788). It seems it was introduced in 67c20979ce7.

repro.sh output without patch:

> rows committed:
> 1
> 2
> 3
>
> changes decoded from slot s:
> table public.t: INSERT: a[integer]:1
> table public.t: INSERT: a[integer]:3

repro.sh output with patch:

> rows committed:
> 1
> 2
> 3
>
> changes decoded from slot s:
> table public.t: INSERT: a[integer]:1
> table public.t: INSERT: a[integer]:2
> table public.t: INSERT: a[integer]:3

Best regards,
Sergei

Attachment

pgsql-hackers by date:

Previous
From: Álvaro Herrera
Date:
Subject: Re: ATTACH PARTITION cost grows linearly with pg_constraint size (seqscan in CloneFkReferenced), much worse since not-null constraints are in pg_constraint (PG 18)
Next
From: Masahiko Sawada
Date:
Subject: Re: REPACK (CONCURRENTLY) can crash a logical decoding session