mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-17 13:01:05 +01:00
With DATABASE_PREPARED_STATEMENTS=true behind a transaction-mode pooler (PgBouncer 1.22+, Neon -pooler hosts), a migration that changes a column type makes the pooler's shared prepared statement fail for every client and process with "cached plan must not change result type", and postgres.js then caches a statement without columns, so later executions on that connection throw a TypeError even after the schema is fixed. When a prepared statement fails with 26000, 42P05, or that 0A000 error, stop preparing its text for the rest of the process (decided at execution, so queued queries see it), retry pooled statements once unprepared, and retry a transaction whose first statement failed. Cap prepared texts at 1,000 per client and skip texts over 8 KB. Expose the counts through preparedStatementStats. Behaviour with the flag unset or false is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>