holland-coredev team mailing list archive
-
holland-coredev team
-
Mailing list archive
-
Message #00391
[Bug 1220841] Re: MySQLdb SHOW SLAVE STATUS does not strictly return unicode
** Changed in: holland-backup
Status: Fix Committed => Fix Released
--
You received this bug notification because you are a member of Holland
Build, which is subscribed to holland-backup.
https://bugs.launchpad.net/bugs/1220841
Title:
MySQLdb SHOW SLAVE STATUS does not strictly return unicode
Status in holland-backup:
Fix Released
Bug description:
If replication has stopped on an error and the statement has invalid
utf8 characters, the Last_Error/Last_SQL_Error is effectively a
bytestring. The MySQL-python connector will abort when the connection
character set is utf-8:
# mysql --default-character-set=utf8
mysql> SELECT @@collation_connection;
+------------------------+
| @@collation_connection |
+------------------------+
| utf8_general_ci |
+------------------------+
1 row in set (0.00 sec)
mysql> show slave status\G
*************************** 1. row ***************************
...
Last_Errno: 1062
Last_Error: Error 'Duplicate entry '1' for key 'PRIMARY'' on query. Default database: ''. Query: 'INSERT INTO test.foo VALUES (1, "�1,000")'
...
Last_SQL_Errno: 1062
Last_SQL_Error: Error 'Duplicate entry '1' for key 'PRIMARY'' on query. Default database: ''. Query: 'INSERT INTO test.foo VALUES (1, "�1,000")'
...
1 row in set (0.00 sec)
>>> connection = MySQLdb.connect(read_default_group='client', charset='utf8')
>>> cursor = c.cursor()
>>> cursor.execute('SHOW SLAVE STATUS')
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "/usr/lib64/python2.4/site-packages/MySQLdb/cursors.py", line 163, in execute
self.errorhandler(self, exc, value)
File "/usr/lib64/python2.4/site-packages/MySQLdb/connections.py", line 35, in defaulterrorhandler
raise errorclass, errorvalue
UnicodeDecodeError: 'utf8' codec can't decode byte 0xa3 in position 119: unexpected code byte
In this specific case the statement is using latin2 even though the
connection char
Holland does not catch UnicodeDecodeErrors in the mysql-lvm plugin
when running SHOW SLAVE STATUS, so this results in unhelpful logs
about what went wrong during the backup.
As a fix, we can perhaps wrap SHOW SLAVE STATUS in a non-unicode
character set so we can avoid having MySQLdb attempt to decode these
invalid string values. I suspect this is an upstream bug in MySQL-
python as well - other connectors, like mysql-connector-python - raise
a proper dbapi error at least in these cases (although still fail).
To manage notifications about this bug go to:
https://bugs.launchpad.net/holland-backup/+bug/1220841/+subscriptions
References