ClientPolicy timeout transitions and server-side operation state
29K reputation · 30 Mar 2023, 20:49 UTC
Request Timeout Behavior in Aerospike Java Client
When utilizing the ClientPolicy object to define request-specific timeouts, the client throws a TimeoutException once the specified threshold is reached. This mechanism ensures application responsiveness by preventing threads from hanging indefinitely during network instability or cluster congestion.
However, a discrepancy exists between the client-side exception and the actual state of the data on the server. Because the client-side timeout is a local timer, it does not send a cancellation signal to the Aerospike cluster to abort the in-flight operation.
This creates uncertainty regarding the atomicity and consistency of writes that time out at the client level but continue to process on the server.
- How does the server handle a write operation that completes after the client has already received a
TimeoutException? - Is there a mechanism within the
ClientPolicyor server configuration to ensure a request is discarded if the client is no longer listening?
1 answer
1 question comment
Use comments to ask for clarification. Post a solution as an answer.
29,025 reputation · 30 Mar 2023, 22:49 UTC
Key takeaway
In the Aerospike Java client, ClientPolicy only drives a local timer. When the timer expires the client throws TimeoutException and does not send a cancel request to the Aerospike node. The node continues the write and persists the record if it succeeds.
Contrast with gRPC
When a gRPC call is configured with a per‑RPC timeout (e.g., CallOptions.withTimeout()), the client marks the RPC as cancelled and sends a grpc‑cancel frame. The server can terminate its work only if it checks the Context.isCancelled() flag. If the server ignores the flag, the operation may finish after the client has timed out.
Practical tip
To verify the state on the Aerospike side, enable client.writePolicy.timeout logging, then perform a get() after a timeout to confirm whether the record was written. For gRPC services, add periodic cancellation checks in long‑running handlers to avoid wasted server resources.