From d5199202525fa9fa3d6aed43a5885c95e58eaa2b Mon Sep 17 00:00:00 2001 From: Dominic Pelini <111786059+DomPeliniAerospike@users.noreply.github.com> Date: Thu, 2 Nov 2023 07:26:57 -0600 Subject: [PATCH] Added maxErrorRate and errorRateWindow configurations CLIENT-1421 Added maxErrorRate and errorRateWindow configurations. Fixed bug with tenderInteval --- lib/config.js | 36 ++++++++++++++++++++++++++++++++++++ src/main/config.cc | 12 +++++++++++- 2 files changed, 47 insertions(+), 1 deletion(-) diff --git a/lib/config.js b/lib/config.js index 12afacf37..042202b31 100644 --- a/lib/config.js +++ b/lib/config.js @@ -400,6 +400,42 @@ class Config { this.maxConnsPerNode = config.maxConnsPerNode } + /** + * @name Config#maxErrorRate + * + * @summary Maximum number of errors allowed per node per error_rate_window before backoff algorithm returns + * AEROSPIKE_MAX_ERROR_RATE for database commands to that node. If max_error_rate is zero, there is no error limit. + * The counted error types are any error that causes the connection to close (socket errors and client timeouts), + * server device overload and server timeouts. + * + * The application should backoff or reduce the transaction load until AEROSPIKE_MAX_ERROR_RATE stops being returned. + * + * @description If the backoff algorithm has been activated, transactions will fail with {@link + * module:aerospike/status.AEROSPIKE_MAX_ERROR_RATE|AEROSPIKE_MAX_ERROR_RATE} until the {@link Config#errorRateWindow} has passed and the + * error count has been reset. + * + * @type {number} + * + * @default 100 + */ + if (Number.isInteger(config.maxErrorRate)) { + this.maxErrorRate = config.maxErrorRate + } + + /** + * @name Config#errorRateWindow + * + * @summary The number of cluster tend iterations that defines the window for {@link Config#maxErrorRate} to be surpassed. One tend iteration is defined + * as {@link Config#tendInterval} plus the time to tend all nodes. At the end of the window, the error count is reset to zero and backoff state is removed on all nodes. + * + * @type {number} + * + * @default 1 + */ + if (Number.isInteger(config.errorRateWindow)) { + this.errorRateWindow = config.errorRateWindow + } + /** * @name Config#minConnsPerNode * diff --git a/src/main/config.cc b/src/main/config.cc index 9bc72e96a..44da4f40a 100644 --- a/src/main/config.cc +++ b/src/main/config.cc @@ -419,7 +419,7 @@ int config_from_jsobject(as_config *config, Local configObj, goto Cleanup; } if ((rc = get_optional_uint32_property(&config->tender_interval, NULL, - configObj, "tendInterval", log)) != + configObj, "tenderInterval", log)) != AS_NODE_PARAM_OK) { goto Cleanup; } @@ -428,6 +428,16 @@ int config_from_jsobject(as_config *config, Local configObj, log)) != AS_NODE_PARAM_OK) { goto Cleanup; } + if ((rc = get_optional_uint32_property(&config->max_error_rate, + NULL, configObj, "maxErrorRate", + log)) != AS_NODE_PARAM_OK) { + goto Cleanup; + } + if ((rc = get_optional_uint32_property(&config->error_rate_window, + NULL, configObj, "errorRateWindow", + log)) != AS_NODE_PARAM_OK) { + goto Cleanup; + } if ((rc = get_optional_uint32_property(&config->async_min_conns_per_node, NULL, configObj, "minConnsPerNode", log)) != AS_NODE_PARAM_OK) {