Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core: Clear ConfigSelector in panic mode #9272

Merged
merged 1 commit into from Jun 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions core/src/main/java/io/grpc/internal/ManagedChannelImpl.java
Expand Up @@ -887,6 +887,7 @@ public String toString() {
}

updateSubchannelPicker(new PanicSubchannelPicker());
realChannel.updateConfigSelector(null);
channelLogger.log(ChannelLogLevel.ERROR, "PANIC! Entering TRANSIENT_FAILURE");
channelStateManager.gotoState(TRANSIENT_FAILURE);
}
Expand Down Expand Up @@ -1755,6 +1756,9 @@ final class NamesResolved implements Runnable {
@SuppressWarnings("ReferenceEquality")
@Override
public void run() {
if (ManagedChannelImpl.this.nameResolver != resolver) {
return;
}

List<EquivalentAddressGroup> servers = resolutionResult.getAddresses();
channelLogger.log(
Expand Down
34 changes: 34 additions & 0 deletions core/src/test/java/io/grpc/internal/ManagedChannelImplTest.java
Expand Up @@ -2799,6 +2799,40 @@ public void run() {
panicExpected = true;
}

@Test
public void panic_atStart() {
final RuntimeException panicReason = new RuntimeException("Simulated NR exception");
final NameResolver failingResolver = new NameResolver() {
@Override public String getServiceAuthority() {
return "fake-authority";
}

@Override public void start(Listener2 listener) {
throw panicReason;
}

@Override public void shutdown() {}
};
channelBuilder.nameResolverFactory(new NameResolver.Factory() {
@Override public NameResolver newNameResolver(URI targetUri, NameResolver.Args args) {
return failingResolver;
}

@Override public String getDefaultScheme() {
return "fakescheme";
}
});
createChannel();

// RPCs fail immediately
ClientCall<String, Integer> call =
channel.newCall(method, CallOptions.DEFAULT.withoutWaitForReady());
call.start(mockCallListener, new Metadata());
executor.runDueTasks();
verifyCallListenerClosed(mockCallListener, Status.Code.INTERNAL, panicReason);
panicExpected = true;
}

private void verifyPanicMode(Throwable cause) {
panicExpected = true;
@SuppressWarnings("unchecked")
Expand Down