Skip to content
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

Issue connecting to partner database when the database is in mirrored state. #167

Open
arpitvarma111 opened this issue Aug 23, 2024 · 1 comment

Comments

@arpitvarma111
Copy link

The library with version (1.15.0) fails to connect to the partner database when the principal db fails (MS SQL Server). We get the following stack trace exception:

Traceback (most recent call last):
  File "/opt/python/sqlalchemy/engine/base.py", line 145, in __init__
    self._dbapi_connection = engine.raw_connection()
  File "/opt/python/sqlalchemy/engine/base.py", line 3288, in raw_connection
    return self.pool.connect()
  File "/opt/python/sqlalchemy/pool/base.py", line 452, in connect
    return _ConnectionFairy._checkout(self)
  File "/opt/python/sqlalchemy/pool/base.py", line 1267, in _checkout
    fairy = _ConnectionRecord.checkout(pool)
  File "/opt/python/sqlalchemy/pool/base.py", line 716, in checkout
    rec = pool._do_get()
  File "/opt/python/sqlalchemy/pool/impl.py", line 170, in _do_get
    self._dec_overflow()
  File "/opt/python/sqlalchemy/util/langhelpers.py", line 147, in __exit__
    raise exc_value.with_traceback(exc_tb)
  File "/opt/python/sqlalchemy/pool/impl.py", line 167, in _do_get
    return self._create_connection()
  File "/opt/python/sqlalchemy/pool/base.py", line 393, in _create_connection
    return _ConnectionRecord(self)
  File "/opt/python/sqlalchemy/pool/base.py", line 678, in __init__
    self.__connect()
  File "/opt/python/sqlalchemy/pool/base.py", line 903, in __connect
    pool.logger.debug("Error on connect(): %s", e)
  File "/opt/python/sqlalchemy/util/langhelpers.py", line 147, in __exit__
    raise exc_value.with_traceback(exc_tb)
  File "/opt/python/sqlalchemy/pool/base.py", line 898, in __connect
    self.dbapi_connection = connection = pool._invoke_creator(self)
  File "/opt/python/sqlalchemy/engine/create.py", line 637, in connect
    return dialect.connect(*cargs, **cparams)
  File "/opt/python/sqlalchemy/engine/default.py", line 615, in connect
    return self.loaded_dbapi.connect(*cargs, **cparams)
  File "/opt/python/pytds/__init__.py", line 398, in connect
    return utils.exponential_backoff(
  File "/opt/python/pytds/utils.py", line 51, in exponential_backoff
    ex_handler(ex)
  File "/opt/python/pytds/__init__.py", line 394, in ex_handler
    raise ex
  File "/opt/python/pytds/utils.py", line 41, in exponential_backoff
    return work(try_time)
  File "/opt/python/pytds/__init__.py", line 357, in attempt
    return _connect(
  File "/opt/python/pytds/__init__.py", line 453, in _connect
    route = tds_socket.login()
  File "/opt/python/pytds/tds_socket.py", line 95, in login
    if not self._main_session.process_login_tokens():
  File "/opt/python/pytds/tds_session.py", line 1571, in process_login_tokens
    self.process_token(marker)
  File "/opt/python/pytds/tds_session.py", line 1586, in process_token
    return handler(self)
  File "/opt/python/pytds/tds_session.py", line 1745, in <lambda>
    tds_base.TDS_DONE_TOKEN: lambda self: self.process_end(tds_base.TDS_DONE_TOKEN),
  File "/opt/python/pytds/tds_session.py", line 430, in process_end
    self.raise_db_exception()
  File "/opt/python/pytds/tds_session.py", line 176, in raise_db_exception
    raise ex
pytds.tds_base.OperationalError: ('Cannot open database "test" requested by the login. The login failed. Login failed for user \'xxx\'.', None)
denisenkom added a commit that referenced this issue Sep 2, 2024
denisenkom added a commit that referenced this issue Sep 2, 2024
denisenkom added a commit that referenced this issue Sep 2, 2024
* Fix failover partner connection rotation

Should address issue: #167
@denisenkom
Copy link
Owner

Failover connection is now fixed. But in your case connection is failing with login error which would not be retried, as that could cause lockout. Therefore you need to fix credentials in your connection.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants