Re: Support worker_spi to execute the function dynamically. - Mailing list pgsql-hackers

From Andres Freund
Subject Re: Support worker_spi to execute the function dynamically.
Date
Msg-id 20230728022332.egqzobhskmlf6ntr@awork3.anarazel.de
Whole thread Raw
In response to Re: Support worker_spi to execute the function dynamically.  (Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>)
Responses Re: Support worker_spi to execute the function dynamically.
List pgsql-hackers
Hi,

The new test fails with my AIO branch occasionally. But I'm fairly certain
that's just due to timing differences.

Excerpt from the log:

2023-07-27 21:43:00.385 UTC [42339] LOG:  worker_spi worker 3 initialized with schema3.counted
2023-07-27 21:43:00.399 UTC [42344] 001_worker_spi.pl LOG:  statement: SELECT datname, count(datname) FROM
pg_stat_activity
                WHERE backend_type = 'worker_spi' GROUP BY datname;
2023-07-27 21:43:00.403 UTC [42340] LOG:  worker_spi worker 2 initialized with schema2.counted
2023-07-27 21:43:00.407 UTC [42341] LOG:  worker_spi worker 1 initialized with schema1.counted
2023-07-27 21:43:00.420 UTC [42346] 001_worker_spi.pl LOG:  statement: SELECT worker_spi_launch(1);
2023-07-27 21:43:00.423 UTC [42347] LOG:  worker_spi dynamic worker 1 initialized with schema1.counted
2023-07-27 21:43:00.432 UTC [42349] 001_worker_spi.pl LOG:  statement: SELECT worker_spi_launch(2);
2023-07-27 21:43:00.437 UTC [42350] LOG:  worker_spi dynamic worker 2 initialized with schema2.counted
2023-07-27 21:43:00.443 UTC [42347] ERROR:  duplicate key value violates unique constraint
"pg_namespace_nspname_index"
2023-07-27 21:43:00.443 UTC [42347] DETAIL:  Key (nspname)=(schema1) already exists.
2023-07-27 21:43:00.443 UTC [42347] CONTEXT:  SQL statement "CREATE SCHEMA "schema1" CREATE TABLE "counted" (
typetext CHECK (type IN ('total', 'delta')),         value    integer)CREATE UNIQUE INDEX "counted_unique_total" ON
"counted"(type) WHERE type = 'total'"
 


As written, dynamic and static workers race each other. It doesn't make a lot
of sense to me to use the same ids for either?

The attached patch reproduces the problem on master.

Note that without the sleep(3) in the test the workers don't actually finish
starting, the test shuts down the cluster before that happens...

Greetings,

Andres Freund

Attachment

pgsql-hackers by date:

Previous
From: Noah Misch
Date:
Subject: Re: Postgres v15 windows bincheck regression test failures
Next
From: Michael Paquier
Date:
Subject: Add assertion on held AddinShmemInitLock in GetNamedLWLockTranche()