Fix bug with polling redirected requests

This commit is contained in:
Tyler Neely 2022-12-05 14:20:06 +00:00
parent ca3f748325
commit 747b8a21cd
3 changed files with 20 additions and 4 deletions

View File

@ -45,6 +45,7 @@
#include "utils/result.hpp" #include "utils/result.hpp"
namespace memgraph::query::v2 { namespace memgraph::query::v2 {
template <typename TStorageClient> template <typename TStorageClient>
class RsmStorageClientManager { class RsmStorageClientManager {
public: public:
@ -608,7 +609,12 @@ class RequestRouter : public RequestRouterInterface {
auto &request = running_requests.at(ready.GetId()); auto &request = running_requests.at(ready.GetId());
auto &storage_client = GetStorageClientForShard(request.shard); auto &storage_client = GetStorageClientForShard(request.shard);
auto poll_result = storage_client.PollAsyncReadRequest(ready); std::optional<utils::BasicResult<io::TimedOut, msgs::ReadResponses>> poll_result =
storage_client.PollAsyncReadRequest(ready);
if (!poll_result.has_value()) {
continue;
}
if (poll_result->HasError()) { if (poll_result->HasError()) {
throw std::runtime_error("RequestRouter Read request timed out"); throw std::runtime_error("RequestRouter Read request timed out");
@ -649,7 +655,12 @@ class RequestRouter : public RequestRouterInterface {
auto &request = running_requests.at(ready.GetId()); auto &request = running_requests.at(ready.GetId());
auto &storage_client = GetStorageClientForShard(request.shard); auto &storage_client = GetStorageClientForShard(request.shard);
auto poll_result = storage_client.PollAsyncWriteRequest(ready); std::optional<utils::BasicResult<io::TimedOut, msgs::WriteResponses>> poll_result =
storage_client.PollAsyncWriteRequest(ready);
if (!poll_result.has_value()) {
continue;
}
if (poll_result->HasError()) { if (poll_result->HasError()) {
throw std::runtime_error("RequestRouter Write request timed out"); throw std::runtime_error("RequestRouter Write request timed out");

View File

@ -611,7 +611,7 @@ msgs::ReadResponses ShardRsm::HandleRead(msgs::GetPropertiesRequest &&req) {
return limit; return limit;
}; };
auto collect_response = [get_limit, &req](auto &elements, auto create_result_row) { auto collect_response = [get_limit, &req](auto &elements, auto create_result_row) -> msgs::ReadResponses {
msgs::GetPropertiesResponse response; msgs::GetPropertiesResponse response;
const auto limit = get_limit(elements); const auto limit = get_limit(elements);
for (size_t index = 0; index != limit; ++index) { for (size_t index = 0; index != limit; ++index) {

View File

@ -18,6 +18,8 @@
#include <thread> #include <thread>
#include <vector> #include <vector>
#include <spdlog/cfg/env.h>
#include "common.hpp" #include "common.hpp"
#include "common/types.hpp" #include "common/types.hpp"
#include "coordinator/coordinator_client.hpp" #include "coordinator/coordinator_client.hpp"
@ -370,4 +372,7 @@ void DoTest() {
} }
} // namespace memgraph::query::v2::tests } // namespace memgraph::query::v2::tests
int main() { memgraph::query::v2::tests::DoTest(); } int main() {
spdlog::cfg::load_env_levels();
memgraph::query::v2::tests::DoTest();
}