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

pgwire: python3 py-postgresql driver error #13191

Closed
catroot opened this issue Jan 27, 2017 · 9 comments · Fixed by #60281
Closed

pgwire: python3 py-postgresql driver error #13191

catroot opened this issue Jan 27, 2017 · 9 comments · Fixed by #60281
Assignees
Labels
A-sql-pgcompat Semantic compatibility with PostgreSQL A-sql-pgwire pgwire protocol issues. C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception) meta-issue Contains a list of several other issues.

Comments

@catroot
Copy link

catroot commented Jan 27, 2017

Tried to connect using py-postgresql driver

postgresql.exceptions.ClientCannotConnectError: could not establish connection to server
  CODE: 08001
  LOCATION: CLIENT
CONNECTION: [failed]
  failures[0]:
    NOSSL socket('192.168.8.170', 26257)
    postgresql.exceptions.ProtocolError: expected message of types b'K', but received b'Z' instead
      CODE: 08P01
      LOCATION: CLIENT
CONNECTOR: [IP4] pq://[email protected]:26257
  category: None
DRIVER: postgresql.driver.pq3.Driver
@jordanlewis
Copy link
Member

Hi @catroot, thanks for your report. I've been able to reproduce your issue - we'll investigate this soon. In the meantime, psycopg2 is a good bet for a compatible Python postgres driver.

@jordanlewis
Copy link
Member

This seems to be a small bug in py-postgresql, which requires a BackendKeyData message be sent during connection initialization. I don't think that this message is strictly required by the Postgres wire protocol format, so I've opened python-postgres/fe#84 for the library author to investigate further.

@jordanlewis
Copy link
Member

This will also be fixed by #13009.

@catroot
Copy link
Author

catroot commented Jan 28, 2017

Thank you.

@vivekmenezes
Copy link
Contributor

Bilal take a look #13009 for the discussion on how cancellation can fix this issue. Assigning to you. Thanks!

@vivekmenezes vivekmenezes modified the milestones: 1.2, 1.1 Aug 30, 2017
@jordanlewis jordanlewis modified the milestones: 2.0, 2.1 Feb 22, 2018
@jordanlewis
Copy link
Member

Unfortunately, this isn't going to make it into 2.0 either. In 2.1, we should look at @asubiotto's recommended approach from #13009 - to send a random query id to just unstick problems with the protocol. Cancellation won't work against that query id, but at least drivers like this one will be able to connect.

@knz knz changed the title python3 py-postgresql driver error pgwire: python3 py-postgresql driver error Apr 27, 2018
@knz knz added C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception) A-sql-pgcompat Semantic compatibility with PostgreSQL A-sql-pgwire pgwire protocol issues. labels Apr 27, 2018
@knz knz removed the C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception) label May 3, 2018
@knz knz added C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception) meta-issue Contains a list of several other issues. labels Jul 21, 2018
@knz
Copy link
Contributor

knz commented Jul 22, 2018

cc @BramGruneir to integrate in the meta lists

@BramGruneir BramGruneir mentioned this issue Aug 6, 2018
16 tasks
@knz knz modified the milestones: 2.1, 2.2 Aug 30, 2018
@petermattis petermattis removed this from the 2.2 milestone Oct 5, 2018
@rafiss rafiss added the S-4 label May 5, 2020
@jordanlewis
Copy link
Member

Hey @rafiss, could we fix this one by issuing a BackendKeyData response with obviously wrong values like 0, 0? Or will that cause issues for clients? I feel like it could be fine - clients already receive an error when trying to cancel a query using the Postgres cancellation protocol, so if they tried to use our obviously false BackendKeyData after such a PR no behavior would really change...

@rafiss
Copy link
Collaborator

rafiss commented Dec 29, 2020

@jordanlewis Sorry I missed your message in October! I think we could use an approach like that. Looks like that's what #13009 did, but it didn't reach the finish line. I don't quite understand why not, but I am in favor of bringing it back for the 21.1 release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-sql-pgcompat Semantic compatibility with PostgreSQL A-sql-pgwire pgwire protocol issues. C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception) meta-issue Contains a list of several other issues.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants