You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This happens as the line returned from the resp.content.iter_any() is not a valid JSON, but a TOO_SLOW error message from ClickHouse:
b'Code: 160. DB::Exception: Estimated query execution time (180.2056076714325 seconds) is too long. Maximum: 20. Estimated rows to process: 114844900: While executing MergeTreeThread. (TOO_SLOW) (version 23.4.2.11 (official build))\n'
b. json=False
We don't get an exception when iterating over the results. However, if we check the list of rows, the last record will actually be the error message from ClickHouse:
>>> [valforvalinrows[-1].values()]
Traceback (mostrecentcalllast):
File"/_collections_abc.py", line930, in__iter__yieldself._mapping[key]
File"/aiochclient/records.py", line47, in__getitem__returnself._getitem(key)
File"/aiochclient/records.py", line52, in_getitemreturnself._row[self._names[key]]
IndexError: tupleindexoutofrange>>>rows[-1]._row
(b'Code: 160. DB::Exception: Estimated query execution time (134.46100121598155 seconds) is too long. Maximum: 20. Estimated rows to process: 114844900: While executing MergeTreeThread. (TOO_SLOW) (version 23.4.2.11 (official build))',)
Expected behavior:
Instead of hiding the underlying error, aiochclient should properly inform the user that their queries are slow for ClickHouse (or at least that ClickHouse returned an error string). Unfortunately the response is successful as this error happens after we have received the response, so there is no easy way to check this. One way to go about it is by catching the JSONDecodeError and IndexError and raising a more informative exception, for example for the JSONDecodeError case:
ifis_json:
rf=FromJsonFabric(loads=self._json.loads)
asyncforlineinresponse:
try:
yieldrf.new(line)
exceptJSONDecodeError:
raiseChClientError(f"Data received from ClickHouse could not be decoded as JSON, potentially because of an error message: {line}")
The text was updated successfully, but these errors were encountered:
Steps to reproduce:
max_execution_time
to something relatively low, I used 120 secs.ChClient
(I usedaiohttp
, maybe the same happens withhttpx
, although I haven't tested):max_execution_time
, two things can happen depending on whether we are callingiterate
withjson=True
orjson=False
:a.
json=True
An exception will be raised as we iterate:
This happens as the line returned from the
resp.content.iter_any()
is not a valid JSON, but aTOO_SLOW
error message from ClickHouse:b.
json=False
We don't get an exception when iterating over the results. However, if we check the list of rows, the last record will actually be the error message from ClickHouse:
Expected behavior:
Instead of hiding the underlying error,
aiochclient
should properly inform the user that their queries are slow for ClickHouse (or at least that ClickHouse returned an error string). Unfortunately the response is successful as this error happens after we have received the response, so there is no easy way to check this. One way to go about it is by catching theJSONDecodeError
andIndexError
and raising a more informative exception, for example for theJSONDecodeError
case:The text was updated successfully, but these errors were encountered: