Skip to content

Commit ab00c3b

Browse files
Wizard1209Vladimir Bobrikovdroserasprout
authored
Increase initial Hasura connection retry count (#857)
Co-authored-by: Vladimir Bobrikov <[email protected]> Co-authored-by: Lev Gorodetskiy <[email protected]>
1 parent bfe1389 commit ab00c3b

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ The format is based on [Keep a Changelog], and this project adheres to [Semantic
1212

1313
### Fixed
1414

15-
16-
- cli: Added warning for timescaledb-ha users
15+
- cli: Use correct data path with timescaledb-ha Docker image.
1716
- demos: Fixed decimal overflow in `demo_uniswap` project.
1817
- evm.node: Fixed incorrect log request parameters.
1918
- evm.subsquid.events: Fixed issue with determining the last level when syncing with node.
19+
- hasura: Increated retry count for initial connection (healthcheck).
2020

2121
## [7.0.0] - 2023-09-25
2222

src/dipdup/hasura.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,9 +210,11 @@ def _get_source(self, metadata: dict[str, Any], name: str) -> dict[str, Any] | N
210210
else:
211211
return None
212212

213-
async def _hasura_request(self, endpoint: str, json: dict[str, Any] | None = None) -> dict[str, Any]:
213+
async def _hasura_request(self, endpoint: str, json: dict[str, Any] | None = None, retry_count: int | None = None) -> dict[str, Any]:
214214
self._logger.debug('Sending `%s` request: %s', endpoint, orjson.dumps(json))
215215
try:
216+
if retry_count is not None:
217+
self._http_config.retry_count, retry_count = retry_count, self._http_config.retry_count
216218
result = await self.request(
217219
method='get' if json is None else 'post',
218220
url=f'v1/{endpoint}',
@@ -221,6 +223,9 @@ async def _hasura_request(self, endpoint: str, json: dict[str, Any] | None = Non
221223
)
222224
except ClientResponseError as e:
223225
raise HasuraError(f'{e.status} {e.message}') from e
226+
finally:
227+
if retry_count is not None:
228+
self._http_config.retry_count, retry_count = retry_count, self._http_config.retry_count
224229

225230
self._logger.debug('Response: %s', result)
226231
if errors := result.get('error') or result.get('errors'):
@@ -230,7 +235,7 @@ async def _hasura_request(self, endpoint: str, json: dict[str, Any] | None = Non
230235

231236
async def _healthcheck(self) -> None:
232237
self._logger.info('Connecting to Hasura instance')
233-
version_json = await self._hasura_request('version')
238+
version_json = await self._hasura_request('version', retry_count=20)
234239
version = version_json['version']
235240
if version.startswith('v1'):
236241
raise UnsupportedAPIError(

0 commit comments

Comments
 (0)