-
-
Notifications
You must be signed in to change notification settings - Fork 504
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
Empty OperationalError on connect #417
Comments
How? Please provide a way to reproduce the issue. |
On a remote windows (10.10.3.17) machine I have a PostgreSQL 9.3 (32-bit) installation. It is in the same local subnet 10.10.2.0/23. In the pg_hba.conf file my client (10.10.3.19) is implicit allowed on host via following config line: In my script I use a line similar to this: On the remote machine in the actual pg_log file there is a logged authentication attempt from ip 10.10.3.19 with wrong password authentication error. I hope this information is sufficient for you to replicate this issue. |
I saw the same issue in my application's log yesterday while it tried to connect in async mode to a DB that was just starting.
I'll try to come up with a way to reproduce this. I'm using python3-psycopg2-2.6.1-1.fc23.x86_64 and postgresql95-9.5.1-1PGDG.f23.x86_64 |
Using Leaving out the password parameter results in a helpful error message of |
@dvarrazzo if synchronous is the default connection type, yes |
I couldn't reproduce the issue. Tried PG 9.3, Py 3.5 on Linux:
The fact that pgerror and pgcode are empty is normal, because the error doesn't come from the server but from the client failing the connection. From your description it seems the text of the exception is empty though: I receive a message instead. Your example is not enough to reproduce the issue to me: it is a normal installation. I can't reproduce it on windows as I don't have any available. |
Ok so there are two factors left which can cause this issue: you have used the libpq string while I used kwargs approach. The other factor is windows. Since you are not able to test it your self how can I help you with this step? I'm not much into psycopg to debug it myself. Further I don't think I can give you more information about my setup since there isn't anymore to say... |
It looks like we don't get pgcode or pgerror for any connection errors. This appears to be a shortcoming of libpq which doesn't provide details for connection failures. See http://stackoverflow.com/questions/23349086/libpq-how-to-get-the-error-code-after-a-failed-pgconn-connection |
@Nerade what is your problem: that pgerror and pgcode are empty or that there is no error message? To be safe I've also tested the keywords approach: there is no difference. |
Since I figured out the reason for the error measure I got no pressure on this. I just thought you could be interested in this issue since other may come in same situation with no helpful error message. |
Can you confirm that with your setup: try:
psycopg2.connect(password="wrong")
except Exception as e:
assert str(e) == "" in this case I'll leave the bug open for further test. If it's only a matter that pgerror and pgcode are None, that's sort of expected (not that it's perfect, but if it's what the libpq returns, we wouldn't make anything up) and the bug can be closed. |
Since I figured out the reason for the error measure I got no pressure on this. I just thought you could be interested in this issue since other may come in same situation with no helpful error message. Your code snippet passed without any message. So the str(e) is indeed empty. |
@quasilyte any chance you can copy and paste the error instead of submitting a screenshot? You are not debugging a videogame, that's text. Probably the error is the same, but I don't have a windows machine to test. It would be helpful compiling and testing psycopg in debug mode. Either some of you (or @jerickso - but it's sad he always has to do the grunt work) give a hand or I am not in the position to help anybody. |
@dvarrazzo posting a text is not a problem, but I see no reason. |
Copying? Pasting? Selecting? Googling? Seeing the entire message instead of the bit you cropped half line? Whatever. |
You are welcome (btw, this thread already indexed and "googled" quite easilly).
Note the empty string. |
@quasilyte, I have not been able to duplicate the issue that you are seeing. I believe the missing error message text is actually passed back from the server through the libpq connection, so for some reason the server is not passing the information/message back. What server version/distribution are you using? By chance have you changed the client_min_messages from NOTICE in the postgres.conf file? Or any other unusually changes to the postgres.conf file? |
I get the error message this ways:
Only encoding related options are redefined in the config file, I do not think it counts as unusual change. More information later (has no that laptop nearby at the moment). |
psycopg2 ver 2.6.2 Ok, I got it.
Everything works as expected and I get the error:
Note that on some weird systems like Windows, server could return result in cp1251 It is a pity that libpq gives no way to get SQLCODE on connection failure. Hope this helps. |
It helps a lot, thank you @quasilyte |
Hi @quasilyte Haven't found a moment yet to play with this issue but I'd like to try. I just don't understand when you say that setting |
Hello, @dvarrazzo. |
Thank you @quasilyte :) |
Thanks for this post!
and I got empty error.
Still helpful in 2019. |
I have a similar issue with psycopg2. When I try to connect with the database and there is a problem with the host, user, database or password I don't get any information from pgcode and pgerror (its value is None). I tried @quasilyte's solution, establish: |
So whats the answer to fix? My error:
|
@joehoeller there is no fix because nobody is writing a patch for it. I don't do development on Window. If someone write a patch for the issue it will be applied and released. |
i fixed it by upgarding
…On Sun, Jul 21, 2019 at 1:04 PM Daniele Varrazzo ***@***.***> wrote:
@joehoeller <https://github.com/joehoeller> there is no fix because
nobody is writing a patch for it. I don't do development on Window.
If someone write a patch for the issue it will be applied and released.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#417?email_source=notifications&email_token=ABHVQHDU6QRR5PGAIBYF3ZDQASQKXA5CNFSM4B6DZRA2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD2OISGA#issuecomment-513575192>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABHVQHF2I5QYCFJ3DODUVE3QASQKXANCNFSM4B6DZRAQ>
.
|
@joehoeller in this case you weren't affected by this bug. Or you have upgraded to a release in the future: you'll have to tell us what pip proxy you use. |
It was actually the order of how my containers were being built and
connecting to the custom docker network bridge: inside docker-compose.yml
you need to build the postgresql container first, then the pgadmin
container, then any other containers, and the proxy server for https
(NGINX) must be built last (Docker will auto connect each container to the
custom network in the automated build process).
|
Ok but where do you set those informations ? Traceback (most recent call last): This is my error message. |
@yhecohen asks:
@quasilyte answered this on Apr 5, 2017:
|
Worked for me, i also restarted the server. Thank you very much |
Hi i have same problem. `Traceback (most recent call last): The above exception was the direct cause of the following exception: Traceback (most recent call last): |
It is quite interesting for package developers to not fix this issue with recent releases. Even it makes sense that connection failures are not returned by database but by client, this logic makes pgcode and pgerror for OperationalError meaningless. It has been 4 years since a guy discovered this and package releases are done without fixing it. I am not sure that psycopg2 package is to be truly trusted in production. |
I got it working on my Docker repo here, it has nothing to do w pkg itself, but how you set it up.
https://github.com/joehoeller/Django2Pro-Container
…On Fri, Jan 17, 2020 at 12:04 PM Muhammet Ali ***@***.***> wrote:
It is quite interesting for package developers to not fix this issue with
recent releases. Even it makes sense that connection failures are not
returned by database but by client, this logic makes pgcode and pgerror for
OperationalError meaningless.
It has been 4 years since a guy discovered this and package releases are
done without fixing it. I am not sure that psycopg2 package are to be truly
trusted in production.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#417?email_source=notifications&email_token=ABHVQHBAWMZBRFXTIJIID6DQ6HXJ3A5CNFSM4B6DZRA2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEJIPZXQ#issuecomment-575732958>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABHVQHA34MIYYAYHNLRMFWLQ6HXJ3ANCNFSM4B6DZRAQ>
.
|
@muhalitas nobody in this thread has provided a consistent way to reproduce their issue. That's including you. This bug has a title which attracts any sort of error, most of which are caused by unreliable server connections. Said that I'm taking the following actions:
Over and out. |
Hello,
I have noticed it is possible to optain an empty OperationalError while connecting to a PostgreSQL database. There is no information attached to this error, both pgerror and pgcode remain empty.
While beeing unsuccessful debugging this issue on client site with this error message looking to the server side reveals a log entry for "password incorrect". As far as I can see in your code there should be an error code explicit for this situation.
Using python 3.5 and PostgreSQL 9.3.
Thanks in advnace and best regards
Nerade
The text was updated successfully, but these errors were encountered: