fairy-select/chronovoyage

"RecursionError: maximum recursion depth exceeded" occurs when the DB client fails to connect to a server

Closed this issue · 0 comments

Description

The function "logger.exception" causes RecursionError when the DB client fails to connect to a server

Condition and operation ("given" and "when" in test structure)

Steps to reproduce the behavior:

  1. Initialize a directory
  2. Configure a wrong connection info
  3. Migrate

Expected behavior ("then" in test structure)

Simply output a message such as "Can't connect to a server on 'xxx'."

Actual behavior

RecursionError occurs.

(.venv) root@f10ae469b0ec:~/sample# chronovoyage migrate
Traceback (most recent call last):
  File "/root/.venv/lib/python3.12/site-packages/chronovoyage/internal/database/mariadb_.py", line 21, in connect
    conn = mariadb.connect(
           ^^^^^^^^^^^^^^^^
  File "/root/.venv/lib/python3.12/site-packages/mariadb/__init__.py", line 146, in connect
    connection = connectionclass(*args, **kwargs)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.venv/lib/python3.12/site-packages/mariadb/connections.py", line 85, in __init__
    super().__init__(*args, **kwargs)
mariadb.OperationalError: Can't connect to server on 'host.docker.internal' (101)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/root/.venv/bin/chronovoyage", line 8, in <module>
    sys.exit(chronovoyage())
             ^^^^^^^^^^^^^^
  File "/root/.venv/lib/python3.12/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.venv/lib/python3.12/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/root/.venv/lib/python3.12/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.venv/lib/python3.12/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.venv/lib/python3.12/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.venv/lib/python3.12/site-packages/chronovoyage/cli/__init__.py", line 73, in migrate
    MigrateDomain(MigrateConfigFactory.create_from_directory(os.getcwd()), logger=get_default_logger()).execute(
  File "/root/.venv/lib/python3.12/site-packages/chronovoyage/domain/migrate.py", line 24, in execute
    self.usecase.migrate(target=target)
  File "/root/.venv/lib/python3.12/site-packages/chronovoyage/usecase/migrate.py", line 20, in migrate
    with DatabaseConnector(logger=self._logger).get_connection(
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.venv/lib/python3.12/site-packages/chronovoyage/internal/database/connection.py", line 23, in get_connection
    return mariadb_.connect(connection_info, logger=self._logger)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.venv/lib/python3.12/site-packages/chronovoyage/internal/database/mariadb_.py", line 29, in connect
    logger.exception("Error connecting to MariaDB Platform")
    ^^^^^^^^^^^^^^^^
  File "/root/.venv/lib/python3.12/site-packages/chronovoyage/internal/logger/logger.py", line 25, in __getattr__
    return getattr(self, item)
           ^^^^^^^^^^^^^^^^^^^
  File "/root/.venv/lib/python3.12/site-packages/chronovoyage/internal/logger/logger.py", line 25, in __getattr__
    return getattr(self, item)
           ^^^^^^^^^^^^^^^^^^^
  File "/root/.venv/lib/python3.12/site-packages/chronovoyage/internal/logger/logger.py", line 25, in __getattr__
    return getattr(self, item)
           ^^^^^^^^^^^^^^^^^^^
  [Previous line repeated 986 more times]
RecursionError: maximum recursion depth exceeded