aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVasily Gerasimov <UgnineSirdis@gmail.com>2022-02-21 21:51:56 +0300
committerVasily Gerasimov <UgnineSirdis@gmail.com>2022-02-21 21:51:56 +0300
commitc53684a42ee8692a90906715a64a7cd561fe3361 (patch)
treefeb8f579c0ab0ff3cbc878818dcb417ee0d1e858
parentbbfcaa2ca914ce3e14d1526439cf0c9da92d00a4 (diff)
downloadydb-c53684a42ee8692a90906715a64a7cd561fe3361.tar.gz
Fix retry synchronization in http gateway
Add comment Fix retry synchronization in http gateway ref:d9a7e74aeb64789f1b3e8d9ecd40398cf456f110
-rw-r--r--ydb/library/yql/providers/common/http_gateway/yql_http_gateway.cpp14
1 files changed, 13 insertions, 1 deletions
diff --git a/ydb/library/yql/providers/common/http_gateway/yql_http_gateway.cpp b/ydb/library/yql/providers/common/http_gateway/yql_http_gateway.cpp
index eccab2fa27..7c3cf7c0b9 100644
--- a/ydb/library/yql/providers/common/http_gateway/yql_http_gateway.cpp
+++ b/ydb/library/yql/providers/common/http_gateway/yql_http_gateway.cpp
@@ -300,6 +300,17 @@ private:
entry = easy;
Easy2RetryState.emplace(easy, std::move(retryPolicy->CreateRetryState()));
Await.emplace(std::move(easy));
+ Wakeup(expectedSize);
+ }
+
+ void OnRetry(TEasyCurl::TPtr easy) {
+ const std::unique_lock lock(Sync);
+ const std::size_t expectedSize = easy->GetExpectedSize();
+ Await.emplace(std::move(easy));
+ Wakeup(expectedSize);
+ }
+
+ void Wakeup(std::size_t expectedSize) {
if (Allocated.size() < MaxHandlers && AllocatedSize + expectedSize + OutputSize.load() <= MaxSimulatenousDownloadsSize) {
curl_multi_wakeup(Handle);
}
@@ -317,7 +328,7 @@ private:
bool Process() override {
if (const auto g = Gateway.lock()) {
Y_VERIFY(Easy);
- g->Await.emplace(std::move(Easy));
+ g->OnRetry(std::move(Easy));
}
return false;
}
@@ -356,6 +367,7 @@ std::atomic_size_t THTTPMultiGateway::OutputSize = 0ULL;
std::mutex THTTPMultiGateway::CreateSync;
THTTPMultiGateway::TWeakPtr THTTPMultiGateway::Singleton;
+// Class that is not used in production (for testing only).
class THTTPEasyGateway : public IHTTPGateway, private std::enable_shared_from_this<THTTPEasyGateway> {
friend class IHTTPGateway;
public: