Query returns error "there is no parameter $1" but server logs that there are two parameters supplied

From: Paul De Audney <paul(dot)deaudney(at)safetyculture(dot)io>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Query returns error "there is no parameter $1" but server logs that there are two parameters supplied
Date: 2023-07-17 02:25:05
Message-ID: CACKYwcL_dBUemZ4ksa608cGo4+yf6ca6t3pF1YyFN36+VpqD4w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Hello,

PostgreSQL slack suggested I submit this as a bug report as we are
supplying parameters but the server is saying we're missing 1. Even when we
supply 2 or more to our queries.

The following is the server logs & parameters supplied for a query that
returns an error message. This occurs around 2-10 times per hour on a
database with around 120-1000 queries per second. With around 300 users
connected, with roughly two thirds of those users idling due to connection
pools in the application code (node-pg).
We have other queries logging the same error on a different database on the
same server infrastructure using golang based connection pools/drivers
(jackc/pgx).

2023-07-17 01:39:20.265 UTC [1857486] user(at)db_name ERROR: there is no
parameter $1 at character 24
2023-07-17 01:39:20.265 UTC [1857486] user(at)db_name CONTEXT: unnamed portal
with parameters: $1 = 'template_31f98dcda25c482eb0b086a0081d28a8', $2 =
'template_31F98DCDA25C482EB0B086A0081D28A8'
2023-07-17 01:39:20.265 UTC [1857486] user(at)db_name STATEMENT:
SELECT templates.id, templates.rev, templates.json,
meta.template_data as meta_template_data, meta.date_draft_modified,
meta.draft_author_name
FROM templates
LEFT JOIN templates_meta as meta
ON templates.id = meta.id
WHERE (templates.id = $1 OR templates.id = $2)

This query does work when re-run exactly as shown there.

PostgreSQL version:

PostgreSQL 14.8 (Ubuntu 14.8-1.pgdg20.04+1) on x86_64-pc-linux-gnu,
compiled by gcc (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0, 64-bit

Extensions loaded are:

postgres=# \dx
List of installed extensions
Name | Version | Schema |
Description
--------------------+---------+------------+------------------------------------------------------------------------
citus | 11.2-2 | pg_catalog | Citus distributed database
citus_columnar | 11.2-1 | pg_catalog | Citus Columnar extension
pg_stat_statements | 1.9 | public | track planning and execution
statistics of all SQL statements executed
pgaudit | 1.6.2 | public | provides auditing functionality
plpgsql | 1.0 | pg_catalog | PL/pgSQL procedural language
(5 rows)

Regards,

Paul De Audney

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message PG Bug reporting form 2023-07-17 05:03:17 BUG #18025: Probably we need to change behaviour of the checkpoint failures in PG
Previous Message Noah Misch 2023-07-17 00:49:05 Re: BUG #17928: Standby fails to decode WAL on termination of primary