-
Notifications
You must be signed in to change notification settings - Fork 178
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
FATAL: 'utf-8' codec can't decode byte 0xe7 in position 128: invalid continuation byte #149
Comments
Hi, Are you using third party extensions on postgres ? Benoit |
Hello, Only pg_stat_statements, but I've been using it since version 9 of postgres, could this problem be related to some incompatibility of pg_activity with postgres 12.3 or CentOS 8? |
Hi sorry for the long delay,
I'll try to reproduce this on my side. Benoit. |
I could reproduce on a debian system with postgres 11 (from debian) by executing the following SQL while pg_activity is running:
By keeping the last transaction uncommitted, the |
Actually, the problem shows up by using psycopg2 directly: >>> conn = psycopg2.connect(database="postgres")
>>> conn.encoding
'UTF8'
>>> cur = conn.cursor()
>>> cur.execute("select query from pg_stat_activity")
>>> cur.fetchall()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe9 in position 26: invalid continuation byte so perhaps it's not really related to @PatrickSiqueira, at the moment, you might try to use |
And incidentally,
|
psql is not smarter: it's dumber, so it works :) it just emits a stream of bytes to the console, and the console has a replace policy. You can do the same by asking psycopg2 to return bytes instead of unicode strings: see https://www.psycopg.org/docs/faq.html#faq-bytes. |
@dvarrazzo, thanks for the tip and explanation. |
Another option would be to cast the The result is the same, you get in control of the decoding, but this way you can choose column-by-column what to retrieve in as unicode and what as bytes, and you can register the typecaster globally. |
We can also get the encoding of the field from pg_database.
The join filters all the non client backends. But right now, we don't care and it would be easy enough to fix. |
When the encoding of a database is not UTF8. Queries with special caracters might crash pg_activity with the message : UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe9 in position 26: ++ invalid continuation byte This patch fixes the issue by querying pg_database.encoding and using it to encode the string.
When the encoding of a database is not UTF8. Queries with special caracters might crash pg_activity with the message : UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe9 in position 26: ++ invalid continuation byte This patch fixes the issue by querying pg_database.encoding and using it to encode the string.
When the encoding of a database is not UTF8. Queries with special caracters might crash pg_activity with the message : UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe9 in position 26: ++ invalid continuation byte This patch fixes the issue by querying pg_database.encoding and using it to encode the string.
This commit adds : * the ability to create a connexion to a different backend with the asynchronous "execute" function * a test case for the issue dalibo#149
This commit adds : * the ability to create a connexion to a different backend with the asynchronous "execute" function * a test case for the issue dalibo#149
When the encoding of a database is not UTF8. Queries with special caracters might crash pg_activity with the message : UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe9 in position 26: ++ invalid continuation byte This patch fixes the issue by querying pg_database.encoding and using it to encode the string.
This commit adds : * the ability to create a connexion to a different backend with the asynchronous "execute" function * a test case for the issue dalibo#149
When the encoding of a database is not UTF8. Queries with special caracters might crash pg_activity with the message : UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe9 in position 26: ++ invalid continuation byte This patch fixes the issue by querying pg_database.encoding and using it to encode the string.
This commit adds : * the ability to create a connexion to a different backend with the asynchronous "execute" function * a test case for the issue dalibo#149
When the encoding of a database is not UTF8. Queries with special caracters might crash pg_activity with the message : UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe9 in position 26: ++ invalid continuation byte This patch fixes the issue by querying pg_database.encoding and using it to encode the string.
This commit adds : * the ability to create a connexion to a different backend with the asynchronous "execute" function * a test case for the issue #149
It took a long while. but it's fixed.. |
Hello people!
I am currently using pg_activity-1.6.1 with PostgreSQL 12.3, after a certain run time, I get the following error:
Traceback (most recent call last):
File "./pg_activity", line 332, in main
procs, disp_procs)
File "/var/lib/pgsql/install/pg_activity-1.6.1/pgactivity/UI.py", line 1191, in poll
disp_proc)
File "/var/lib/pgsql/install/pg_activity-1.6.1/pgactivity/UI.py", line 1337, in __poll_activities
queries = self.data.pg_get_activities(self.duration_mode)
File "/var/lib/pgsql/install/pg_activity-1.6.1/pgactivity/Data.py", line 510, in pg_get_activities
ret = cur.fetchall()
File "/usr/lib64/python3.6/site-packages/psycopg2/extras.py", line 100, in fetchall
res = super(DictCursorBase, self).fetchall()
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe7 in position 128: invalid continuation byte
FATAL: 'utf-8' codec can't decode byte 0xe7 in position 128: invalid continuation byte
Previously with version 9 of PostgreSQL, I did not receive these errors, after the migration to version 12 is that I am having this. can you help me?
The text was updated successfully, but these errors were encountered: