Skip to content

Random issue with creating pool #158

New issue

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

By clicking “No 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? No Sign in to your account

Closed
nxsofsys opened this issue Jun 18, 2017 · 16 comments
Closed

Random issue with creating pool #158

nxsofsys opened this issue Jun 18, 2017 · 16 comments

Comments

@nxsofsys
Copy link

  • asyncpg version: 0.11.0
  • PostgreSQL version: 10 Beta
  • Python version: 3.6.1 (miniconda)
  • Platform: Fedora
  • 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?
    : yes

Hi, I have random issue with creating pool - sometimes (about one of 5 attempts) password authentication fails =(

Here is code:

import asyncio
import asyncpg

async def init():
    pool = await asyncpg.create_pool(
        "postgres://postgres:postgres@localhost:5432/postgres", min_size=10, max_size=10)

loop = asyncio.get_event_loop()
loop.run_until_complete(init())

Traceback:

Traceback (most recent call last):
  File "asyncio_test.py", line 10, in <module>
    loop.run_until_complete(init())
  File "/home/user/miniconda3/envs/backend/lib/python3.6/asyncio/base_events.py", line 466, in run_until_complete
    return future.result()
  File "asyncio_test.py", line 7, in init
    "postgres://postgres:postgres@localhost:5432/postgres", min_size=40, max_size=40)
  File "/home/user/miniconda3/envs/backend/lib/python3.6/site-packages/asyncpg/pool.py", line 344, in _async__init__
    await asyncio.gather(*connect_tasks, loop=self._loop)
  File "/home/user/miniconda3/envs/backend/lib/python3.6/site-packages/asyncpg/pool.py", line 133, in connect
    connection_class=self._pool._connection_class)
  File "/home/user/miniconda3/envs/backend/lib/python3.6/site-packages/asyncpg/connect_utils.py", line 274, in _connect_addr
    await asyncio.wait_for(connected, loop=loop, timeout=timeout)
  File "/home/user/miniconda3/envs/backend/lib/python3.6/asyncio/tasks.py", line 352, in wait_for
    return fut.result()
asyncpg.exceptions.InvalidPasswordError: password authentication failed for user "postgres"

Postgres log:

[12683] [5946c2a0.318b] [2017-06-18 21:12:48.687 MSK] [0]: FATAL:  password authentication failed for user "postgres"
[12683] [5946c2a0.318b] [2017-06-18 21:12:48.687 MSK] [0]: DETAIL:  Password does not match for user "postgres".
	Connection matched pg_hba.conf line 92: "host	all		all		::/0			md5"

Of course, it may be issue of Postgresql 10 beta.
Thanks.

@lelit
Copy link
Contributor

lelit commented Jun 29, 2017

Yes, I'm hitting the same problem, trying out PG 10beta1. Maybe unrelated, but PG emits the following immediately before the error:

2017-06-29 11:24:56.001 UTC [168] LOG:  incomplete startup packet
2017-06-29 11:24:56.023 UTC [174] LOG:  incomplete startup packet
2017-06-29 11:24:56.042 UTC [180] LOG:  incomplete startup packet
2017-06-29 11:24:56.047 UTC [182] FATAL:  password authentication failed for user "user"
2017-06-29 11:24:56.047 UTC [182] DETAIL:  Password does not match for user "user".

@1st1
Copy link
Member

1st1 commented Jun 30, 2017

Can you guys reproduce this with stable Postgres?

@lelit
Copy link
Contributor

lelit commented Jun 30, 2017

I tried, but was unable to unfortunately. In the DB tests suite of my application, all is good with 9.6.3, while with PG10b1 it never finishes correctly, at least one out of the more of 70 tests fails, never at the same point.

@lelit
Copy link
Contributor

lelit commented Jul 3, 2017

Of course I'm willing to try harder, if you have some hint on how to dig further.

@dpnova
Copy link

dpnova commented Jul 6, 2017

FWIW I've noticed this error lately too in a config that was working fine. I see this post is about 5 days old and the last update on the postgres dockerhub is 6 days ago.

Please see the issue referring to this one for my fix.. not sure if it's relevant here.

@lelit
Copy link
Contributor

lelit commented Jul 17, 2017

FYI, the same happens against the PG10b2 hub.docker.com official image.

@lelit
Copy link
Contributor

lelit commented Jul 24, 2017

I spent a few more hours trying to distill a recipe to reproduce the problem, and this is the result. I hope it at least helps in determining if the problem is with the PG beta image or not.

@1st1
Copy link
Member

1st1 commented Jul 24, 2017

Thank you very much, @lelit! We'll take a look at this in detail soon.

@elprans
Copy link
Member

elprans commented Jul 24, 2017

@lelit This seems to be an issue with the docker image. I could not reproduce on a locally built version of PostgreSQL 10 beta 2.

@lelit
Copy link
Contributor

lelit commented Jul 24, 2017

Ok, thank you both!

@lelit
Copy link
Contributor

lelit commented Jul 25, 2017

FYI, I posted the recipe (augmented with an alternative the uses plain docker) also on the docker-library/postgres #308.

@lelit
Copy link
Contributor

lelit commented Aug 19, 2017

Uhm, the problem is still there in PG10b3.

@dpnova
Copy link

dpnova commented Aug 30, 2017

FYI I'm convinced this is an issue with the image and not clients. I was using nodejs at work when I reported the issue, but now using asyncpg in my own personal thing and the image is ok if password isn't set.

elprans added a commit that referenced this issue Sep 8, 2017
Not doing so makes Cython wrap the result with
__Pyx_PyObject_AsWritableString, which causes data loss if there is a
NULL-byte in the middle of the returned char* buffer.

While at it, constify the pointers returned by ReadBuffer methods, as
the returned data is not supposed to be modified.

Fixes: #158.
@lelit
Copy link
Contributor

lelit commented Sep 11, 2017

Yay, I confirm that my recipe works now, thank you!

@lelit
Copy link
Contributor

lelit commented Oct 6, 2017

The final version of PG 10 is out, yay! 🎆 🍻

I wonder if you have an ETA for a new release of asyncpg?

@elprans
Copy link
Member

elprans commented Oct 6, 2017

We need to deal with a couple of open PRs and will cut the release shortly thereafter.

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

No branches or pull requests

5 participants