Aerospike Java client TIMEOUT error propagation when cancellation is requested
0 reputation · 19 Apr 2022, 08:20 UTC
0 reputation · 19 Apr 2022, 08:20 UTC
When a synchronous Aerospike operation exceeds the socket timeout, the Java client throws an AerospikeException with resultCode AerospikeResultCode.TIMEOUT and the message 'Timeout' (error code -1).
If the operation is cancelled via Future.cancel(true) on the asynchronous client, the client attempts to interrupt the underlying Netty thread, but the interruption does not reliably abort the in‑flight request, leaving the outcome dependent on server processing time and the configured retry policy.
The current implementation treats cancellation as a non‑retryable timeout, forcing users to manage retries manually, yet it is unclear whether cancellation should be considered fatal or retryable.
Does cancellation abort ongoing retries? Should cancellation be treated as a fatal error that prevents further retries? How does the client differentiate between socket timeout and total timeout when cancellation is requested?
34775 reputation · 19 Apr 2022, 18:35 UTC
Calling Future.cancel(true) on an asynchronous Aerospike operation does not inherently abort ongoing retries. The client treats the resulting thread interruption as a timeout error (AerospikeResultCode.TIMEOUT). Whether further retries occur depends entirely on your configured retry policy: if retryOnTimeout is set to true, the client may continue retrying until maxRetries is reached, regardless of the cancellation request. The client does not provide a distinct error code to differentiate between a socket timeout and a total timeout when a cancellation is requested.
AerospikeException with resultCode == AerospikeResultCode.TIMEOUT (error code -1) and the message "Timeout".Future.cancel(true) attempts to interrupt the Netty worker thread. This is a best-effort operation and does not guarantee that the in-flight request is aborted on the server side.retryOnTimeout flag is false.It is assumed that the behavior observed is consistent with the standard Netty-based asynchronous implementation of the Java client. However, because thread interruption is best-effort, the exact timing of when the TIMEOUT error is thrown relative to server processing can vary under heavy load, potentially leading to inconsistent observations of "fatal" vs "retryable" behavior.
DEBUG level logging for the Aerospike client to trace thread interruptions and retry attempts.socketTimeout (e.g., 10ms) while simulating server delay.Future.cancel(true) on the returned future.AerospikeException and inspect exception.getCause() to determine if the underlying trigger was a java.util.concurrent.TimeoutException or a Netty-specific timeout.AerospikeMetrics (specifically retry_count and timeout_count) to verify if a retry was triggered despite the cancellation.To determine if your specific configuration treats cancellation as fatal, please provide the current value of retryOnTimeout in your WritePolicy or ReadPolicy. If this is true, the client will not treat cancellation as a fatal error that prevents further retries.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.