Skip to content

Commit

Permalink
Warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
mmastrac committed Aug 6, 2024
1 parent c607503 commit afae053
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
3 changes: 2 additions & 1 deletion edb/server/connpool/pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,8 @@ async def _connect(
# 3D000 - INVALID CATALOG NAME, database does not exist
# Skip retry and propagate the error immediately
if block.connect_failures_num <= config.CONNECT_FAILURE_RETRIES:
block.connect_failures_num = config.CONNECT_FAILURE_RETRIES + 1
block.connect_failures_num = (
config.CONNECT_FAILURE_RETRIES + 1)

if block.connect_failures_num > config.CONNECT_FAILURE_RETRIES:
# Abort all waiters on this block and propagate the error, as
Expand Down
9 changes: 6 additions & 3 deletions tests/test_server_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -1496,7 +1496,8 @@ async def main():

asyncio.run(main())

@unittest.mock.patch('edb.server.connpool.config.CONNECT_FAILURE_RETRIES', 2)
@unittest.mock.patch('edb.server.connpool.config.CONNECT_FAILURE_RETRIES',
2)
def test_connpool_connect_error(self):
from edb.server.pgcon import errors

Expand All @@ -1511,7 +1512,8 @@ class ConnectError(Exception):

self._test_connpool_connect_error(ConnectError, 3)

@unittest.mock.patch('edb.server.connpool.config.CONNECT_FAILURE_RETRIES', 0)
@unittest.mock.patch('edb.server.connpool.config.CONNECT_FAILURE_RETRIES',
0)
def test_connpool_connect_error_zero_retry(self):
class ConnectError(Exception):
pass
Expand All @@ -1521,7 +1523,8 @@ class ConnectError(Exception):
@unittest.mock.patch('edb.server.connpool.pool.logger',
new_callable=MockLogger)
@unittest.mock.patch('edb.server.connpool.config.MIN_LOG_TIME_THRESHOLD', 0)
@unittest.mock.patch('edb.server.connpool.config.CONNECT_FAILURE_RETRIES', 5)
@unittest.mock.patch('edb.server.connpool.config.CONNECT_FAILURE_RETRIES',
5)
def test_connpool_steal_connect_error(self, logger: MockLogger):
count = 0
connect = self.make_fake_connect()
Expand Down

0 comments on commit afae053

Please sign in to comment.