Skip to content

incorrect PostgreSQL version, failed to connect to PG10/Debian #250

Closed

Description

@ldgeo
  • asyncpg version: 0.14.0
  • PostgreSQL version: 10.1
  • Python version: 3.6.4
  • Platform: Linux Debian sid
  • Do you use pgbouncer?: no
  • Did you install asyncpg with pip?: yes
  • If you built asyncpg locally, which version of Cython did you use?:
  • Can the issue be reproduced under both asyncio and
    uvloop?
    : not related to event loop

I experience an issue when trying to connect to my local postgresql cluster. The error is :

  File "/home/ludo/.virtualenvs/pyvt/lib/python3.6/site-packages/asyncpg/serverversion.py", line 49, in <listcomp>
    versions = [int(p) for p in parts][:3]
ValueError: invalid literal for int() with base 10: '1 (Debian 10'

PostgreSQL version given by the server itself :

[ludo@postgres] # select version();
                                                 version                                                 
---------------------------------------------------------------------------------------------------------
 PostgreSQL 10.1 (Debian 10.1-3) on x86_64-pc-linux-gnu, compiled by gcc (Debian 7.2.0-19) 7.2.0, 64-bit
(1 ligne)

PostgreSQL was installed from the main debian repositories :

apt-cache policy postgresql-10
postgresql-10:
  Installé : 10.1-3
  Candidat : 10.1-3
 Table de version :
 *** 10.1-3 500
        500 http://httpredir.debian.org/debian sid/main amd64 Packages
        100 /var/lib/dpkg/status

I looked into the code but failed to find where the version is fetched from PG.
The version_string received in the split_server_version_string function is equal to "10.1 (Debian 10.1-3)" but it should be only "10.1" according to the rest of the function.

Any ideas to fix it ?

Activity

  1. added a commit that references this issue on Jan 31, 2018
    7ab3724
  2. elprans commented on Jan 31, 2018

    @elprans
    Member

    Sigh, arguably it's a Debian bug. There's no good reason why they should adulterate the PG_VERSION risking breakage like this. #251 has a workaround.

  3. ldgeo commented on Jan 31, 2018

    @ldgeo
    Author

    thanks for the quick fix.
    For my understanding how do you retrieve the PG version ?

  4. elprans commented on Jan 31, 2018

    @elprans
    Member

    The version is reported by the server when the connection is established via a ParameterStatus protocol message.

  5. added a commit that references this issue on Jan 31, 2018
    05dce25
  6. jodal commented on Feb 14, 2018

    @jodal

    It seems like this problem is now present in new/upgrades PostgreSQL databases on Heroku, so anyone running asyncpg on Heroku with a recent PostgreSQL version now needs to run asyncpg from master. It would be lovely to have a new release cut which includes this workaround.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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