Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: quota limit was not reached, but the limit was exceeded #31337

Merged
merged 2 commits into from
Nov 20, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/Access/EnabledQuota.cpp
Expand Up @@ -52,9 +52,7 @@ struct EnabledQuota::Impl
return end;
}

/// We reset counters only if the interval's end has been calculated before.
/// If it hasn't we just calculate the interval's end for the first time and don't reset counters yet.
bool need_reset_counters = (end_loaded.count() != 0);
bool need_reset_counters = false;

do
{
Expand All @@ -66,7 +64,12 @@ struct EnabledQuota::Impl
UInt64 n = static_cast<UInt64>((current_time - end + duration) / duration);
end = end + duration * n;
if (end_of_interval.compare_exchange_strong(end_loaded, end.time_since_epoch()))
{
/// We reset counters only if the interval's end has been calculated before.
/// If it hasn't we just calculate the interval's end for the first time and don't reset counters yet.
need_reset_counters = true;
vitlibar marked this conversation as resolved.
Show resolved Hide resolved
break;
}
end = std::chrono::system_clock::time_point{end_loaded};
}
while (current_time >= end);
Expand Down