julien-duponchelle / python-mysql-replication

Pure Python Implementation of MySQL replication protocol build on top of PyMYSQL
2.31k stars 678 forks source link

__checksum_enabled : TypeError: unhashable type: 'slice' #616

Closed AdrienPensart closed 4 months ago

AdrienPensart commented 5 months ago

Version

Please specify the versions you are using. Exact version numbers are preferred.

System Variables

List relevant system variables using the query SHOW VARIABLES LIKE '<variable_name_here>';

If you are using MySQL 8.0.14 or later, please also provide the following variables:

Symptoms

2024-04-09 12:19:38,468 WARNING:
                          A pymysql.OperationalError error occurred, Re-request the connection.

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/cache_invalidator/main.py", line 113, in start_app
    syncer.sync()
  File "/root/.cache/pypoetry/virtualenvs/cache-invalidator-il7asoJj-py3.11/lib/python3.11/site-packages/tenacity/__init__.py", line 289, in wrapped_f
    return self(f, *args, **kw)
           ^^^^^^^^^^^^^^^^^^^^
  File "/root/.cache/pypoetry/virtualenvs/cache-invalidator-il7asoJj-py3.11/lib/python3.11/site-packages/tenacity/__init__.py", line 379, in __call__
    do = self.iter(retry_state=retry_state)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.cache/pypoetry/virtualenvs/cache-invalidator-il7asoJj-py3.11/lib/python3.11/site-packages/tenacity/__init__.py", line 314, in iter
    return fut.result()
           ^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/concurrent/futures/_base.py", line 449, in result
    return self.__get_result()
           ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/concurrent/futures/_base.py", line 401, in __get_result
    raise self._exception
  File "/root/.cache/pypoetry/virtualenvs/cache-invalidator-il7asoJj-py3.11/lib/python3.11/site-packages/tenacity/__init__.py", line 382, in __call__
    result = fn(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^
  File "/cache_invalidator/main.py", line 91, in sync
    for binlogevent in stream:
  File "/root/.cache/pypoetry/virtualenvs/cache-invalidator-il7asoJj-py3.11/lib/python3.11/site-packages/pymysqlreplication/binlogstream.py", line 587, in fetchone
    self.__connect_to_stream()
  File "/root/.cache/pypoetry/virtualenvs/cache-invalidator-il7asoJj-py3.11/lib/python3.11/site-packages/pymysqlreplication/binlogstream.py", line 351, in __connect_to_stream
    self.__use_checksum = self.__checksum_enabled()
                          ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.cache/pypoetry/virtualenvs/cache-invalidator-il7asoJj-py3.11/lib/python3.11/site-packages/pymysqlreplication/binlogstream.py", line 324, in __checksum_enabled
    var, value = result[:2]
                 ~~~~~~^^^^
TypeError: unhashable type: 'slice'

Steps to Reproduce

Issue appear after Connection reset by peer error 104

Planning to Resolve

sean-k1 commented 5 months ago

@AdrienPensart Sorry for late Colud you make pr for this issue?

AdrienPensart commented 5 months ago

Not sure how to fix that...maybe you have some clues ?

sean-k1 commented 4 months ago

@AdrienPensart Using mariadb or mysql? Can I get your version too?

AdrienPensart commented 4 months ago

We have mariadb 10.6.10.

sean-k1 commented 4 months ago

@AdrienPensart I'm not able to reproduce this issue. Is it possible to debug what values are in the result?

AdrienPensart commented 4 months ago

I have more debug!

On a disconnection, it seems this function is call twice :

----> disconnection stacktrace CHECKSUM_ENABLED_RESULT: ('binlog_checksum', 'CRC32') ----> here no stacktrace CHECKSUM_ENABLED_RESULT: {'Variable_name': 'binlog_checksum', 'Value': 'CRC32'} ----> here no stacktrace

It is seems related to the type of cursor we are using in our cache-invalidator code.

AdrienPensart commented 4 months ago

It is caused by our code, sorry for noise...

self.database_settings["cursorclass"] = DictCursor stream = BinLogStreamReader( connection_settings=self.database_settings,