-
-
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
(DatabaseError) error with no message from the libpq #281
Comments
What version of psycopg and libpq are these? Are you talking with straight Postgres or to some derived database (AWS) or to some middleware? Is your network reliable? I can take a look better to what happens only if I see psycopg debug log, unfortunately a sqlalchemy is of no use. Please check the documentation to see how to compile psycopg in debug mode. |
Hi Daniele, I'll try to have some logs. |
I think psycopg is doing the right thing here in handling an unexpected status from the libpq. If you find ways to improve what is going on feel free to reopen. |
I also hit the issue. how to fix it finally. |
Same issue here. |
CherryPy server talking to PostgresSQL (9.2.7)
|
@ajoyoommen: good you can reproduce it but we need more info. Can you please compile psycopg in debug mode and post the output here? Also please report the psycopg version. Thank you very much. |
@dvarrazzo I will most probably be able to work on this next week. I will post further details then. But this error always occurs on one table (sales). I have another table on another url, but there is no error. Could it be due to some specific data values? I don't know for sure, but I'll update this thread. |
The SQL statement that raises this error fetches about 9000 sale ids. Individual queries for each id do not raise any errors. AWS AMI Psycopg: installed with pip. Version: 2.5.2
Ubuntu 14.04 I cloned the same database on my Ubuntu 14.04. I can't reproduce the error, so far. Psycopg: installed with pip. Version: (same) 2.5.2
|
Suggested by Craig Ringer in pull request psycopg#353, should also give more information for other cases we were reported on flaky servers (AWS, digital ocean...), see bug psycopg#281.
Did anyone find the fix for this problem. In my case I am having the problem while trying to connect to heroku postgres and dumping them into csv. I am using psycopg2 to dump many tables in parallel and the error is generated only for certain tables which are very big. I am working with ubuntu machine. One thing I suspect is that the libpq installed on ubuntu and libpq in heroku might be of different version ( although both of them are of version greater than 9.x.x and hence compatibility?). I am not sure how to check the version of the libpq in heroku. Best. |
Same here when I do the following actions several times repeatedly:
|
@dayusor "Same here" do you mean against Heroku, AWS, etc. or against a vanilla Postgres server? What psycopg version are you using? |
thank you guys, i have gotten to the root of the problem. So the cause was actually not the psycopg2. It was a network error between a client program and a postgres it was trying to connect to in the Heroku. Somehow instead of throwing a connection error, psycopg2 will only throw error which are built in by default. In this case the error was ".. no message from libpq". This error was misleading as it indicated there was something with the psycopg2 happening in the background. Way i debugged is >> I used the psycopg2.errorcodes ( please look into the documentation, its pretty well explained there). In my case i found that the exception throwed a NULL object which under normal try catch would throw the misleading error. Since none of the objects in the psycopg2.errorcodes matched NONE object, it defaulted to (DatabaseError) error with no message from the libpq. I have verified it by shifting the application form local server to the AWS where it works perfectly fine. I hope the finding might be useful in other scenarios as well. |
Thank you @supadhyaya. Yes, when the database gives a polite error it communicates back the error code you saw. Even when there is some connectivity error the libpq tells that in a better way (it's often an error in the underlying socket). Even killing -9 the database (don't do this at home) results in a less cryptic message. "No message from the libpq" seems being a synonym of "communication problem with AWS/Heroku". While I don't think we can do much better it would be great to report a better error message here. |
Interestingly I am facing the same issue however, my script does multiple uploads. I am sure there is a well established connection between my app and the database. Observation: |
@Mnw2212 you know that you cannot use a connection in a separate process, right? You should create instead a new connection in the working process. |
I am running into the same issue. I use smart_open with copy_expert inside and it fails with this error INFO - uploading part #1, 52428941 bytes (total 0.049GB) smart_open tries to upload a large file in multiple parts using the multi_part upload, but then after the 1st part the process fails. Any help on this will be much appreciated. Dinesh |
We are consistently running into the same issue, on red hat, in python, and it's non-deterministic, we have this problem in Mac OS, Red Hat, running on a server, in AWS, or on bare metal. Do you have any recommendations for what we can do? Libraries
Python Linux |
Don't remember exactly which package I installed but i resolved this. I had
to install some package in python which in turn installed libpq on its own
/ or other helper library. But for sure the error message is misleading as
it does not show what package is missing, rather it complains about library
used by that package. If there is something I can find, I will share that
asap.
…On Wed, Jan 2, 2019, 9:14 PM daefresh ***@***.*** wrote:
We are consistently running into the same issue, on red hat, in python,
and it's non-deterministic, we have this problem in Mac OS, Red Hat,
running on a server, in AWS, or on bare metal. Do you have any
recommendations for what we can do?
*Libraries*
- psycopg2-binary==2.7.4
- psycopg2==2.7.4
- sqlalchemy==1.2.6
*Python*
Python 3.6.5 :: Anaconda, Inc.
*Linux*
Linux 3.10.0-693.5.2.el7.x86_64 #1
<#1> SMP Fri Oct 13 10:46:25 EDT
2017 x86_64 x86_64 x86_64 GNU/Linux
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#281 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AERY_CEQOBIP28ABHdlBol_jQ89ijIyCks5u_RMigaJpZM4DUhR->
.
|
Thanks for responding so quickly! Do you know if it was to install |
I am not sure. Need to look at my logs. But in the mean time u can try
installing libpq as well. If I find what I did then will surely share with
u. But rest assured, it's fixable
…On Wed, Jan 2, 2019, 9:23 PM daefresh ***@***.*** wrote:
Thanks for responding so quickly! Do you know if it was to install libpq?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#281 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AERY_B7Nz4GD0hcpHtg3pCEPBvLCl-5kks5u_RU3gaJpZM4DUhR->
.
|
I did try to install python library |
This hasn't vanished yet. Any other ideas? |
Try either VACUUM FULL ANALYSE; or restarting the DB server. |
I see it appear inconsistently I am using flask and peewee to talk to AWS RDS Postgres. Does anyone know a fix for this? |
its hapend with multiprocess mode. When use fork() for create many process. Dettach from damaged SQLA pull (use engine.dispose()). After first request connect will be restored https://docs.sqlalchemy.org/en/13/core/connections.html#engine-disposal example (file wsgi.py) `
` |
@daefresh |
i also got this problem:
however this not the psycopg2 problem, sqlalchemy report this problem and give some solution for this issue:https://docs.sqlalchemy.org/en/14/core/pooling.html#using-connection-pools-with-multiprocessing this way works for me:
|
@helloninglei have you mentioned the problem to SQLAlchemy? |
This can also be caused by the Postgres server disconnecting the connected client, either because it hit an internal error and the server process aborted (killing the connection), or because the client hit something like the server's So it's worth checking the Postgres server logs just before this error occurred. The client might not notice immediately, only when it next tries to send a message to the server and discovers that the connection has been terminated. |
Found. This happens when uwsgi (or gunicorn) starts when multiple workers are forked from the first process. You had to specify lazy: true, lazy-apps: true (uwsgi) or preload_app = False (gunicorn) In this case, add. workers do not fork, but run themselves and open their normal connections themselves |
Hi guys, I get randomly this error:
The stack is flask with sqlalchemy and postgres.
The text was updated successfully, but these errors were encountered: