pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Alexander Lakhin <exclusion@gmail.com>
To: vignesh C <vignesh21@gmail.com>
Cc: Zhijie Hou (Fujitsu) <houzj.fnst@fujitsu.com>
Cc: pgsql-hackers <pgsql-hackers@postgresql.org>
Subject: Re: Race condition in FetchTableStates() breaks synchronization of subscription tables
Date: Tue, 6 Feb 2024 16:00:00 +0300
Message-ID: <a50d1da6-e3fb-1f06-0ae4-8e038d1c4d85@gmail.com> (raw)
In-Reply-To: <CALDaNm16SW3X2snvTKu-YQxGWGhjWLWj5H9eqXc-bTK4inUtJw@mail.gmail.com>
References: <711a6afe-edb7-1211-cc27-1bef8239eec7@gmail.com>
	<CALDaNm2=SjA_=e9bhYO0ChBm-Wdh-=HYF0RHsR+_2gnqwcyOkg@mail.gmail.com>
	<OS0PR01MB5716B4C05F90F59C0ED227C2947D2@OS0PR01MB5716.jpnprd01.prod.outlook.com>
	<CALDaNm1n-EHOAU7MMoVCEBOmX_V40dfpB1XTpETDk4qQivXXUg@mail.gmail.com>
	<OS0PR01MB5716DBE439D9D3BA6D16DD8C947D2@OS0PR01MB5716.jpnprd01.prod.outlook.com>
	<CALDaNm0hP4J6fbmsNDWBTbb8GxcM=YkB=tjdJbWFTocB8u4MQQ@mail.gmail.com>
	<858a7622-2c81-1687-d1df-1322dfcb2e72@gmail.com>
	<CALDaNm16SW3X2snvTKu-YQxGWGhjWLWj5H9eqXc-bTK4inUtJw@mail.gmail.com>

05.02.2024 13:13, vignesh C wrote:
> Thanks for the steps for the issue, I was able to reproduce this issue
> in my environment with the steps provided. The attached patch has a
> proposed fix where the latch will not be set in case of the apply
> worker exiting immediately after starting.

It looks like the proposed fix doesn't help when ApplyLauncherWakeup()
called by a backend executing CREATE SUBSCRIPTION command.
That is, with the v4-0002 patch applied and pg_usleep(300000L); added
just below
             if (!worker_in_use)
                 return worker_in_use;
I still observe the test 027_nosuperuser running for 3+ minutes:
t/027_nosuperuser.pl .. ok
All tests successful.
Files=1, Tests=19, 187 wallclock secs ( 0.01 usr  0.00 sys +  4.82 cusr  4.47 csys =  9.30 CPU)

IIUC, it's because a launcher wakeup call, sent by "CREATE SUBSCRIPTION
regression_sub ...", gets missed when launcher waits for start of another
worker (logical replication worker for subscription "admin_sub"), launched
just before that command.

Best regards,
Alexander





view thread (25+ messages)  latest in thread

Message-ID: <a50d1da6-e3fb-1f06-0ae4-8e038d1c4d85@gmail.com>
Permalink:  ../a50d1da6-e3fb-1f06-0ae4-8e038d1c4d85@gmail.com/
Also on:    postgresql.org/message-id/a50d1da6-e3fb-1f06-0ae4-8e038d1c4d85@gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-hackers@postgresql.org
  Cc: exclusion@gmail.com, vignesh21@gmail.com, houzj.fnst@fujitsu.com
  Subject: Re: Race condition in FetchTableStates() breaks synchronization of subscription tables
  In-Reply-To: <a50d1da6-e3fb-1f06-0ae4-8e038d1c4d85@gmail.com>
  References: <711a6afe-edb7-1211-cc27-1bef8239eec7@gmail.com> <CALDaNm2=SjA_=e9bhYO0ChBm-Wdh-=HYF0RHsR+_2gnqwcyOkg@mail.gmail.com> <OS0PR01MB5716B4C05F90F59C0ED227C2947D2@OS0PR01MB5716.jpnprd01.prod.outlook.com> <CALDaNm1n-EHOAU7MMoVCEBOmX_V40dfpB1XTpETDk4qQivXXUg@mail.gmail.com> <OS0PR01MB5716DBE439D9D3BA6D16DD8C947D2@OS0PR01MB5716.jpnprd01.prod.outlook.com> <CALDaNm0hP4J6fbmsNDWBTbb8GxcM=YkB=tjdJbWFTocB8u4MQQ@mail.gmail.com> <858a7622-2c81-1687-d1df-1322dfcb2e72@gmail.com> <CALDaNm16SW3X2snvTKu-YQxGWGhjWLWj5H9eqXc-bTK4inUtJw@mail.gmail.com> <a50d1da6-e3fb-1f06-0ae4-8e038d1c4d85@gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox