Merge pull request #19624 from hcaseyal/channelz_sockets

Track channelz server sockets in the server node
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 8dfa4e8..a68f5ca 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -638,6 +638,9 @@
 add_dependencies(buildtests_cxx grpc_tool_test)
 add_dependencies(buildtests_cxx grpclb_api_test)
 add_dependencies(buildtests_cxx grpclb_end2end_test)
+if(_gRPC_PLATFORM_LINUX)
+add_dependencies(buildtests_cxx grpclb_fallback_test)
+endif()
 add_dependencies(buildtests_cxx h2_ssl_cert_test)
 add_dependencies(buildtests_cxx h2_ssl_session_reuse_test)
 add_dependencies(buildtests_cxx health_service_end2end_test)
@@ -14467,6 +14470,70 @@
 
 endif (gRPC_BUILD_TESTS)
 if (gRPC_BUILD_TESTS)
+if(_gRPC_PLATFORM_LINUX)
+
+add_executable(grpclb_fallback_test
+  ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/empty.pb.cc
+  ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/empty.grpc.pb.cc
+  ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/empty.pb.h
+  ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/empty.grpc.pb.h
+  ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/messages.pb.cc
+  ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/messages.grpc.pb.cc
+  ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/messages.pb.h
+  ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/messages.grpc.pb.h
+  ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/test.pb.cc
+  ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/test.grpc.pb.cc
+  ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/test.pb.h
+  ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/test.grpc.pb.h
+  test/cpp/interop/grpclb_fallback_test.cc
+  third_party/googletest/googletest/src/gtest-all.cc
+  third_party/googletest/googlemock/src/gmock-all.cc
+)
+
+protobuf_generate_grpc_cpp(
+  src/proto/grpc/testing/empty.proto
+)
+protobuf_generate_grpc_cpp(
+  src/proto/grpc/testing/messages.proto
+)
+protobuf_generate_grpc_cpp(
+  src/proto/grpc/testing/test.proto
+)
+
+target_include_directories(grpclb_fallback_test
+  PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
+  PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
+  PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
+  PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
+  PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
+  PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
+  PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
+  PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
+  PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR}
+  PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR}
+  PRIVATE third_party/googletest/googletest/include
+  PRIVATE third_party/googletest/googletest
+  PRIVATE third_party/googletest/googlemock/include
+  PRIVATE third_party/googletest/googlemock
+  PRIVATE ${_gRPC_PROTO_GENS_DIR}
+)
+
+target_link_libraries(grpclb_fallback_test
+  ${_gRPC_PROTOBUF_LIBRARIES}
+  ${_gRPC_ALLTARGETS_LIBRARIES}
+  grpc++_test_util
+  grpc_test_util
+  grpc++
+  grpc
+  gpr
+  grpc++_test_config
+  ${_gRPC_GFLAGS_LIBRARIES}
+)
+
+
+endif()
+endif (gRPC_BUILD_TESTS)
+if (gRPC_BUILD_TESTS)
 
 add_executable(h2_ssl_cert_test
   test/core/end2end/h2_ssl_cert_test.cc
diff --git a/Makefile b/Makefile
index 2a1bfad..952b201 100644
--- a/Makefile
+++ b/Makefile
@@ -1228,6 +1228,7 @@
 grpc_tool_test: $(BINDIR)/$(CONFIG)/grpc_tool_test
 grpclb_api_test: $(BINDIR)/$(CONFIG)/grpclb_api_test
 grpclb_end2end_test: $(BINDIR)/$(CONFIG)/grpclb_end2end_test
+grpclb_fallback_test: $(BINDIR)/$(CONFIG)/grpclb_fallback_test
 h2_ssl_cert_test: $(BINDIR)/$(CONFIG)/h2_ssl_cert_test
 h2_ssl_session_reuse_test: $(BINDIR)/$(CONFIG)/h2_ssl_session_reuse_test
 health_service_end2end_test: $(BINDIR)/$(CONFIG)/health_service_end2end_test
@@ -1697,6 +1698,7 @@
   $(BINDIR)/$(CONFIG)/grpc_tool_test \
   $(BINDIR)/$(CONFIG)/grpclb_api_test \
   $(BINDIR)/$(CONFIG)/grpclb_end2end_test \
+  $(BINDIR)/$(CONFIG)/grpclb_fallback_test \
   $(BINDIR)/$(CONFIG)/h2_ssl_cert_test \
   $(BINDIR)/$(CONFIG)/h2_ssl_session_reuse_test \
   $(BINDIR)/$(CONFIG)/health_service_end2end_test \
@@ -1862,6 +1864,7 @@
   $(BINDIR)/$(CONFIG)/grpc_tool_test \
   $(BINDIR)/$(CONFIG)/grpclb_api_test \
   $(BINDIR)/$(CONFIG)/grpclb_end2end_test \
+  $(BINDIR)/$(CONFIG)/grpclb_fallback_test \
   $(BINDIR)/$(CONFIG)/h2_ssl_cert_test \
   $(BINDIR)/$(CONFIG)/h2_ssl_session_reuse_test \
   $(BINDIR)/$(CONFIG)/health_service_end2end_test \
@@ -2366,6 +2369,8 @@
 	$(Q) $(BINDIR)/$(CONFIG)/grpclb_api_test || ( echo test grpclb_api_test failed ; exit 1 )
 	$(E) "[RUN]     Testing grpclb_end2end_test"
 	$(Q) $(BINDIR)/$(CONFIG)/grpclb_end2end_test || ( echo test grpclb_end2end_test failed ; exit 1 )
+	$(E) "[RUN]     Testing grpclb_fallback_test"
+	$(Q) $(BINDIR)/$(CONFIG)/grpclb_fallback_test || ( echo test grpclb_fallback_test failed ; exit 1 )
 	$(E) "[RUN]     Testing h2_ssl_cert_test"
 	$(Q) $(BINDIR)/$(CONFIG)/h2_ssl_cert_test || ( echo test h2_ssl_cert_test failed ; exit 1 )
 	$(E) "[RUN]     Testing h2_ssl_session_reuse_test"
@@ -17488,6 +17493,59 @@
 $(OBJDIR)/$(CONFIG)/test/cpp/end2end/grpclb_end2end_test.o: $(GENDIR)/src/proto/grpc/lb/v1/load_balancer.pb.cc $(GENDIR)/src/proto/grpc/lb/v1/load_balancer.grpc.pb.cc
 
 
+GRPCLB_FALLBACK_TEST_SRC = \
+    $(GENDIR)/src/proto/grpc/testing/empty.pb.cc $(GENDIR)/src/proto/grpc/testing/empty.grpc.pb.cc \
+    $(GENDIR)/src/proto/grpc/testing/messages.pb.cc $(GENDIR)/src/proto/grpc/testing/messages.grpc.pb.cc \
+    $(GENDIR)/src/proto/grpc/testing/test.pb.cc $(GENDIR)/src/proto/grpc/testing/test.grpc.pb.cc \
+    test/cpp/interop/grpclb_fallback_test.cc \
+
+GRPCLB_FALLBACK_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(GRPCLB_FALLBACK_TEST_SRC))))
+ifeq ($(NO_SECURE),true)
+
+# You can't build secure targets if you don't have OpenSSL.
+
+$(BINDIR)/$(CONFIG)/grpclb_fallback_test: openssl_dep_error
+
+else
+
+
+
+
+ifeq ($(NO_PROTOBUF),true)
+
+# You can't build the protoc plugins or protobuf-enabled targets if you don't have protobuf 3.5.0+.
+
+$(BINDIR)/$(CONFIG)/grpclb_fallback_test: protobuf_dep_error
+
+else
+
+$(BINDIR)/$(CONFIG)/grpclb_fallback_test: $(PROTOBUF_DEP) $(GRPCLB_FALLBACK_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a
+	$(E) "[LD]      Linking $@"
+	$(Q) mkdir -p `dirname $@`
+	$(Q) $(LDXX) $(LDFLAGS) $(GRPCLB_FALLBACK_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/grpclb_fallback_test
+
+endif
+
+endif
+
+$(OBJDIR)/$(CONFIG)/src/proto/grpc/testing/empty.o:  $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a
+
+$(OBJDIR)/$(CONFIG)/src/proto/grpc/testing/messages.o:  $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a
+
+$(OBJDIR)/$(CONFIG)/src/proto/grpc/testing/test.o:  $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a
+
+$(OBJDIR)/$(CONFIG)/test/cpp/interop/grpclb_fallback_test.o:  $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a
+
+deps_grpclb_fallback_test: $(GRPCLB_FALLBACK_TEST_OBJS:.o=.dep)
+
+ifneq ($(NO_SECURE),true)
+ifneq ($(NO_DEPS),true)
+-include $(GRPCLB_FALLBACK_TEST_OBJS:.o=.dep)
+endif
+endif
+$(OBJDIR)/$(CONFIG)/test/cpp/interop/grpclb_fallback_test.o: $(GENDIR)/src/proto/grpc/testing/empty.pb.cc $(GENDIR)/src/proto/grpc/testing/empty.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/messages.pb.cc $(GENDIR)/src/proto/grpc/testing/messages.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/test.pb.cc $(GENDIR)/src/proto/grpc/testing/test.grpc.pb.cc
+
+
 H2_SSL_CERT_TEST_SRC = \
     test/core/end2end/h2_ssl_cert_test.cc \
 
diff --git a/build.yaml b/build.yaml
index 5915b9c..c36b3c7 100644
--- a/build.yaml
+++ b/build.yaml
@@ -5041,6 +5041,23 @@
   - grpc++
   - grpc
   - gpr
+- name: grpclb_fallback_test
+  build: test
+  language: c++
+  src:
+  - src/proto/grpc/testing/empty.proto
+  - src/proto/grpc/testing/messages.proto
+  - src/proto/grpc/testing/test.proto
+  - test/cpp/interop/grpclb_fallback_test.cc
+  deps:
+  - grpc++_test_util
+  - grpc_test_util
+  - grpc++
+  - grpc
+  - gpr
+  - grpc++_test_config
+  platforms:
+  - linux
 - name: h2_ssl_cert_test
   gtest: true
   build: test
diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec
index 340c7b4..2dfcb31 100644
--- a/gRPC-Core.podspec
+++ b/gRPC-Core.podspec
@@ -1387,8 +1387,7 @@
 
   # TODO (mxyan): Instead of this hack, add include path "third_party" to C core's include path?
   s.prepare_command = <<-END_OF_COMMAND
-    find src/core/ -type f ! -path '*.grpc_back' -print0 | xargs -0 -L1 sed -E -i'.grpc_back' 's;#include "(pb(_.*)?\\.h)";#include <nanopb/\\1>;g'
-    find src/core/ -type f -path '*.grpc_back' -print0 | xargs -0 rm
-    find src/core/ -type f \\( -path '*.h' -or -path '*.cc' \\) -print0 | xargs -0 -L1 sed -E -i'.grpc_back' 's;#include <openssl/;#include <openssl_grpc/;g'
+    find src/core/ -type f -print0 | xargs -0 -L1 sed -E -i '' 's;#include "(pb(_.*)?\\.h)";#if COCOAPODS\\\n  #include <nanopb/\\1>\\\n#else\\\n  #include "\\1"\\\n#endif;g'
+    find src/core/ -type f \\( -path '*.h' -or -path '*.cc' \\) -print0 | xargs -0 -L1 sed -E -i '' 's;#include <openssl/(.*)>;#if COCOAPODS\\\n  #include <openssl_grpc/\\1>\\\n#else\\\n  #include <openssl/\\1>\\\n#endif;g'
   END_OF_COMMAND
 end
diff --git a/src/core/lib/gprpp/debug_location.h b/src/core/lib/gprpp/debug_location.h
index 287761b..d2384fd 100644
--- a/src/core/lib/gprpp/debug_location.h
+++ b/src/core/lib/gprpp/debug_location.h
@@ -25,10 +25,12 @@
 // No-op for non-debug builds.
 // Callers can use the DEBUG_LOCATION macro in either case.
 #ifndef NDEBUG
+// TODO(roth): See if there's a way to automatically populate this,
+// similarly to how absl::SourceLocation::current() works, so that
+// callers don't need to explicitly pass DEBUG_LOCATION anywhere.
 class DebugLocation {
  public:
   DebugLocation(const char* file, int line) : file_(file), line_(line) {}
-  bool Log() const { return true; }
   const char* file() const { return file_; }
   int line() const { return line_; }
 
@@ -40,7 +42,6 @@
 #else
 class DebugLocation {
  public:
-  bool Log() const { return false; }
   const char* file() const { return nullptr; }
   int line() const { return -1; }
 };
diff --git a/src/core/lib/gprpp/ref_counted.h b/src/core/lib/gprpp/ref_counted.h
index cab1aaa..5c7a5cf 100644
--- a/src/core/lib/gprpp/ref_counted.h
+++ b/src/core/lib/gprpp/ref_counted.h
@@ -89,72 +89,114 @@
   }
 
   // Increases the ref-count by `n`.
-  void Ref(Value n = 1) { value_.FetchAdd(n, MemoryOrder::RELAXED); }
+  void Ref(Value n = 1) {
+#ifndef NDEBUG
+    const Value prior = value_.FetchAdd(n, MemoryOrder::RELAXED);
+    if (trace_flag_ != nullptr && trace_flag_->enabled()) {
+      gpr_log(GPR_INFO, "%s:%p ref %" PRIdPTR " -> %" PRIdPTR,
+              trace_flag_->name(), this, prior, prior + n);
+    }
+#else
+    value_.FetchAdd(n, MemoryOrder::RELAXED);
+#endif
+  }
   void Ref(const DebugLocation& location, const char* reason, Value n = 1) {
 #ifndef NDEBUG
-    if (location.Log() && trace_flag_ != nullptr && trace_flag_->enabled()) {
-      const RefCount::Value old_refs = get();
+    const Value prior = value_.FetchAdd(n, MemoryOrder::RELAXED);
+    if (trace_flag_ != nullptr && trace_flag_->enabled()) {
       gpr_log(GPR_INFO, "%s:%p %s:%d ref %" PRIdPTR " -> %" PRIdPTR " %s",
               trace_flag_->name(), this, location.file(), location.line(),
-              old_refs, old_refs + n, reason);
+              prior, prior + n, reason);
     }
+#else
+    value_.FetchAdd(n, MemoryOrder::RELAXED);
 #endif
-    Ref(n);
   }
 
   // Similar to Ref() with an assert on the ref-count being non-zero.
   void RefNonZero() {
 #ifndef NDEBUG
     const Value prior = value_.FetchAdd(1, MemoryOrder::RELAXED);
+    if (trace_flag_ != nullptr && trace_flag_->enabled()) {
+      gpr_log(GPR_INFO, "%s:%p ref %" PRIdPTR " -> %" PRIdPTR,
+              trace_flag_->name(), this, prior, prior + 1);
+    }
     assert(prior > 0);
 #else
-    Ref();
+    value_.FetchAdd(1, MemoryOrder::RELAXED);
 #endif
   }
   void RefNonZero(const DebugLocation& location, const char* reason) {
 #ifndef NDEBUG
-    if (location.Log() && trace_flag_ != nullptr && trace_flag_->enabled()) {
-      const RefCount::Value old_refs = get();
+    const Value prior = value_.FetchAdd(1, MemoryOrder::RELAXED);
+    if (trace_flag_ != nullptr && trace_flag_->enabled()) {
       gpr_log(GPR_INFO, "%s:%p %s:%d ref %" PRIdPTR " -> %" PRIdPTR " %s",
               trace_flag_->name(), this, location.file(), location.line(),
-              old_refs, old_refs + 1, reason);
+              prior, prior + 1, reason);
     }
-#endif
+    assert(prior > 0);
+#else
     RefNonZero();
+#endif
   }
 
-  bool RefIfNonZero() { return value_.IncrementIfNonzero(); }
-
+  bool RefIfNonZero() {
+#ifndef NDEBUG
+    if (trace_flag_ != nullptr && trace_flag_->enabled()) {
+      const Value prior = get();
+      gpr_log(GPR_INFO, "%s:%p ref_if_non_zero %" PRIdPTR " -> %" PRIdPTR,
+              trace_flag_->name(), this, prior, prior + 1);
+    }
+#endif
+    return value_.IncrementIfNonzero();
+  }
   bool RefIfNonZero(const DebugLocation& location, const char* reason) {
 #ifndef NDEBUG
-    if (location.Log() && trace_flag_ != nullptr && trace_flag_->enabled()) {
-      const RefCount::Value old_refs = get();
+    if (trace_flag_ != nullptr && trace_flag_->enabled()) {
+      const Value prior = get();
       gpr_log(GPR_INFO,
               "%s:%p %s:%d ref_if_non_zero "
               "%" PRIdPTR " -> %" PRIdPTR " %s",
               trace_flag_->name(), this, location.file(), location.line(),
-              old_refs, old_refs + 1, reason);
+              prior, prior + 1, reason);
     }
 #endif
-    return RefIfNonZero();
+    return value_.IncrementIfNonzero();
   }
 
   // Decrements the ref-count and returns true if the ref-count reaches 0.
   bool Unref() {
+#ifndef NDEBUG
+    // Grab a copy of the trace flag before the atomic change, since we
+    // can't safely access it afterwards if we're going to be freed.
+    auto* trace_flag = trace_flag_;
+#endif
     const Value prior = value_.FetchSub(1, MemoryOrder::ACQ_REL);
+#ifndef NDEBUG
+    if (trace_flag != nullptr && trace_flag->enabled()) {
+      gpr_log(GPR_INFO, "%s:%p unref %" PRIdPTR " -> %" PRIdPTR,
+              trace_flag->name(), this, prior, prior - 1);
+    }
     GPR_DEBUG_ASSERT(prior > 0);
+#endif
     return prior == 1;
   }
   bool Unref(const DebugLocation& location, const char* reason) {
 #ifndef NDEBUG
-    if (location.Log() && trace_flag_ != nullptr && trace_flag_->enabled()) {
-      const RefCount::Value old_refs = get();
-      gpr_log(GPR_INFO, "%s:%p %s:%d unref %" PRIdPTR " -> %" PRIdPTR " %s",
-              trace_flag_->name(), this, location.file(), location.line(),
-              old_refs, old_refs - 1, reason);
-    }
+    // Grab a copy of the trace flag before the atomic change, since we
+    // can't safely access it afterwards if we're going to be freed.
+    auto* trace_flag = trace_flag_;
 #endif
-    return Unref();
+    const Value prior = value_.FetchSub(1, MemoryOrder::ACQ_REL);
+#ifndef NDEBUG
+    if (trace_flag != nullptr && trace_flag->enabled()) {
+      gpr_log(GPR_INFO, "%s:%p %s:%d unref %" PRIdPTR " -> %" PRIdPTR " %s",
+              trace_flag->name(), this, location.file(), location.line(), prior,
+              prior - 1, reason);
+    }
+    GPR_DEBUG_ASSERT(prior > 0);
+#endif
+    return prior == 1;
   }
 
  private:
diff --git a/src/core/lib/transport/byte_stream.cc b/src/core/lib/transport/byte_stream.cc
index 16b85ca..1dd234c 100644
--- a/src/core/lib/transport/byte_stream.cc
+++ b/src/core/lib/transport/byte_stream.cc
@@ -55,17 +55,15 @@
 
 bool SliceBufferByteStream::Next(size_t max_size_hint,
                                  grpc_closure* on_complete) {
-  GPR_ASSERT(cursor_ < backing_buffer_.count);
+  GPR_DEBUG_ASSERT(backing_buffer_.count > 0);
   return true;
 }
 
 grpc_error* SliceBufferByteStream::Pull(grpc_slice* slice) {
-  if (shutdown_error_ != GRPC_ERROR_NONE) {
+  if (GPR_UNLIKELY(shutdown_error_ != GRPC_ERROR_NONE)) {
     return GRPC_ERROR_REF(shutdown_error_);
   }
-  GPR_ASSERT(cursor_ < backing_buffer_.count);
-  *slice = grpc_slice_ref_internal(backing_buffer_.slices[cursor_]);
-  ++cursor_;
+  *slice = grpc_slice_buffer_take_first(&backing_buffer_);
   return GRPC_ERROR_NONE;
 }
 
diff --git a/src/core/lib/transport/byte_stream.h b/src/core/lib/transport/byte_stream.h
index eff8325..0650301 100644
--- a/src/core/lib/transport/byte_stream.h
+++ b/src/core/lib/transport/byte_stream.h
@@ -99,9 +99,8 @@
   void Shutdown(grpc_error* error) override;
 
  private:
-  grpc_slice_buffer backing_buffer_;
-  size_t cursor_ = 0;
   grpc_error* shutdown_error_ = GRPC_ERROR_NONE;
+  grpc_slice_buffer backing_buffer_;
 };
 
 //
diff --git a/src/csharp/Grpc.Core.Tests/CallCancellationTest.cs b/src/csharp/Grpc.Core.Tests/CallCancellationTest.cs
index e040f52..753b8b2 100644
--- a/src/csharp/Grpc.Core.Tests/CallCancellationTest.cs
+++ b/src/csharp/Grpc.Core.Tests/CallCancellationTest.cs
@@ -178,5 +178,16 @@
                 Assert.AreEqual(StatusCode.Cancelled, ex.Status.StatusCode);
             }
         }
