Is SPI + Procedures (with COMMIT) inside a bgworker broken? - Mailing list pgsql-hackers

From Fabrízio de Royes Mello
Subject Is SPI + Procedures (with COMMIT) inside a bgworker broken?
Date
Msg-id CAFcNs+p+fD5HEXEiZMZC1COnXkJCMnUK0=r4agmZP=9Hi+YcJA@mail.gmail.com
Whole thread Raw
Responses Re: Is SPI + Procedures (with COMMIT) inside a bgworker broken?  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
Hi all,

I'm trying to execute a PROCEDURE (with COMMIT inside) called from a background worker using SPI but I'm always getting the error below:

2021-09-13 09:36:43.568 -03 [23845] LOG:  worker_spi worker 2 initialized with schema2.counted
2021-09-13 09:36:43.568 -03 [23846] LOG:  worker_spi worker 1 initialized with schema1.counted
2021-09-13 09:36:43.571 -03 [23846] ERROR:  invalid transaction termination
2021-09-13 09:36:43.571 -03 [23846] CONTEXT:  PL/pgSQL function schema1.counted_proc() line 1 at COMMIT
SQL statement "CALL "schema1"."counted_proc"()"
2021-09-13 09:36:43.571 -03 [23846] STATEMENT:  CALL "schema1"."counted_proc"()
2021-09-13 09:36:43.571 -03 [23845] ERROR:  invalid transaction termination
2021-09-13 09:36:43.571 -03 [23845] CONTEXT:  PL/pgSQL function schema2.counted_proc() line 1 at COMMIT
SQL statement "CALL "schema2"."counted_proc"()"
2021-09-13 09:36:43.571 -03 [23845] STATEMENT:  CALL "schema2"."counted_proc"()
2021-09-13 09:36:43.571 -03 [23838] LOG:  background worker "worker_spi" (PID 23845) exited with exit code 1
2021-09-13 09:36:43.571 -03 [23838] LOG:  background worker "worker_spi" (PID 23846) exited with exit code 1

I changed the worker_spi example (attached) a bit to execute a simple procedure. Even using SPI_connect_ext(SPI_OPT_NONATOMIC) I'm getting the error "invalid transaction termination".

There are something wrong with the attached example or am I missing something?

Regards,

--
Fabrízio de Royes Mello
Attachment

pgsql-hackers by date:

Previous
From: Daniel Gustafsson
Date:
Subject: Re: Online verification of checksums
Next
From: Daniel Gustafsson
Date:
Subject: Re: proposal: possibility to read dumped table's name from file