Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pgoutput logical decoding plugin fails with "client sent proto_version=0 but server only supports protocol 1 or higher" #1690

Open
hgdeoro opened this issue Apr 3, 2024 · 3 comments

Comments

@hgdeoro
Copy link

hgdeoro commented Apr 3, 2024

Please complete the following information:

  • OS: Linux
  • Psycopg version: psycopg2-binary==2.9.9
  • Python version: Python 3.11.6
  • PostgreSQL version: postgres:16.2-alpine (docker) PostgreSQL 16.2 on x86_64-pc-linux-musl, compiled by gcc (Alpine 13.2.1_git20231014) 13.2.1 20231014, 64-bit
  • PostgreSQL version: postgres:16.2 (docker) PostgreSQL 16.2 (Debian 16.2-1.pgdg120+2) on x86_64-pc-linux-gnu, compiled by gcc (Debian 12.2.0-14) 12.2.0, 64-bit
  • pip version: pip 23.2

Describe the bug
Please let us know:

1: what you did

I can successfully create_replication_slot() and start_replication() when using the test_decoding output plugin:

    with conn.cursor() as cur:
        cur.create_replication_slot("pytest_logical", output_plugin="test_decoding")
        cur.start_replication(slot_name="pytest_logical", decode=False)

When trying to use the pgoutput plugin, create_replication_slot() succeeds, but start_replication() fails:

    with conn.cursor() as cur:
        cur.create_replication_slot("pytest_logical", output_plugin="pgoutput")
        cur.start_replication(slot_name="pytest_logical", decode=False)

2: what you expected to happen

I expect to be able to use the pgoutput plugin, at least to be able to consume but start_replication() fails.

The plugin is installed in both docker images that I tried postgres:16.2-alpine and postgres:16.2. I got the error in both flavors of PostgreSql 16.2

3: what happened instead

The error in Python is:

>       self.start_replication_expert(
            command, decode=decode, status_interval=status_interval)
E       psycopg2.errors.FeatureNotSupported: client sent proto_version=0 but server only supports protocol 1 or higher
E       CONTEXT:  slot "pytest_logical", output plugin "pgoutput", in the startup callback

venv/lib/python3.11/site-packages/psycopg2/extras.py:616: FeatureNotSupported

and I can see this logs in PostgreSql:

db-1  | 2024-04-03 22:37:21.746 UTC [57] LOG:  logical decoding found consistent point at 0/1BED5D8
db-1  | 2024-04-03 22:37:21.746 UTC [57] DETAIL:  There are no running transactions.
db-1  | 2024-04-03 22:37:21.746 UTC [57] STATEMENT:  CREATE_REPLICATION_SLOT "pytest_logical" LOGICAL "pgoutput"
db-1  | 2024-04-03 22:37:21.746 UTC [57] LOG:  exported logical decoding snapshot: "00000003-00000028-1" with 0 transaction IDs
db-1  | 2024-04-03 22:37:21.746 UTC [57] STATEMENT:  CREATE_REPLICATION_SLOT "pytest_logical" LOGICAL "pgoutput"
db-1  | 2024-04-03 22:37:21.747 UTC [57] ERROR:  client sent proto_version=0 but server only supports protocol 1 or higher
db-1  | 2024-04-03 22:37:21.747 UTC [57] CONTEXT:  slot "pytest_logical", output plugin "pgoutput", in the startup callback
db-1  | 2024-04-03 22:37:21.747 UTC [57] STATEMENT:  START_REPLICATION SLOT "pytest_logical" LOGICAL 0/00000000

Since I'm using docker compose and some automated tests, I also tried PostgreSQL 14.11 (Debian 14.11-1.pgdg120+2) on x86_64-pc-linux-gnu, compiled by gcc (Debian 12.2.0-14) 12.2.0, 64-bit with same results.

If possible, provide a script reproducing the issue.

@hgdeoro
Copy link
Author

hgdeoro commented Apr 4, 2024

For the record, using output_plugin="wal2json" works (I haven't consume any message, but start_replication() works)

    with conn.cursor() as cur:
        cur.create_replication_slot("pytest_logical", output_plugin="wal2json")
        cur.start_replication(slot_name="pytest_logical", decode=False)

@dvarrazzo
Copy link
Member

Sorry for the silence. Unfortunately I am not very familiar with the replication support and I don't have the bandwidth to work on this issue.

@hgdeoro
Copy link
Author

hgdeoro commented Apr 9, 2024

I'm new to replication too. Also, since wal2json worked, I don't know if this issue is caused by psycopg2. I'll try to run psycopg2 tests in these days and see if I discover something.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants