-
Notifications
You must be signed in to change notification settings - Fork 0
Description
By reproducing the error that cause summary endpoint failing, with the tool locust in local . I caught the following exception returned from cosmos:
the sql query text exceeded the maximum limit of 262144 characters
This looked suspicious as only happened when the server was under big load. By adding some logs, I found the following section of query string growing on each call, e.g. :
First call
...
AND
((c.start_date BETWEEN @start_date AND @end_date) OR
(c.end_date BETWEEN @start_date AND @end_date))
...
Second call
...
AND
((c.start_date BETWEEN @start_date AND @end_date) OR
(c.end_date BETWEEN @start_date AND @end_date))
AND
((c.start_date BETWEEN @start_date AND @end_date) OR
(c.end_date BETWEEN @start_date AND @end_date))
...
And so on. Until the query string become so big that exceeds the limit of character.
Later, I debugged the code and found the following piece of code, that was the cause that query string was growing on each call:
def find_all_entries(
self,
event_context: EventContext,
conditions: dict = {},
custom_sql_conditions: List[str] = [],
date_range: dict = {},
):
where the list custom_sql_conditions
was preserved across calls and It was not an empty list as expected. This is a classical error of mutable defaults in python as stated here
After fix this. I reproduced the error with about 15000 request and didn't fail for the former error. It had some fails because of azure blocking too much requests.
TODO :
- Fix this issue as a hotfix and make PR
- Create new issue to fix this classical error and avoid unexpected behaviors in the future because of this.