53c405c699
Summary: This diff changes the RPC layer to directly return `TResponse` to the user when issuing a `Call<...>` RPC call. The call throws an exception on failure (instead of the previous return `nullopt`). All servers (network, RPC and distributed) are set to have explicit `Shutdown` methods so that a controlled shutdown can always be performed. The object destructors now have `CHECK`s to enforce that the `AwaitShutdown` methods were called. The distributed memgraph is changed that none of the binaries (master/workers) crash when there is a communication failure. Instead, the whole cluster starts a graceful shutdown when a persistent communication error is detected. Transient errors are allowed during execution. The transaction that errored out will be aborted on the whole cluster. The cluster state is managed using a new Heartbeat RPC call. Reviewers: buda, teon.banek, msantl Reviewed By: teon.banek Subscribers: pullbot Differential Revision: https://phabricator.memgraph.io/D1604
57 lines
1.2 KiB
C++
57 lines
1.2 KiB
C++
#ifndef NDEBUG
|
|
#define NDEBUG
|
|
#endif
|
|
|
|
#include <chrono>
|
|
#include <iostream>
|
|
|
|
#include "network_common.hpp"
|
|
|
|
static constexpr const char interface[] = "127.0.0.1";
|
|
|
|
unsigned char data[SIZE];
|
|
|
|
using namespace std::chrono_literals;
|
|
|
|
TEST(Network, SessionLeak) {
|
|
// initialize test data
|
|
initialize_data(data, SIZE);
|
|
|
|
// initialize listen socket
|
|
Endpoint endpoint(interface, 0);
|
|
|
|
// initialize server
|
|
TestData session_data;
|
|
ContextT context;
|
|
ServerT server(endpoint, &session_data, &context, -1, "Test", 2);
|
|
|
|
// start clients
|
|
int N = 50;
|
|
std::vector<std::thread> clients;
|
|
|
|
const auto &ep = server.endpoint();
|
|
int testlen = 3000;
|
|
for (int i = 0; i < N; ++i) {
|
|
clients.push_back(std::thread(client_run, i, interface, ep.port(), data,
|
|
testlen, testlen));
|
|
std::this_thread::sleep_for(10ms);
|
|
}
|
|
|
|
// cleanup clients
|
|
for (int i = 0; i < N; ++i) clients[i].join();
|
|
|
|
std::this_thread::sleep_for(2s);
|
|
|
|
// shutdown server
|
|
server.Shutdown();
|
|
server.AwaitShutdown();
|
|
}
|
|
|
|
// run with "valgrind --leak-check=full ./network_session_leak" to check for
|
|
// memory leaks
|
|
int main(int argc, char **argv) {
|
|
google::InitGoogleLogging(argv[0]);
|
|
::testing::InitGoogleTest(&argc, argv);
|
|
return RUN_ALL_TESTS();
|
|
}
|