I have a Next.js project where I'm using Prisma to read from Postgresql.
I have code like:
const rows = await prisma.receipts.findMany({
where: {
action_receipts: {
// https://www.prisma.io/docs/concepts/components/prisma-client/filtering-and-sorting#filter-on-relations
signer_account_id: {
equals: accountName,
},
},
},
orderBy: {
included_in_block_timestamp: 'desc',
},
take: 2,
});
I'm often getting errors like:
error: PrismaClientUnknownRequestError:
Invalid `prisma.receipts.findMany()` invocation:
Error occurred during query execution:
ConnectorError(ConnectorError { user_facing_error: None, kind: QueryError(Error { kind: Db, cause: Some(DbError { severity: "ERROR", parsed_severity: Some(Error), code: SqlState("42P05"), message: "prepared statement \"s0\" already exists", detail: None, hint: None, position: None, where_: None, schema: None, table: None, column: None, datatype: None, constraint: None, file: Some("prepare.c"), line: Some(480), routine: Some("StorePreparedStatement") }) }) })
(Sometimes instead of "s0" it says something else though, such as "s8".)
What does this mean, and how can I avoid it?
It seems like the problem often goes away if I stop my local server and wait a minute and then start again via yarn dev
and then try my Prisma query again. But I'm oblivious to the root cause, which I want to identify and solve.
yarn.lock
, which I haven't checked yet. – Dordrecht