Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagec#
titleUser-implemented retry logic
while (maxRetries-- > 0)
{
    try
    {
        cache.Put(1, "Hello");
        break;
    }
    catch (Exception e) when (e.GetBaseException() is SocketException)
    {
        // Retry.
    }
}

...

Summary

  • Java thin client has retry, but it can be dangerous and can't be fine-tuned.
  • Other thin client clients don't have retry and the user has to write cumbersome code.

Proposal

TODO: ClientRetryPolicy interface.

Risks and Assumptions

1. Introduce ClientRetryPolicy interface


Code Block
languagejava
titleClientRetryPolicy.java
/**
 * Client retry policy determines whether client operations that have failed due to a connection issue should be retried.
 */
public interface ClientRetryPolicy {
    /**
     * Gets a value indicating whether a client operation that has failed due to a connection issue should be retried.
     *
     * @param client Ignite client instance.
     * @param operationType Operation type.
     * @param iteration Current iteration index (greater or equal to 0).
     * @param exception Exception that caused the operation to fail.
     * @return {@code true} if the operation should be retried on another connection, {@code false} otherwise.
     */
    public boolean shouldRetry(IgniteClient client, ClientOperationType operationType, int iteration, ClientConnectionException exception);
}


2. Provide predefined implementations, for example: ClientRetryAllPolicy, ClientRetryReadPolicy, ClientRetryIdempotentPolicy

3. Add corresponding property to the client configuration.

Risks and Assumptions

Ideally, we could pass more information to the shouldRetry method: cache keys and values, SQL query text, and so on, according to the operation at hand. However, this will require extra heap allocations - for every client method call, we'll need to store the arguments somewhere. This means overhead for the entire thin client API, which is not acceptable. We could also make this behavior optional with a property like ClientRetryPolicy.requiresArguments. For now, this is considered out of scope// Describe project risks, such as API or binary compatibility issues, major protocol changes, etc.

Discussion Links

// Links to discussions on the devlist, if applicable.

Reference Links

// Links to various reference documents, if applicable.

Tickets

// TODO: Links or report with relevant JIRA tickets.