Skip to content

maridab client libs also report utf8mb3 in some way , need to handle it #7136

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

Closed
zzzeek opened this issue Oct 2, 2021 · 3 comments
Closed
Labels
Milestone

Comments

@zzzeek
Copy link
Member

zzzeek commented Oct 2, 2021

continuing from #7115 it seems likely that the new Mariadb 10.6 client is also returniung "utf8mb3" for client encoding , which will break for SQLAlchemy prior to the #7115 commit because we try to use that encoding at the Python level. we see this via failure on CI:

[jenkins@41dceb4d72b3 bce7ae67]$ .tox/py39-cext-mysql/bin/python -m pytest \
\         --dburi 'mysql+mysqldb://scott:tiger@mariadb105/test?charset=utf8mb4' \
s         test/dialect/mysql/test_dialect.py::DialectTest::test_special_encodings
============================= test session starts ==============================
platform linux -- Python 3.9.7, pytest-6.2.5, py-1.10.0, pluggy-1.0.0 -- /home/jenkins/workspace/sqlalchemy_gerrit/bce7ae67/.tox/py39-cext-mysql/bin/python
cachedir: .pytest_cache
rootdir: /home/jenkins/workspace/sqlalchemy_gerrit/bce7ae67, configfile: setup.cfg
plugins: forked-1.3.0, xdist-2.4.0
collected 1 item                                                               

test/dialect/mysql/test_dialect.py::DialectTest::test_special_encodings FAILED [100%]

=================================== FAILURES ===================================
______________________ DialectTest.test_special_encodings ______________________
Traceback (most recent call last):
  File "/home/jenkins/workspace/sqlalchemy_gerrit/bce7ae67/test/dialect/mysql/test_dialect.py", line 260, in test_special_encodings
    eq_(conn.dialect._connection_charset, enc)
  File "/home/jenkins/workspace/sqlalchemy_gerrit/bce7ae67/test/../lib/sqlalchemy/testing/assertions.py", line 244, in eq_
    assert a == b, msg or "%r != %r" % (a, b)
AssertionError: 'utf8mb3' != 'utf8'
assert 'utf8mb3' == 'utf8'
  - utf8
  + utf8mb3
=========================== short test summary info ============================
FAILED test/dialect/mysql/test_dialect.py::DialectTest::test_special_encodings
============================== 1 failed in 0.09s ===============================

on CI, mariadb client is installed from maridb's RPMs:

# rpm -qa | grep -i mariadb
MariaDB-client-10.6.4-1.el8.x86_64
MariaDB-shared-10.6.4-1.el8.x86_64
MariaDB-devel-10.6.4-1.el8.x86_64
MariaDB-common-10.6.4-1.el8.x86_64

code that breaks with "utf8mb3" is at

