]> git.feebdaed.xyz Git - 0xmirror/grpc.git/commitdiff
[Call] Skip clearing peer string during call cancellation (#41062)
authorVignesh Babu <vigneshbabu@google.com>
Fri, 14 Nov 2025 22:39:11 +0000 (14:39 -0800)
committerCopybara-Service <copybara-worker@google.com>
Fri, 14 Nov 2025 22:41:52 +0000 (14:41 -0800)
Potential fix for b/428185413

Closes #41062

PiperOrigin-RevId: 832462330

bazel/experiments.bzl
src/core/lib/experiments/experiments.cc
src/core/lib/experiments/experiments.h
src/core/lib/experiments/experiments.yaml
src/core/lib/experiments/rollouts.yaml
src/core/lib/surface/filter_stack_call.cc
tools/artifact_gen/artifact_gen.sh

index 5bfaf8b19f98c10b4b3ad2ea363842edf3dfa584..caf6c4cf1e1ccee7a9f326ed973f588e1050e59c 100644 (file)
@@ -55,6 +55,7 @@ EXPERIMENT_ENABLES = {
     "schedule_cancellation_over_write": "schedule_cancellation_over_write",
     "secure_endpoint_offload_large_reads": "event_engine_client,event_engine_listener,event_engine_secure_endpoint,secure_endpoint_offload_large_reads",
     "secure_endpoint_offload_large_writes": "event_engine_client,event_engine_listener,event_engine_secure_endpoint,secure_endpoint_offload_large_writes",
+    "skip_clear_peer_on_cancellation": "skip_clear_peer_on_cancellation",
     "sleep_promise_exec_ctx_removal": "sleep_promise_exec_ctx_removal",
     "sleep_use_non_owning_waker": "sleep_use_non_owning_waker",
     "subchannel_wrapper_cleanup_on_orphan": "subchannel_wrapper_cleanup_on_orphan",
index 9e439f03df0be2aaf7fd53433562a2062baddf25..54cde9f0f20ba1ebcb57e2416503c8c44fa8df74 100644 (file)
@@ -182,6 +182,9 @@ const uint8_t required_experiments_secure_endpoint_offload_large_writes[] = {
     static_cast<uint8_t>(grpc_core::kExperimentIdEventEngineClient),
     static_cast<uint8_t>(grpc_core::kExperimentIdEventEngineListener),
     static_cast<uint8_t>(grpc_core::kExperimentIdEventEngineSecureEndpoint)};
+const char* const description_skip_clear_peer_on_cancellation =
+    "If set, skips clearing of peer string on call cancellation.";
+const char* const additional_constraints_skip_clear_peer_on_cancellation = "{}";
 const char* const description_sleep_promise_exec_ctx_removal =
     "If set, polling the sleep promise does not rely on the ExecCtx.";
 const char* const additional_constraints_sleep_promise_exec_ctx_removal = "{}";
@@ -338,6 +341,10 @@ const ExperimentMetadata g_experiment_metadata[] = {
      description_secure_endpoint_offload_large_writes,
      additional_constraints_secure_endpoint_offload_large_writes,
      required_experiments_secure_endpoint_offload_large_writes, 3, false, true},
+    {"skip_clear_peer_on_cancellation",
+     description_skip_clear_peer_on_cancellation,
+     additional_constraints_skip_clear_peer_on_cancellation, nullptr, 0, false,
+     true},
     {"sleep_promise_exec_ctx_removal",
      description_sleep_promise_exec_ctx_removal,
      additional_constraints_sleep_promise_exec_ctx_removal, nullptr, 0, false,
@@ -532,6 +539,9 @@ const uint8_t required_experiments_secure_endpoint_offload_large_writes[] = {
     static_cast<uint8_t>(grpc_core::kExperimentIdEventEngineClient),
     static_cast<uint8_t>(grpc_core::kExperimentIdEventEngineListener),
     static_cast<uint8_t>(grpc_core::kExperimentIdEventEngineSecureEndpoint)};
+const char* const description_skip_clear_peer_on_cancellation =
+    "If set, skips clearing of peer string on call cancellation.";
+const char* const additional_constraints_skip_clear_peer_on_cancellation = "{}";
 const char* const description_sleep_promise_exec_ctx_removal =
     "If set, polling the sleep promise does not rely on the ExecCtx.";
 const char* const additional_constraints_sleep_promise_exec_ctx_removal = "{}";
@@ -688,6 +698,10 @@ const ExperimentMetadata g_experiment_metadata[] = {
      description_secure_endpoint_offload_large_writes,
      additional_constraints_secure_endpoint_offload_large_writes,
      required_experiments_secure_endpoint_offload_large_writes, 3, false, true},
+    {"skip_clear_peer_on_cancellation",
+     description_skip_clear_peer_on_cancellation,
+     additional_constraints_skip_clear_peer_on_cancellation, nullptr, 0, false,
+     true},
     {"sleep_promise_exec_ctx_removal",
      description_sleep_promise_exec_ctx_removal,
      additional_constraints_sleep_promise_exec_ctx_removal, nullptr, 0, false,
@@ -882,6 +896,9 @@ const uint8_t required_experiments_secure_endpoint_offload_large_writes[] = {
     static_cast<uint8_t>(grpc_core::kExperimentIdEventEngineClient),
     static_cast<uint8_t>(grpc_core::kExperimentIdEventEngineListener),
     static_cast<uint8_t>(grpc_core::kExperimentIdEventEngineSecureEndpoint)};
+const char* const description_skip_clear_peer_on_cancellation =
+    "If set, skips clearing of peer string on call cancellation.";
+const char* const additional_constraints_skip_clear_peer_on_cancellation = "{}";
 const char* const description_sleep_promise_exec_ctx_removal =
     "If set, polling the sleep promise does not rely on the ExecCtx.";
 const char* const additional_constraints_sleep_promise_exec_ctx_removal = "{}";
@@ -1038,6 +1055,10 @@ const ExperimentMetadata g_experiment_metadata[] = {
      description_secure_endpoint_offload_large_writes,
      additional_constraints_secure_endpoint_offload_large_writes,
      required_experiments_secure_endpoint_offload_large_writes, 3, false, true},
+    {"skip_clear_peer_on_cancellation",
+     description_skip_clear_peer_on_cancellation,
+     additional_constraints_skip_clear_peer_on_cancellation, nullptr, 0, false,
+     true},
     {"sleep_promise_exec_ctx_removal",
      description_sleep_promise_exec_ctx_removal,
      additional_constraints_sleep_promise_exec_ctx_removal, nullptr, 0, false,
index 2c7473a160b5057f8ad273af711454479f90f7dd..5bbfb7fa874f0a4fdbb6a12c9ba170c66086b380 100644 (file)
@@ -108,6 +108,7 @@ inline bool IsRrWrrConnectFromRandomIndexEnabled() { return false; }
 inline bool IsScheduleCancellationOverWriteEnabled() { return false; }
 inline bool IsSecureEndpointOffloadLargeReadsEnabled() { return false; }
 inline bool IsSecureEndpointOffloadLargeWritesEnabled() { return false; }
+inline bool IsSkipClearPeerOnCancellationEnabled() { return false; }
 inline bool IsSleepPromiseExecCtxRemovalEnabled() { return false; }
 inline bool IsSleepUseNonOwningWakerEnabled() { return false; }
 inline bool IsSubchannelWrapperCleanupOnOrphanEnabled() { return false; }
@@ -170,6 +171,7 @@ inline bool IsRrWrrConnectFromRandomIndexEnabled() { return false; }
 inline bool IsScheduleCancellationOverWriteEnabled() { return false; }
 inline bool IsSecureEndpointOffloadLargeReadsEnabled() { return false; }
 inline bool IsSecureEndpointOffloadLargeWritesEnabled() { return false; }
+inline bool IsSkipClearPeerOnCancellationEnabled() { return false; }
 inline bool IsSleepPromiseExecCtxRemovalEnabled() { return false; }
 inline bool IsSleepUseNonOwningWakerEnabled() { return false; }
 inline bool IsSubchannelWrapperCleanupOnOrphanEnabled() { return false; }
@@ -232,6 +234,7 @@ inline bool IsRrWrrConnectFromRandomIndexEnabled() { return false; }
 inline bool IsScheduleCancellationOverWriteEnabled() { return false; }
 inline bool IsSecureEndpointOffloadLargeReadsEnabled() { return false; }
 inline bool IsSecureEndpointOffloadLargeWritesEnabled() { return false; }
+inline bool IsSkipClearPeerOnCancellationEnabled() { return false; }
 inline bool IsSleepPromiseExecCtxRemovalEnabled() { return false; }
 inline bool IsSleepUseNonOwningWakerEnabled() { return false; }
 inline bool IsSubchannelWrapperCleanupOnOrphanEnabled() { return false; }
@@ -283,6 +286,7 @@ enum ExperimentIds {
   kExperimentIdScheduleCancellationOverWrite,
   kExperimentIdSecureEndpointOffloadLargeReads,
   kExperimentIdSecureEndpointOffloadLargeWrites,
+  kExperimentIdSkipClearPeerOnCancellation,
   kExperimentIdSleepPromiseExecCtxRemoval,
   kExperimentIdSleepUseNonOwningWaker,
   kExperimentIdSubchannelWrapperCleanupOnOrphan,
@@ -446,6 +450,10 @@ inline bool IsSecureEndpointOffloadLargeReadsEnabled() {
 inline bool IsSecureEndpointOffloadLargeWritesEnabled() {
   return IsExperimentEnabled<kExperimentIdSecureEndpointOffloadLargeWrites>();
 }
+#define GRPC_EXPERIMENT_IS_INCLUDED_SKIP_CLEAR_PEER_ON_CANCELLATION
+inline bool IsSkipClearPeerOnCancellationEnabled() {
+  return IsExperimentEnabled<kExperimentIdSkipClearPeerOnCancellation>();
+}
 #define GRPC_EXPERIMENT_IS_INCLUDED_SLEEP_PROMISE_EXEC_CTX_REMOVAL
 inline bool IsSleepPromiseExecCtxRemovalEnabled() {
   return IsExperimentEnabled<kExperimentIdSleepPromiseExecCtxRemoval>();
index 4a89f674016fe4659551b3cb1ec46a545e9865d1..68f8d54a81b59f27afc34e8b23886208db7f9da8 100644 (file)
       "event_engine_listener",
       "event_engine_secure_endpoint",
     ]
+- name: skip_clear_peer_on_cancellation
+  description: If set, skips clearing of peer string on call cancellation.
+  expiry: 2026/03/01
+  owner: vigneshbabu@google.com
+  test_tags: []
 - name: sleep_promise_exec_ctx_removal
   description: If set, polling the sleep promise does not rely on the ExecCtx.
   expiry: 2026/02/01
index 8fe27f569e3b2673836089807fd35fd225331754..2b6490b9dffd3ce793e8258c7d8b4300dedad119 100644 (file)
@@ -90,6 +90,8 @@
   default: false
 - name: schedule_cancellation_over_write
   default: false
+- name: skip_clear_peer_on_cancellation
+  default: false
 - name: sleep_promise_exec_ctx_removal
   default: false
 - name: sleep_use_non_owning_waker
index 8ec571fafa4b9058440d1342e283f63b81763345..21059a251f6feacdea45548cd8114f358d85d5ff 100644 (file)
@@ -327,7 +327,9 @@ void FilterStackCall::CancelWithError(grpc_error_handle error) {
   GRPC_TRACE_LOG(call_error, INFO)
       << "CancelWithError " << (is_client() ? "CLI" : "SVR") << " "
       << StatusToString(error);
-  ClearPeerString();
+  if (!IsSkipClearPeerOnCancellationEnabled()) {
+    ClearPeerString();
+  }
   InternalRef("termination");
   ResetDeadline();
   // Inform the call combiner of the cancellation, so that it can cancel
index 72993955b2c53b2c7a0e600665682b497e0df101..b89cb6386ca05dd9b5fa142764fef44443ff95ba 100755 (executable)
@@ -28,7 +28,7 @@ tools/bazel query --noimplicit_deps --output=xml 'kind(http_archive, //external:
 
 # PHASE 1: generate artifacts
 cd tools/artifact_gen
-../../tools/bazel build -c opt :artifact_gen 
+../../tools/bazel build -c opt --cxxopt='-std=c++17' :artifact_gen 
 bazel-bin/artifact_gen \
        --target_query=`pwd`/test_deps.xml,`pwd`/root_all_deps.xml,`pwd`/compiler_deps.xml,`pwd`/third_party_alias_deps.xml,`pwd`/envoy_api_proto_deps.xml,`pwd`/upb_deps.xml \
        --external_http_archive_query=`pwd`/external_http_archive_deps.xml \