RE: [PATCH] Fix stale relation close in sequence synchronization

From: "Hayato Kuroda (Fujitsu)" <kuroda(dot)hayato(at)fujitsu(dot)com>
To: 'Ayush Tiwari' <ayushtiwari(dot)slg01(at)gmail(dot)com>
Cc: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, vignesh C <vignesh21(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: RE: [PATCH] Fix stale relation close in sequence synchronization
Date: 2026-04-28 12:13:59
Message-ID: OS9PR01MB121492298361AC9CF08AF93B2F5372@OS9PR01MB12149.jpnprd01.prod.outlook.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Dear Ayush,

> I found a crash in the logical replication sequence synchronization worker
> when the publisher returns NULL sequence data for a sequence after at least
> one sequence in the same sync batch has already been processed.

Good catch. I confirmed the HEAD can crash with your added test.

> The attached patch clears the output Relation pointer at the start of
> get_and_validate_seq_info() and clears the local pointer in copy_sequences()
> after closing it. That keeps early returns from reusing a relation from a
> previous row.

To confirm; can't we declare the sequence_rel in the inner-loop? My first
impression was the bug caused by the wrong lifetime. Are there any other
thoughts around here?

Added Vignesh in CC because he was a primary author.

Best regards,
Hayato Kuroda
FUJITSU LIMITED

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Ayush Tiwari 2026-04-28 12:34:40 Re: [PATCH] Fix stale relation close in sequence synchronization
Previous Message shveta malik 2026-04-28 11:38:50 Re: Include schema-qualified names in publication error messages.