amogh-jahagirdar commented on code in PR #10458:
URL: https://github.com/apache/iceberg/pull/10458#discussion_r1630572426
##########
core/src/main/java/org/apache/iceberg/ClientPoolImpl.java:
##########
@@ -67,30 +71,27 @@ public <R> R run(Action<R, C, E> action) throws E,
InterruptedException {
@Override
public <R> R run(Action<R, C, E> action, boolean retry) throws E,
InterruptedException {
- C client = get();
- try {
- return action.run(client);
- } catch (Exception exc) {
- if (retry && isConnectionException(exc)) {
- int retryAttempts = 0;
- while (retryAttempts < maxRetries) {
- try {
- client = reconnect(client);
- return action.run(client);
- } catch (Exception e) {
- if (isConnectionException(e)) {
- retryAttempts++;
- Thread.sleep(connectionRetryWaitPeriodMs);
- } else {
- throw reconnectExc.cast(exc);
- }
- }
- }
- }
+ AtomicReference<C> clientReference = new AtomicReference<>();
+ clientReference.set(get());
+
+ RetryPolicy<Object> retryPolicy =
+ RetryPolicy.builder()
+ .handle(reconnectExc)
+ .withMaxRetries(retry ? maxRetries : 0)
+ .withDelay(Duration.ofMillis(connectionRetryWaitPeriodMs))
+ .onRetry(
+ exc -> {
+ C currentClient = clientReference.get();
+ clientReference.set(reconnect(currentClient));
+ })
+ .build();
Review Comment:
This change will also impact the JDBC catalog, since that uses
ClientPoolImpl as well. CC @jbonofre if you were interested in taking a look at
this, and would like your perspective on introducing Failsafe here.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]