question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

26000: prepared statement "_auto2" does not exist

See original GitHub issue

Steps to reproduce

non yet, unfortunately

The issue

After upgrading to latest npgsql/ef.core 3.1.1.1 and npgsql to 4.1.3 these errors started to appear. Nothing relevant changed in the code base except for that update and updating FluentAssertions (which is only used in unit test projects, so it shouldn’t have an effect)

When running our e2e tests we see on ~every second run, maybe 2 out of 3 the error:

26000: prepared statement "_auto2" does not exist

as far as I could see, it was always _auto2 (from 10 different checks) pointing to either a command or a query, but always the same one. Before we start running the tests (which can execute in a random order), we do have a setup procedure which is always executed in the same order in parallel for 2 tenants. So that’s where _auto2 could always be initialized to the same query.

This is different from https://github.com/npgsql/npgsql/issues/2482 - I don’t recall ever seeing this before (although, it’s the same application)

Might be related to https://github.com/npgsql/npgsql/issues/2731 - we just switched to .net core 3 (3.1) last week. But given how persistent the error is right now, I doubt we’d have missed it last week.

Given, that we just use auto prepared statements with EF Core and never touch an npgsql connection directly, I don’t know how we could have caused this. One thing that we wrap some requests in a repeatable read transaction and retry it if it fails due to concurrent update issues. In order to be able to retry it properly, we have to clean the EF Core with their internal method:

        private void ClearChangeTracker()
        {
            var me = (IDbContextPoolable)this;

            lock (me)
            {
                _acquiredLocks.Clear();

                me.ResetState();
#pragma warning disable EF1001
                me.Resurrect(me.SnapshotConfiguration());
#pragma warning restore EF1001
            }
        }

But that code exists already for 2 years, so hard to imagine that it would start breaking now.

Further technical details

Npgsql version: 4.1.3 (it did work in 4.1.2) PostgreSQL version: 11 Operating system: docker image FROM mcr.microsoft.com/dotnet/core/aspnet:3.1

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:12 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
rpatrick00commented, May 13, 2020

@roji Sorry, there was an error in my code where the parameter binding didn’t match the query string…

1reaction
pgrmcommented, Feb 7, 2020

In that case, is there any way you can try to not do that and confirm whether the issue still occurs?

good point - I’ll try that out, definitely easier than trying to reproduce the whole thing

Read more comments on GitHub >

github_iconTop Results From Across the Web

pq driver: prepared statement does not exist
Query will first prepare a query, execute the statement, ... I don't see where the lib/pq PostgreSQL driver implements Queryer .
Read more >
MySQL 8.0 Reference Manual :: 13.5 Prepared Statements
To create a test case that reproduces a problem with prepared statements, so that you can file a bug report. PREPARE, EXECUTE, and...
Read more >
Prepared statements with pgBouncer
When I connect the DB directly, I didn't see any errors. It was running more than a year without any proxy. We are...
Read more >
PostgreSQL prepared statements in PL/pgSQL
In this blog post I'll show that static SQL within PL/pgSQL blocks are automatically prepared but doing the same with dynamic statement is...
Read more >
Prepared Statements | Npgsql Documentation
The only potential disadvantage of prepared statements is that they hold server-side resources (e.g. cached plans). If you're dynamically generating SQL queries ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found