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

Add on-by-default option to use TCP keepalive in the REST client. #5319

Merged
merged 2 commits into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions test/src/unit-capi-config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ void check_save_to_file() {
ss << "rest.capnp_traversal_limit 2147483648\n";
ss << "rest.curl.buffer_size 524288\n";
ss << "rest.curl.retry_errors true\n";
ss << "rest.curl.tcp_keepalive true\n";
ss << "rest.curl.verbose false\n";
ss << "rest.http_compressor any\n";
ss << "rest.load_enumerations_on_array_open false\n";
Expand Down Expand Up @@ -612,6 +613,7 @@ TEST_CASE("C API: Test config iter", "[capi][config]") {
all_param_values["rest.capnp_traversal_limit"] = "2147483648";
all_param_values["rest.curl.buffer_size"] = "524288";
all_param_values["rest.curl.retry_errors"] = "true";
all_param_values["rest.curl.tcp_keepalive"] = "true";
all_param_values["rest.curl.verbose"] = "false";
all_param_values["rest.load_metadata_on_array_open"] = "false";
all_param_values["rest.load_non_empty_domain_on_array_open"] = "false";
Expand Down
3 changes: 3 additions & 0 deletions tiledb/api/c_api/config/config_api_external.h
Original file line number Diff line number Diff line change
Expand Up @@ -739,6 +739,9 @@ TILEDB_EXPORT void tiledb_config_free(tiledb_config_t** config) TILEDB_NOEXCEPT;
* Set curl to run in verbose mode for REST requests <br>
* curl will print to stdout with this option
* **Default**: false
* - `rest.curl.tcp_keepalive` <br>
* Set curl to use TCP keepalive for REST requests <br>
* **Default**: true
* - `rest.load_metadata_on_array_open` <br>
* If true, array metadata will be loaded and sent to server together with
* the open array <br>
Expand Down
4 changes: 4 additions & 0 deletions tiledb/sm/config/config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ const std::string Config::REST_RETRY_DELAY_FACTOR = "1.25";
const std::string Config::REST_CURL_BUFFER_SIZE = "524288";
const std::string Config::REST_CAPNP_TRAVERSAL_LIMIT = "2147483648";
const std::string Config::REST_CURL_VERBOSE = "false";
const std::string REST_CURL_TCP_KEEPALIVE = "true";
const std::string Config::REST_CURL_RETRY_ERRORS = "true";
const std::string Config::REST_LOAD_ENUMERATIONS_ON_ARRAY_OPEN = "false";
const std::string Config::REST_LOAD_METADATA_ON_ARRAY_OPEN = "true";
Expand Down Expand Up @@ -257,6 +258,7 @@ const std::map<std::string, std::string> default_config_values = {
std::make_pair("rest.curl.buffer_size", Config::REST_CURL_BUFFER_SIZE),
std::make_pair(
"rest.capnp_traversal_limit", Config::REST_CAPNP_TRAVERSAL_LIMIT),
std::make_pair("rest.curl.tcp_keepalive", REST_CURL_TCP_KEEPALIVE),
std::make_pair("rest.curl.verbose", Config::REST_CURL_VERBOSE),
std::make_pair("rest.curl.retry_errors", Config::REST_CURL_RETRY_ERRORS),
std::make_pair(
Expand Down Expand Up @@ -803,6 +805,8 @@ Status Config::sanity_check(
RETURN_NOT_OK(utils::parse::convert(value, &v));
} else if (param == "ssl.verify") {
RETURN_NOT_OK(utils::parse::convert(value, &v));
} else if (param == "rest.curl.tcp_keepalive") {
RETURN_NOT_OK(utils::parse::convert(value, &v));
} else if (param == "vfs.min_parallel_size") {
RETURN_NOT_OK(utils::parse::convert(value, &vuint64));
} else if (param == "vfs.max_batch_size") {
Expand Down
3 changes: 3 additions & 0 deletions tiledb/sm/cpp_api/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -913,6 +913,9 @@ class Config {
* Set curl to run in verbose mode for REST requests <br>
* curl will print to stdout with this option
* **Default**: false
* - `rest.curl.tcp_keepalive` <br>
* Set curl to use TCP keepalive for REST requests <br>
* **Default**: true
* - `rest.load_metadata_on_array_open` <br>
* If true, array metadata will be loaded and sent to server together with
* the open array <br>
Expand Down
5 changes: 5 additions & 0 deletions tiledb/sm/rest/curl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,11 @@ Status Curl::init(
curl_easy_setopt(curl_.get(), CURLOPT_CAPATH, ssl_cfg.ca_path().c_str());
}

bool tcp_keepalive =
config_->get<bool>("rest.curl.tcp_keepalive", Config::must_find);

curl_easy_setopt(curl_.get(), CURLOPT_TCP_KEEPALIVE, tcp_keepalive ? 1L : 0L);

bool found;
RETURN_NOT_OK(
config_->get<uint64_t>("rest.retry_count", &retry_count_, &found));
Expand Down
Loading