hydra icon indicating copy to clipboard operation
hydra copied to clipboard

[Bug]: parallel operation error during CREATE TABLE statements

Open bonesmoses opened this issue 7 months ago • 3 comments

What's wrong?

This was first reported in #50, and PR #138 (pushed to main Nov 2, 2023) claimed to have fixed the problem. However, the repro case provided there still applies as recently as 11.1-12, dated May 21, 2024.

As a refresh. The repro case:

CREATE TABLE sampletable (x numeric);
INSERT INTO sampletable SELECT i FROM generate_series(1,10000000) i;

Make sure that there are sufficient background workers to cause the race condition. The settings I used:

max_worker_processes = 16
max_parallel_workers_per_gather = 8

Note that I increased the size of the sample data to 10,000,000 rows rather than 1,000,000, as the previous amount was not enough to trigger the error reliably. This is because it's far more likely to occur when there are sufficient extra parallel workers.

Then repeatedly run the following SQL in a new session:

CREATE TABLE sampletable_columnar USING columnar AS SELECT * FROM sampletable ORDER BY 1 ASC;

I did this with a simple for loop:

for x in {1..20}; do 
  psql -c "CREATE TABLE sampletable_columnar USING columnar AS SELECT * FROM sampletable ORDER BY 1 ASC;"
done

It may run successfully, but should eventually fail as before:

ERROR:  cannot start commands during a parallel operation

bonesmoses avatar Jul 26 '24 20:07 bonesmoses