diff --git a/src/include/aerospike/as_cluster.h b/src/include/aerospike/as_cluster.h index ef70aba3a..99381af4e 100644 --- a/src/include/aerospike/as_cluster.h +++ b/src/include/aerospike/as_cluster.h @@ -612,50 +612,73 @@ as_cluster_disable_metrics(as_error* err, as_cluster* cluster); * @private * Increment transaction count when metrics are enabled. */ -void -as_cluster_add_tran(as_cluster* cluster); +static inline void +as_cluster_add_tran(as_cluster* cluster) +{ + if (cluster->metrics_enabled) { + as_incr_uint64(&cluster->tran_count); + } +} /** * @private * Return transaction count. The value is cumulative and not reset per metrics interval. */ -uint64_t -as_cluster_get_tran_count(const as_cluster* cluster); +static inline uint64_t +as_cluster_get_tran_count(const as_cluster* cluster) +{ + return as_load_uint64(&cluster->tran_count); +} /** * @private * Increment async delay queue timeout count. */ -void -as_cluster_add_retry(as_cluster* cluster); +static inline void +as_cluster_add_retry(as_cluster* cluster) +{ + as_incr_uint64(&cluster->retry_count); +} /** * @private * Add transaction retry count. There can be multiple retries for a single transaction. */ -void -as_cluster_add_retries(as_cluster* cluster, uint32_t count); +static inline void +as_cluster_add_retries(as_cluster* cluster, uint32_t count) +{ + as_faa_uint64(&cluster->retry_count, count); +} /** * @private * Return transaction retry count. The value is cumulative and not reset per metrics interval. */ -uint64_t -as_cluster_get_retry_count(const as_cluster* cluster); +static inline uint64_t +as_cluster_get_retry_count(const as_cluster* cluster) +{ + return as_load_uint64(&cluster->retry_count); +} /** * @private * Increment async delay queue timeout count. */ -void -as_cluster_add_delay_queue_timeout(as_cluster* cluster); +static inline void +as_cluster_add_delay_queue_timeout(as_cluster* cluster) +{ + as_incr_uint64(&cluster->delay_queue_timeout_count); +} /** * @private * Return async delay queue timeout count. */ -uint64_t -as_cluster_get_delay_queue_timeout_count(const as_cluster* cluster); +static inline uint64_t +as_cluster_get_delay_queue_timeout_count(const as_cluster* cluster) +{ + return as_load_uint64(&cluster->delay_queue_timeout_count); +} /** * @private diff --git a/src/include/aerospike/as_node.h b/src/include/aerospike/as_node.h index 7fbf332ea..2463e788c 100644 --- a/src/include/aerospike/as_node.h +++ b/src/include/aerospike/as_node.h @@ -688,28 +688,40 @@ as_node_enable_metrics(as_node* node, const struct as_metrics_policy_s* policy); /** * Return transaction error count. The value is cumulative and not reset per metrics interval. */ -uint64_t -as_node_get_error_count(as_node* node); +static inline uint64_t +as_node_get_error_count(as_node* node) +{ + return as_load_uint64(&node->error_count); +} /** * Increment transaction error count. If the error is retryable, multiple errors per * transaction may occur. */ -void -as_node_add_error(as_node* node); +static inline void +as_node_add_error(as_node* node) +{ + as_incr_uint64(&node->error_count); +} /** * Return transaction timeout count. The value is cumulative and not reset per metrics interval. */ -uint64_t -as_node_get_timeout_count(as_node* node); +static inline uint64_t +as_node_get_timeout_count(as_node* node) +{ + return as_load_uint64(&node->timeout_count); +} /** * Increment transaction timeout count. If the timeout is retryable (ie socketTimeout), * multiple timeouts per transaction may occur. */ -void -as_node_add_timeout(as_node* node); +static inline void +as_node_add_timeout(as_node* node) +{ + as_incr_uint64(&node->timeout_count); +} /** * @private diff --git a/src/main/aerospike/as_cluster.c b/src/main/aerospike/as_cluster.c index 85934485b..e2f6e4757 100644 --- a/src/main/aerospike/as_cluster.c +++ b/src/main/aerospike/as_cluster.c @@ -655,50 +655,6 @@ as_cluster_disable_metrics(as_error* err, as_cluster* cluster) return status; } -void -as_cluster_add_tran(as_cluster* cluster) -{ - if (cluster->metrics_enabled) { - as_incr_uint64(&cluster->tran_count); - } -} - -uint64_t -as_cluster_get_tran_count(const as_cluster* cluster) -{ - return as_load_uint64(&cluster->tran_count); -} - -void -as_cluster_add_retry(as_cluster* cluster) -{ - as_incr_uint64(&cluster->retry_count); -} - -void -as_cluster_add_retries(as_cluster* cluster, uint32_t count) -{ - as_faa_uint64(&cluster->retry_count, count); -} - -uint64_t -as_cluster_get_retry_count(const as_cluster* cluster) -{ - return as_load_uint64(&cluster->retry_count); -} - -void -as_cluster_add_delay_queue_timeout(as_cluster* cluster) -{ - as_incr_uint64(&cluster->delay_queue_timeout_count); -} - -uint64_t -as_cluster_get_delay_queue_timeout_count(const as_cluster* cluster) -{ - return as_load_uint64(&cluster->delay_queue_timeout_count); -} - static as_status as_cluster_remove_nodes(as_error* err, as_cluster* cluster, as_vector* /* */ nodes_to_remove) { diff --git a/src/main/aerospike/as_command.c b/src/main/aerospike/as_command.c index 5deeccbcc..18c855afc 100644 --- a/src/main/aerospike/as_command.c +++ b/src/main/aerospike/as_command.c @@ -681,6 +681,8 @@ as_command_execute(as_command* cmd, as_error* err) goto Retry; case AEROSPIKE_ERR_TIMEOUT: + as_node_add_timeout(node); + if (is_server_timeout(err)) { as_node_put_conn_error(node, &socket); } diff --git a/src/main/aerospike/as_event.c b/src/main/aerospike/as_event.c index 19e8bf1b3..eaf89bf8a 100644 --- a/src/main/aerospike/as_event.c +++ b/src/main/aerospike/as_event.c @@ -823,6 +823,8 @@ as_event_socket_timeout(as_event_command* cmd) return; } + as_node_add_timeout(cmd->node); + if (cmd->pipe_listener) { as_pipe_timeout(cmd, true); return; @@ -847,15 +849,15 @@ as_event_delay_timeout(as_event_command* cmd) { cmd->state = AS_ASYNC_STATE_QUEUE_ERROR; + if (cmd->latency_type != AS_LATENCY_TYPE_NONE) { + as_cluster_add_delay_queue_timeout(cmd->cluster); + } + as_error err; as_error_set_message(&err, AEROSPIKE_ERR_TIMEOUT, "Delay queue timeout"); // Notify user, but do not destroy command. as_event_notify_error(cmd, &err); - if (cmd->latency_type != AS_LATENCY_TYPE_NONE) - { - as_cluster_add_delay_queue_timeout(cmd->cluster); - } } void @@ -887,12 +889,14 @@ as_event_process_timer(as_event_command* cmd) void as_event_total_timeout(as_event_command* cmd) { + // Node should not be null at this point. + as_node_add_timeout(cmd->node); + if (cmd->pipe_listener) { as_pipe_timeout(cmd, false); return; } - // Node should not be null at this point. as_event_connection_timeout(cmd, &cmd->node->async_conn_pools[cmd->event_loop->index]); as_error err; @@ -1312,6 +1316,11 @@ as_event_response_error(as_event_command* cmd, as_error* err) as_event_release_connection(cmd->conn, pool); as_node_incr_error_rate(cmd->node); break; + + case AEROSPIKE_ERR_TIMEOUT: + as_node_add_timeout(cmd->node); + as_event_put_connection(cmd, pool); + break; default: as_event_put_connection(cmd, pool); diff --git a/src/main/aerospike/as_node.c b/src/main/aerospike/as_node.c index 296ea7f27..eabf9563d 100644 --- a/src/main/aerospike/as_node.c +++ b/src/main/aerospike/as_node.c @@ -1400,30 +1400,6 @@ as_node_enable_metrics(as_node* node, const as_metrics_policy* policy) node->metrics = as_node_metrics_init(policy->latency_columns, policy->latency_shift); } -uint64_t -as_node_get_error_count(as_node* node) -{ - return as_load_uint64(&node->error_count); -} - -void -as_node_add_error(as_node* node) -{ - as_incr_uint64(&node->error_count); -} - -uint64_t -as_node_get_timeout_count(as_node* node) -{ - return as_load_uint64(&node->timeout_count); -} - -void -as_node_add_timeout(as_node* node) -{ - as_incr_uint64(&node->timeout_count); -} - static as_status as_node_process_racks(as_cluster* cluster, as_error* err, as_node* node, as_vector* values) {