+
+        [Test]
+        public void CanDisposeDefaultCancellationRegistration()
+        {
+            // prove that we're fine to dispose default CancellationTokenRegistration
+            // values without boxing them to IDisposable for a null-check
+            var obj = default(CancellationTokenRegistration);
+            obj.Dispose();
+
+            using (obj) {}
+        }
     }
 }
diff --git a/src/csharp/Grpc.Core/Internal/AsyncCall.cs b/src/csharp/Grpc.Core/Internal/AsyncCall.cs
index a1c6881..ce3508d 100644
--- a/src/csharp/Grpc.Core/Internal/AsyncCall.cs
+++ b/src/csharp/Grpc.Core/Internal/AsyncCall.cs
@@ -38,7 +38,7 @@
         bool registeredWithChannel;
 
         // Dispose of to de-register cancellation token registration
-        IDisposable cancellationTokenRegistration;
+        CancellationTokenRegistration cancellationTokenRegistration;
 
         // Completion of a pending unary response if not null.
         TaskCompletionSource<TResponse> unaryResponseTcs;
@@ -409,7 +409,7 @@
             // deadlock.
             // See https://github.com/grpc/grpc/issues/14777
             // See https://github.com/dotnet/corefx/issues/14903
-            cancellationTokenRegistration?.Dispose();
+            cancellationTokenRegistration.Dispose();
         }
 
         protected override bool IsClient
