Re: Fix race condition in InvalidatePossiblyObsoleteSlot()

Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>

From: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
To: Michael Paquier <michael@paquier.xyz>
Cc: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>, pgsql-hackers@lists.postgresql.org, exclusion@gmail.com
Date: 2024-03-06T12:15:56Z
Lists: pgsql-hackers
On Wed, Mar 6, 2024 at 4:51 PM Michael Paquier <michael@paquier.xyz> wrote:
>
> On Wed, Mar 06, 2024 at 09:17:58AM +0000, Bertrand Drouvot wrote:
> > Right, somehow out of context here.
>
> We're not yet in the green yet, one of my animals has complained:
> https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=hachi&dt=2024-03-06%2010%3A10%3A03
>
> This is telling us that the xmin horizon is unchanged, and the test
> cannot move on with the injection point wake up that would trigger the
> following logs:
> 2024-03-06 20:12:59.039 JST [21143] LOG:  invalidating obsolete replication slot "injection_activeslot"
> 2024-03-06 20:12:59.039 JST [21143] DETAIL:  The slot conflicted with xid horizon 770.
>
> Not sure what to think about that yet.

Windows - Server 2019, VS 2019 - Meson & ninja on my CI setup isn't
happy about that as well [1]. It looks like the slot's catalog_xmin on
the standby isn't moving forward.

[1]
https://cirrus-ci.com/task/5132148995260416

[09:11:17.851] 285/285 postgresql:recovery /
recovery/035_standby_logical_decoding               ERROR
553.48s   (exit status 255 or signal 127 SIGinvalid)
[09:11:17.855] >>>
INITDB_TEMPLATE=C:/cirrus/build/tmp_install/initdb-template
enable_injection_points=yes
PG_REGRESS=C:\cirrus\build\src/test\regress\pg_regress.exe
MALLOC_PERTURB_=172
REGRESS_SHLIB=C:\cirrus\build\src/test\regress\regress.dll
PATH=C:/cirrus/build/tmp_install/usr/local/pgsql/bin;C:\cirrus\build\src/test\recovery;C:/cirrus/build/src/test/recovery/test;C:\BuildTools\VC\Tools\MSVC\14.29.30133\bin\HostX64\x64;C:\BuildTools\MSBuild\Current\bin\Roslyn;C:\Program
Files (x86)\Windows Kits\10\bin\10.0.20348.0\x64;C:\Program Files
(x86)\Windows Kits\10\bin\x64;C:\BuildTools\\MSBuild\Current\Bin;C:\Windows\Microsoft.NET\Framework64\v4.0.30319;C:\BuildTools\Common7\IDE\;C:\BuildTools\Common7\Tools\;C:\BuildTools\VC\Auxiliary\Build;C:\zstd\zstd-v1.5.2-win64;C:\zlib;C:\lz4;C:\icu;C:\winflexbison;C:\strawberry\5.26.3.1\perl\bin;C:\python\Scripts\;C:\python\;C:\Windows
Kits\10\Debuggers\x64;C:\Program
Files\Git\usr\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\ProgramData\GooGet;C:\Program
Files\Google\Compute Engine\metadata_scripts;C:\Program Files
(x86)\Google\Cloud SDK\google-cloud-sdk\bin;C:\Program
Files\PowerShell\7\;C:\Program Files\Google\Compute
Engine\sysprep;C:\ProgramData\chocolatey\bin;C:\Program
Files\Git\cmd;C:\Program Files\Git\mingw64\bin;C:\Program
Files\Git\usr\bin;C:\Windows\system32\config\systemprofile\AppData\Local\Microsoft\WindowsApps
C:\python\python3.EXE C:\cirrus\build\..\src/tools/testwrap --basedir
C:\cirrus\build --srcdir C:\cirrus\src/test\recovery --testgroup
recovery --testname 035_standby_logical_decoding --
C:\strawberry\5.26.3.1\perl\bin\perl.EXE -I C:/cirrus/src/test/perl -I
C:\cirrus\src/test\recovery
C:/cirrus/src/test/recovery/t/035_standby_logical_decoding.pl
[09:11:17.855] ------------------------------------- 8<
-------------------------------------
[09:11:17.855] stderr:
[09:11:17.855] # poll_query_until timed out executing this query:

[09:11:17.855] # SELECT (SELECT catalog_xmin::text::int - 770 from
pg_catalog.pg_replication_slots where slot_name =
'injection_activeslot') > 0

[09:11:17.855] # expecting this output:

[09:11:17.855] # t

[09:11:17.855] # last actual query output:

[09:11:17.855] # f

[09:11:17.855] # with stderr:

[09:11:17.855] # Tests were run but no plan was declared and
done_testing() was not seen.

[09:11:17.855] # Looks like your test exited with 255 just after 57.

-- 
Bharath Rupireddy
PostgreSQL Contributors Team
RDS Open Source Databases
Amazon Web Services: https://aws.amazon.com



Commits

  1. Revert "Add recovery TAP test for race condition with slot invalidations"

  2. Add recovery TAP test for race condition with slot invalidations

  3. Fix race leading to incorrect conflict cause in InvalidatePossiblyObsoleteSlot()