postgres.git / summary / log / commit / refs

commit    b68e356a680ee1155b0dc612a89655e98320121a
Author:   Michael Paquier <michael@paquier.xyz>
Date:     Sat Jul 29 02:34:53 2023 +0000
First released in: 17.0

    worker_spi: Fix race condition in newly-added TAP tests
    
    The second portion of the tests had a race condition where it would be
    possible for the startup of the dynamic workers to fail, in the event
    where the static workers started before them with the library loading in
    shared_preload_libraries did not finish to create their respective
    schemas.  The conflict is caused by the fact that the dynamic and static
    workers used the same IDs, overlapping each other, so, for now, switch
    the dynamic workers to use different IDs, leading to different schemas
    created.
    
    Reported-by: Andres Freund
    Discussion: https://postgr.es/m/20230728022332.egqzobhskmlf6ntr@awork3.anarazel.de


src/test/modules/worker_spi/t/001_worker_spi.pl | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/test/modules/worker_spi/t/001_worker_spi.pl b/src/test/modules/worker_spi/t/001_worker_spi.pl index c2938713134..74e109f9a1f 100644 --- a/src/test/modules/worker_spi/t/001_worker_spi.pl +++ b/src/test/modules/worker_spi/t/001_worker_spi.pl @@ -65,9 +65,11 @@ ok( $node->poll_query_until( ) or die "Timed out while waiting for bgworkers to be launched"; # Ask worker_spi to launch dynamic bgworkers with the library loaded, then -# check their existence. -my $worker1_pid = $node->safe_psql('mydb', 'SELECT worker_spi_launch(1);'); -my $worker2_pid = $node->safe_psql('mydb', 'SELECT worker_spi_launch(2);'); +# check their existence. Use IDs that do not overlap with the schemas created +# by the previous workers. +my $worker1_pid = $node->safe_psql('mydb', 'SELECT worker_spi_launch(10);'); +my $worker2_pid = $node->safe_psql('mydb', 'SELECT worker_spi_launch(11);'); + ok( $node->poll_query_until( 'mydb', qq[SELECT datname, count(datname) FROM pg_stat_activity [parent: 6d982e3b3bd4]