Skip to content

Commit

Permalink
add fixes for socket shutdown (#20877)
Browse files Browse the repository at this point in the history
* Fix SSL connection retry attempts for cluster-internal connections

* Fix connection retry attempts for cluster-internal TLS connections that ran
  into the 15 seconds timeout during the connection establishing attempt.
  In this case, the low-level socket was repurposed, but not reset properly.
  This could leave the connection in an improper state and lead to callbacks
  for some requests to not being called as expected.

* apply some review comments

* check if connection was aborted

* revert change to cmakelists for tests

* disable socket rearming for now

* simplify PR

* remove retry entirely

* fix arangosh build

* further fixes for socket shutdown

* fix ownership issue

* fix compiler warning

* simplify PR

* reset timer earlier

* make sure callback is always called

* fix timer cancelation race

* fixes for socket shutdown

* remove invalid assertion

* Fix: check if socket is open in connect callback
It is possible that the timeout went off right before and has closed the socket before the callback was executed with a success code.

* fix compilation

* add tests

* increase connection timeout

* fix spurious test failure

---------

Co-authored-by: Vadim Kondratev <vadim@arangodb.com>
Co-authored-by: mpoeter <manuel@arangodb.com>
  • Loading branch information
3 people committed May 13, 2024
1 parent 4c24422 commit 54dfe12
Show file tree
Hide file tree
Showing 15 changed files with 454 additions and 140 deletions.
12 changes: 3 additions & 9 deletions 3rdParty/fuerte/include/fuerte/FuerteLogger.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,15 @@
#if 0
#include <iostream>
#include <sstream>
#include <string_view>

extern void LogHackWriter(char const* p);
extern void LogHackWriter(std::string_view p);

class LogHack {
std::stringstream _s;
public:
LogHack() {};
~LogHack() { LogHackWriter(_s.str().c_str()); };
~LogHack() { LogHackWriter(_s.str()); };
template<typename T> LogHack& operator<<(T const& o) { _s << o; return *this; }
typedef std::basic_ostream<char, std::char_traits<char> > CoutType;
typedef CoutType& (*StandardEndLine)(CoutType&);
Expand Down Expand Up @@ -115,11 +116,4 @@ class LogHack {
if (0) std::cout
#endif

#if ENABLE_FUERTE_LOG_NODE > 0
#define FUERTE_LOG_NODE std::cout
#else
#define FUERTE_LOG_NODE \
if (0) std::cout
#endif

#endif
8 changes: 8 additions & 0 deletions 3rdParty/fuerte/include/fuerte/connection.h
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,14 @@ class ConnectionBuilder {
return *this;
}

#ifdef ARANGODB_USE_GOOGLE_TESTS
unsigned failConnectAttempts() const { return _conf._failConnectAttempts; }
ConnectionBuilder& failConnectAttempts(unsigned f) {
_conf._failConnectAttempts = f;
return *this;
}
#endif

// Set the authentication type of the connection
AuthenticationType authenticationType() const {
return _conf._authenticationType;
Expand Down
2 changes: 2 additions & 0 deletions 3rdParty/fuerte/include/fuerte/loop.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@

#include <fuerte/asio_ns.h>

#include <memory>
#include <mutex>
#include <thread>
#include <utility>
#include <vector>

// run / runWithWork / poll for Loop mapping to ioservice
// free function run with threads / with thread group barrier and work
Expand Down
8 changes: 7 additions & 1 deletion 3rdParty/fuerte/include/fuerte/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -216,10 +216,13 @@ struct ConnectionConfiguration {
_host("localhost"),
_port("8529"),
_verifyHost(false),
_connectTimeout(15000),
_connectTimeout(60000),
_idleTimeout(300000),
_connectRetryPause(1000),
_maxConnectRetries(3),
#ifdef ARANGODB_USE_GOOGLE_TESTS
_failConnectAttempts(0),
#endif
_useIdleTimeout(true),
_authenticationType(AuthenticationType::None),
_user(""),
Expand All @@ -240,6 +243,9 @@ struct ConnectionConfiguration {
std::chrono::milliseconds _idleTimeout;
std::chrono::milliseconds _connectRetryPause;
unsigned _maxConnectRetries;
#ifdef ARANGODB_USE_GOOGLE_TESTS
unsigned _failConnectAttempts;
#endif
bool _useIdleTimeout;

AuthenticationType _authenticationType;
Expand Down

0 comments on commit 54dfe12

Please sign in to comment.