Repository navigation
Conversation
|
This is an automated comment for commit 7ec911f with description of existing statuses. It's updated for the latest CI running ❌ Click here to open a full report in a separate page
Successful checks
|
max_execution_time dependencymax_execution_time
| if (execution_time > 0) | ||
| { | ||
| Int64 retries = 0; | ||
| while (true) | ||
| { | ||
| retries++; | ||
| uint64_t calculated_delay = calculateDelayOnRetries(retries, scaleFactor); | ||
| if (calculated_delay > maxDelayMs) | ||
| { | ||
| retries += execution_time / maxDelayMs; | ||
| break; | ||
| } | ||
| execution_time -= calculated_delay; | ||
| if (execution_time < 0) | ||
| break; | ||
| } | ||
| maxRetries = maxRetries < retries ? maxRetries : uint32_t(retries); | ||
| } |
There was a problem hiding this comment.
I think we can write a formula here, instead of writing the loop.
First, we can calculate how many steps is required to get maxDelayMs: maxDelayMs <= minDelayMs * (scaleFactor ^ steps) => steps = log_(scaleFactor)(maxDelayMs / minDelayMs) = ln(maxDelayMs / minDelayMs) / ln(scaleFactor) (or just log_2(maxDelayMs / minDelayMs) if scaleFactor = 2).
Then, we can get the time required to get to maxDelayMs, its t = minDelayMs * (1 - scaleFactor ^ steps) / (1 - scaleFactor).
If t > max_execution_time, then max_execution_time = minDelayMs * (1 - scaleFactor ^ maxRetries) / (1 - scaleFactor), so (max_execution_time / minDelayMs) * (1 - scaleFactor) = 1 - scaleFactor ^ maxRetries or maxRetries = ln(1 - (max_execution_time / minDelayMs) * (1 - scaleFactor)) / ln(scaleFactor).
In other case, maxRetries = steps + (max_execution_time - t) * maxDelayMs
There was a problem hiding this comment.
(but please validate this)
| /// Calculating number of retries based on the `max_execution_time` and delays between retries | ||
| if (context != nullptr) | ||
| { | ||
| Int64 execution_time = context->getSettingsRef().max_execution_time.totalMilliseconds() / 2; /// Here we put total time/2 knowing that we will do retries |
There was a problem hiding this comment.
Let's avoid using context here (end everywhere when possible). It's much better to pass max_execution_time as unit param.
|
BTW, in the logs during query |
|
Do we create here one more limit settings for such scenario or do we reuse query execution limit? Why do we bring limits of query execution to the |
|
The idea is changed because we make a decision about doing a time limits in not appropriate place. Also, there is a problem regarding cancelling of queries that is also need to fix because we check if the query is cancelled only when we receive some sort of data from it and currently, queries can be retried for a long time. The best solution that was discussed is to make a global thread, which will make a decision that we need to cancel the query. It should contain "deadline scheduler", which will check statuses of the processes and then send signal if process should be cancelled. |
|
Note: the commit above can only work as a temporary solution, the full problem is described here and should be solved in the better way. |
max_execution_timemax_execution_time
|
What's the status ? |
|
@LGDHuaOPER currently working on it🙂 |
That's great ! Thank you very much ! |
|
Dear @KochetovNicolai, @CheSema, this PR hasn't been updated for a while. You will be unassigned. Will you continue working on it? If so, please feel free to reassign yourself. |
|
Dear @CheSema, this PR hasn't been updated for a while. You will be unassigned. Will you continue working on it? If so, please feel free to reassign yourself. |
eca3a9b to
d01c6c1
Compare
Closes #62371, Closes #59084
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
While executing queries like
select * from s3('https://s3queue.clickhouse.com.amazonaws.com/data/*.json', 'JSONEachRow') limit 1, was encountered a delay in the retrial process, taking around 2 hours. This pull request tackles the issue, ensuring that queries undergo retries within the definedmax_execution_timelimit, preventing prolonged waiting periods. Also, there is not possible to cancel the query, problem description: #58479Documentation entry for user-facing changes