julien-duponchelle/python-mysql-replication

__checksum_enabled : TypeError: unhashable type: 'slice'

AdrienPensart opened this issue · 7 comments

Version

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

  • MariaDB:

System Variables

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

  • log_bin: absent
  • binlog_format: ROW
  • binlog_row_image: FULL
  • enforce_gtid_consistency: absent
  • gtid_mode: absent

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

  • binlog_row_metadata: FULL
  • binlog_row_value_options: absent

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

  • I plan to create a pull request to resolve this issue.
  • I don't plan to resolve this myself and would like someone else to address it.

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

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

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

We have mariadb 10.6.10.

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

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.

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

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