Skip to content

Pod error: prepared statement \"ecto_69\" does not exist error when using existing postgresql connected using pgbouncer #5551

@Falcondevils

Description

@Falcondevils

Past Issues Searched

  • I have searched open and closed issues to make sure that the bug has not yet been reported

Issue is a Bug Report

  • This is a bug report and not a feature request, nor asking for self-hosted support

Using official Plausible Cloud hosting or self-hosting?

Self-hosting

Describe the bug

I am using community edition plausible analytics image.

I am trying to use existing postgresql instance. I use pgbouncer to connect to postgres in transaction mode.
pgbouncer uses prepared statements in transaction mode.

So when i redeploy analytics container, the pod keeps restarting with error:

  • /entrypoint.sh run
    21:11:58.072 [error] Error refreshing 'sites_by_domain' - %Postgrex.Error{message: nil, postgres: %{code: :invalid_sql_statement_name, line: "448", message: "prepared statement "ecto_9061" does not exist", file: "prepare.c", unknown: "ERROR", severity: "ERROR", pg_code: "26000", routine: "FetchPreparedStatement"}, connection_id: 1095456199, query: nil}
    21:11:58.072 [error] Error refreshing 'hostname_allowlist_by_domain' - %Postgrex.Error{message: nil, postgres: %{code: :invalid_sql_statement_name, line: "448", message: "prepared statement "ecto_9125" does not exist", file: "prepare.c", unknown: "ERROR", severity: "ERROR", pg_code: "26000", routine: "FetchPreparedStatement"}, connection_id: 1095456199, query: nil}
    21:11:58.073 [error] Error refreshing 'page_blocklist_by_domain' - %Postgrex.Error{message: nil, postgres: %{code: :invalid_sql_statement_name, line: "448", message: "prepared statement "ecto_1186" does not exist", file: "prepare.c", unknown: "ERROR", severity: "ERROR", pg_code: "26000", routine: "FetchPreparedStatement"}, connection_id: 110844769, query: nil}
    21:11:58.073 [error] Error refreshing 'country_blocklist_by_domain' - %Postgrex.Error{message: nil, postgres: %{code: :invalid_sql_statement_name, line: "448", message: "prepared statement "ecto_1122" does not exist", file: "prepare.c", unknown: "ERROR", severity: "ERROR", pg_code: "26000", routine: "FetchPreparedStatement"}, connection_id: 725085946, query: nil}
    21:11:58.073 [error] Error refreshing 'country_blocklist_by_domain' - %Postgrex.Error{message: nil, postgres: %{code: :invalid_sql_statement_name, line: "448", message: "prepared statement "ecto_1154" does not exist", file: "prepare.c", unknown: "ERROR", severity: "ERROR", pg_code: "26000", routine: "FetchPreparedStatement"}, connection_id: 52924400, query: nil}
    21:11:58.073 [error] Error refreshing 'ip_blocklist_by_domain' - %Postgrex.Error{message: nil, postgres: %{code: :invalid_sql_statement_name, line: "448", message: "prepared statement "ecto_1090" does not exist", file: "prepare.c", unknown: "ERROR", severity: "ERROR", pg_code: "26000", routine: "FetchPreparedStatement"}, connection_id: 1809192939, query: nil}
    21:11:58.074 [error] Error refreshing 'page_blocklist_by_domain' - %Postgrex.Error{message: nil, postgres: %{code: :invalid_sql_statement_name, line: "448", message: "prepared statement "ecto_1218" does not exist", file: "prepare.c", unknown: "ERROR", severity: "ERROR", pg_code: "26000", routine: "FetchPreparedStatement"}, connection_id: 1809192939, query: nil}
    21:11:58.083 [notice] Application plausible exited: Plausible.Application.start(:normal, []) returned an error: shutdown: failed to start child: Plausible.Session.Salts

Expected behavior

The code should be enhanced to be able to change the statement behavior while using pgbouncer something like below:
config :plausible, Plausible.Repo,
statement_cache_mode: :describe

Screenshots

No response

Environment

- OS: 
- Browser:
- Browser Version:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions