-
-
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
SystemError: <built-in function utf_8_decode> returned a result with an error set #551
Comments
Hello @alanhamlett I've seen this error while developing the codecs cache speedup in psycopg 2.7. It was related to accessing utf8 decoding functions without holding the GIL. Apparently it is happening in some untested code path. Please compile psycopg in debug mode and provide a log of what happened; alternatively please provide a self-contained test to reproduce the issue. Thank you. |
Hello, we just saw this in our Django application. We are now at Python 3.6.0, Django 1.10.7 and psycopg2 2.7.1. It occurred when a request took too long, so Gunicorn killed the worker. Here's our stack trace (with our code removed):
Hope this can help. Thanks! |
Hey @ljodal thank you for reporting, but I need a self-contained test to debug the issue, or if you can run psycopg in debug mode and provide its info I may try and understand what's going on. Thank you very much! |
We have also been seeing this issue for multiple months, but it is very irregular. We see quite a bit of traffic and this happens once every week. It always happens like Ijodal's example inside a |
I'm seeing this daily in our celery workers. Some tasks pulling from external API's hit their soft timeout, and 20% of the time we get this error rather than a SoftTimeLimitExceeded exception. |
@adamcharnock could you please compile psycopg in debug mode and provide some context of when the problem occurs? I would like to make a release to fix this problem. Thank you very much. |
Hi @dvarrazzo, thanks for the quick reply. I actually meant to mention that in my reply but clearly got distracted. Unfortunately, deploying a custom compiled psycopg into production/staging is something I cannot realistically do at the moment for a variety of reasons, and I don't think I can recreate the problem locally. I really appreciate how willing you are to take a look, and I'm sorry if this is all rather frustrating. |
@adamcharnock It's ok, keep me informed if you manage to reproduce the bug using a debug build. |
If any of you manage to create a debug trace of this error happening I'll fix it for 2.7.2. Otherwise it will have to wait. |
I'm pretty sure I'm seeing the same problem. Here's a minimal test case that I came up with. The problem occurs when a signal handler raises sys.exit() while processing an INSERT query. Raising sys.exit() from a signal handler is how gunicorn handles worker timeouts. Run this code and then from another process send it a SIGABRT.
(I'm running on Ubuntu with Python 3.5, psycopg2 2.7.1) And here's some debug output from a debug build, snipped to only show the last couple queries before crash:
One thing I noticed is that if you don't use the |
@brownan Thank you so much for this analysis! I'll see what we can do. Probably the signal handler makes an hole into our lock management... |
We have now also seen a |
There. I think it was a mundane case of return value not checked, in one of the most ancient parts of the codebase. Testing from you affected by the issue is welcome. The fix is now in master and will be released in psycopg 2.7.2. |
Thanks @dvarrazzo. For anyone else coming upon this issue, the underlying problem for me was actually that Gunicorn has a default request timeout of 30 seconds (that I had forgotten about), so it was killing the workers after 30 seconds. For a long-running task that does a lot of inserts, it was likely to error within psycopg2's cursor.execute(). The exception that was being raised was misleading, and that's what this bug fixed. After installing this fix, I no longer see those tracebacks, but sending a signal will still stop the process (as expected), but now it's much more graceful. |
Getting this error when a
billiard.exceptions.SoftTimeLimitExceeded
exception occurs interrupting a query:Using Python 3.5.2, SQLAlchemy 1.1.9 and psycopg2 2.7.1.
The text was updated successfully, but these errors were encountered: