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

CLIENT-1421 #592

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
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
36 changes: 36 additions & 0 deletions lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down
12 changes: 11 additions & 1 deletion src/main/config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ int config_from_jsobject(as_config *config, Local<Object> 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;
}
Expand All @@ -428,6 +428,16 @@ int config_from_jsobject(as_config *config, Local<Object> 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) {
Expand Down