[XdsClient] do async hop when unreffing gRPC transport (#34197)

Possible fix for deadlock described in b/297601540.
pull/34202/head
Mark D. Roth 2 years ago committed by GitHub
parent f6a994229e
commit 1305f1a5e5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 12
      src/core/ext/xds/xds_transport_grpc.cc

@ -28,6 +28,7 @@
#include <grpc/byte_buffer.h>
#include <grpc/byte_buffer_reader.h>
#include <grpc/event_engine/event_engine.h>
#include <grpc/grpc.h>
#include <grpc/impl/channel_arg_names.h>
#include <grpc/impl/connectivity_state.h>
@ -42,11 +43,13 @@
#include "src/core/lib/channel/channel_fwd.h"
#include "src/core/lib/channel/channel_stack.h"
#include "src/core/lib/config/core_configuration.h"
#include "src/core/lib/event_engine/default_event_engine.h"
#include "src/core/lib/gprpp/debug_location.h"
#include "src/core/lib/gprpp/orphanable.h"
#include "src/core/lib/gprpp/ref_counted_ptr.h"
#include "src/core/lib/gprpp/time.h"
#include "src/core/lib/iomgr/closure.h"
#include "src/core/lib/iomgr/exec_ctx.h"
#include "src/core/lib/iomgr/pollset_set.h"
#include "src/core/lib/security/credentials/channel_creds_registry.h"
#include "src/core/lib/security/credentials/credentials.h"
@ -302,7 +305,14 @@ void GrpcXdsTransportFactory::GrpcXdsTransport::Orphan() {
GPR_ASSERT(client_channel != nullptr);
client_channel->RemoveConnectivityWatcher(watcher_);
}
Unref();
// Do an async hop before unreffing. This avoids a deadlock upon
// shutdown in the case where the xDS channel is itself an xDS channel
// (e.g., when using one control plane to find another control plane).
grpc_event_engine::experimental::GetDefaultEventEngine()->Run([this]() {
ApplicationCallbackExecCtx application_exec_ctx;
ExecCtx exec_ctx;
Unref();
});
}
OrphanablePtr<XdsTransportFactory::XdsTransport::StreamingCall>

Loading…
Cancel
Save