@@ -509,11 +509,7 @@
         // Make sure that once cancellationToken for this call is cancelled, Cancel() will be called.
         private void RegisterCancellationCallback()
         {
-            var token = details.Options.CancellationToken;
-            if (token.CanBeCanceled)
-            {
-                cancellationTokenRegistration = token.Register(() => this.Cancel());
-            }
+            cancellationTokenRegistration = RegisterCancellationCallbackForToken(details.Options.CancellationToken);
         }
 
         /// <summary>
diff --git a/src/csharp/Grpc.Core/Internal/AsyncCallBase.cs b/src/csharp/Grpc.Core/Internal/AsyncCallBase.cs
index 0b99aaf..ac1f906 100644
--- a/src/csharp/Grpc.Core/Internal/AsyncCallBase.cs
+++ b/src/csharp/Grpc.Core/Internal/AsyncCallBase.cs
@@ -394,5 +394,13 @@
         {
             HandleReadFinished(success, receivedMessageReader);
         }
+
+        internal CancellationTokenRegistration RegisterCancellationCallbackForToken(CancellationToken cancellationToken)
+        {
+            if (cancellationToken.CanBeCanceled) return cancellationToken.Register(CancelCallFromToken, this);
+            return default(CancellationTokenRegistration);
+        }
+
+        private static readonly Action<object> CancelCallFromToken = state => ((AsyncCallBase<TWrite, TRead>)state).Cancel();
     }
 }
diff --git a/src/csharp/Grpc.Core/Internal/ClientResponseStream.cs b/src/csharp/Grpc.Core/Internal/ClientResponseStream.cs
index ab649ee..ff73b26 100644
--- a/src/csharp/Grpc.Core/Internal/ClientResponseStream.cs
+++ b/src/csharp/Grpc.Core/Internal/ClientResponseStream.cs
@@ -49,8 +49,7 @@
 
         public async Task<bool> MoveNext(CancellationToken token)
         {
-            var cancellationTokenRegistration = token.CanBeCanceled ? token.Register(() => call.Cancel()) : (IDisposable) null;
-            using (cancellationTokenRegistration)
+            using (call.RegisterCancellationCallbackForToken(token))
             {
                 var result = await call.ReadMessageAsync().ConfigureAwait(false);
                 this.current = result;
diff --git a/src/csharp/Grpc.Core/Internal/ServerRequestStream.cs b/src/csharp/Grpc.Core/Internal/ServerRequestStream.cs
index 058dddb..f365513 100644
--- a/src/csharp/Grpc.Core/Internal/ServerRequestStream.cs
+++ b/src/csharp/Grpc.Core/Internal/ServerRequestStream.cs
@@ -49,9 +49,7 @@
 
         public async Task<bool> MoveNext(CancellationToken token)
         {
-            
-            var cancellationTokenRegistration = token.CanBeCanceled ? token.Register(() => call.Cancel()) : (IDisposable) null;
-            using (cancellationTokenRegistration)
+            using (call.RegisterCancellationCallbackForToken(token))
             {
                 var result = await call.ReadMessageAsync().ConfigureAwait(false);
                 this.current = result;
diff --git a/src/proto/grpc/testing/messages.proto b/src/proto/grpc/testing/messages.proto
index 3b966ae..4fed83f 100644
--- a/src/proto/grpc/testing/messages.proto
+++ b/src/proto/grpc/testing/messages.proto
@@ -48,6 +48,21 @@
   string message = 2;
 }
 
+// The type of route that a client took to reach a server w.r.t. gRPCLB.
+// The server must fill in "fallback" if it detects that the RPC reached
+// the server via the "gRPCLB fallback" path, and "backend" if it detects
+// that the RPC reached the server via "gRPCLB backend" path (i.e. if it got
+// the address of this server from the gRPCLB server BalanceLoad RPC). Exactly
+// how this detection is done is context and server dependant.
+enum GrpclbRouteType {
+  // Server didn't detect the route that a client took to reach it.
+  GRPCLB_ROUTE_TYPE_UNKNOWN = 0;
+  // Indicates that a client reached a server via gRPCLB fallback.
+  GRPCLB_ROUTE_TYPE_FALLBACK = 1;
+  // Indicates that a client reached a server as a gRPCLB-given backend.
+  GRPCLB_ROUTE_TYPE_BACKEND = 2;
+}
+
 // Unary request.
 message SimpleRequest {
   // Desired payload type in the response from the server.
@@ -80,6 +95,9 @@
 
   // Whether SimpleResponse should include server_id.
   bool fill_server_id = 9;
+
+  // Whether SimpleResponse should include grpclb_route_type.
+  bool fill_grpclb_route_type = 10;
 }
 
 // Unary response, as configured by the request.
@@ -95,6 +113,8 @@
   // Server ID. This must be unique among different server instances,
   // but the same across all RPC's made to a particular server instance.
   string server_id = 4;
+  // gRPCLB Path.
+  GrpclbRouteType grpclb_route_type = 5;
 }
 
 // Client-streaming request.
diff --git a/src/ruby/lib/grpc/generic/rpc_server.rb b/src/ruby/lib/grpc/generic/rpc_server.rb
index 3d34419..a566afa 100644
--- a/src/ruby/lib/grpc/generic/rpc_server.rb
+++ b/src/ruby/lib/grpc/generic/rpc_server.rb
@@ -210,7 +210,7 @@
     # A server arguments hash to be passed down to the underlying core server
     #
     # * interceptors:
-    # Am array of GRPC::ServerInterceptor objects that will be used for
+    # An array of GRPC::ServerInterceptor objects that will be used for
     # intercepting server handlers to provide extra functionality.
     # Interceptors are an EXPERIMENTAL API.
     #
diff --git a/templates/gRPC-Core.podspec.template b/templates/gRPC-Core.podspec.template
index 89a1e91..652c4ed 100644
--- a/templates/gRPC-Core.podspec.template
+++ b/templates/gRPC-Core.podspec.template
@@ -212,8 +212,7 @@
 
     # TODO (mxyan): Instead of this hack, add include path "third_party" to C core's include path?
     s.prepare_command = <<-END_OF_COMMAND
-      find src/core/ -type f ! -path '*.grpc_back' -print0 | xargs -0 -L1 sed -E -i'.grpc_back' 's;#include "(pb(_.*)?\\.h)";#include <nanopb/\\1>;g'
-      find src/core/ -type f -path '*.grpc_back' -print0 | xargs -0 rm
-      find src/core/ -type f \\( -path '*.h' -or -path '*.cc' \\) -print0 | xargs -0 -L1 sed -E -i'.grpc_back' 's;#include <openssl/;#include <openssl_grpc/;g'
+      find src/core/ -type f -print0 | xargs -0 -L1 sed -E -i '' 's;#include "(pb(_.*)?\\.h)";#if COCOAPODS\\\n  #include <nanopb/\\1>\\\n#else\\\n  #include "\\1"\\\n#endif;g'
+      find src/core/ -type f \\( -path '*.h' -or -path '*.cc' \\) -print0 | xargs -0 -L1 sed -E -i '' 's;#include <openssl/(.*)>;#if COCOAPODS\\\n  #include <openssl_grpc/\\1>\\\n#else\\\n  #include <openssl/\\1>\\\n#endif;g'
     END_OF_COMMAND
   end
diff --git a/test/cpp/interop/BUILD b/test/cpp/interop/BUILD
index 802302b..e575ef8 100644
--- a/test/cpp/interop/BUILD
+++ b/test/cpp/interop/BUILD
@@ -39,6 +39,22 @@
 )
 
 grpc_cc_binary(
+    name = "grpclb_fallback_test",
+    srcs = [
+        "grpclb_fallback_test.cc",
+    ],
+    language = "C++",
+    deps = [
+        "//src/proto/grpc/testing:empty_proto",
+        "//src/proto/grpc/testing:messages_proto",
+        "//src/proto/grpc/testing:test_proto",
+        "//test/cpp/util:test_config",
+        "//test/cpp/util:test_util",
+        "//:grpc++",
+    ],
+)
+
+grpc_cc_binary(
     name = "interop_server",
     srcs = [
         "interop_server_bootstrap.cc",
diff --git a/test/cpp/interop/grpclb_fallback_test.cc b/test/cpp/interop/grpclb_fallback_test.cc
new file mode 100644
index 0000000..3622482
--- /dev/null
+++ b/test/cpp/interop/grpclb_fallback_test.cc
@@ -0,0 +1,272 @@
+/*
+ *
+ * Copyright 2019 gRPC authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <grpc/support/port_platform.h>
+
+#include <arpa/inet.h>
+#include <fcntl.h>
+#include <gflags/gflags.h>
+#include <inttypes.h>
+#include <netinet/in.h>
+#include <netinet/tcp.h>
+#include <sys/wait.h>
+#include <unistd.h>
+#include <chrono>
+#include <cstdlib>
+#include <memory>
+#include <string>
+#include <thread>
+
+#include <grpc/support/alloc.h>
+#include <grpc/support/log.h>
+#include <grpcpp/channel.h>
+#include <grpcpp/client_context.h>
+#include <grpcpp/grpcpp.h>
+#include <grpcpp/support/channel_arguments.h>
+
+#include "src/core/lib/gpr/string.h"
+#include "src/core/lib/iomgr/socket_mutator.h"
+#include "src/proto/grpc/testing/empty.pb.h"
+#include "src/proto/grpc/testing/messages.pb.h"
+#include "src/proto/grpc/testing/test.grpc.pb.h"
+#include "src/proto/grpc/testing/test.pb.h"
+
+#include "test/cpp/util/test_config.h"
+#include "test/cpp/util/test_credentials_provider.h"
+
+DEFINE_string(custom_credentials_type, "", "User provided credentials type.");
+DEFINE_string(server_uri, "localhost:1000", "Server URI target");
+DEFINE_string(unroute_lb_and_backend_addrs_cmd, "exit 1",
+              "Shell command used to make LB and backend addresses unroutable");
+DEFINE_string(blackhole_lb_and_backend_addrs_cmd, "exit 1",
+              "Shell command used to make LB and backend addresses blackholed");
+DEFINE_string(
+    test_case, "",
+    "Test case to run. Valid options are:\n\n"
+    "fast_fallback_before_startup : fallback before establishing connection to "
+    "LB;\n"
+    "fast_fallback_after_startup : fallback after startup due to LB/backend "
+    "addresses becoming unroutable;\n"
+    "slow_fallback_before_startup : fallback before startup due to LB address "
+    "being blackholed;\n"
+    "slow_fallback_after_startup : fallback after startup due to LB/backend "
+    "addresses becoming blackholed;\n");
+
+using grpc::testing::GrpclbRouteType;
+using grpc::testing::SimpleRequest;
+using grpc::testing::SimpleResponse;
+using grpc::testing::TestService;
+
+namespace {
+
+enum RpcMode {
+  FailFast,
+  WaitForReady,
+};
+
+GrpclbRouteType DoRPCAndGetPath(TestService::Stub* stub, int deadline_seconds,
+                                RpcMode rpc_mode) {
+  gpr_log(GPR_INFO, "DoRPCAndGetPath deadline_seconds:%d rpc_mode:%d",
+          deadline_seconds, rpc_mode);
+  SimpleRequest request;
+  SimpleResponse response;
+  grpc::ClientContext context;
+  if (rpc_mode == WaitForReady) {
+    context.set_wait_for_ready(true);
+  }
+  request.set_fill_grpclb_route_type(true);
+  std::chrono::system_clock::time_point deadline =
+      std::chrono::system_clock::now() + std::chrono::seconds(deadline_seconds);
+  context.set_deadline(deadline);
+  grpc::Status s = stub->UnaryCall(&context, request, &response);
+  if (!s.ok()) {
+    gpr_log(GPR_INFO, "DoRPCAndGetPath failed. status-message: %s",
+            s.error_message().c_str());
+    return GrpclbRouteType::GRPCLB_ROUTE_TYPE_UNKNOWN;
+  }
+  GPR_ASSERT(response.grpclb_route_type() ==
+                 GrpclbRouteType::GRPCLB_ROUTE_TYPE_BACKEND ||
+             response.grpclb_route_type() ==
+                 GrpclbRouteType::GRPCLB_ROUTE_TYPE_FALLBACK);
+  gpr_log(GPR_INFO, "DoRPCAndGetPath done. grpclb_route_type:%d",
+          response.grpclb_route_type());
+  return response.grpclb_route_type();
+}
+
+GrpclbRouteType DoRPCAndGetPath(TestService::Stub* stub, int deadline_seconds) {
+  return DoRPCAndGetPath(stub, deadline_seconds, FailFast);
+}
+
+GrpclbRouteType DoWaitForReadyRPCAndGetPath(TestService::Stub* stub,
+                                            int deadline_seconds) {
+  return DoRPCAndGetPath(stub, deadline_seconds, WaitForReady);
+}
+
+bool TcpUserTimeoutMutateFd(int fd, grpc_socket_mutator* mutator) {
+  int timeout = 20000;  // 20 seconds
+  gpr_log(GPR_INFO, "Setting socket option TCP_USER_TIMEOUT on fd: %d", fd);
+  if (0 != setsockopt(fd, IPPROTO_TCP, TCP_USER_TIMEOUT, &timeout,
+                      sizeof(timeout))) {
+    gpr_log(GPR_ERROR, "Failed to set socket option TCP_USER_TIMEOUT");
+    abort();
+  }
+  int newval;
+  socklen_t len = sizeof(newval);
+  if (0 != getsockopt(fd, IPPROTO_TCP, TCP_USER_TIMEOUT, &newval, &len) ||
+      newval != timeout) {
+    gpr_log(GPR_ERROR, "Failed to get expected socket option TCP_USER_TIMEOUT");
+    abort();
+  }
+  return true;
+}
+
+int TcpUserTimeoutCompare(grpc_socket_mutator* a, grpc_socket_mutator* b) {
+  return 0;
+}
+
+void TcpUserTimeoutDestroy(grpc_socket_mutator* mutator) { gpr_free(mutator); }
+
+const grpc_socket_mutator_vtable kTcpUserTimeoutMutatorVtable =
+    grpc_socket_mutator_vtable{
+        .mutate_fd = TcpUserTimeoutMutateFd,
+        .compare = TcpUserTimeoutCompare,
+        .destroy = TcpUserTimeoutDestroy,
+    };
+
+std::unique_ptr<TestService::Stub> CreateFallbackTestStub() {
+  grpc::ChannelArguments channel_args;
+  grpc_socket_mutator* tcp_user_timeout_mutator =
+      static_cast<grpc_socket_mutator*>(
+          gpr_malloc(sizeof(tcp_user_timeout_mutator)));
+  grpc_socket_mutator_init(tcp_user_timeout_mutator,
+                           &kTcpUserTimeoutMutatorVtable);
+  channel_args.SetSocketMutator(tcp_user_timeout_mutator);
+  // Allow LB policy to be configured by service config
+  channel_args.SetInt(GRPC_ARG_SERVICE_CONFIG_DISABLE_RESOLUTION, 0);
+  std::shared_ptr<grpc::ChannelCredentials> channel_creds =
+      grpc::testing::GetCredentialsProvider()->GetChannelCredentials(
+          FLAGS_custom_credentials_type, &channel_args);
+  return TestService::NewStub(
+      grpc::CreateCustomChannel(FLAGS_server_uri, channel_creds, channel_args));
+}
+
+void RunCommand(const std::string& command) {
+  gpr_log(GPR_INFO, "RunCommand: |%s|", command.c_str());
+  int out = std::system(command.c_str());
+  if (WIFEXITED(out)) {
+    int code = WEXITSTATUS(out);
+    if (code != 0) {
+      gpr_log(GPR_ERROR, "RunCommand failed exit code:%d command:|%s|", code,
+              command.c_str());
+      abort();
+    }
+  } else {
+    gpr_log(GPR_ERROR, "RunCommand failed command:|%s|", command.c_str());
+    abort();
+  }
+}
+
+void RunFallbackBeforeStartupTest(
+    const std::string& break_lb_and_backend_conns_cmd,
+    int per_rpc_deadline_seconds) {
+  std::unique_ptr<TestService::Stub> stub = CreateFallbackTestStub();
+  RunCommand(break_lb_and_backend_conns_cmd);
+  for (size_t i = 0; i < 30; i++) {
+    GrpclbRouteType grpclb_route_type =
+        DoRPCAndGetPath(stub.get(), per_rpc_deadline_seconds);
+    if (grpclb_route_type != GrpclbRouteType::GRPCLB_ROUTE_TYPE_FALLBACK) {
+      gpr_log(GPR_ERROR, "Expected grpclb route type: FALLBACK. Got: %d",
+              grpclb_route_type);
+      abort();
+    }
+    std::this_thread::sleep_for(std::chrono::seconds(1));
+  }
+}
+
+void DoFastFallbackBeforeStartup() {
+  RunFallbackBeforeStartupTest(FLAGS_unroute_lb_and_backend_addrs_cmd, 9);
+}
+
+void DoSlowFallbackBeforeStartup() {
+  RunFallbackBeforeStartupTest(FLAGS_blackhole_lb_and_backend_addrs_cmd, 20);
+}
+
+void RunFallbackAfterStartupTest(
+    const std::string& break_lb_and_backend_conns_cmd) {
+  std::unique_ptr<TestService::Stub> stub = CreateFallbackTestStub();
+  GrpclbRouteType grpclb_route_type = DoRPCAndGetPath(stub.get(), 20);
+  if (grpclb_route_type != GrpclbRouteType::GRPCLB_ROUTE_TYPE_BACKEND) {
+    gpr_log(GPR_ERROR, "Expected grpclb route type: BACKEND. Got: %d",
+            grpclb_route_type);
+    abort();
+  }
+  RunCommand(break_lb_and_backend_conns_cmd);
+  for (size_t i = 0; i < 40; i++) {
+    GrpclbRouteType grpclb_route_type =
+        DoWaitForReadyRPCAndGetPath(stub.get(), 1);
+    // Backends should be unreachable by now, otherwise the test is broken.
+    GPR_ASSERT(grpclb_route_type != GrpclbRouteType::GRPCLB_ROUTE_TYPE_BACKEND);
+    if (grpclb_route_type == GrpclbRouteType::GRPCLB_ROUTE_TYPE_FALLBACK) {
+      gpr_log(GPR_INFO,
+              "Made one successul RPC to a fallback. Now expect the same for "
+              "the rest.");
+      break;
+    } else {
+      gpr_log(GPR_ERROR, "Retryable RPC failure on iteration: %" PRIdPTR, i);
+    }
+  }
+  for (size_t i = 0; i < 30; i++) {
+    GrpclbRouteType grpclb_route_type = DoRPCAndGetPath(stub.get(), 20);
+    if (grpclb_route_type != GrpclbRouteType::GRPCLB_ROUTE_TYPE_FALLBACK) {
+      gpr_log(GPR_ERROR, "Expected grpclb route type: FALLBACK. Got: %d",
+              grpclb_route_type);
+      abort();
+    }
+    std::this_thread::sleep_for(std::chrono::seconds(1));
+  }
+}
+
+void DoFastFallbackAfterStartup() {
+  RunFallbackAfterStartupTest(FLAGS_unroute_lb_and_backend_addrs_cmd);
+}
+
+void DoSlowFallbackAfterStartup() {
+  RunFallbackAfterStartupTest(FLAGS_blackhole_lb_and_backend_addrs_cmd);
+}
+}  // namespace
+
+int main(int argc, char** argv) {
+  grpc::testing::InitTest(&argc, &argv, true);
+  gpr_log(GPR_INFO, "Testing: %s", FLAGS_test_case.c_str());
+  if (FLAGS_test_case == "fast_fallback_before_startup") {
+    DoFastFallbackBeforeStartup();
+    gpr_log(GPR_INFO, "DoFastFallbackBeforeStartup done!");
+  } else if (FLAGS_test_case == "slow_fallback_before_startup") {
+    DoSlowFallbackBeforeStartup();
+    gpr_log(GPR_INFO, "DoSlowFallbackBeforeStartup done!");
+  } else if (FLAGS_test_case == "fast_fallback_after_startup") {
+    DoFastFallbackAfterStartup();
+    gpr_log(GPR_INFO, "DoFastFallbackAfterStartup done!");
+  } else if (FLAGS_test_case == "slow_fallback_after_startup") {
+    DoSlowFallbackAfterStartup();
+    gpr_log(GPR_INFO, "DoSlowFallbackAfterStartup done!");
+  } else {
+    gpr_log(GPR_ERROR, "Invalid test case: %s", FLAGS_test_case.c_str());
+    abort();
+  }
+}
diff --git a/tools/release/verify_python_release.py b/tools/release/verify_python_release.py
new file mode 100644
index 0000000..6cbc399
--- /dev/null
+++ b/tools/release/verify_python_release.py
@@ -0,0 +1,114 @@
+#!/usr/bin/env python3
+
+#Copyright 2019 gRPC authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+"""Verifies that all gRPC Python artifacts have been successfully published.
+
+This script is intended to be run from a directory containing the artifacts
+that have been uploaded and only the artifacts that have been uploaded. We use
+PyPI's JSON API to verify that the proper filenames and checksums are present.
+
+Note that PyPI may take several minutes to update its metadata. Don't have a
+heart attack immediately.
+
+This sanity check is a good first step, but ideally, we would automate the
+entire release process.
+"""
+
+import argparse
+import collections
+import hashlib
+import os
+import requests
+import sys
+
+_DEFAULT_PACKAGES = [
+    "grpcio",
+    "grpcio-tools",
+    "grpcio-status",
+    "grpcio-health-checking",
+    "grpcio-reflection",
+    "grpcio-channelz",
+    "grpcio-testing",
+]
+
+Artifact = collections.namedtuple("Artifact", ("filename", "checksum"))
+
+
+def _get_md5_checksum(filename):
+    """Calculate the md5sum for a file."""
+    hash_md5 = hashlib.md5()
+    with open(filename, 'rb') as f:
+        for chunk in iter(lambda: f.read(4096), b""):
+            hash_md5.update(chunk)
+        return hash_md5.hexdigest()
+
+
+def _get_local_artifacts():
+    """Get a set of artifacts representing all files in the cwd."""
+    return set(
+        Artifact(f, _get_md5_checksum(f)) for f in os.listdir(os.getcwd()))
+
+
+def _get_remote_artifacts_for_package(package, version):
+    """Get a list of artifacts based on PyPi's json metadata.
+
+    Note that this data will not updated immediately after upload. In my
+    experience, it has taken a minute on average to be fresh.
+    """
+    artifacts = set()
+    payload = requests.get("https://pypi.org/pypi/{}/{}/json".format(
+        package, version)).json()
+    for download_info in payload['releases'][version]:
+        artifacts.add(
+            Artifact(download_info['filename'], download_info['md5_digest']))
+    return artifacts
+
+
+def _get_remote_artifacts_for_packages(packages, version):
+    artifacts = set()
+    for package in packages:
+        artifacts |= _get_remote_artifacts_for_package(package, version)
+    return artifacts
+
+
+def _verify_release(version, packages):
+    """Compare the local artifacts to the packages uploaded to PyPI."""
+    local_artifacts = _get_local_artifacts()
+    remote_artifacts = _get_remote_artifacts_for_packages(packages, version)
+    if local_artifacts != remote_artifacts:
+        local_but_not_remote = local_artifacts - remote_artifacts
+        remote_but_not_local = remote_artifacts - local_artifacts
+        if local_but_not_remote:
+            print("The following artifacts exist locally but not remotely.")
+            for artifact in local_but_not_remote:
+                print(artifact)
+        if remote_but_not_local:
+            print("The following artifacts exist remotely but not locally.")
+            for artifact in remote_but_not_local:
+                print(artifact)
+        sys.exit(1)
+    print("Release verified successfully.")
+
+
+if __name__ == "__main__":
+    parser = argparse.ArgumentParser(
+        "Verify a release. Run this from a directory containing only the"
+        "artifacts to be uploaded. Note that PyPI may take several minutes"
+        "after the upload to reflect the proper metadata.")
+    parser.add_argument("version")
+    parser.add_argument(
+        "packages", nargs='*', type=str, default=_DEFAULT_PACKAGES)
+    args = parser.parse_args()
+    _verify_release(args.version, args.packages)
diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json
index 7a1baae..0b56c7b 100644
--- a/tools/run_tests/generated/sources_and_headers.json
+++ b/tools/run_tests/generated/sources_and_headers.json
@@ -4042,6 +4042,35 @@
       "gpr", 
       "grpc", 
       "grpc++", 
+      "grpc++_test_config", 
+      "grpc++_test_util", 
+      "grpc_test_util"
+    ], 
+    "headers": [
+      "src/proto/grpc/testing/empty.grpc.pb.h", 
+      "src/proto/grpc/testing/empty.pb.h", 
+      "src/proto/grpc/testing/empty_mock.grpc.pb.h", 
+      "src/proto/grpc/testing/messages.grpc.pb.h", 
+      "src/proto/grpc/testing/messages.pb.h", 
+      "src/proto/grpc/testing/messages_mock.grpc.pb.h", 
+      "src/proto/grpc/testing/test.grpc.pb.h", 
+      "src/proto/grpc/testing/test.pb.h", 
+      "src/proto/grpc/testing/test_mock.grpc.pb.h"
+    ], 
+    "is_filegroup": false, 
+    "language": "c++", 
+    "name": "grpclb_fallback_test", 
+    "src": [
+      "test/cpp/interop/grpclb_fallback_test.cc"
+    ], 
+    "third_party": false, 
+    "type": "target"
+  }, 
+  {
+    "deps": [
+      "gpr", 
+      "grpc", 
+      "grpc++", 
       "grpc++_test", 
       "grpc_test_util"
     ], 
diff --git a/tools/run_tests/generated/tests.json b/tools/run_tests/generated/tests.json
index 2ac5292..f4757e5 100644
--- a/tools/run_tests/generated/tests.json
+++ b/tools/run_tests/generated/tests.json
@@ -4817,6 +4817,24 @@
     "args": [], 
     "benchmark": false, 
     "ci_platforms": [
+      "linux"
+    ], 
+    "cpu_cost": 1.0, 
+    "exclude_configs": [], 
+    "exclude_iomgrs": [], 
+    "flaky": false, 
+    "gtest": false, 
+    "language": "c++", 
+    "name": "grpclb_fallback_test", 
+    "platforms": [
+      "linux"
+    ], 
+    "uses_polling": true
+  }, 
+  {
+    "args": [], 
+    "benchmark": false, 
+    "ci_platforms": [
       "linux", 
       "mac", 
       "posix",