Skip to content

Commit db801cf

Browse files
Marcelo Vanzindongjoon-hyun
authored andcommitted
[SPARK-27219][CORE] Treat timeouts as fatal in SASL fallback path.
When a timeout happens we don't know what's the state of the remote end, so there is no point in doing anything else since it will most probably fail anyway. The change also demotes the log message printed when falling back to SASL, since a warning is too noisy for when the fallback is really needed (e.g. old shuffle service, or shuffle service with new auth disabled). Closes apache#24160 from vanzin/SPARK-27219. Authored-by: Marcelo Vanzin <[email protected]> Signed-off-by: Dongjoon Hyun <[email protected]>
1 parent 84ec06d commit db801cf

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

common/network-common/src/main/java/org/apache/spark/network/crypto/AuthClientBootstrap.java

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import java.io.IOException;
2121
import java.nio.ByteBuffer;
2222
import java.security.GeneralSecurityException;
23+
import java.util.concurrent.TimeoutException;
2324

2425
import com.google.common.base.Throwables;
2526
import io.netty.buffer.ByteBuf;
@@ -82,13 +83,19 @@ public void doBootstrap(TransportClient client, Channel channel) {
8283
} catch (RuntimeException e) {
8384
// There isn't a good exception that can be caught here to know whether it's really
8485
// OK to switch back to SASL (because the server doesn't speak the new protocol). So
85-
// try it anyway, and in the worst case things will fail again.
86-
if (conf.saslFallback()) {
87-
LOG.warn("New auth protocol failed, trying SASL.", e);
88-
doSaslAuth(client, channel);
89-
} else {
86+
// try it anyway, unless it's a timeout, which is locally fatal. In the worst case
87+
// things will fail again.
88+
if (!conf.saslFallback() || e.getCause() instanceof TimeoutException) {
9089
throw e;
9190
}
91+
92+
if (LOG.isDebugEnabled()) {
93+
Throwable cause = e.getCause() != null ? e.getCause() : e;
94+
LOG.debug("New auth protocol failed, trying SASL.", cause);
95+
} else {
96+
LOG.info("New auth protocol failed, trying SASL.");
97+
}
98+
doSaslAuth(client, channel);
9299
}
93100
}
94101

0 commit comments

Comments
 (0)