_encoding_compat = {
as this lookup will fail. also need to update that test.

@zzzeek zzzeek added bug Something isn't working documentation tests mariadb labels Oct 2, 2021
@zzzeek zzzeek added this to the 1.4.x milestone Oct 2, 2021
@zzzeek
Copy link
Member Author

zzzeek commented Oct 2, 2021

on 1.4.25 on CI, stack trace:

test/dialect/mysql/test_dialect.py::DialectTest::test_special_encodings FAILED [100%]

=================================== FAILURES ===================================
______________________ DialectTest.test_special_encodings ______________________
Traceback (most recent call last):
  File "/home/jenkins/workspace/sqlalchemy_gerrit/bce7ae67/test/dialect/mysql/test_dialect.py", line 259, in test_special_encodings
    conn = eng.connect()
  File "/home/jenkins/workspace/sqlalchemy_gerrit/bce7ae67/test/../lib/sqlalchemy/engine/base.py", line 3194, in connect
    return self._connection_cls(self, close_with_result=close_with_result)
  File "/home/jenkins/workspace/sqlalchemy_gerrit/bce7ae67/test/../lib/sqlalchemy/engine/base.py", line 96, in __init__
    else engine.raw_connection()
  File "/home/jenkins/workspace/sqlalchemy_gerrit/bce7ae67/test/../lib/sqlalchemy/engine/base.py", line 3273, in raw_connection
    return self._wrap_pool_connect(self.pool.connect, _connection)
  File "/home/jenkins/workspace/sqlalchemy_gerrit/bce7ae67/test/../lib/sqlalchemy/engine/base.py", line 3240, in _wrap_pool_connect
    return fn()
  File "/home/jenkins/workspace/sqlalchemy_gerrit/bce7ae67/test/../lib/sqlalchemy/pool/base.py", line 310, in connect
    return _ConnectionFairy._checkout(self)
  File "/home/jenkins/workspace/sqlalchemy_gerrit/bce7ae67/test/../lib/sqlalchemy/pool/base.py", line 868, in _checkout
    fairy = _ConnectionRecord.checkout(pool)
  File "/home/jenkins/workspace/sqlalchemy_gerrit/bce7ae67/test/../lib/sqlalchemy/pool/base.py", line 476, in checkout
    rec = pool._do_get()
  File "/home/jenkins/workspace/sqlalchemy_gerrit/bce7ae67/test/../lib/sqlalchemy/pool/impl.py", line 146, in _do_get
    self._dec_overflow()
  File "/home/jenkins/workspace/sqlalchemy_gerrit/bce7ae67/test/../lib/sqlalchemy/util/langhelpers.py", line 70, in __exit__
    compat.raise_(
  File "/home/jenkins/workspace/sqlalchemy_gerrit/bce7ae67/test/../lib/sqlalchemy/util/compat.py", line 207, in raise_
    raise exception
  File "/home/jenkins/workspace/sqlalchemy_gerrit/bce7ae67/test/../lib/sqlalchemy/pool/impl.py", line 143, in _do_get
    return self._create_connection()
  File "/home/jenkins/workspace/sqlalchemy_gerrit/bce7ae67/test/../lib/sqlalchemy/pool/base.py", line 256, in _create_connection
    return _ConnectionRecord(self)
  File "/home/jenkins/workspace/sqlalchemy_gerrit/bce7ae67/test/../lib/sqlalchemy/pool/base.py", line 371, in __init__
    self.__connect()
  File "/home/jenkins/workspace/sqlalchemy_gerrit/bce7ae67/test/../lib/sqlalchemy/pool/base.py", line 677, in __connect
    pool.dispatch.connect.for_modify(
  File "/home/jenkins/workspace/sqlalchemy_gerrit/bce7ae67/test/../lib/sqlalchemy/event/attr.py", line 329, in _exec_w_sync_on_first_run
    self(*args, **kw)
  File "/home/jenkins/workspace/sqlalchemy_gerrit/bce7ae67/test/../lib/sqlalchemy/event/attr.py", line 343, in __call__
    fn(*args, **kw)
  File "/home/jenkins/workspace/sqlalchemy_gerrit/bce7ae67/test/../lib/sqlalchemy/util/langhelpers.py", line 1691, in go
    return once_fn(*arg, **kw)
  File "/home/jenkins/workspace/sqlalchemy_gerrit/bce7ae67/test/../lib/sqlalchemy/engine/create.py", line 686, in first_connect
    dialect.initialize(c)
  File "/home/jenkins/workspace/sqlalchemy_gerrit/bce7ae67/test/../lib/sqlalchemy/dialects/mysql/base.py", line 2954, in initialize
    self._detect_sql_mode(connection)
  File "/home/jenkins/workspace/sqlalchemy_gerrit/bce7ae67/test/../lib/sqlalchemy/dialects/mysql/base.py", line 3411, in _detect_sql_mode
    self._sql_mode = row[1] or ""
  File "/home/jenkins/workspace/sqlalchemy_gerrit/bce7ae67/test/../lib/sqlalchemy/dialects/mysql/base.py", line 3519, in __getitem__
    return item.decode(self.charset)
LookupError: unknown encoding: utf8mb3
=========================== short test summary info ============================
FAILED test/dialect/mysql/test_dialect.py::DialectTest::test_special_encodings
============================== 1 failed in 0.09s ===============================

we should likely backport to 1.3 unfortunately

@sqla-tester
Copy link
Collaborator

Mike Bayer has proposed a fix for this issue in the master branch:

support utf8mb3 char encoding fully for mysqlclient, others https://gerrit.sqlalchemy.org/c/sqlalchemy/sqlalchemy/+/3125

@sqla-tester
Copy link
Collaborator

Mike Bayer has proposed a fix for this issue in the rel_1_3 branch:

support utf8mb3 char encoding fully for mysqlclient, others https://gerrit.sqlalchemy.org/c/sqlalchemy/sqlalchemy/+/3126

sqlalchemy-bot pushed a commit that referenced this issue Oct 2, 2021
Fixes to accommodate for the MariaDB 10.6 series, including backwards
incompatible changes in both the mariadb-connector Python driver as well
as the native 10.6 client libraries that are used automatically by the
mysqlclient DBAPI.  The "utf8mb3" encoding symbol is now reported by
these client libraries when the encoding is stated as "utf8", leading to
lookup and encoding errors within the MySQL dialect that does not expect
this symbol.   Updates to both the MySQL base library to accommodate for
this utf8mb3 symbol being reported as well as to the test suite.
Thanks to Georg Richter for support.

Fixes: #7136
Fixes: #7115
Change-Id: I655d9d9868aef76037023d0c602b8a7c881780b0
(cherry picked from commit f43e65f9b557b2d110141137a0216c661ba038b4)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants