julien-duponchelle / python-mysql-replication

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

logging statement in `BinLogStreamReader.fetchone` is using logging.WARN instead logging.log #607

Closed bentsku closed 8 months ago

bentsku commented 8 months ago

Version

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

System Variables

Not relevant for this issue.

Symptoms

When setting a read_timeout parameter to the connection_settings of the BinLogStreamReader, and the timeout is actually raised, an exception is raised even though it should be ignored and continued in the fetchone call.

    binlog_event = stream.fetchone()
                   ^^^^^^^^^^^^^^^^^
  File ".../.venv/lib/python3.11/site-packages/pymysqlreplication/binlogstream.py", line 602, in fetchone
    logging.WARN(
TypeError: 'int' object is not callable

I've manually fixed it and it properly ignored the exception and reconnected on the next call.

The fix is clear and I'll open a PR shortly, this is because we call the logging level WARN.

Steps to Reproduce

Create a BinLogStreamReader with blocking=True and a connection_settings read_timeout=1 value, to trigger an timeout from reading from the database.

Expected Outcome

The timeout is ignored and we can call fetchone again.

Actual Outcome

The timeout is not ignored and an unexpected exception is raised.

Planning to Resolve

bentsku commented 8 months ago

Fixed with #608