Skip to content

idle-in-transaction timeout termination not reported to end user #378

@AndrewJackson2020

Description

@AndrewJackson2020

What happens?

If you encounter an idle-in-transaction termination in psql the error message sent to the end user shows that this was in fact the reason why their connection was closed. In duckdb-postgres the reported error message is much more ambiguous and does not mention idle-in-transaction at all.

I think the issue has to do with this line. Possibly there is more to the error message than what is returned by the PQresultErrorMessage function.

To Reproduce

To recreate first set up a postgres instance on localhost with on port 5432

duckdb-postgres

> import duckdb
> duckdb.install_extension('postgres')
> duckdb.load_extension('postgres')
> duckdb.sql(f"ATTACH 'user=postgres host=localhost' AS db (TYPE postgres, READ_ONLY);")

> duckdb.sql("SELECT * FROM postgres_query('db', 'begin; SELECT pg_sleep(10);')")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
_duckdb.Error: Failed to execute query "ROLLBACK": server closed the connection unexpectedly
        This probably means the server terminated abnormally
        before or while processing the request.

Expected (psql)

> begin;
BEGIN

> -- wait a few second

> select 1;
FATAL:  terminating connection due to idle-in-transaction timeout
server closed the connection unexpectedly
        This probably means the server terminated abnormally
        before or while processing the request.
The connection to the server was lost. Attempting reset: Succeeded.

OS:

linux

PostgreSQL Version:

17.6

DuckDB Version:

1.4.1

DuckDB Client:

python

Full Name:

Andrew Jackson

Affiliation:

Andrew Jackson

Have you tried this on the latest main branch?

  • I agree

Have you tried the steps to reproduce? Do they include all relevant data and configuration? Does the issue you report still appear there?

  • I agree

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions