With the upgrade to the latest release, we've been running in troubles with server side prepared statements and async usage: Statement handles got mixed up in the same processes and errors looked like this one
DBD::Pg::st execute failed: ERROR: prepared statement "dbdpg_p239066_1" already exists
or mismatch of bind variables count.
Two work-arounds have been
(1) Disable pg_server_prepare
(2) Do not use prepare_cached (in a setup where async and non-async queries are mixed)
The issue seems to be related to prepare_number not being incremented with 48bf171 in the async case which this patch does address:
host:dbdpg✔ [master]$ git diff dbdimp.c
diff --git a/dbdimp.c b/dbdimp.c
index cd6e093..4d42032 100644
--- a/dbdimp.c
+++ b/dbdimp.c
@@ -2552,9 +2552,11 @@ static int pg_st_prepare_statement (pTHX_ SV * sth, imp_sth_t * imp_sth)
TRACE_PQSENDPREPARE;
status = PQsendPrepare(imp_dbh->conn, imp_sth->prepare_name, statement, params,
imp_sth->PQoids);
- if (status)
+ if (status) {
imp_sth->async_status = STH_ASYNC_PREPARE;
- else {
+ imp_sth->prepared_by_us = DBDPG_TRUE;
+ imp_dbh->prepare_number++;
+ } else {
status = PGRES_FATAL_ERROR;
_fatal_sqlstate(aTHX_ imp_dbh);
}
As I am neither an expert in dbdimp.c nor could I reproduce this with updating 08async.t (maybe related to our local PgBouncer usage?), I am opening this a bug ticket instead of PR.
With the upgrade to the latest release, we've been running in troubles with server side prepared statements and async usage: Statement handles got mixed up in the same processes and errors looked like this one
or mismatch of bind variables count.
Two work-arounds have been
(1) Disable
pg_server_prepare(2) Do not use
prepare_cached(in a setup where async and non-async queries are mixed)The issue seems to be related to
prepare_numbernot being incremented with 48bf171 in the async case which this patch does address:As I am neither an expert in
dbdimp.cnor could I reproduce this with updating08async.t(maybe related to our local PgBouncer usage?), I am opening this a bug ticket instead of PR.