diff --git a/deps/grpc/.bazelignore b/deps/grpc/.bazelignore index d17d3332cf9..7e4e4056311 100644 --- a/deps/grpc/.bazelignore +++ b/deps/grpc/.bazelignore @@ -27,6 +27,7 @@ test/distrib/bazel/python test/distrib/bazel/python_second_test_repo # Directories build containing own BUILD files. +test/bzlmod src/python/grpcio_tests/src/ tools/distrib/python/grpcio_tools/build/ tools/distrib/python/grpcio_tools/protobuf/ diff --git a/deps/grpc/.bcr/metadata.template.json b/deps/grpc/.bcr/metadata.template.json index fa9185b0529..f9f9c73e069 100644 --- a/deps/grpc/.bcr/metadata.template.json +++ b/deps/grpc/.bcr/metadata.template.json @@ -1,30 +1,12 @@ { "homepage": "https://github.com/grpc/grpc", "maintainers": [ - { - "email": "veblush@google.com", - "github": "veblush", - "name": "Esun Kim", - "github_user_id": 2793282 - }, { "email": "bpawan@google.com", "github": "pawbhard", "name": "Pawan Bhardwaj", "github_user_id": 13415978 }, - { - "email": "eostroukhov@google.com", - "github": "eugeneo", - "name": "Eugene Ostroukhov", - "github_user_id": 287917 - }, - { - "email": "hork@google.com", - "github": "drfloob", - "name": "Adam Heller", - "github_user_id": 295906 - }, { "email": "rishesh@google.com", "github": "rishesh007", @@ -37,35 +19,29 @@ "name": "Mark Roth", "github_user_id": 18664614 }, - { - "email": "yashkt@google.com", - "github": "yashykt", - "name": "Yash Tibrewal", - "github_user_id": 4181124 - }, - { - "email": "apolcyn@google.com", - "github": "apolcyn", - "name": "Alexander Polcyn", - "github_user_id": 9566254 - }, { "email": "sergiitk@google.com", "github": "sergiitk", "name": "Sergii Tkachenko", "github_user_id": 672669 }, + { + "email": "weizheyuan@google.com", + "github": "yuanweiz", + "name": "Weizhe Yuan", + "github_user_id": 5679340 + }, + { + "email": "asheshvidyut@google.com", + "github": "asheshvidyut", + "name": "Ashesh Vidyut", + "github_user_id": 134911583 + }, { "email": "ssreenithi@google.com", "github": "sreenithi", "name": "Sreenithi Sridharan", "github_user_id": 22791051 - }, - { - "email": "stanleycheung@google.com", - "github": "stanley-cheung", - "name": "Stanley Cheung", - "github_user_id": 11674202 } ], "repository": [ diff --git a/deps/grpc/.clang-format b/deps/grpc/.clang-format index 6c6c4548e80..97e6471915a 100644 --- a/deps/grpc/.clang-format +++ b/deps/grpc/.clang-format @@ -8,6 +8,22 @@ IncludeCategories: # ruby.h is even more first if it's included - Regex: '^' Priority: -200 + - Regex: '^("absl/)' + Priority: 400 + SortPriority: 500 + - Regex: '^"gmock/gmock.h"' + Priority: 400 + SortPriority: 450 + - Regex: '^"gtest/gtest.h"' + Priority: 400 + SortPriority: 450 + - Regex: '^<.*\.h>' + Priority: 200 + - Regex: '^<.*' + Priority: 300 + - Regex: '.*' + Priority: 400 + SortPriority: 400 --- Language: ObjC BasedOnStyle: Google diff --git a/deps/grpc/.gitattributes b/deps/grpc/.gitattributes index 48fb8d0b38d..e3f4a476f84 100644 --- a/deps/grpc/.gitattributes +++ b/deps/grpc/.gitattributes @@ -19,8 +19,7 @@ src/python/grpcio/grpc_core_dependencies.py linguist-generated=true src/ruby/ext/grpc/rb_grpc_imports.generated.h linguist-generated=true src/ruby/ext/grpc/rb_grpc_imports.generated.c linguist-generated=true include/grpc/module.modulemap linguist-generated=true -test/core/security/grpc_tls_credentials_options_comparator_test.cc linguist-generated=true -tools/distrib/python/xds_protos/** linguist-generated=true +py_xds_protos/** linguist-generated=true tools/doxygen/Doxyfile.c++ linguist-generated=true tools/doxygen/Doxyfile.c++.internal linguist-generated=true tools/doxygen/Doxyfile.core linguist-generated=true @@ -32,6 +31,7 @@ tools/run_tests/generated/sources_and_headers.json linguist-generated=true src/core/config/config_vars.h linguist-generated=true src/core/config/config_vars.cc linguist-generated=true src/core/credentials/transport/tls/grpc_tls_credentials_options.h linguist-generated=true +test/core/credentials/transport/tls/grpc_tls_credentials_options_comparator_test.cc linguist-generated=true src/core/telemetry/stats_data.h linguist-generated=true src/core/telemetry/stats_data.cc linguist-generated=true src/core/lib/experiments/experiments.h linguist-generated=true diff --git a/deps/grpc/.pylintrc b/deps/grpc/.pylintrc index 006796e54ed..17e0ac9b065 100644 --- a/deps/grpc/.pylintrc +++ b/deps/grpc/.pylintrc @@ -1,4 +1,5 @@ [MAIN] +py-version = 3.9 load-plugins= pylint.extensions.no_self_use, pylint.extensions.comparison_placement, @@ -10,6 +11,9 @@ ignore= src/python/grpcio/grpc/framework/common, src/python/grpcio/grpc/framework/foundation, src/python/grpcio/grpc/framework/interfaces, +ignore-patterns= + .*pb2\.py, + .*pb2_grpc\.py, extension-pkg-whitelist=grpc._cython.cygrpc diff --git a/deps/grpc/.pylintrc-examples b/deps/grpc/.pylintrc-examples index 6690ae3d304..722412c8539 100644 --- a/deps/grpc/.pylintrc-examples +++ b/deps/grpc/.pylintrc-examples @@ -1,4 +1,5 @@ [MAIN] +py-version = 3.9 load-plugins= pylint.extensions.no_self_use, pylint.extensions.comparison_placement, @@ -10,6 +11,9 @@ ignore= src/python/grpcio/grpc/framework/common, src/python/grpcio/grpc/framework/foundation, src/python/grpcio/grpc/framework/interfaces, +ignore-patterns= + .*pb2\.py, + .*pb2_grpc\.py, [VARIABLES] diff --git a/deps/grpc/.pylintrc-tests b/deps/grpc/.pylintrc-tests index 794e776c653..23a525535fe 100644 --- a/deps/grpc/.pylintrc-tests +++ b/deps/grpc/.pylintrc-tests @@ -1,4 +1,5 @@ [MAIN] +py-version = 3.9 load-plugins= pylint.extensions.no_self_use, pylint.extensions.comparison_placement, @@ -9,6 +10,9 @@ ignore= src/python/grpcio_tests/tests/unit/framework, src/python/grpcio_tests/tests/unit/framework/common, src/python/grpcio_tests/tests/unit/framework/foundation, +ignore-patterns= + .*pb2\.py, + .*pb2_grpc\.py, [VARIABLES] diff --git a/deps/grpc/Makefile b/deps/grpc/Makefile index f9313ed4f0c..dd4fedf629b 100644 --- a/deps/grpc/Makefile +++ b/deps/grpc/Makefile @@ -367,8 +367,8 @@ E = @echo Q = @ endif -CORE_VERSION = 51.0.0 -CPP_VERSION = 1.76.0 +CORE_VERSION = 52.0.0 +CPP_VERSION = 1.78.1 CPPFLAGS_NO_ARCH += $(addprefix -I, $(INCLUDES)) $(addprefix -D, $(DEFINES)) CPPFLAGS += $(CPPFLAGS_NO_ARCH) $(ARCH_FLAGS) @@ -404,7 +404,7 @@ SHARED_EXT_CORE = dll SHARED_EXT_CPP = dll SHARED_PREFIX = -SHARED_VERSION_CORE = -51 +SHARED_VERSION_CORE = -52 SHARED_VERSION_CPP = -1 else ifeq ($(SYSTEM),Darwin) EXECUTABLE_SUFFIX = @@ -690,6 +690,7 @@ LIBGRPC_SRC = \ src/core/channelz/v2tov1/legacy_api.cc \ src/core/channelz/v2tov1/property_list.cc \ src/core/client_channel/backup_poller.cc \ + src/core/client_channel/buffered_call.cc \ src/core/client_channel/client_channel.cc \ src/core/client_channel/client_channel_factory.cc \ src/core/client_channel/client_channel_filter.cc \ @@ -807,6 +808,7 @@ LIBGRPC_SRC = \ src/core/ext/transport/chttp2/transport/frame_security.cc \ src/core/ext/transport/chttp2/transport/frame_settings.cc \ src/core/ext/transport/chttp2/transport/frame_window_update.cc \ + src/core/ext/transport/chttp2/transport/goaway.cc \ src/core/ext/transport/chttp2/transport/hpack_encoder.cc \ src/core/ext/transport/chttp2/transport/hpack_encoder_table.cc \ src/core/ext/transport/chttp2/transport/hpack_parse_result.cc \ @@ -824,6 +826,7 @@ LIBGRPC_SRC = \ src/core/ext/transport/chttp2/transport/ping_callbacks.cc \ src/core/ext/transport/chttp2/transport/ping_promise.cc \ src/core/ext/transport/chttp2/transport/ping_rate_policy.cc \ + src/core/ext/transport/chttp2/transport/security_frame.cc \ src/core/ext/transport/chttp2/transport/stream_lists.cc \ src/core/ext/transport/chttp2/transport/transport_common.cc \ src/core/ext/transport/chttp2/transport/varint.cc \ @@ -1328,6 +1331,7 @@ LIBGRPC_SRC = \ src/core/lib/resource_quota/memory_quota.cc \ src/core/lib/resource_quota/periodic_update.cc \ src/core/lib/resource_quota/resource_quota.cc \ + src/core/lib/resource_quota/stream_quota.cc \ src/core/lib/resource_quota/thread_quota.cc \ src/core/lib/resource_tracker/resource_tracker.cc \ src/core/lib/security/authorization/audit_logging.cc \ @@ -1828,11 +1832,13 @@ PUBLIC_HEADERS_C += \ include/grpc/grpc_posix.h \ include/grpc/grpc_security.h \ include/grpc/grpc_security_constants.h \ + include/grpc/impl/call.h \ include/grpc/impl/channel_arg_names.h \ include/grpc/impl/codegen/byte_buffer.h \ include/grpc/impl/codegen/byte_buffer_reader.h \ include/grpc/impl/codegen/compression_types.h \ include/grpc/impl/codegen/connectivity_state.h \ + include/grpc/impl/codegen/fork.h \ include/grpc/impl/codegen/grpc_types.h \ include/grpc/impl/codegen/propagation_bits.h \ include/grpc/impl/codegen/slice.h \ @@ -1885,8 +1891,8 @@ $(LIBDIR)/$(CONFIG)/libgrpc$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE): $(LIBGRPC_ ifeq ($(SYSTEM),Darwin) $(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -install_name $(SHARED_PREFIX)grpc$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) -dynamiclib -o $(LIBDIR)/$(CONFIG)/libgrpc$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGRPC_OBJS) $(LIBDIR)/$(CONFIG)/libcares.a $(OPENSSL_MERGE_LIBS) $(ZLIB_MERGE_LIBS) $(LDLIBS_SECURE) $(LDLIBS) else - $(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,libgrpc.so.51 -o $(LIBDIR)/$(CONFIG)/libgrpc$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGRPC_OBJS) $(LIBDIR)/$(CONFIG)/libcares.a $(OPENSSL_MERGE_LIBS) $(ZLIB_MERGE_LIBS) $(LDLIBS_SECURE) $(LDLIBS) - $(Q) ln -sf $(SHARED_PREFIX)grpc$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBDIR)/$(CONFIG)/libgrpc$(SHARED_VERSION_CORE).so.51 + $(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,libgrpc.so.52 -o $(LIBDIR)/$(CONFIG)/libgrpc$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGRPC_OBJS) $(LIBDIR)/$(CONFIG)/libcares.a $(OPENSSL_MERGE_LIBS) $(ZLIB_MERGE_LIBS) $(LDLIBS_SECURE) $(LDLIBS) + $(Q) ln -sf $(SHARED_PREFIX)grpc$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBDIR)/$(CONFIG)/libgrpc$(SHARED_VERSION_CORE).so.52 $(Q) ln -sf $(SHARED_PREFIX)grpc$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBDIR)/$(CONFIG)/libgrpc$(SHARED_VERSION_CORE).so endif endif diff --git a/deps/grpc/grpc.gyp b/deps/grpc/grpc.gyp index 3e9a8f0c119..a6b20e01e8d 100644 --- a/deps/grpc/grpc.gyp +++ b/deps/grpc/grpc.gyp @@ -121,6 +121,7 @@ 'src/core/call/server_call.cc', 'src/core/call/status_util.cc', 'src/core/client_channel/backup_poller.cc', + 'src/core/client_channel/buffered_call.cc', 'src/core/client_channel/client_channel.cc', 'src/core/client_channel/client_channel_factory.cc', 'src/core/client_channel/client_channel_filter.cc', @@ -256,6 +257,7 @@ 'src/core/ext/transport/chttp2/transport/frame_security.cc', 'src/core/ext/transport/chttp2/transport/frame_settings.cc', 'src/core/ext/transport/chttp2/transport/frame_window_update.cc', + 'src/core/ext/transport/chttp2/transport/goaway.cc', 'src/core/ext/transport/chttp2/transport/hpack_encoder.cc', 'src/core/ext/transport/chttp2/transport/hpack_encoder_table.cc', 'src/core/ext/transport/chttp2/transport/hpack_parse_result.cc', diff --git a/deps/grpc/include/grpc/credentials.h b/deps/grpc/include/grpc/credentials.h index 3b5d49f8821..bc5cacc1af9 100644 --- a/deps/grpc/include/grpc/credentials.h +++ b/deps/grpc/include/grpc/credentials.h @@ -19,9 +19,12 @@ #ifndef GRPC_CREDENTIALS_H #define GRPC_CREDENTIALS_H -#include #include +#include +#include +#include #include +#include #include #ifdef __cplusplus @@ -34,6 +37,8 @@ extern "C" { call. These credentials can be composed with a channel credentials object so that they are sent with every call on this channel. */ +typedef struct grpc_server_credentials grpc_server_credentials; +typedef struct grpc_channel_credentials grpc_channel_credentials; typedef struct grpc_call_credentials grpc_call_credentials; typedef struct grpc_auth_context grpc_auth_context; diff --git a/deps/grpc/include/grpc/event_engine/memory_allocator.h b/deps/grpc/include/grpc/event_engine/memory_allocator.h index d50404c71ab..fc4fbc47b97 100644 --- a/deps/grpc/include/grpc/event_engine/memory_allocator.h +++ b/deps/grpc/include/grpc/event_engine/memory_allocator.h @@ -50,6 +50,8 @@ class MemoryAllocator { MemoryAllocator(MemoryAllocator&&) = default; MemoryAllocator& operator=(MemoryAllocator&&) = default; + bool IsValid() const { return allocator_ != nullptr; } + /// Drop the underlying allocator and make this an empty object. /// The object will not be usable after this call unless it's a valid /// allocator is moved into it. diff --git a/deps/grpc/include/grpc/event_engine/memory_request.h b/deps/grpc/include/grpc/event_engine/memory_request.h index 76bcbb20361..ad8cab842ed 100644 --- a/deps/grpc/include/grpc/event_engine/memory_request.h +++ b/deps/grpc/include/grpc/event_engine/memory_request.h @@ -17,6 +17,8 @@ #include #include +#include + #include "absl/strings/string_view.h" namespace grpc_event_engine { diff --git a/deps/grpc/include/grpc/impl/channel_arg_names.h b/deps/grpc/include/grpc/impl/channel_arg_names.h index e1b5cf4bea6..bd8a2cb44d1 100644 --- a/deps/grpc/include/grpc/impl/channel_arg_names.h +++ b/deps/grpc/include/grpc/impl/channel_arg_names.h @@ -384,6 +384,11 @@ * Note that this works only with the "ares" DNS resolver; it isn't supported * by the "native" DNS resolver. Boolean valued. Defaults to false. */ #define GRPC_ARG_DNS_ENABLE_SRV_QUERIES "grpc.dns_enable_srv_queries" +/** The cap for max_connections_per_subchannel when set via service + * config. If the configured value is higher than this, it will be + * capped at this value. Defaults to 10. */ +#define GRPC_ARG_MAX_CONNECTIONS_PER_SUBCHANNEL_CAP \ + "grpc.max_connections_per_subchannel_cap" /** If set, determines an upper bound on the number of milliseconds that the * c-ares based DNS resolver will wait on queries before cancelling them. * The default value is 120,000ms. Setting this to "0" will disable the diff --git a/deps/grpc/include/grpc/support/metrics.h b/deps/grpc/include/grpc/support/metrics.h index 55d60d5de19..06616f86855 100644 --- a/deps/grpc/include/grpc/support/metrics.h +++ b/deps/grpc/include/grpc/support/metrics.h @@ -15,11 +15,17 @@ #ifndef GRPC_SUPPORT_METRICS_H #define GRPC_SUPPORT_METRICS_H -#include #include #include "absl/strings/string_view.h" +// Forward declaration for EndpointConfig +namespace grpc_event_engine { +namespace experimental { +class EndpointConfig; // Forward declaration +} // namespace experimental +} // namespace grpc_event_engine + namespace grpc_core { namespace experimental { diff --git a/deps/grpc/include/grpcpp/channel.h b/deps/grpc/include/grpcpp/channel.h index 37afaa0dc80..4602e401dd8 100644 --- a/deps/grpc/include/grpcpp/channel.h +++ b/deps/grpc/include/grpcpp/channel.h @@ -74,6 +74,9 @@ class Channel final : public grpc::ChannelInterface, /// not available. std::string GetServiceConfigJSON() const; + grpc_event_engine::experimental::MemoryAllocator* memory_allocator() + const override; + private: template friend class grpc::internal::BlockingUnaryCallImpl; diff --git a/deps/grpc/include/grpcpp/ext/csm_observability.h b/deps/grpc/include/grpcpp/ext/csm_observability.h index 265d91949cd..17dbd2d0e48 100644 --- a/deps/grpc/include/grpcpp/ext/csm_observability.h +++ b/deps/grpc/include/grpcpp/ext/csm_observability.h @@ -24,10 +24,10 @@ #include +#include "opentelemetry/metrics/meter_provider.h" #include "absl/functional/any_invocable.h" #include "absl/status/statusor.h" #include "absl/strings/string_view.h" -#include "opentelemetry/metrics/meter_provider.h" namespace grpc { diff --git a/deps/grpc/include/grpcpp/ext/otel_plugin.h b/deps/grpc/include/grpcpp/ext/otel_plugin.h index 86261153559..27a221d42fd 100644 --- a/deps/grpc/include/grpcpp/ext/otel_plugin.h +++ b/deps/grpc/include/grpcpp/ext/otel_plugin.h @@ -28,13 +28,13 @@ #include +#include "opentelemetry/context/propagation/text_map_propagator.h" +#include "opentelemetry/metrics/meter_provider.h" +#include "opentelemetry/trace/tracer_provider.h" #include "absl/functional/any_invocable.h" #include "absl/status/status.h" #include "absl/status/statusor.h" #include "absl/strings/string_view.h" -#include "opentelemetry/context/propagation/text_map_propagator.h" -#include "opentelemetry/metrics/meter_provider.h" -#include "opentelemetry/trace/tracer_provider.h" namespace grpc { namespace internal { diff --git a/deps/grpc/include/grpcpp/impl/call_op_set.h b/deps/grpc/include/grpcpp/impl/call_op_set.h index 3ed80330e4b..5de617001af 100644 --- a/deps/grpc/include/grpcpp/impl/call_op_set.h +++ b/deps/grpc/include/grpcpp/impl/call_op_set.h @@ -19,6 +19,7 @@ #ifndef GRPCPP_IMPL_CALL_OP_SET_H #define GRPCPP_IMPL_CALL_OP_SET_H +#include #include #include #include @@ -292,23 +293,33 @@ class CallOpSendMessage { /// Send \a message using \a options for the write. The \a options are cleared /// after use. template - GRPC_MUST_USE_RESULT Status SendMessage(const M& message, - WriteOptions options); + GRPC_MUST_USE_RESULT Status + SendMessage(const M& message, WriteOptions options, + grpc_event_engine::experimental::MemoryAllocator* allocator); template - GRPC_MUST_USE_RESULT Status SendMessage(const M& message); + GRPC_MUST_USE_RESULT Status + SendMessage(const M& message, + grpc_event_engine::experimental::MemoryAllocator* allocator) { + return SendMessage(message, WriteOptions(), allocator); + } /// Send \a message using \a options for the write. The \a options are cleared /// after use. This form of SendMessage allows gRPC to reference \a message /// beyond the lifetime of SendMessage. template - GRPC_MUST_USE_RESULT Status SendMessagePtr(const M* message, - WriteOptions options); + GRPC_MUST_USE_RESULT Status + SendMessagePtr(const M* message, WriteOptions options, + grpc_event_engine::experimental::MemoryAllocator* allocator); /// This form of SendMessage allows gRPC to reference \a message beyond the /// lifetime of SendMessage. template - GRPC_MUST_USE_RESULT Status SendMessagePtr(const M* message); + GRPC_MUST_USE_RESULT Status + SendMessagePtr(const M* message, + grpc_event_engine::experimental::MemoryAllocator* allocator) { + return SendMessagePtr(message, WriteOptions(), allocator); + } protected: void AddOp(grpc_op* ops, size_t* nops) { @@ -378,12 +389,13 @@ class CallOpSendMessage { }; template -Status CallOpSendMessage::SendMessage(const M& message, WriteOptions options) { +Status CallOpSendMessage::SendMessage( + const M& message, WriteOptions options, + grpc_event_engine::experimental::MemoryAllocator* allocator) { write_options_ = options; // Serialize immediately since we do not have access to the message pointer bool own_buf; - Status result = SerializationTraits::Serialize( - message, send_buf_.bbuf_ptr(), &own_buf); + Status result = Serialize(allocator, message, send_buf_.bbuf_ptr(), &own_buf); if (!own_buf) { send_buf_.Duplicate(); } @@ -391,24 +403,20 @@ Status CallOpSendMessage::SendMessage(const M& message, WriteOptions options) { } template -Status CallOpSendMessage::SendMessage(const M& message) { - return SendMessage(message, WriteOptions()); -} - -template -Status CallOpSendMessage::SendMessagePtr(const M* message, - WriteOptions options) { +Status CallOpSendMessage::SendMessagePtr( + const M* message, WriteOptions options, + grpc_event_engine::experimental::MemoryAllocator* allocator) { msg_ = message; write_options_ = options; // Store the serializer for later since we have access to the message - serializer_ = [this](const void* message) { + serializer_ = [this, allocator](const void* message) { bool own_buf; // TODO(vjpai): Remove the void below when possible // The void in the template parameter below should not be needed // (since it should be implicit) but is needed due to an observed // difference in behavior between clang and gcc for certain internal users - Status result = SerializationTraits::Serialize( - *static_cast(message), send_buf_.bbuf_ptr(), &own_buf); + Status result = Serialize(allocator, *static_cast(message), + send_buf_.bbuf_ptr(), &own_buf); if (!own_buf) { send_buf_.Duplicate(); } @@ -417,11 +425,6 @@ Status CallOpSendMessage::SendMessagePtr(const M* message, return Status(); } -template -Status CallOpSendMessage::SendMessagePtr(const M* message) { - return SendMessagePtr(message, WriteOptions()); -} - template class CallOpRecvMessage { public: @@ -447,8 +450,7 @@ class CallOpRecvMessage { if (recv_buf_.Valid()) { if (*status) { got_message = *status = - SerializationTraits::Deserialize(recv_buf_.bbuf_ptr(), message_) - .ok(); + grpc::Deserialize(recv_buf_.bbuf_ptr(), message_).ok(); recv_buf_.Release(); } else { got_message = false; @@ -516,7 +518,7 @@ class DeserializeFuncType final : public DeserializeFunc { public: explicit DeserializeFuncType(R* message) : message_(message) {} Status Deserialize(ByteBuffer* buf) override { - return SerializationTraits::Deserialize(buf->bbuf_ptr(), message_); + return grpc::Deserialize(buf->bbuf_ptr(), message_); } ~DeserializeFuncType() override {} diff --git a/deps/grpc/include/grpcpp/impl/channel_interface.h b/deps/grpc/include/grpcpp/impl/channel_interface.h index 48d9661f6fa..eb0a173b438 100644 --- a/deps/grpc/include/grpcpp/impl/channel_interface.h +++ b/deps/grpc/include/grpcpp/impl/channel_interface.h @@ -19,6 +19,7 @@ #ifndef GRPCPP_IMPL_CHANNEL_INTERFACE_H #define GRPCPP_IMPL_CHANNEL_INTERFACE_H +#include #include #include #include @@ -102,6 +103,11 @@ class ChannelInterface { return true; } + virtual grpc_event_engine::experimental::MemoryAllocator* memory_allocator() + const { + return nullptr; + } + private: template friend class grpc::ClientReader; diff --git a/deps/grpc/include/grpcpp/impl/client_unary_call.h b/deps/grpc/include/grpcpp/impl/client_unary_call.h index c2fdcd99a34..5cb1271c2ca 100644 --- a/deps/grpc/include/grpcpp/impl/client_unary_call.h +++ b/deps/grpc/include/grpcpp/impl/client_unary_call.h @@ -65,7 +65,8 @@ class BlockingUnaryCallImpl { CallOpRecvInitialMetadata, CallOpRecvMessage, CallOpClientSendClose, CallOpClientRecvStatus> ops; - status_ = ops.SendMessagePtr(&request); + + status_ = ops.SendMessagePtr(&request, channel->memory_allocator()); if (!status_.ok()) { return; } diff --git a/deps/grpc/include/grpcpp/impl/delegating_channel.h b/deps/grpc/include/grpcpp/impl/delegating_channel.h index add88a23bb0..601ff284336 100644 --- a/deps/grpc/include/grpcpp/impl/delegating_channel.h +++ b/deps/grpc/include/grpcpp/impl/delegating_channel.h @@ -38,6 +38,11 @@ class DelegatingChannel : public grpc::ChannelInterface { return delegate_channel()->GetState(try_to_connect); } + grpc_event_engine::experimental::MemoryAllocator* memory_allocator() + const override { + return delegate_channel_->memory_allocator(); + } + std::shared_ptr delegate_channel() { return delegate_channel_; } diff --git a/deps/grpc/include/grpcpp/impl/generic_serialize.h b/deps/grpc/include/grpcpp/impl/generic_serialize.h index 2efec89819d..931fd6eab10 100644 --- a/deps/grpc/include/grpcpp/impl/generic_serialize.h +++ b/deps/grpc/include/grpcpp/impl/generic_serialize.h @@ -16,6 +16,7 @@ #define GRPCPP_IMPL_GENERIC_SERIALIZE_H #include +#include #include #include #include @@ -40,8 +41,9 @@ namespace grpc { // ProtoBufferWriter must be a subclass of ::protobuf::io::ZeroCopyOutputStream. template -Status GenericSerialize(const grpc::protobuf::MessageLite& msg, ByteBuffer* bb, - bool* own_buffer) { +Status GenericSerialize( + const grpc::protobuf::MessageLite& msg, ByteBuffer* bb, bool* own_buffer, + grpc_event_engine::experimental::MemoryAllocator* allocator = nullptr) { static_assert(std::is_base_of::value, "ProtoBufferWriter must be a subclass of " @@ -64,7 +66,7 @@ Status GenericSerialize(const grpc::protobuf::MessageLite& msg, ByteBuffer* bb, return grpc::Status::OK; } ProtoBufferWriter writer(bb, kProtoBufferWriterMaxBufferLength, - static_cast(byte_size)); + static_cast(byte_size), allocator); protobuf::io::CodedOutputStream cs(&writer); msg.SerializeWithCachedSizes(&cs); return !cs.HadError() diff --git a/deps/grpc/include/grpcpp/impl/intercepted_channel.h b/deps/grpc/include/grpcpp/impl/intercepted_channel.h index 908655a6e47..b6e03168190 100644 --- a/deps/grpc/include/grpcpp/impl/intercepted_channel.h +++ b/deps/grpc/include/grpcpp/impl/intercepted_channel.h @@ -42,6 +42,11 @@ class InterceptedChannel : public ChannelInterface { return channel_->GetState(try_to_connect); } + grpc_event_engine::experimental::MemoryAllocator* memory_allocator() + const override { + return channel_->memory_allocator(); + } + private: InterceptedChannel(ChannelInterface* channel, size_t pos) : channel_(channel), interceptor_pos_(pos) {} diff --git a/deps/grpc/include/grpcpp/impl/serialization_traits.h b/deps/grpc/include/grpcpp/impl/serialization_traits.h index 83ba0bb2d56..8b6bda3d141 100644 --- a/deps/grpc/include/grpcpp/impl/serialization_traits.h +++ b/deps/grpc/include/grpcpp/impl/serialization_traits.h @@ -19,6 +19,11 @@ #ifndef GRPCPP_IMPL_SERIALIZATION_TRAITS_H #define GRPCPP_IMPL_SERIALIZATION_TRAITS_H +#include + +#include +#include + namespace grpc { /// Defines how to serialize and deserialize some type. @@ -57,6 +62,65 @@ template class SerializationTraits; +namespace impl { + +// Helper trait to robustly check if the allocator-aware Serialize exists. +template +struct has_allocator_serialize : std::false_type {}; + +template +struct has_allocator_serialize< + Message, BufferPtr, + std::void_t::Serialize( + std::declval(), + std::declval(), std::declval(), + std::declval()))>> : std::true_type {}; + +template +inline constexpr bool has_allocator_serialize_v = + has_allocator_serialize::value; + +// Primary template for SerializeDispatch, now switched by a bool. +template > +struct SerializeDispatch; + +// Specialization for when the allocator-aware Serialize *exists*. +template +struct SerializeDispatch { + static auto Serialize( + grpc_event_engine::experimental::MemoryAllocator* allocator, + const Message& msg, BufferPtr buffer, bool* own_buffer) { + return SerializationTraits::Serialize(allocator, msg, buffer, + own_buffer); + } +}; + +// Specialization for when the allocator-aware Serialize *does not* exist. +template +struct SerializeDispatch { + static auto Serialize( + grpc_event_engine::experimental::MemoryAllocator* /*allocator*/, + const Message& msg, BufferPtr buffer, bool* own_buffer) { + // Fallback to the old Serialize, ignoring the allocator. + return SerializationTraits::Serialize(msg, buffer, own_buffer); + } +}; + +} // namespace impl + +template +auto Serialize(grpc_event_engine::experimental::MemoryAllocator* allocator, + const Message& msg, BufferPtr buffer, bool* own_buffer) { + return impl::SerializeDispatch::Serialize( + allocator, msg, buffer, own_buffer); +} + +template +auto Deserialize(BufferPtr buffer, Message* msg) { + return SerializationTraits::Deserialize(buffer, msg); +} + } // namespace grpc #endif // GRPCPP_IMPL_SERIALIZATION_TRAITS_H diff --git a/deps/grpc/include/grpcpp/impl/server_callback_handlers.h b/deps/grpc/include/grpcpp/impl/server_callback_handlers.h index 034bb0d958b..bc3965f675a 100644 --- a/deps/grpc/include/grpcpp/impl/server_callback_handlers.h +++ b/deps/grpc/include/grpcpp/impl/server_callback_handlers.h @@ -95,8 +95,7 @@ class CallbackUnaryHandler : public grpc::internal::MethodHandler { } *handler_data = allocator_state; request = allocator_state->request(); - *status = - grpc::SerializationTraits::Deserialize(&buf, request); + *status = grpc::Deserialize(&buf, request); buf.Release(); if (status->ok()) { return request; @@ -138,8 +137,9 @@ class CallbackUnaryHandler : public grpc::internal::MethodHandler { } // The response is dropped if the status is not OK. if (s.ok()) { - finish_ops_.ServerSendStatus(&ctx_->trailing_metadata_, - finish_ops_.SendMessagePtr(response())); + finish_ops_.ServerSendStatus( + &ctx_->trailing_metadata_, + finish_ops_.SendMessagePtr(response(), ctx_->memory_allocator())); } else { finish_ops_.ServerSendStatus(&ctx_->trailing_metadata_, s); } @@ -326,8 +326,9 @@ class CallbackClientStreamingHandler : public grpc::internal::MethodHandler { } // The response is dropped if the status is not OK. if (s.ok()) { - finish_ops_.ServerSendStatus(&ctx_->trailing_metadata_, - finish_ops_.SendMessagePtr(&resp_)); + finish_ops_.ServerSendStatus( + &ctx_->trailing_metadata_, + finish_ops_.SendMessagePtr(&resp_, ctx_->memory_allocator())); } else { finish_ops_.ServerSendStatus(&ctx_->trailing_metadata_, s); } @@ -495,8 +496,7 @@ class CallbackServerStreamingHandler : public grpc::internal::MethodHandler { buf.set_buffer(req); auto* request = new (grpc_call_arena_alloc(call, sizeof(RequestType))) RequestType(); - *status = - grpc::SerializationTraits::Deserialize(&buf, request); + *status = grpc::Deserialize(&buf, request); buf.Release(); if (status->ok()) { return request; @@ -578,7 +578,9 @@ class CallbackServerStreamingHandler : public grpc::internal::MethodHandler { ctx_->sent_initial_metadata_ = true; } // TODO(vjpai): don't assert - ABSL_CHECK(write_ops_.SendMessagePtr(resp, options).ok()); + ABSL_CHECK( + write_ops_.SendMessagePtr(resp, options, ctx_->memory_allocator()) + .ok()); call_.PerformOps(&write_ops_); } @@ -586,7 +588,9 @@ class CallbackServerStreamingHandler : public grpc::internal::MethodHandler { grpc::Status s) override { // This combines the write into the finish callback // TODO(vjpai): don't assert - ABSL_CHECK(finish_ops_.SendMessagePtr(resp, options).ok()); + ABSL_CHECK( + finish_ops_.SendMessagePtr(resp, options, ctx_->memory_allocator()) + .ok()); Finish(std::move(s)); } @@ -790,14 +794,18 @@ class CallbackBidiHandler : public grpc::internal::MethodHandler { ctx_->sent_initial_metadata_ = true; } // TODO(vjpai): don't assert - ABSL_CHECK(write_ops_.SendMessagePtr(resp, options).ok()); + ABSL_CHECK( + write_ops_.SendMessagePtr(resp, options, ctx_->memory_allocator()) + .ok()); call_.PerformOps(&write_ops_); } void WriteAndFinish(const ResponseType* resp, grpc::WriteOptions options, grpc::Status s) override { // TODO(vjpai): don't assert - ABSL_CHECK(finish_ops_.SendMessagePtr(resp, options).ok()); + ABSL_CHECK( + finish_ops_.SendMessagePtr(resp, options, ctx_->memory_allocator()) + .ok()); Finish(std::move(s)); } diff --git a/deps/grpc/include/grpcpp/server.h b/deps/grpc/include/grpcpp/server.h index 37f71ff7d62..0392bae4dbc 100644 --- a/deps/grpc/include/grpcpp/server.h +++ b/deps/grpc/include/grpcpp/server.h @@ -20,6 +20,7 @@ #define GRPCPP_SERVER_H #include +#include #include #include #include @@ -208,6 +209,8 @@ class Server : public ServerInterface, private internal::GrpcLibrary { return health_check_service_disabled_; } + grpc_event_engine::experimental::MemoryAllocator* memory_allocator() override; + private: std::vector>* interceptor_creators() override { @@ -297,8 +300,11 @@ class Server : public ServerInterface, private internal::GrpcLibrary { /// the \a sync_server_cqs) std::vector> sync_req_mgrs_; + // Memory allocator for the server. + grpc_event_engine::experimental::MemoryAllocator memory_allocator_; + // Server status - internal::Mutex mu_; + mutable internal::Mutex mu_; bool started_; bool shutdown_ ABSL_GUARDED_BY(mu_); bool shutdown_notified_ diff --git a/deps/grpc/include/grpcpp/server_context.h b/deps/grpc/include/grpcpp/server_context.h index 6530fe4126f..76d8f22781c 100644 --- a/deps/grpc/include/grpcpp/server_context.h +++ b/deps/grpc/include/grpcpp/server_context.h @@ -297,6 +297,10 @@ class ServerContextBase { return call_metric_recorder_; } + grpc_event_engine::experimental::MemoryAllocator* memory_allocator() { + return memory_allocator_; + } + /// EXPERIMENTAL API /// Returns the call's authority. grpc::string_ref ExperimentalGetAuthority() const; @@ -419,12 +423,15 @@ class ServerContextBase { /// Return the tag queued by BeginCompletionOp() grpc::internal::CompletionQueueTag* GetCompletionOpTag(); - void set_call(grpc_call* call, bool call_metric_recording_enabled, - experimental::ServerMetricRecorder* server_metric_recorder) { + void set_call( + grpc_call* call, bool call_metric_recording_enabled, + experimental::ServerMetricRecorder* server_metric_recorder, + grpc_event_engine::experimental::MemoryAllocator* memory_allocator) { call_.call = call; if (call_metric_recording_enabled) { CreateCallMetricRecorder(server_metric_recorder); } + memory_allocator_ = memory_allocator; } void BindDeadlineAndMetadata(gpr_timespec deadline, grpc_metadata_array* arr); @@ -495,6 +502,7 @@ class ServerContextBase { RpcAllocatorState* message_allocator_state_ = nullptr; ContextAllocator* context_allocator_ = nullptr; experimental::CallMetricRecorder* call_metric_recorder_ = nullptr; + grpc_event_engine::experimental::MemoryAllocator* memory_allocator_ = nullptr; class Reactor : public grpc::ServerUnaryReactor { public: diff --git a/deps/grpc/include/grpcpp/server_interface.h b/deps/grpc/include/grpcpp/server_interface.h index 3e6680f1767..a1454959f5d 100644 --- a/deps/grpc/include/grpcpp/server_interface.h +++ b/deps/grpc/include/grpcpp/server_interface.h @@ -111,6 +111,9 @@ class ServerInterface : public internal::CallHook { /// call \a Shutdown for this function to ever return. virtual void Wait() = 0; + virtual grpc_event_engine::experimental::MemoryAllocator* + memory_allocator() = 0; + protected: friend class grpc::Service; @@ -265,9 +268,8 @@ class ServerInterface : public internal::CallHook { return RegisteredAsyncRequest::FinalizeResult(tag, status); } if (*status) { - if (!payload_.Valid() || !SerializationTraits::Deserialize( - payload_.bbuf_ptr(), request_) - .ok()) { + if (!payload_.Valid() || + !grpc::Deserialize(payload_.bbuf_ptr(), request_).ok()) { // If deserialization fails, we cancel the call and instantiate // a new instance of ourselves to request another call. We then // return false, which prevents the call from being returned to diff --git a/deps/grpc/include/grpcpp/support/async_stream.h b/deps/grpc/include/grpcpp/support/async_stream.h index 7264fa15045..4ca0e99f8a4 100644 --- a/deps/grpc/include/grpcpp/support/async_stream.h +++ b/deps/grpc/include/grpcpp/support/async_stream.h @@ -192,7 +192,7 @@ class ClientAsyncReaderFactory { grpc::internal::Call call = channel->CreateCall(method, context, cq); return new ( grpc_call_arena_alloc(call.call(), sizeof(ClientAsyncReader))) - ClientAsyncReader(call, context, request, start, tag); + ClientAsyncReader(channel, call, context, request, start, tag); } }; } // namespace internal @@ -266,11 +266,13 @@ class ClientAsyncReader final : public ClientAsyncReaderInterface { private: friend class internal::ClientAsyncReaderFactory; template - ClientAsyncReader(grpc::internal::Call call, grpc::ClientContext* context, - const W& request, bool start, void* tag) - : context_(context), call_(call), started_(start) { + ClientAsyncReader(grpc::ChannelInterface* channel, grpc::internal::Call call, + grpc::ClientContext* context, const W& request, bool start, + void* tag) + : channel_(channel), context_(context), call_(call), started_(start) { // TODO(ctiller): don't assert - ABSL_CHECK(init_ops_.SendMessage(request).ok()); + ABSL_CHECK( + init_ops_.SendMessage(request, channel_->memory_allocator()).ok()); init_ops_.ClientSendClose(); if (start) { StartCallInternal(tag); @@ -286,6 +288,7 @@ class ClientAsyncReader final : public ClientAsyncReaderInterface { call_.PerformOps(&init_ops_); } + grpc::ChannelInterface* channel_; grpc::ClientContext* context_; grpc::internal::Call call_; bool started_; @@ -340,7 +343,7 @@ class ClientAsyncWriterFactory { grpc::internal::Call call = channel->CreateCall(method, context, cq); return new ( grpc_call_arena_alloc(call.call(), sizeof(ClientAsyncWriter))) - ClientAsyncWriter(call, context, response, start, tag); + ClientAsyncWriter(channel, call, context, response, start, tag); } }; } // namespace internal @@ -389,7 +392,7 @@ class ClientAsyncWriter final : public ClientAsyncWriterInterface { ABSL_CHECK(started_); write_ops_.set_output_tag(tag); // TODO(ctiller): don't assert - ABSL_CHECK(write_ops_.SendMessage(msg).ok()); + ABSL_CHECK(write_ops_.SendMessage(msg, channel_->memory_allocator()).ok()); call_.PerformOps(&write_ops_); } @@ -400,8 +403,11 @@ class ClientAsyncWriter final : public ClientAsyncWriterInterface { options.set_buffer_hint(); write_ops_.ClientSendClose(); } + // TODO(ctiller): don't assert - ABSL_CHECK(write_ops_.SendMessage(msg, options).ok()); + ABSL_CHECK( + write_ops_.SendMessage(msg, options, channel_->memory_allocator()) + .ok()); call_.PerformOps(&write_ops_); } @@ -432,9 +438,10 @@ class ClientAsyncWriter final : public ClientAsyncWriterInterface { private: friend class internal::ClientAsyncWriterFactory; template - ClientAsyncWriter(grpc::internal::Call call, grpc::ClientContext* context, - R* response, bool start, void* tag) - : context_(context), call_(call), started_(start) { + ClientAsyncWriter(grpc::ChannelInterface* channel, grpc::internal::Call call, + grpc::ClientContext* context, R* response, bool start, + void* tag) + : channel_(channel), context_(context), call_(call), started_(start) { finish_ops_.RecvMessage(response); finish_ops_.AllowNoMessage(); if (start) { @@ -455,6 +462,7 @@ class ClientAsyncWriter final : public ClientAsyncWriterInterface { } } + grpc::ChannelInterface* channel_; grpc::ClientContext* context_; grpc::internal::Call call_; bool started_; @@ -505,7 +513,7 @@ class ClientAsyncReaderWriterFactory { return new (grpc_call_arena_alloc(call.call(), sizeof(ClientAsyncReaderWriter))) - ClientAsyncReaderWriter(call, context, start, tag); + ClientAsyncReaderWriter(channel, call, context, start, tag); } }; } // namespace internal @@ -566,7 +574,7 @@ class ClientAsyncReaderWriter final ABSL_CHECK(started_); write_ops_.set_output_tag(tag); // TODO(ctiller): don't assert - ABSL_CHECK(write_ops_.SendMessage(msg).ok()); + ABSL_CHECK(write_ops_.SendMessage(msg, channel_->memory_allocator()).ok()); call_.PerformOps(&write_ops_); } @@ -578,7 +586,9 @@ class ClientAsyncReaderWriter final write_ops_.ClientSendClose(); } // TODO(ctiller): don't assert - ABSL_CHECK(write_ops_.SendMessage(msg, options).ok()); + ABSL_CHECK( + write_ops_.SendMessage(msg, options, channel_->memory_allocator()) + .ok()); call_.PerformOps(&write_ops_); } @@ -605,9 +615,10 @@ class ClientAsyncReaderWriter final private: friend class internal::ClientAsyncReaderWriterFactory; - ClientAsyncReaderWriter(grpc::internal::Call call, + ClientAsyncReaderWriter(grpc::ChannelInterface* channel, + grpc::internal::Call call, grpc::ClientContext* context, bool start, void* tag) - : context_(context), call_(call), started_(start) { + : channel_(channel), context_(context), call_(call), started_(start) { if (start) { StartCallInternal(tag); } else { @@ -626,6 +637,7 @@ class ClientAsyncReaderWriter final } } + grpc::ChannelInterface* channel_; grpc::ClientContext* context_; grpc::internal::Call call_; bool started_; @@ -752,8 +764,9 @@ class ServerAsyncReader final : public ServerAsyncReaderInterface { } // The response is dropped if the status is not OK. if (status.ok()) { - finish_ops_.ServerSendStatus(&ctx_->trailing_metadata_, - finish_ops_.SendMessage(msg)); + finish_ops_.ServerSendStatus( + &ctx_->trailing_metadata_, + finish_ops_.SendMessage(msg, ctx_->memory_allocator())); } else { finish_ops_.ServerSendStatus(&ctx_->trailing_metadata_, status); } @@ -876,7 +889,7 @@ class ServerAsyncWriter final : public ServerAsyncWriterInterface { write_ops_.set_output_tag(tag); EnsureInitialMetadataSent(&write_ops_); // TODO(ctiller): don't assert - ABSL_CHECK(write_ops_.SendMessage(msg).ok()); + ABSL_CHECK(write_ops_.SendMessage(msg, ctx_->memory_allocator()).ok()); call_.PerformOps(&write_ops_); } @@ -888,7 +901,8 @@ class ServerAsyncWriter final : public ServerAsyncWriterInterface { EnsureInitialMetadataSent(&write_ops_); // TODO(ctiller): don't assert - ABSL_CHECK(write_ops_.SendMessage(msg, options).ok()); + ABSL_CHECK( + write_ops_.SendMessage(msg, options, ctx_->memory_allocator()).ok()); call_.PerformOps(&write_ops_); } @@ -907,7 +921,8 @@ class ServerAsyncWriter final : public ServerAsyncWriterInterface { write_ops_.set_output_tag(tag); EnsureInitialMetadataSent(&write_ops_); options.set_buffer_hint(); - ABSL_CHECK(write_ops_.SendMessage(msg, options).ok()); + ABSL_CHECK( + write_ops_.SendMessage(msg, options, ctx_->memory_allocator()).ok()); write_ops_.ServerSendStatus(&ctx_->trailing_metadata_, status); call_.PerformOps(&write_ops_); } @@ -1048,7 +1063,7 @@ class ServerAsyncReaderWriter final write_ops_.set_output_tag(tag); EnsureInitialMetadataSent(&write_ops_); // TODO(ctiller): don't assert - ABSL_CHECK(write_ops_.SendMessage(msg).ok()); + ABSL_CHECK(write_ops_.SendMessage(msg, ctx_->memory_allocator()).ok()); call_.PerformOps(&write_ops_); } @@ -1058,7 +1073,8 @@ class ServerAsyncReaderWriter final options.set_buffer_hint(); } EnsureInitialMetadataSent(&write_ops_); - ABSL_CHECK(write_ops_.SendMessage(msg, options).ok()); + ABSL_CHECK( + write_ops_.SendMessage(msg, options, ctx_->memory_allocator()).ok()); call_.PerformOps(&write_ops_); } @@ -1078,7 +1094,8 @@ class ServerAsyncReaderWriter final write_ops_.set_output_tag(tag); EnsureInitialMetadataSent(&write_ops_); options.set_buffer_hint(); - ABSL_CHECK(write_ops_.SendMessage(msg, options).ok()); + ABSL_CHECK( + write_ops_.SendMessage(msg, options, ctx_->memory_allocator()).ok()); write_ops_.ServerSendStatus(&ctx_->trailing_metadata_, status); call_.PerformOps(&write_ops_); } diff --git a/deps/grpc/include/grpcpp/support/async_unary_call.h b/deps/grpc/include/grpcpp/support/async_unary_call.h index b50798ae7cf..8bbec3ab196 100644 --- a/deps/grpc/include/grpcpp/support/async_unary_call.h +++ b/deps/grpc/include/grpcpp/support/async_unary_call.h @@ -99,9 +99,10 @@ class ClientAsyncResponseReaderHelper { ClientAsyncResponseReader* result = new (grpc_call_arena_alloc( call.call(), sizeof(ClientAsyncResponseReader))) ClientAsyncResponseReader(call, context); - SetupRequest( - call.call(), &result->single_buf_, &result->read_initial_metadata_, - &result->finish_, static_cast(request)); + SetupRequest(channel, call.call(), &result->single_buf_, + &result->read_initial_metadata_, + &result->finish_, + static_cast(request)); return result; } @@ -110,7 +111,7 @@ class ClientAsyncResponseReaderHelper { template static void SetupRequest( - grpc_call* call, + grpc::ChannelInterface* channel, grpc_call* call, grpc::internal::CallOpSendInitialMetadata** single_buf_ptr, std::function* @@ -130,8 +131,10 @@ class ClientAsyncResponseReaderHelper { SingleBufType* single_buf = new (grpc_call_arena_alloc(call, sizeof(SingleBufType))) SingleBufType; *single_buf_ptr = single_buf; + // TODO(ctiller): don't assert - ABSL_CHECK(single_buf->SendMessage(request).ok()); + ABSL_CHECK( + single_buf->SendMessage(request, channel->memory_allocator()).ok()); single_buf->ClientSendClose(); // The purpose of the following functions is to type-erase the actual @@ -349,8 +352,9 @@ class ServerAsyncResponseWriter final } // The response is dropped if the status is not OK. if (status.ok()) { - finish_buf_.ServerSendStatus(&ctx_->trailing_metadata_, - finish_buf_.SendMessage(msg)); + finish_buf_.ServerSendStatus( + &ctx_->trailing_metadata_, + finish_buf_.SendMessage(msg, ctx_->memory_allocator())); } else { finish_buf_.ServerSendStatus(&ctx_->trailing_metadata_, status); } diff --git a/deps/grpc/include/grpcpp/support/client_callback.h b/deps/grpc/include/grpcpp/support/client_callback.h index 481e1c7e590..392632282c8 100644 --- a/deps/grpc/include/grpcpp/support/client_callback.h +++ b/deps/grpc/include/grpcpp/support/client_callback.h @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -94,7 +95,7 @@ class CallbackUnaryCallImpl { call.call(), std::move(on_completion), ops); // TODO(vjpai): Unify code with sync API as much as possible - grpc::Status s = ops->SendMessagePtr(request); + grpc::Status s = ops->SendMessagePtr(request, channel->memory_allocator()); if (!s.ok()) { tag->force_run(s); return; @@ -530,8 +531,11 @@ class ClientCallbackReaderWriterImpl options.set_buffer_hint(); write_ops_.ClientSendClose(); } + // TODO(vjpai): don't assert - ABSL_CHECK(write_ops_.SendMessagePtr(msg, options).ok()); + ABSL_CHECK( + write_ops_.SendMessagePtr(msg, options, channel_->memory_allocator()) + .ok()); callbacks_outstanding_.fetch_add(1, std::memory_order_relaxed); if (GPR_UNLIKELY(corked_write_needed_)) { write_ops_.SendInitialMetadata(&context_->send_initial_metadata_, @@ -582,10 +586,12 @@ class ClientCallbackReaderWriterImpl private: friend class ClientCallbackReaderWriterFactory; - ClientCallbackReaderWriterImpl(grpc::internal::Call call, + ClientCallbackReaderWriterImpl(grpc::ChannelInterface* channel, + grpc::internal::Call call, grpc::ClientContext* context, ClientBidiReactor* reactor) - : context_(context), + : channel_(channel), + context_(context), call_(call), reactor_(reactor), start_corked_(context_->initial_metadata_corked_), @@ -656,6 +662,7 @@ class ClientCallbackReaderWriterImpl } } + grpc::ChannelInterface* const channel_; grpc::ClientContext* const context_; grpc::internal::Call call_; ClientBidiReactor* const reactor_; @@ -713,8 +720,8 @@ class ClientCallbackReaderWriterFactory { grpc_call_ref(call.call()); new (grpc_call_arena_alloc( call.call(), sizeof(ClientCallbackReaderWriterImpl))) - ClientCallbackReaderWriterImpl(call, context, - reactor); + ClientCallbackReaderWriterImpl(channel, call, + context, reactor); } }; @@ -802,13 +809,15 @@ class ClientCallbackReaderImpl : public ClientCallbackReader { friend class ClientCallbackReaderFactory; template - ClientCallbackReaderImpl(grpc::internal::Call call, + ClientCallbackReaderImpl(grpc::ChannelInterface* channel, + grpc::internal::Call call, grpc::ClientContext* context, Request* request, ClientReadReactor* reactor) : context_(context), call_(call), reactor_(reactor) { this->BindReactor(reactor); // TODO(vjpai): don't assert - ABSL_CHECK(start_ops_.SendMessagePtr(request).ok()); + ABSL_CHECK( + start_ops_.SendMessagePtr(request, channel->memory_allocator()).ok()); start_ops_.ClientSendClose(); } @@ -875,7 +884,8 @@ class ClientCallbackReaderFactory { grpc_call_ref(call.call()); new (grpc_call_arena_alloc(call.call(), sizeof(ClientCallbackReaderImpl))) - ClientCallbackReaderImpl(call, context, request, reactor); + ClientCallbackReaderImpl(channel, call, context, request, + reactor); } }; @@ -932,8 +942,11 @@ class ClientCallbackWriterImpl : public ClientCallbackWriter { options.set_buffer_hint(); write_ops_.ClientSendClose(); } + // TODO(vjpai): don't assert - ABSL_CHECK(write_ops_.SendMessagePtr(msg, options).ok()); + ABSL_CHECK( + write_ops_.SendMessagePtr(msg, options, channel_->memory_allocator()) + .ok()); callbacks_outstanding_.fetch_add(1, std::memory_order_relaxed); if (GPR_UNLIKELY(corked_write_needed_)) { @@ -989,10 +1002,12 @@ class ClientCallbackWriterImpl : public ClientCallbackWriter { friend class ClientCallbackWriterFactory; template - ClientCallbackWriterImpl(grpc::internal::Call call, + ClientCallbackWriterImpl(grpc::ChannelInterface* channel, + grpc::internal::Call call, grpc::ClientContext* context, Response* response, ClientWriteReactor* reactor) - : context_(context), + : channel_(channel), + context_(context), call_(call), reactor_(reactor), start_corked_(context_->initial_metadata_corked_), @@ -1051,6 +1066,7 @@ class ClientCallbackWriterImpl : public ClientCallbackWriter { } } + grpc::ChannelInterface* const channel_; grpc::ClientContext* const context_; grpc::internal::Call call_; ClientWriteReactor* const reactor_; @@ -1106,7 +1122,8 @@ class ClientCallbackWriterFactory { grpc_call_ref(call.call()); new (grpc_call_arena_alloc(call.call(), sizeof(ClientCallbackWriterImpl))) - ClientCallbackWriterImpl(call, context, response, reactor); + ClientCallbackWriterImpl(channel, call, context, response, + reactor); } }; @@ -1155,13 +1172,16 @@ class ClientCallbackUnaryImpl final : public ClientCallbackUnary { friend class ClientCallbackUnaryFactory; template - ClientCallbackUnaryImpl(grpc::internal::Call call, + ClientCallbackUnaryImpl(grpc::ChannelInterface* channel, + grpc::internal::Call call, grpc::ClientContext* context, Request* request, Response* response, ClientUnaryReactor* reactor) : context_(context), call_(call), reactor_(reactor) { this->BindReactor(reactor); + // TODO(vjpai): don't assert - ABSL_CHECK(start_ops_.SendMessagePtr(request).ok()); + ABSL_CHECK( + start_ops_.SendMessagePtr(request, channel->memory_allocator()).ok()); start_ops_.ClientSendClose(); finish_ops_.RecvMessage(response); finish_ops_.AllowNoMessage(); @@ -1217,7 +1237,7 @@ class ClientCallbackUnaryFactory { grpc_call_ref(call.call()); new (grpc_call_arena_alloc(call.call(), sizeof(ClientCallbackUnaryImpl))) - ClientCallbackUnaryImpl(call, context, + ClientCallbackUnaryImpl(channel, call, context, static_cast(request), static_cast(response), reactor); } diff --git a/deps/grpc/include/grpcpp/support/global_callback_hook.h b/deps/grpc/include/grpcpp/support/global_callback_hook.h index c453bc807f4..9bc9d54aece 100644 --- a/deps/grpc/include/grpcpp/support/global_callback_hook.h +++ b/deps/grpc/include/grpcpp/support/global_callback_hook.h @@ -45,7 +45,7 @@ class GlobalCallbackHook { class DefaultGlobalCallbackHook final : public GlobalCallbackHook { public: - void RunCallback(grpc_call* call, + void RunCallback(grpc_call* /* call */, absl::FunctionRef callback) override { CatchingCallback(callback); } diff --git a/deps/grpc/include/grpcpp/support/method_handler.h b/deps/grpc/include/grpcpp/support/method_handler.h index a61843bdb86..230c6ce7ec4 100644 --- a/deps/grpc/include/grpcpp/support/method_handler.h +++ b/deps/grpc/include/grpcpp/support/method_handler.h @@ -69,7 +69,7 @@ void UnaryRunHandlerHelper(const MethodHandler::HandlerParameter& param, ops.set_compression_level(param.server_context->compression_level()); } if (status.ok()) { - status = ops.SendMessagePtr(rsp); + status = ops.SendMessagePtr(rsp, param.server_context->memory_allocator()); } ops.ServerSendStatus(¶m.server_context->trailing_metadata_, status); param.call->PerformOps(&ops); @@ -83,8 +83,7 @@ void* UnaryDeserializeHelper(grpc_byte_buffer* req, grpc::Status* status, RequestType* request) { grpc::ByteBuffer buf; buf.set_buffer(req); - *status = grpc::SerializationTraits::Deserialize( - &buf, static_cast(request)); + *status = grpc::Deserialize(&buf, static_cast(request)); buf.Release(); if (status->ok()) { return request; @@ -171,7 +170,8 @@ class ClientStreamingHandler : public grpc::internal::MethodHandler { } } if (status.ok()) { - status = ops.SendMessagePtr(&rsp); + status = + ops.SendMessagePtr(&rsp, param.server_context->memory_allocator()); } ops.ServerSendStatus(¶m.server_context->trailing_metadata_, status); param.call->PerformOps(&ops); @@ -233,8 +233,7 @@ class ServerStreamingHandler : public grpc::internal::MethodHandler { buf.set_buffer(req); auto* request = new (grpc_call_arena_alloc(call, sizeof(RequestType))) RequestType(); - *status = - grpc::SerializationTraits::Deserialize(&buf, request); + *status = grpc::Deserialize(&buf, request); buf.Release(); if (status->ok()) { return request; diff --git a/deps/grpc/include/grpcpp/support/proto_buffer_writer.h b/deps/grpc/include/grpcpp/support/proto_buffer_writer.h index 225c8555fb9..439d53b5af0 100644 --- a/deps/grpc/include/grpcpp/support/proto_buffer_writer.h +++ b/deps/grpc/include/grpcpp/support/proto_buffer_writer.h @@ -20,6 +20,7 @@ #define GRPCPP_SUPPORT_PROTO_BUFFER_WRITER_H #include +#include #include #include #include @@ -59,10 +60,13 @@ class ProtoBufferWriter : public grpc::protobuf::io::ZeroCopyOutputStream { /// \param[out] byte_buffer A pointer to the grpc::ByteBuffer created /// \param block_size How big are the chunks to allocate at a time /// \param total_size How many total bytes are required for this proto - ProtoBufferWriter(ByteBuffer* byte_buffer, int block_size, int total_size) + ProtoBufferWriter( + ByteBuffer* byte_buffer, int block_size, int total_size, + grpc_event_engine::experimental::MemoryAllocator* allocator = nullptr) : block_size_(block_size), total_size_(total_size), byte_count_(0), + allocator_(allocator), have_backup_(false) { ABSL_CHECK(!byte_buffer->Valid()); /// Create an empty raw byte buffer and look at its underlying slice buffer @@ -98,11 +102,16 @@ class ProtoBufferWriter : public grpc::protobuf::io::ZeroCopyOutputStream { } else { // When less than a whole block is needed, only allocate that much. // But make sure the allocated slice is not inlined. - size_t allocate_length = + const size_t allocate_length = remain > static_cast(block_size_) ? block_size_ : remain; - slice_ = grpc_slice_malloc(allocate_length > GRPC_SLICE_INLINED_SIZE - ? allocate_length - : GRPC_SLICE_INLINED_SIZE + 1); + const size_t slice_size = allocate_length > GRPC_SLICE_INLINED_SIZE + ? allocate_length + : GRPC_SLICE_INLINED_SIZE + 1; + if (allocator_ == nullptr) { + slice_ = grpc_slice_malloc(slice_size); + } else { + slice_ = allocator_->MakeSlice(slice_size); + } } *data = GRPC_SLICE_START_PTR(slice_); // On win x64, int is only 32bit @@ -207,6 +216,7 @@ class ProtoBufferWriter : public grpc::protobuf::io::ZeroCopyOutputStream { const int block_size_; ///< size to alloc for each new \a grpc_slice needed const int total_size_; ///< byte size of proto being serialized int64_t byte_count_; ///< bytes written since this object was created + grpc_event_engine::experimental::MemoryAllocator* allocator_ = nullptr; grpc_slice_buffer* slice_buffer_; ///< internal buffer of slices holding the serialized data bool have_backup_; ///< if we are holding a backup slice or not diff --git a/deps/grpc/include/grpcpp/support/sync_stream.h b/deps/grpc/include/grpcpp/support/sync_stream.h index cacf605a979..ddd504d5d26 100644 --- a/deps/grpc/include/grpcpp/support/sync_stream.h +++ b/deps/grpc/include/grpcpp/support/sync_stream.h @@ -260,7 +260,7 @@ class ClientReader final : public ClientReaderInterface { ops.SendInitialMetadata(&context->send_initial_metadata_, context->initial_metadata_flags()); // TODO(ctiller): don't assert - ABSL_CHECK(ops.SendMessagePtr(&request).ok()); + ABSL_CHECK(ops.SendMessagePtr(&request, channel->memory_allocator()).ok()); ops.ClientSendClose(); call_.PerformOps(&ops); cq_.Pluck(&ops); @@ -337,7 +337,7 @@ class ClientWriter : public ClientWriterInterface { context_->initial_metadata_flags()); context_->set_initial_metadata_corked(false); } - if (!ops.SendMessagePtr(&msg, options).ok()) { + if (!ops.SendMessagePtr(&msg, options, channel_->memory_allocator()).ok()) { return false; } @@ -381,7 +381,8 @@ class ClientWriter : public ClientWriterInterface { ClientWriter(grpc::ChannelInterface* channel, const grpc::internal::RpcMethod& method, grpc::ClientContext* context, R* response) - : context_(context), + : channel_(channel), + context_(context), cq_(grpc_completion_queue_attributes{ GRPC_CQ_CURRENT_VERSION, GRPC_CQ_PLUCK, GRPC_CQ_DEFAULT_POLLING, nullptr}), // Pluckable cq @@ -398,6 +399,7 @@ class ClientWriter : public ClientWriterInterface { } } + grpc::ChannelInterface* channel_; grpc::ClientContext* context_; grpc::internal::CallOpSet { context_->initial_metadata_flags()); context_->set_initial_metadata_corked(false); } - if (!ops.SendMessagePtr(&msg, options).ok()) { + if (!ops.SendMessagePtr(&msg, options, channel_->memory_allocator()).ok()) { return false; } @@ -544,6 +546,7 @@ class ClientReaderWriter final : public ClientReaderWriterInterface { private: friend class internal::ClientReaderWriterFactory; + grpc::ChannelInterface* channel_; grpc::ClientContext* context_; grpc::CompletionQueue cq_; grpc::internal::Call call_; @@ -554,7 +557,8 @@ class ClientReaderWriter final : public ClientReaderWriterInterface { ClientReaderWriter(grpc::ChannelInterface* channel, const grpc::internal::RpcMethod& method, grpc::ClientContext* context) - : context_(context), + : channel_(channel), + context_(context), cq_(grpc_completion_queue_attributes{ GRPC_CQ_CURRENT_VERSION, GRPC_CQ_PLUCK, GRPC_CQ_DEFAULT_POLLING, nullptr}), // Pluckable cq @@ -665,7 +669,9 @@ class ServerWriter final : public ServerWriterInterface { options.set_buffer_hint(); } - if (!ctx_->pending_ops_.SendMessagePtr(&msg, options).ok()) { + if (!ctx_->pending_ops_ + .SendMessagePtr(&msg, options, ctx_->memory_allocator()) + .ok()) { return false; } if (!ctx_->sent_initial_metadata_) { @@ -748,7 +754,9 @@ class ServerReaderWriterBody final { if (options.is_last_message()) { options.set_buffer_hint(); } - if (!ctx_->pending_ops_.SendMessagePtr(&msg, options).ok()) { + if (!ctx_->pending_ops_ + .SendMessagePtr(&msg, options, ctx_->memory_allocator()) + .ok()) { return false; } if (!ctx_->sent_initial_metadata_) { diff --git a/deps/grpc/include/grpcpp/version_info.h b/deps/grpc/include/grpcpp/version_info.h index 9e2ae617b64..30cbffb4ccd 100644 --- a/deps/grpc/include/grpcpp/version_info.h +++ b/deps/grpc/include/grpcpp/version_info.h @@ -19,9 +19,9 @@ #define GRPCPP_VERSION_INFO_H #define GRPC_CPP_VERSION_MAJOR 1 -#define GRPC_CPP_VERSION_MINOR 76 -#define GRPC_CPP_VERSION_PATCH 0 +#define GRPC_CPP_VERSION_MINOR 78 +#define GRPC_CPP_VERSION_PATCH 1 #define GRPC_CPP_VERSION_TAG "" -#define GRPC_CPP_VERSION_STRING "1.76.0" +#define GRPC_CPP_VERSION_STRING "1.78.1" #endif // GRPCPP_VERSION_INFO_H diff --git a/deps/grpc/src/compiler/BUILD b/deps/grpc/src/compiler/BUILD index 14d53bb464a..c78d632313c 100644 --- a/deps/grpc/src/compiler/BUILD +++ b/deps/grpc/src/compiler/BUILD @@ -23,8 +23,8 @@ load( package( default_visibility = ["//visibility:public"], features = [ - "-layering_check", - "-parse_headers", + "layering_check", + "parse_headers", ], ) @@ -84,6 +84,9 @@ grpc_cc_library( "//:grpc++_config_proto", "@com_google_protobuf//src/google/protobuf/compiler:code_generator", "@com_google_protobuf//src/google/protobuf/compiler:plugin", + "@com_google_protobuf//src/google/protobuf/compiler/csharp:names", + "@com_google_protobuf//src/google/protobuf/compiler/objectivec:names", + "@com_google_protobuf//src/google/protobuf/compiler/php:names", "@com_google_protobuf//src/google/protobuf/io", "@com_google_protobuf//src/google/protobuf/io:printer", ], diff --git a/deps/grpc/src/compiler/cpp_plugin.h b/deps/grpc/src/compiler/cpp_plugin.h index 8ae6d7e6c4c..2cccbe6fb78 100644 --- a/deps/grpc/src/compiler/cpp_plugin.h +++ b/deps/grpc/src/compiler/cpp_plugin.h @@ -45,7 +45,13 @@ class CppGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator { return grpc::protobuf::Edition::EDITION_PROTO2; } grpc::protobuf::Edition GetMaximumEdition() const override { + // TODO(yuanweiz): Remove when the protobuf is updated to a version + // that supports edition 2024. +#if !defined(GOOGLE_PROTOBUF_VERSION) || GOOGLE_PROTOBUF_VERSION >= 6032000 + return grpc::protobuf::Edition::EDITION_2024; +#else return grpc::protobuf::Edition::EDITION_2023; +#endif } #endif diff --git a/deps/grpc/src/compiler/csharp_plugin.cc b/deps/grpc/src/compiler/csharp_plugin.cc index a7a2e74deb9..6281bf08c0a 100644 --- a/deps/grpc/src/compiler/csharp_plugin.cc +++ b/deps/grpc/src/compiler/csharp_plugin.cc @@ -42,7 +42,13 @@ class CSharpGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator { return grpc::protobuf::Edition::EDITION_PROTO2; } grpc::protobuf::Edition GetMaximumEdition() const override { + // TODO(yuanweiz): Remove when the protobuf is updated to a version + // that supports edition 2024. +#if !defined(GOOGLE_PROTOBUF_VERSION) || GOOGLE_PROTOBUF_VERSION >= 6032000 + return grpc::protobuf::Edition::EDITION_2024; +#else return grpc::protobuf::Edition::EDITION_2023; +#endif } #endif diff --git a/deps/grpc/src/compiler/objective_c_plugin.cc b/deps/grpc/src/compiler/objective_c_plugin.cc index 250df04220d..d6b35e06d68 100644 --- a/deps/grpc/src/compiler/objective_c_plugin.cc +++ b/deps/grpc/src/compiler/objective_c_plugin.cc @@ -93,7 +93,13 @@ class ObjectiveCGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator { return grpc::protobuf::Edition::EDITION_PROTO2; } grpc::protobuf::Edition GetMaximumEdition() const override { + // TODO(yuanweiz): Remove when the protobuf is updated to a version + // that supports edition 2024. +#if !defined(GOOGLE_PROTOBUF_VERSION) || GOOGLE_PROTOBUF_VERSION >= 6032000 + return grpc::protobuf::Edition::EDITION_2024; +#else return grpc::protobuf::Edition::EDITION_2023; +#endif } #endif diff --git a/deps/grpc/src/compiler/php_plugin.cc b/deps/grpc/src/compiler/php_plugin.cc index 9fafe52678c..06fccfe5627 100644 --- a/deps/grpc/src/compiler/php_plugin.cc +++ b/deps/grpc/src/compiler/php_plugin.cc @@ -46,7 +46,13 @@ class PHPGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator { return grpc::protobuf::Edition::EDITION_PROTO2; } grpc::protobuf::Edition GetMaximumEdition() const override { + // TODO(yuanweiz): Remove when the protobuf is updated to a version + // that supports edition 2024. +#if !defined(GOOGLE_PROTOBUF_VERSION) || GOOGLE_PROTOBUF_VERSION >= 6032000 + return grpc::protobuf::Edition::EDITION_2024; +#else return grpc::protobuf::Edition::EDITION_2023; +#endif } #endif diff --git a/deps/grpc/src/compiler/python_generator.h b/deps/grpc/src/compiler/python_generator.h index 1ea0e0a0968..10ac03b008f 100644 --- a/deps/grpc/src/compiler/python_generator.h +++ b/deps/grpc/src/compiler/python_generator.h @@ -59,7 +59,13 @@ class PythonGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator { return grpc::protobuf::Edition::EDITION_PROTO2; } grpc::protobuf::Edition GetMaximumEdition() const override { + // TODO(yuanweiz): Remove when the protobuf is updated to a version + // that supports edition 2024. +#if !defined(GOOGLE_PROTOBUF_VERSION) || GOOGLE_PROTOBUF_VERSION >= 6032000 + return grpc::protobuf::Edition::EDITION_2024; +#else return grpc::protobuf::Edition::EDITION_2023; +#endif } #endif diff --git a/deps/grpc/src/compiler/ruby_plugin.cc b/deps/grpc/src/compiler/ruby_plugin.cc index c70206c6b37..b5f1d497be5 100644 --- a/deps/grpc/src/compiler/ruby_plugin.cc +++ b/deps/grpc/src/compiler/ruby_plugin.cc @@ -42,7 +42,13 @@ class RubyGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator { return grpc::protobuf::Edition::EDITION_PROTO2; } grpc::protobuf::Edition GetMaximumEdition() const override { + // TODO(yuanweiz): Remove when the protobuf is updated to a version + // that supports edition 2024. +#if !defined(GOOGLE_PROTOBUF_VERSION) || GOOGLE_PROTOBUF_VERSION >= 6032000 + return grpc::protobuf::Edition::EDITION_2024; +#else return grpc::protobuf::Edition::EDITION_2023; +#endif } #endif diff --git a/deps/grpc/src/core/BUILD b/deps/grpc/src/core/BUILD index 0a8eebafb9e..0412d76c954 100644 --- a/deps/grpc/src/core/BUILD +++ b/deps/grpc/src/core/BUILD @@ -30,6 +30,7 @@ package( default_visibility = ["//:__subpackages__"], features = [ "layering_check", + "parse_headers", ], ) @@ -150,6 +151,7 @@ grpc_cc_library( hdrs = [ "util/postmortem_emit.h", ], + defines = ["GRPC_POSTMORTEM_CHECKS"], deps = [ "//:channelz", "//:stats", @@ -164,8 +166,11 @@ grpc_cc_library( "absl/log:check", "absl/log", ], + select_deps = [{ + "//:grpc_postmortem_checks_enabled": [":postmortem"], + "//conditions:default": [], + }], deps = [ - "postmortem", ], ) @@ -190,6 +195,7 @@ grpc_cc_library( "//bazel:event_engine_base_hdrs", ], deps = [ + "instrument", "memory_quota", "tcp_tracer", "//:channelz", @@ -233,6 +239,17 @@ grpc_cc_library( ], ) +grpc_cc_library( + name = "tcp_telemetry", + hdrs = [ + "lib/event_engine/tcp_telemetry.h", + ], + deps = [ + "histogram", + "instrument", + ], +) + grpc_cc_library( name = "transport_framing_endpoint_extension", hdrs = [ @@ -274,6 +291,10 @@ grpc_cc_library( ], visibility = ["//bazel:latent_see"], deps = [ + "channelz_property_list", + "function_signature", + "json", + "json_writer", "notification", "sync", "//:backoff", @@ -488,6 +509,7 @@ grpc_cc_library( "time_precise", "//:gpr_platform", "//:gpr_public_hdrs", + "//:grpc_support_time", ], ) @@ -504,6 +526,7 @@ grpc_cc_library( deps = [ "//:gpr_platform", "//:gpr_public_hdrs", + "//:grpc_support_time", ], ) @@ -523,9 +546,10 @@ grpc_cc_library( "nofixdeps", ], deps = [ + ":gpr_time", "//:gpr_platform", "//:gpr_public_hdrs", - "//src/core:gpr_time", + "//:grpc_support_time", ], ) @@ -556,6 +580,7 @@ grpc_cc_library( "time_util", "//:gpr_platform", "//:gpr_public_hdrs", + "//:grpc_support_time", ], ) @@ -1364,6 +1389,17 @@ grpc_cc_library( ], ) +grpc_cc_library( + name = "call_channelz_context", + hdrs = [ + "call/channelz_context.h", + ], + deps = [ + "arena", + "//:channelz", + ], +) + grpc_cc_library( name = "pipe", hdrs = [ @@ -1376,6 +1412,7 @@ grpc_cc_library( deps = [ "activity", "arena", + "channelz_property_list", "context", "grpc_check", "if", @@ -1761,6 +1798,7 @@ grpc_cc_library( "exec_ctx_wakeup_scheduler", "experiments", "grpc_check", + "instrument", "loop", "map", "periodic_update", @@ -1840,6 +1878,28 @@ grpc_cc_library( ], ) +grpc_cc_library( + name = "stream_quota", + srcs = [ + "lib/resource_quota/stream_quota.cc", + ], + hdrs = [ + "lib/resource_quota/stream_quota.h", + ], + external_deps = [ + "absl/base:core_headers", + "absl/log:check", + ], + deps = [ + "periodic_update", + "ref_counted", + "sync", + ":per_cpu", + "//:gpr", + "//:ref_counted_ptr", + ], +) + grpc_cc_library( name = "connection_quota", srcs = [ @@ -1901,6 +1961,7 @@ grpc_cc_library( "ref_counted", "resource_quota_telemetry", "single_set_ptr", + "stream_quota", "thread_quota", "useful", "//:channel_arg_names", @@ -1936,10 +1997,10 @@ grpc_cc_library( ], public_hdrs = [ "//:include/grpc/slice.h", + "//:include/grpc/impl/slice_type.h", ], deps = [ "//:debug_location", - "//:event_engine_base_hdrs", "//:gpr", "//:grpc_trace", ], @@ -1967,8 +2028,8 @@ grpc_cc_library( "slice_cast", "slice_refcount", "//:debug_location", - "//:event_engine_base_hdrs", "//:gpr", + "//:grpc_event_engine_slice", ], ) @@ -1984,8 +2045,9 @@ grpc_cc_library( external_deps = ["absl/log:check"], deps = [ "slice", - "slice_refcount", "//:gpr", + "//:gpr_platform", + "//:grpc_slice", ], ) @@ -2015,6 +2077,7 @@ grpc_cc_library( "useful", "//:gpr", "//:grpc_public_hdrs", + "//:grpc_support_time", "//:grpc_trace", ], ) @@ -2061,6 +2124,7 @@ grpc_cc_library( "useful", "//:event_engine_base_hdrs", "//:gpr", + "//:grpc_support_time", ], ) @@ -2320,6 +2384,7 @@ grpc_cc_library( "time", "//:event_engine_base_hdrs", "//:gpr", + "//:grpc_support_time", "//:grpc_trace", ], ) @@ -2664,6 +2729,7 @@ grpc_cc_library( "sync", "//:event_engine_base_hdrs", "//:gpr", + "//:grpc_support_time", ], ) @@ -2947,6 +3013,8 @@ grpc_cc_library( srcs = ["lib/event_engine/windows/native_windows_dns_resolver.cc"], hdrs = ["lib/event_engine/windows/native_windows_dns_resolver.h"], external_deps = [ + "absl/status", + "absl/status:statusor", "absl/strings", "absl/strings:str_format", ], @@ -3095,6 +3163,7 @@ grpc_cc_library( "useful", "//:event_engine_base_hdrs", "//:gpr", + "//:grpc_trace", "//:parse_address", "//:ref_counted_ptr", "//:sockaddr_utils", @@ -3321,7 +3390,6 @@ grpc_cc_library( "absl/status:statusor", "absl/strings", "absl/strings:str_format", - "address_sorting", "cares", ], deps = [ @@ -3350,6 +3418,7 @@ grpc_cc_library( "//:parse_address", "//:ref_counted_ptr", "//:sockaddr_utils", + "//third_party/address_sorting", ], ) @@ -3382,6 +3451,7 @@ grpc_cc_library( "grpc_check", "time", "//:gpr", + "//:grpc_support_time", "//:grpc_trace", ], ) @@ -3734,6 +3804,9 @@ grpc_cc_library( "blackboard", "channel_fwd", "match", + "ref_counted", + "unique_type_name", + "//:ref_counted_ptr", ], ) @@ -3856,6 +3929,7 @@ grpc_cc_library( ], deps = [ "channel_args", + "env", "json", "json_args", "json_object_loader", @@ -4876,6 +4950,7 @@ grpc_cc_library( "poll", "pollset_set", "ref_counted", + "status_conversion", "sync", "time", "useful", @@ -5678,6 +5753,7 @@ grpc_cc_library( "//:grpc_resolver", "//:grpc_resolver_fake", "//:grpc_security_base", + "//:grpc_support_time", "//:grpc_trace", "//:lb_child_policy_handler", "//:orphanable", @@ -5822,6 +5898,7 @@ grpc_cc_library( ], deps = [ "//:gpr", + "//:grpc_support_time", "//:protobuf_duration_upb", "//:protobuf_timestamp_upb", ], @@ -8041,6 +8118,7 @@ grpc_cc_library( ], deps = [ ":chttp2_flow_control", + ":grpc_check", ":http2_settings", "//:chttp2_frame", ], @@ -8199,26 +8277,40 @@ grpc_cc_library( "ext/transport/chttp2/transport/http2_settings_promises.h", ], external_deps = [ - "absl/functional:function_ref", - "absl/log:check", + "absl/functional:any_invocable", "absl/log", + "absl/log:check", + "absl/status", + "absl/status:statusor", "absl/strings", + "absl/types:span", ], deps = [ + "activity", "channel_args", "channelz_property_list", + "context", "grpc_check", "http2_settings", "http2_settings_manager", "http2_status", "poll", + "promise_status", "race", + "ref_counted", + "seq", "sleep", "time", "try_seq", "useful", + ":chttp2_flow_control", + ":slice_buffer", "//:chttp2_frame", + "//:event_engine_base_hdrs", + "//:exec_ctx", "//:gpr_platform", + "//:promise", + "//:ref_counted_ptr", ], ) @@ -8253,12 +8345,16 @@ grpc_cc_library( ], external_deps = [ "absl/log", + "absl/status", + "absl/strings", ], deps = [ + "error", "grpc_check", "http2_status", "metadata_batch", "shared_bit_gen", + "status_helper", ":slice", ":slice_buffer", "//:chttp2_frame", @@ -8269,6 +8365,22 @@ grpc_cc_library( ], ) +grpc_cc_library( + name = "incoming_metadata_tracker", + hdrs = [ + "ext/transport/chttp2/transport/incoming_metadata_tracker.h", + ], + external_deps = [ + "absl/log", + "absl/strings", + ], + deps = [ + "grpc_check", + ":metadata_info", + "//:chttp2_frame", + ], +) + grpc_cc_library( name = "message_assembler", hdrs = [ @@ -8285,6 +8397,7 @@ grpc_cc_library( ":slice", ":slice_buffer", "//:chttp2_frame", + "//:gpr_platform", "//:ref_counted_ptr", ], ) @@ -8296,16 +8409,27 @@ grpc_cc_library( ], external_deps = [ "absl/log", + "absl/status", ], deps = [ + "activity", "arena", + "context", "grpc_check", "header_assembler", "http2_status", "message", "message_assembler", "metadata_batch", + "poll", + "ref_counted", + "sync", "transport_common", + ":slice_buffer", + "//:chttp2_frame", + "//:gpr_platform", + "//:hpack_encoder", + "//:ref_counted_ptr", ], ) @@ -8316,12 +8440,22 @@ grpc_cc_library( ], external_deps = [ "absl/log", + "absl/status", ], deps = [ "call_spine", - "http2_transport", + "grpc_check", + "header_assembler", + "http2_status", + "message", + "message_assembler", + "metadata", + "ref_counted", "stream_data_queue", ":chttp2_flow_control", + "//:chttp2_frame", + "//:gpr_platform", + "//:hpack_encoder", "//:ref_counted_ptr", ], ) @@ -8335,33 +8469,47 @@ grpc_cc_library( "ext/transport/chttp2/transport/http2_client_transport.h", ], external_deps = [ + "absl/base:core_headers", "absl/container:flat_hash_map", + "absl/container:flat_hash_set", + "absl/functional:any_invocable", "absl/log", "absl/status", "absl/status:statusor", "absl/strings", + "absl/types:span", + "absl/strings:cord", ], deps = [ "1999", + "activity", "arena", "call_spine", "channel_args", "check_class_size", + "closure", "connectivity_state", + "context", "flow_control_manager", "for_each", + "goaway", "grpc_check", "grpc_promise_endpoint", "header_assembler", + "http2_security_frame", "http2_settings", "http2_settings_manager", "http2_settings_promises", "http2_status", "http2_transport", "http2_ztrace_collector", + "if", + "incoming_metadata_tracker", "inter_activity_mutex", "internal_channel_arg_names", + "iomgr_fwd", "keepalive", + "latch", "latent_see", "loop", "map", @@ -8370,12 +8518,16 @@ grpc_cc_library( "message_assembler", "metadata", "metadata_batch", + "metadata_info", "mpsc", "ph2_stream", "ping_promise", + "race", "resource_quota", + "sleep", "stream_data_queue", "sync", + "time", "transport_common", "writable_streams", ":chttp2_flow_control", @@ -8384,7 +8536,10 @@ grpc_cc_library( ":slice", ":slice_buffer", ":try_seq", + "//:channelz", "//:chttp2_frame", + "//:debug_location", + "//:exec_ctx", "//:gpr_platform", "//:grpc_base", "//:grpc_trace", @@ -8445,6 +8600,29 @@ grpc_cc_library( ], ) +grpc_cc_library( + name = "http2_security_frame", + srcs = [ + "ext/transport/chttp2/transport/security_frame.cc", + ], + hdrs = [ + "ext/transport/chttp2/transport/security_frame.h", + ], + external_deps = [ + "absl/log", + "absl/status", + "absl/status:statusor", + ], + deps = [ + "grpc_promise_endpoint", + "//:grpc_public_hdrs", + "//src/core:event_engine_extensions", + "//src/core:slice", + "//src/core:slice_buffer", + "//src/core:transport_framing_endpoint_extension", + ], +) + grpc_cc_library( name = "http2_stats_collector", srcs = [ @@ -8471,6 +8649,10 @@ grpc_cc_library( external_deps = [ "absl/random", ], + visibility = [ + "//:__subpackages__", + "//bazel:transport_common", + ], deps = [ ":shared_bit_gen", ":time", @@ -8486,30 +8668,41 @@ grpc_cc_library( "ext/transport/chttp2/transport/http2_transport.h", ], external_deps = [ + "absl/types:span", "absl/log", "absl/status", "absl/status:statusor", ], deps = [ "1999", + "activity", "arena", "call_spine", "channel_args", "chttp2_flow_control", + "context", "grpc_check", "grpc_promise_endpoint", + "header_assembler", "http2_settings", + "http2_settings_manager", + "http2_settings_promises", + "http2_status", + "internal_channel_arg_names", "loop", "map", "metadata_info", "mpsc", + "ph2_stream", "sync", + "time", ":event_engine_tcp_socket_utils", ":match_promise", ":poll", ":slice", ":slice_buffer", ":try_seq", + "//:channel_arg_names", "//:channelz", "//:chttp2_frame", "//:gpr_platform", @@ -8926,6 +9119,7 @@ grpc_cc_library( ], external_deps = ["absl/status:statusor"], deps = [ + "channel_args", "dual_ref_counted", "grpc_promise_endpoint", "//:promise", @@ -9290,6 +9484,7 @@ grpc_cc_library( "//:orphanable", "//:ref_counted_ptr", "//:server", + "//:transport_auth_context", ], ) @@ -9977,6 +10172,7 @@ grpc_cc_library( deps = [ "//:gpr", "//:grpc_public_hdrs", + "//:grpc_support_time", ], ) @@ -10035,6 +10231,7 @@ grpc_cc_library( deps = [ "call_final_info", "call_state", + "channelz_property_list", "dump_args", "for_each", "grpc_check", @@ -10091,6 +10288,7 @@ grpc_cc_library( "call_destination", "call_filters", "call_spine", + "filter_args", "match", "metadata", "ref_counted", @@ -10180,6 +10378,7 @@ grpc_cc_library( deps = [ "1999", "call_arena_allocator", + "call_channelz_context", "call_filters", "dual_ref_counted", "event_engine_context", @@ -10194,6 +10393,7 @@ grpc_cc_library( "promise_status", "status_flag", "try_seq", + "//:channelz", "//:gpr", "//:promise", ], @@ -10320,6 +10520,7 @@ grpc_cc_library( "slice", "time", "//:gpr", + "//:grpc_support_time", ], ) @@ -10384,6 +10585,7 @@ grpc_cc_library( deps = [ "channel_args", "grpc_check", + "instrument", "no_destruct", "slice", "sync", @@ -10405,6 +10607,7 @@ grpc_cc_library( "absl/base:core_headers", "absl/functional:any_invocable", "absl/functional:function_ref", + "absl/log:check", "absl/log", "absl/strings", "absl/types:span", @@ -10415,13 +10618,17 @@ grpc_cc_library( ], deps = [ "avl", + "channelz_property_list", "dual_ref_counted", "grpc_check", "histogram", "match", + "no_destruct", "per_cpu", "ref_counted", + "single_set_ptr", "sync", + "//:channelz", "//:gpr", "//:ref_counted_ptr", ], @@ -10471,6 +10678,8 @@ grpc_cc_library( ], deps = [ "1999", + "channel_args", + "grpc_check", "if", "inter_activity_latch", "latch", @@ -10505,11 +10714,13 @@ grpc_cc_library( deps = [ "1999", "all_ok", + "grpc_check", "if", "latch", "loop", "race", "sleep", + "time", "try_seq", "//:promise", ], @@ -10529,6 +10740,7 @@ grpc_cc_library( ], deps = [ "activity", + "grpc_check", "http2_status", "if", "race", @@ -10580,6 +10792,7 @@ grpc_cc_library( }), external_deps = [ "absl/container:flat_hash_set", + "absl/meta:type_traits", "absl/status", "@com_google_protobuf//upb/mem", ], @@ -10587,6 +10800,7 @@ grpc_cc_library( "channelz_text_encode", "function_signature", "json_writer", + "latent_see", "memory_usage", "single_set_ptr", "sync", @@ -10595,6 +10809,7 @@ grpc_cc_library( "//:channelz_service_upb", "//:channelz_upb", "//:gpr", + "//:grpc_support_time", "//:grpc_trace", "//:protobuf_any_upb", "//:protobuf_any_upbdefs", @@ -10633,6 +10848,7 @@ grpc_cc_library( "time", "upb_utils", "//:channelz_property_list_upb", + "//:channelz_property_list_upbdefs", "//:channelz_upb", "//:gpr", "//:protobuf_any_upb", @@ -10768,6 +10984,7 @@ grpc_cc_library( "absl/strings", "absl/status:statusor", ], + visibility = ["//bazel:channelz"], deps = [ "zviz_strings", "//src/proto/grpc/channelz/v2:channelz_cc_proto", @@ -10869,6 +11086,7 @@ grpc_cc_library( "absl/strings", "absl/types:span", ], + visibility = ["//bazel:channelz"], deps = [ "zviz_data", "zviz_environment", @@ -10927,6 +11145,7 @@ grpc_cc_library( "absl/strings", "absl/strings:str_format", ], + visibility = ["//bazel:channelz"], deps = [ "zviz_layout", ], @@ -11033,13 +11252,16 @@ grpc_cc_library( hdrs = ["ext/transport/chttp2/transport/writable_streams.h"], external_deps = [ "absl/log", + "absl/strings", "absl/log:check", + "absl/status", ], deps = [ "grpc_check", "if", "mpsc", "race", + "status_flag", "transport_common", "try_seq", ], diff --git a/deps/grpc/src/core/call/call_filters.cc b/deps/grpc/src/core/call/call_filters.cc index 5963cf9004a..f6992b10fda 100644 --- a/deps/grpc/src/core/call/call_filters.cc +++ b/deps/grpc/src/core/call/call_filters.cc @@ -16,10 +16,10 @@ #include -#include "absl/log/log.h" #include "src/core/call/metadata.h" #include "src/core/util/crash.h" #include "src/core/util/grpc_check.h" +#include "absl/log/log.h" namespace grpc_core { // Call data for those calls that don't have any call data diff --git a/deps/grpc/src/core/call/call_filters.h b/deps/grpc/src/core/call/call_filters.h index efba8d245d0..c05a4bdc1c5 100644 --- a/deps/grpc/src/core/call/call_filters.h +++ b/deps/grpc/src/core/call/call_filters.h @@ -26,6 +26,7 @@ #include "src/core/call/call_state.h" #include "src/core/call/message.h" #include "src/core/call/metadata.h" +#include "src/core/channelz/property_list.h" #include "src/core/lib/promise/for_each.h" #include "src/core/lib/promise/if.h" #include "src/core/lib/promise/latch.h" @@ -53,6 +54,7 @@ // - OnClientToServerHalfClose - no value // - OnServerTrailingMetadata - $VALUE_TYPE = ServerMetadata // - OnFinalize - special, see below +// - ChannelzProperties - special, see below // These members define an interception point for a particular event in // the call lifecycle. // @@ -89,7 +91,7 @@ // It's also acceptable to return a promise that resolves to the // relevant return type listed above. // -// Finally, OnFinalize is added to intecept call finalization. +// OnFinalize is added to intecept call finalization. // It must have one of the signatures: // - static inline const NoInterceptor OnFinalize: // the filter does not intercept call finalization. @@ -98,6 +100,11 @@ // - void OnFinalize(const grpc_call_final_info*, FilterType*): // the filter intercepts call finalization. // +// ChannelzProperties is added to provide channelz data. +// It must have one of the signatures: +// - channelz::PropertyList ChannelzProperties(); +// - channelz::PropertyList ChannelzProperties(FilterType*); +// // The constructor of the Call object can either take a pointer to the channel // object, or not take any arguments. // @@ -1042,6 +1049,14 @@ struct ChannelDataDestructor { void* channel_data; }; +struct FilterMetadata { + absl::string_view name; + void* channel_data; + size_t call_data_offset; + channelz::PropertyList (*channelz_properties)(void* channel_data, + void* call_data); +}; + // StackData contains the main datastructures built up by this module. // It's a complete representation of all the code that needs to be invoked // to execute a call for a given set of filters. @@ -1071,6 +1086,79 @@ struct StackData { // A list of functions to call when this stack data is destroyed // (to capture ownership of channel data) std::vector channel_data_destructors; + // A list of metadata about filters for this stack. + std::vector filter_metadata; + + channelz::PropertyList ChannelzProperties(void* call_data) const { + absl::flat_hash_map + channel_data_to_filter_metadata; + for (const auto& filter_metadata : filter_metadata) { + channel_data_to_filter_metadata[filter_metadata.channel_data] = + &filter_metadata; + } + auto filter_chain = + [&channel_data_to_filter_metadata](const auto& container) { + std::vector filter_names; + for (const auto& filter : container) { + void* channel_data = filter.channel_data; + auto it = channel_data_to_filter_metadata.find(channel_data); + if (it != channel_data_to_filter_metadata.end()) { + filter_names.push_back(it->second->name); + } else { + filter_names.push_back("unknown_filter"); + } + } + return absl::StrJoin(filter_names, ", "); + }; + auto layout_properties = [&](const auto& layout) { + return channelz::PropertyList() + .Set("promise_size", layout.promise_size) + .Set("promise_alignment", layout.promise_alignment) + .Set("filters", filter_chain(layout.ops)); + }; + return channelz::PropertyList() + .Set("call_data_alignment", call_data_alignment) + .Set("call_data_size", call_data_size) + .Set("filters", + [&, this]() { + channelz::PropertyTable table; + for (const auto& filter : filter_metadata) { + table.AppendRow( + channelz::PropertyList() + .Set("name", filter.name) + .Set("call_data_offset", filter.call_data_offset) + .Merge([&]() { + if (call_data == nullptr) { + return channelz::PropertyList(); + } + if (filter.channelz_properties == nullptr) { + return channelz::PropertyList(); + } + return filter.channelz_properties( + filter.channel_data, + Offset(call_data, filter.call_data_offset)); + }())); + } + return table; + }()) + .Set("constructors", filter_chain(filter_constructor)) + // TODO(ctiller): Add the list of destructors (need to figure out how to + // map them). + .Set("client_initial_metadata", + layout_properties(client_initial_metadata)) + .Set("server_initial_metadata", + layout_properties(server_initial_metadata)) + .Set("client_to_server_messages", + layout_properties(client_to_server_messages)) + .Set("client_to_server_half_close", + filter_chain(client_to_server_half_close)) + .Set("server_to_client_messages", + layout_properties(server_to_client_messages)) + .Set("server_trailing_metadata", filter_chain(server_trailing_metadata)) + .Set("finalizers", filter_chain(finalizers)) + .Set("channel_data_destructors", + filter_chain(channel_data_destructors)); + } bool empty() const { return filter_constructor.empty() && filter_destructor.empty() && @@ -1253,6 +1341,69 @@ struct StackData { }, }); } + + template + void AddFilterMetadata(FilterType* channel_data, size_t call_offset, + channelz::PropertyList (FilterType::Call::*p)() + const) { + GRPC_DCHECK(p == &FilterType::Call::ChannelzProperties); + filter_metadata.push_back(FilterMetadata{ + TypeName(), + channel_data, + call_offset, + [](void* /*channel_data*/, void* call_data) { + return static_cast(call_data) + ->ChannelzProperties(); + }, + }); + } + + template + void AddFilterMetadata(FilterType* channel_data, size_t call_offset, + channelz::PropertyList (FilterType::Call::*p)()) { + GRPC_DCHECK(p == &FilterType::Call::ChannelzProperties); + filter_metadata.push_back(FilterMetadata{ + TypeName(), + channel_data, + call_offset, + [](void* /*channel_data*/, void* call_data) { + return static_cast(call_data) + ->ChannelzProperties(); + }, + }); + } + + template + void AddFilterMetadata( + FilterType* channel_data, size_t call_offset, + channelz::PropertyList (FilterType::Call::*p)(FilterType*) const) { + GRPC_DCHECK(p == &FilterType::Call::ChannelzProperties); + filter_metadata.push_back(FilterMetadata{ + TypeName(), + channel_data, + call_offset, + [](void* channel_data, void* call_data) { + return static_cast(call_data) + ->ChannelzProperties(static_cast(channel_data)); + }, + }); + } + + template + void AddFilterMetadata( + FilterType* channel_data, size_t call_offset, + channelz::PropertyList (FilterType::Call::*p)(FilterType*)) { + GRPC_DCHECK(p == &FilterType::Call::ChannelzProperties); + filter_metadata.push_back(FilterMetadata{ + TypeName(), + channel_data, + call_offset, + [](void* channel_data, void* call_data) { + return static_cast(call_data) + ->ChannelzProperties(static_cast(channel_data)); + }, + }); + } }; // OperationExecutor is a helper class to execute a sequence of operations @@ -1400,6 +1551,9 @@ class ServerTrailingMetadataInterceptor { ServerTrailingMetadataInterceptor* filter) { filter->fn_(md); } + channelz::PropertyList ChannelzProperties() { + return channelz::PropertyList(); + } }; explicit ServerTrailingMetadataInterceptor(Fn fn) : fn_(std::move(fn)) {} @@ -1423,6 +1577,10 @@ class ClientInitialMetadataInterceptor { static const inline NoInterceptor OnServerToClientMessage; static const inline NoInterceptor OnServerTrailingMetadata; static const inline NoInterceptor OnFinalize; + + channelz::PropertyList ChannelzProperties() { + return channelz::PropertyList(); + } }; explicit ClientInitialMetadataInterceptor(Fn fn) : fn_(std::move(fn)) {} @@ -1577,6 +1735,8 @@ class CallFilters { data_.AddServerToClientMessageOp(filter, call_offset); data_.AddServerTrailingMetadataOp(filter, call_offset); data_.AddFinalizer(filter, call_offset, &FilterType::Call::OnFinalize); + data_.AddFilterMetadata(filter, call_offset, + &FilterType::Call::ChannelzProperties); } void AddOwnedObject(void (*destroy)(void* p), void* p) { @@ -1646,6 +1806,20 @@ class CallFilters { return push_client_initial_metadata_.get(); } + channelz::PropertyTable ChannelzProperties() { + channelz::PropertyTable properties; + for (size_t i = 0; i < stacks_.size(); ++i) { + void* stack_call_offset = + filters_detail::Offset(call_data_, stacks_[i].call_data_offset); + properties.AppendRow( + channelz::PropertyList() + .Set("call_data_offset", stacks_[i].call_data_offset) + .Merge(stacks_[i].stack->data_.ChannelzProperties( + stack_call_offset))); + } + return properties; + } + private: template -#include "absl/functional/any_invocable.h" #include "src/core/lib/event_engine/event_engine_context.h" #include "src/core/lib/promise/for_each.h" #include "src/core/lib/promise/try_seq.h" +#include "absl/functional/any_invocable.h" namespace grpc_core { diff --git a/deps/grpc/src/core/call/call_spine.h b/deps/grpc/src/core/call/call_spine.h index 901c1ce7cfa..260b107cfb7 100644 --- a/deps/grpc/src/core/call/call_spine.h +++ b/deps/grpc/src/core/call/call_spine.h @@ -19,8 +19,10 @@ #include "src/core/call/call_arena_allocator.h" #include "src/core/call/call_filters.h" +#include "src/core/call/channelz_context.h" #include "src/core/call/message.h" #include "src/core/call/metadata.h" +#include "src/core/channelz/channelz.h" #include "src/core/lib/promise/detail/status.h" #include "src/core/lib/promise/if.h" #include "src/core/lib/promise/latch.h" @@ -39,7 +41,7 @@ namespace grpc_core { // CallInitiator and CallHandler - which provide interfaces that are appropriate // for each side of a call. // Hosts context, call filters, and the arena. -class CallSpine final : public Party { +class CallSpine final : public Party, public channelz::DataSource { public: static RefCountedPtr Create( ClientMetadataHandle client_initial_metadata, @@ -49,7 +51,10 @@ class CallSpine final : public Party { std::move(client_initial_metadata), std::move(arena))); } - ~CallSpine() override { CallOnDone(true); } + ~CallSpine() override { + CallOnDone(true); + SourceDestructing(); + } CallFilters& call_filters() { return call_filters_; } @@ -285,12 +290,29 @@ class CallSpine final : public Party { } } + void AddData(channelz::DataSink sink) override { + this->ExportToChannelz( + "call_spine", sink, [self = RefAsSubclass()]() { + return channelz::PropertyList() + .Set("filters", self->call_filters_.ChannelzProperties()) + .Set("child_calls", self->child_calls_.size()) + .Set("has_on_done", self->on_done_ != nullptr); + }); + } + private: friend class Arena; CallSpine(ClientMetadataHandle client_initial_metadata, - RefCountedPtr arena) - : Party(std::move(arena)), - call_filters_(std::move(client_initial_metadata)) {} + RefCountedPtr a) + : Party(std::move(a)), + channelz::DataSource([this]() -> RefCountedPtr { + auto* p = arena()->GetContext(); + if (p == nullptr) return nullptr; + return p->Ref(); + }()), + call_filters_(std::move(client_initial_metadata)) { + SourceConstructed(); + } SpawnSerializer* client_to_server_serializer() { if (client_to_server_serializer_ == nullptr) { diff --git a/deps/grpc/src/core/call/channelz_context.h b/deps/grpc/src/core/call/channelz_context.h new file mode 100644 index 00000000000..7c2919f9553 --- /dev/null +++ b/deps/grpc/src/core/call/channelz_context.h @@ -0,0 +1,30 @@ +// Copyright 2025 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. + +#ifndef GRPC_SRC_CORE_CALL_CHANNELZ_CONTEXT_H +#define GRPC_SRC_CORE_CALL_CHANNELZ_CONTEXT_H + +#include "src/core/channelz/channelz.h" +#include "src/core/lib/resource_quota/arena.h" + +namespace grpc_core { + +template <> +struct ArenaContextType { + static void Destroy(channelz::CallNode*) {} +}; + +} // namespace grpc_core + +#endif // GRPC_SRC_CORE_CALL_CHANNELZ_CONTEXT_H diff --git a/deps/grpc/src/core/call/client_call.cc b/deps/grpc/src/core/call/client_call.cc index bffb52ced87..0dc6c9fdece 100644 --- a/deps/grpc/src/core/call/client_call.cc +++ b/deps/grpc/src/core/call/client_call.cc @@ -39,8 +39,6 @@ #include #include -#include "absl/status/status.h" -#include "absl/strings/string_view.h" #include "src/core/call/metadata.h" #include "src/core/lib/event_engine/event_engine_context.h" #include "src/core/lib/promise/all_ok.h" @@ -57,6 +55,8 @@ #include "src/core/util/latent_see.h" #include "src/core/util/ref_counted.h" #include "src/core/util/ref_counted_ptr.h" +#include "absl/status/status.h" +#include "absl/strings/string_view.h" namespace grpc_core { @@ -105,7 +105,7 @@ ClientCall::ClientCall(grpc_call*, uint32_t, grpc_completion_queue* cq, grpc_compression_options compression_options, RefCountedPtr arena, RefCountedPtr destination) - : Call(false, deadline, std::move(arena)), + : Call(/*is_client=*/true, deadline, std::move(arena)), DualRefCounted("ClientCall"), cq_(cq), call_destination_(std::move(destination)), @@ -120,8 +120,37 @@ ClientCall::ClientCall(grpc_call*, uint32_t, grpc_completion_queue* cq, reinterpret_cast(static_cast(registered_method))); if (deadline != Timestamp::InfFuture()) { send_initial_metadata_->Set(GrpcTimeoutMetadata(), deadline); - UpdateDeadline(deadline); + UpdateDeadline(deadline).IgnoreError(); } + SourceConstructed(); +} + +void ClientCall::AddData(channelz::DataSink sink) { + Call::AddData(sink); + sink.AddData( + "client_call", + channelz::PropertyList() + .Set("call_state", + [this]() { + switch (call_state_.load(std::memory_order_relaxed)) { + case kUnstarted: + return "Unstarted"; + case kStarted: + return "Started"; + case kCancelled: + return "Cancelled"; + default: + return "StartedWithoutInitialMetadata"; + } + }()) + .Set("cancel_status", + [this]() -> std::string { + auto* p = cancel_status_.Get(); + if (p == nullptr) return "not cancelled"; + return p->ToString(); + }()) + .Set("saw_trailing_metadata", + saw_trailing_metadata_.load(std::memory_order_relaxed))); } grpc_call_error ClientCall::StartBatch(const grpc_op* ops, size_t nops, @@ -228,11 +257,20 @@ Party::WakeupHold ClientCall::StartCall( const grpc_op& send_initial_metadata_op) { GRPC_LATENT_SEE_SCOPE("ClientCall::StartCall"); auto cur_state = call_state_.load(std::memory_order_acquire); + // TODO(akshitpatel): [PH2][P3]: Might need to invoke + // PrepareApplicationMetadata here. CToMetadata(send_initial_metadata_op.data.send_initial_metadata.metadata, send_initial_metadata_op.data.send_initial_metadata.count, send_initial_metadata_.get()); PrepareOutgoingInitialMetadata(send_initial_metadata_op, *send_initial_metadata_); + send_initial_metadata_->Set( + WaitForReady(), + WaitForReady::ValueType{ + (send_initial_metadata_op.flags & + GRPC_INITIAL_METADATA_WAIT_FOR_READY) != 0, + (send_initial_metadata_op.flags & + GRPC_INITIAL_METADATA_WAIT_FOR_READY_EXPLICITLY_SET) != 0}); auto call = MakeCallPair(std::move(send_initial_metadata_), arena()->Ref()); started_call_initiator_ = std::move(call.initiator); Party::WakeupHold wakeup_hold{started_call_initiator_.party()}; @@ -264,7 +302,7 @@ bool ClientCall::StartCallMaybeUpdateState(uintptr_t& cur_state, std::memory_order_acquire)) { call_destination_->StartCall(std::move(handler)); auto unordered_start = reinterpret_cast(cur_state); - while (unordered_start->next != nullptr) { + while (unordered_start != nullptr) { unordered_start->start_pending_batch(); auto next = unordered_start->next; delete unordered_start; diff --git a/deps/grpc/src/core/call/client_call.h b/deps/grpc/src/core/call/client_call.h index 57db571b9d7..553c99075cd 100644 --- a/deps/grpc/src/core/call/client_call.h +++ b/deps/grpc/src/core/call/client_call.h @@ -37,9 +37,6 @@ #include #include -#include "absl/status/status.h" -#include "absl/strings/str_format.h" -#include "absl/strings/string_view.h" #include "src/core/call/metadata.h" #include "src/core/lib/promise/status_flag.h" #include "src/core/lib/resource_quota/arena.h" @@ -49,6 +46,9 @@ #include "src/core/util/ref_counted.h" #include "src/core/util/ref_counted_ptr.h" #include "src/core/util/single_set_ptr.h" +#include "absl/status/status.h" +#include "absl/strings/str_format.h" +#include "absl/strings/string_view.h" namespace grpc_core { @@ -78,6 +78,7 @@ class ClientCall final void InternalUnref(const char*) override { WeakUnref(); } void Orphaned() override { + SourceDestructing(); if (!saw_trailing_metadata_.load(std::memory_order_relaxed)) { CancelWithError(absl::CancelledError()); } @@ -118,6 +119,8 @@ class ClientCall final this->~ClientCall(); } + void AddData(channelz::DataSink sink) override; + private: struct UnorderedStart { absl::AnyInvocable start_pending_batch; diff --git a/deps/grpc/src/core/call/filter_fusion.h b/deps/grpc/src/core/call/filter_fusion.h index 0a2188661bd..9f8a34236a5 100644 --- a/deps/grpc/src/core/call/filter_fusion.h +++ b/deps/grpc/src/core/call/filter_fusion.h @@ -23,10 +23,6 @@ #include #include -#include "absl/log/log.h" -#include "absl/memory/memory.h" -#include "absl/status/status.h" -#include "absl/strings/str_join.h" #include "src/core/call/call_filters.h" #include "src/core/call/metadata.h" #include "src/core/lib/channel/channel_args.h" @@ -38,6 +34,10 @@ #include "src/core/util/manual_constructor.h" #include "src/core/util/status_helper.h" #include "src/core/util/type_list.h" +#include "absl/log/log.h" +#include "absl/memory/memory.h" +#include "absl/status/status.h" +#include "absl/strings/str_join.h" struct grpc_transport_op; diff --git a/deps/grpc/src/core/call/interception_chain.h b/deps/grpc/src/core/call/interception_chain.h index bba88f658cd..7fb79ed572f 100644 --- a/deps/grpc/src/core/call/interception_chain.h +++ b/deps/grpc/src/core/call/interception_chain.h @@ -24,6 +24,7 @@ #include "src/core/call/call_filters.h" #include "src/core/call/call_spine.h" #include "src/core/call/metadata.h" +#include "src/core/filter/filter_args.h" #include "src/core/util/ref_counted.h" namespace grpc_core { @@ -171,10 +172,10 @@ class InterceptionChainBuilder final { // call_filters.h. template absl::enable_if_t - Add() { + Add(RefCountedPtr config) { if (!status_.ok()) return *this; - auto filter = - T::Create(args_, {FilterInstanceId(FilterTypeId()), blackboard_}); + auto filter = T::Create(args_, {FilterInstanceId(FilterTypeId()), + std::move(config), blackboard_}); if (!filter.ok()) { status_ = filter.status(); return *this; @@ -189,9 +190,9 @@ class InterceptionChainBuilder final { template absl::enable_if_t::value, InterceptionChainBuilder&> - Add() { - AddInterceptor( - T::Create(args_, {FilterInstanceId(FilterTypeId()), blackboard_})); + Add(RefCountedPtr config) { + AddInterceptor(T::Create(args_, {FilterInstanceId(FilterTypeId()), + std::move(config), blackboard_})); return *this; }; diff --git a/deps/grpc/src/core/call/metadata_batch.cc b/deps/grpc/src/core/call/metadata_batch.cc index c6d39abe3a5..35c5df92867 100644 --- a/deps/grpc/src/core/call/metadata_batch.cc +++ b/deps/grpc/src/core/call/metadata_batch.cc @@ -20,15 +20,60 @@ #include #include -#include "absl/base/no_destructor.h" -#include "absl/container/flat_hash_set.h" +#include "src/core/lib/transport/timeout_encoding.h" #include "absl/strings/escaping.h" #include "absl/strings/match.h" #include "absl/strings/str_cat.h" #include "absl/strings/str_format.h" -#include "src/core/lib/transport/timeout_encoding.h" namespace grpc_core { + +bool IsMetadataKeyAllowedInDebugOutput(absl::string_view key) { + // We have intentionally not allowed for any way to add to the allow list at + // run time, (using a flag or some other setting) because such workarounds + // may lead to security issues. + // go/keep-sorted start + if (key == ContentTypeMetadata::key()) return true; + if (key == EndpointLoadMetricsBinMetadata::key()) return true; + if (key == GrpcAcceptEncodingMetadata::key()) return true; + if (key == GrpcEncodingMetadata::key()) return true; + if (key == GrpcInternalEncodingRequest::key()) return true; + if (key == GrpcLbClientStatsMetadata::key()) return true; + if (key == GrpcMessageMetadata::key()) return true; + if (key == GrpcPreviousRpcAttemptsMetadata::key()) return true; + if (key == GrpcRetryPushbackMsMetadata::key()) return true; + if (key == GrpcServerStatsBinMetadata::key()) return true; + if (key == GrpcStatusMetadata::key()) return true; + if (key == GrpcTagsBinMetadata::key()) return true; + if (key == GrpcTimeoutMetadata::key()) return true; + if (key == GrpcTraceBinMetadata::key()) return true; + if (key == HostMetadata::key()) return true; + if (key == HttpAuthorityMetadata::key()) return true; + if (key == HttpMethodMetadata::key()) return true; + if (key == HttpPathMetadata::key()) return true; + if (key == HttpSchemeMetadata::key()) return true; + if (key == HttpStatusMetadata::key()) return true; + if (key == LbCostBinMetadata::key()) return true; + if (key == LbTokenMetadata::key()) return true; + if (key == TeMetadata::key()) return true; + if (key == UserAgentMetadata::key()) return true; + if (key == W3CTraceParentMetadata::key()) return true; + if (key == XEnvoyPeerMetadata::key()) return true; + // go/keep-sorted end + // go/keep-sorted start + if (key == GrpcCallWasCancelled::DebugKey()) return true; + if (key == GrpcRegisteredMethod::DebugKey()) return true; + if (key == GrpcStatusContext::DebugKey()) return true; + if (key == GrpcStatusFromWire::DebugKey()) return true; + if (key == GrpcStreamNetworkState::DebugKey()) return true; + if (key == GrpcTarPit::DebugKey()) return true; + if (key == GrpcTrailersOnly::DebugKey()) return true; + if (key == PeerString::DebugKey()) return true; + if (key == WaitForReady::DebugKey()) return true; + // go/keep-sorted end + return false; +} + namespace metadata_detail { void DebugStringBuilder::Add(absl::string_view key, absl::string_view value) { @@ -38,7 +83,7 @@ void DebugStringBuilder::Add(absl::string_view key, absl::string_view value) { void DebugStringBuilder::AddAfterRedaction(absl::string_view key, absl::string_view value) { - if (IsAllowListed(key)) { + if (IsMetadataKeyAllowedInDebugOutput(key)) { Add(key, value); } else { // If the type of metadata is not in the allow list, we want to prevent it @@ -51,57 +96,6 @@ void DebugStringBuilder::AddAfterRedaction(absl::string_view key, } } -bool DebugStringBuilder::IsAllowListed(const absl::string_view key) const { - // We have intentionally not allowed for any way to add to the allow list at - // run time, (using a flag or some other setting) because such workarounds - // may lead to security issues. - static const absl::NoDestructor> allow_list( - [] { - absl::flat_hash_set allow_list; - // go/keep-sorted start - allow_list.insert(std::string(ContentTypeMetadata::key())); - allow_list.insert(std::string(EndpointLoadMetricsBinMetadata::key())); - allow_list.insert(std::string(GrpcAcceptEncodingMetadata::key())); - allow_list.insert(std::string(GrpcEncodingMetadata::key())); - allow_list.insert(std::string(GrpcInternalEncodingRequest::key())); - allow_list.insert(std::string(GrpcLbClientStatsMetadata::key())); - allow_list.insert(std::string(GrpcMessageMetadata::key())); - allow_list.insert(std::string(GrpcPreviousRpcAttemptsMetadata::key())); - allow_list.insert(std::string(GrpcRetryPushbackMsMetadata::key())); - allow_list.insert(std::string(GrpcServerStatsBinMetadata::key())); - allow_list.insert(std::string(GrpcStatusMetadata::key())); - allow_list.insert(std::string(GrpcTagsBinMetadata::key())); - allow_list.insert(std::string(GrpcTimeoutMetadata::key())); - allow_list.insert(std::string(GrpcTraceBinMetadata::key())); - allow_list.insert(std::string(HostMetadata::key())); - allow_list.insert(std::string(HttpAuthorityMetadata::key())); - allow_list.insert(std::string(HttpMethodMetadata::key())); - allow_list.insert(std::string(HttpPathMetadata::key())); - allow_list.insert(std::string(HttpSchemeMetadata::key())); - allow_list.insert(std::string(HttpStatusMetadata::key())); - allow_list.insert(std::string(LbCostBinMetadata::key())); - allow_list.insert(std::string(LbTokenMetadata::key())); - allow_list.insert(std::string(TeMetadata::key())); - allow_list.insert(std::string(UserAgentMetadata::key())); - allow_list.insert(std::string(W3CTraceParentMetadata::key())); - allow_list.insert(std::string(XEnvoyPeerMetadata::key())); - // go/keep-sorted end - // go/keep-sorted start - allow_list.insert(std::string(GrpcCallWasCancelled::DebugKey())); - allow_list.insert(std::string(GrpcRegisteredMethod::DebugKey())); - allow_list.insert(std::string(GrpcStatusContext::DebugKey())); - allow_list.insert(std::string(GrpcStatusFromWire::DebugKey())); - allow_list.insert(std::string(GrpcStreamNetworkState::DebugKey())); - allow_list.insert(std::string(GrpcTarPit::DebugKey())); - allow_list.insert(std::string(GrpcTrailersOnly::DebugKey())); - allow_list.insert(std::string(PeerString::DebugKey())); - allow_list.insert(std::string(WaitForReady::DebugKey())); - // go/keep-sorted end - return allow_list; - }()); - return allow_list->contains(key); -} - void UnknownMap::Append(absl::string_view key, Slice value) { unknown_.emplace_back(Slice::FromCopiedString(key), value.Ref()); } diff --git a/deps/grpc/src/core/call/metadata_batch.h b/deps/grpc/src/core/call/metadata_batch.h index 8032024bad9..675578ba752 100644 --- a/deps/grpc/src/core/call/metadata_batch.h +++ b/deps/grpc/src/core/call/metadata_batch.h @@ -30,11 +30,6 @@ #include #include -#include "absl/container/inlined_vector.h" -#include "absl/functional/function_ref.h" -#include "absl/meta/type_traits.h" -#include "absl/strings/numbers.h" -#include "absl/strings/string_view.h" #include "src/core/call/custom_metadata.h" #include "src/core/call/metadata_compression_traits.h" #include "src/core/call/parsed_metadata.h" @@ -49,6 +44,11 @@ #include "src/core/util/packed_table.h" #include "src/core/util/time.h" #include "src/core/util/type_list.h" +#include "absl/container/inlined_vector.h" +#include "absl/functional/function_ref.h" +#include "absl/meta/type_traits.h" +#include "absl/strings/numbers.h" +#include "absl/strings/string_view.h" namespace grpc_core { @@ -630,6 +630,8 @@ struct GrpcTarPit { static absl::string_view DisplayValue(Empty) { return "tarpit"; } }; +bool IsMetadataKeyAllowedInDebugOutput(absl::string_view key); + namespace metadata_detail { // Build a key/value formatted debug string. @@ -646,7 +648,6 @@ class DebugStringBuilder { std::string TakeOutput() { return std::move(out_); } private: - bool IsAllowListed(absl::string_view key) const; void Add(absl::string_view key, absl::string_view value); std::string out_; }; diff --git a/deps/grpc/src/core/call/metadata_channelz.cc b/deps/grpc/src/core/call/metadata_channelz.cc new file mode 100644 index 00000000000..3365795cd45 --- /dev/null +++ b/deps/grpc/src/core/call/metadata_channelz.cc @@ -0,0 +1,37 @@ +// Copyright 2025 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 "src/core/call/metadata_channelz.h" + +namespace grpc_core { + +channelz::PropertyList MetadataToChannelzProperties( + const Arena::PoolPtr& md) { + if (md == nullptr) { + return channelz::PropertyList(); + } + return MetadataToChannelzProperties(*md); +} + +channelz::PropertyList MetadataToChannelzProperties( + const grpc_metadata_batch& md) { + channelz::PropertyList properties; + md.Log([&properties](absl::string_view key, absl::string_view value) { + if (!IsMetadataKeyAllowedInDebugOutput(key)) return; + properties.Add(key, value); + }); + return properties; +} + +} // namespace grpc_core diff --git a/deps/grpc/src/core/call/metadata_channelz.h b/deps/grpc/src/core/call/metadata_channelz.h new file mode 100644 index 00000000000..38616b778d6 --- /dev/null +++ b/deps/grpc/src/core/call/metadata_channelz.h @@ -0,0 +1,30 @@ +// Copyright 2025 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. + +#ifndef GRPC_SRC_CORE_CALL_METADATA_CHANNELZ_H +#define GRPC_SRC_CORE_CALL_METADATA_CHANNELZ_H + +#include "src/core/call/metadata.h" +#include "src/core/channelz/property_list.h" + +namespace grpc_core { + +channelz::PropertyList MetadataToChannelzProperties( + const Arena::PoolPtr& md); +channelz::PropertyList MetadataToChannelzProperties( + const grpc_metadata_batch& md); + +} // namespace grpc_core + +#endif // GRPC_SRC_CORE_CALL_METADATA_CHANNELZ_H diff --git a/deps/grpc/src/core/call/metadata_info.cc b/deps/grpc/src/core/call/metadata_info.cc index 8bb684be38f..02be5a4d115 100644 --- a/deps/grpc/src/core/call/metadata_info.cc +++ b/deps/grpc/src/core/call/metadata_info.cc @@ -19,8 +19,8 @@ #include #include -#include "absl/strings/str_cat.h" #include "src/core/lib/slice/slice.h" +#include "absl/strings/str_cat.h" namespace grpc_core { diff --git a/deps/grpc/src/core/call/parsed_metadata.h b/deps/grpc/src/core/call/parsed_metadata.h index 3d12ee4e986..e43cc53e13a 100644 --- a/deps/grpc/src/core/call/parsed_metadata.h +++ b/deps/grpc/src/core/call/parsed_metadata.h @@ -24,14 +24,14 @@ #include #include +#include "src/core/lib/slice/slice.h" +#include "src/core/util/time.h" #include "absl/functional/function_ref.h" #include "absl/meta/type_traits.h" #include "absl/strings/escaping.h" #include "absl/strings/match.h" #include "absl/strings/str_cat.h" #include "absl/strings/string_view.h" -#include "src/core/lib/slice/slice.h" -#include "src/core/util/time.h" namespace grpc_core { diff --git a/deps/grpc/src/core/call/request_buffer.cc b/deps/grpc/src/core/call/request_buffer.cc index c53972d558f..f16279d0318 100644 --- a/deps/grpc/src/core/call/request_buffer.cc +++ b/deps/grpc/src/core/call/request_buffer.cc @@ -17,8 +17,8 @@ #include #include -#include "absl/strings/str_cat.h" #include "src/core/util/match.h" +#include "absl/strings/str_cat.h" namespace grpc_core { diff --git a/deps/grpc/src/core/call/security_context.cc b/deps/grpc/src/core/call/security_context.cc index cc9ed6e6278..a9388925699 100644 --- a/deps/grpc/src/core/call/security_context.cc +++ b/deps/grpc/src/core/call/security_context.cc @@ -25,7 +25,6 @@ #include -#include "absl/log/log.h" #include "src/core/credentials/call/call_credentials.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/debug/trace.h" @@ -34,6 +33,7 @@ #include "src/core/lib/surface/call.h" #include "src/core/util/grpc_check.h" #include "src/core/util/ref_counted_ptr.h" +#include "absl/log/log.h" // --- grpc_call --- diff --git a/deps/grpc/src/core/call/security_context.h b/deps/grpc/src/core/call/security_context.h index 6094e8d016e..5377cdcf544 100644 --- a/deps/grpc/src/core/call/security_context.h +++ b/deps/grpc/src/core/call/security_context.h @@ -27,7 +27,6 @@ #include #include -#include "absl/strings/string_view.h" #include "src/core/credentials/call/call_credentials.h" // IWYU pragma: keep #include "src/core/lib/debug/trace.h" #include "src/core/lib/resource_quota/arena.h" @@ -38,6 +37,7 @@ #include "src/core/util/ref_counted.h" #include "src/core/util/ref_counted_ptr.h" #include "src/core/util/useful.h" +#include "absl/strings/string_view.h" // --- grpc_security_context_extension --- diff --git a/deps/grpc/src/core/call/server_call.cc b/deps/grpc/src/core/call/server_call.cc index d20580270ca..a3a457857c4 100644 --- a/deps/grpc/src/core/call/server_call.cc +++ b/deps/grpc/src/core/call/server_call.cc @@ -37,7 +37,6 @@ #include #include -#include "absl/strings/string_view.h" #include "src/core/call/metadata.h" #include "src/core/call/metadata_batch.h" #include "src/core/lib/promise/all_ok.h" @@ -52,6 +51,7 @@ #include "src/core/util/bitset.h" #include "src/core/util/grpc_check.h" #include "src/core/util/latent_see.h" +#include "absl/strings/string_view.h" namespace grpc_core { diff --git a/deps/grpc/src/core/call/server_call.h b/deps/grpc/src/core/call/server_call.h index 7072c8fe734..403e6a76575 100644 --- a/deps/grpc/src/core/call/server_call.h +++ b/deps/grpc/src/core/call/server_call.h @@ -39,9 +39,6 @@ #include #include -#include "absl/status/status.h" -#include "absl/strings/str_format.h" -#include "absl/strings/string_view.h" #include "src/core/call/metadata.h" #include "src/core/call/metadata_batch.h" #include "src/core/lib/promise/poll.h" @@ -55,6 +52,9 @@ #include "src/core/util/grpc_check.h" #include "src/core/util/ref_counted.h" #include "src/core/util/ref_counted_ptr.h" +#include "absl/status/status.h" +#include "absl/strings/str_format.h" +#include "absl/strings/string_view.h" namespace grpc_core { @@ -72,6 +72,7 @@ class ServerCall final : public Call, public DualRefCounted { cq_(cq), server_(server) { global_stats().IncrementServerCallsCreated(); + SourceConstructed(); } void CancelWithError(grpc_error_handle error) override { @@ -97,6 +98,7 @@ class ServerCall final : public Call, public DualRefCounted { void InternalUnref(const char*) override { WeakUnref(); } void Orphaned() override { + SourceDestructing(); if (!saw_was_cancelled_.load(std::memory_order_relaxed)) { CancelWithError(absl::CancelledError()); } diff --git a/deps/grpc/src/core/call/simple_slice_based_metadata.h b/deps/grpc/src/core/call/simple_slice_based_metadata.h index 43ceae3d1a5..b595b1fd8ca 100644 --- a/deps/grpc/src/core/call/simple_slice_based_metadata.h +++ b/deps/grpc/src/core/call/simple_slice_based_metadata.h @@ -17,9 +17,9 @@ #include -#include "absl/strings/string_view.h" #include "src/core/call/parsed_metadata.h" #include "src/core/lib/slice/slice.h" +#include "absl/strings/string_view.h" namespace grpc_core { diff --git a/deps/grpc/src/core/call/status_util.cc b/deps/grpc/src/core/call/status_util.cc index 62955f4c14a..a98ec5a0524 100644 --- a/deps/grpc/src/core/call/status_util.cc +++ b/deps/grpc/src/core/call/status_util.cc @@ -23,9 +23,9 @@ #include +#include "src/core/util/useful.h" #include "absl/strings/str_cat.h" #include "absl/strings/str_join.h" -#include "src/core/util/useful.h" struct status_string_entry { const char* str; diff --git a/deps/grpc/src/core/channelz/channel_trace.cc b/deps/grpc/src/core/channelz/channel_trace.cc index 5431b93a24e..db921d8bca0 100644 --- a/deps/grpc/src/core/channelz/channel_trace.cc +++ b/deps/grpc/src/core/channelz/channel_trace.cc @@ -26,7 +26,6 @@ #include #include -#include "absl/strings/str_cat.h" #include "google/protobuf/any.upb.h" #include "src/core/channelz/channelz.h" #include "src/core/lib/slice/slice.h" @@ -38,6 +37,7 @@ #include "src/core/util/upb_utils.h" #include "src/proto/grpc/channelz/v2/channelz.upb.h" #include "upb/base/string_view.h" +#include "absl/strings/str_cat.h" namespace grpc_core { namespace channelz { diff --git a/deps/grpc/src/core/channelz/channel_trace.h b/deps/grpc/src/core/channelz/channel_trace.h index 7ae22433cbb..b8633797fd7 100644 --- a/deps/grpc/src/core/channelz/channel_trace.h +++ b/deps/grpc/src/core/channelz/channel_trace.h @@ -31,9 +31,6 @@ #include #include -#include "absl/base/thread_annotations.h" -#include "absl/strings/str_cat.h" -#include "absl/strings/string_view.h" #include "src/core/lib/debug/trace_flags.h" #include "src/core/util/json/json.h" #include "src/core/util/memory_usage.h" @@ -41,6 +38,9 @@ #include "src/core/util/sync.h" #include "src/core/util/time.h" #include "src/proto/grpc/channelz/v2/channelz.upb.h" +#include "absl/base/thread_annotations.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/string_view.h" namespace grpc_core { namespace channelz { diff --git a/deps/grpc/src/core/channelz/channelz.cc b/deps/grpc/src/core/channelz/channelz.cc index 4153507fc8d..986819cb3e0 100644 --- a/deps/grpc/src/core/channelz/channelz.cc +++ b/deps/grpc/src/core/channelz/channelz.cc @@ -30,12 +30,6 @@ #include #include -#include "absl/cleanup/cleanup.h" -#include "absl/log/check.h" -#include "absl/status/statusor.h" -#include "absl/strings/escaping.h" -#include "absl/strings/str_cat.h" -#include "absl/strings/strip.h" #include "src/core/channelz/channelz_registry.h" #include "src/core/channelz/property_list.h" #include "src/core/lib/address_utils/parse_address.h" @@ -52,6 +46,12 @@ #include "src/core/util/uri.h" #include "src/core/util/useful.h" #include "src/proto/grpc/channelz/v2/channelz.upb.h" +#include "absl/cleanup/cleanup.h" +#include "absl/log/check.h" +#include "absl/status/statusor.h" +#include "absl/strings/escaping.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/strip.h" namespace grpc_core { namespace channelz { @@ -177,13 +177,15 @@ void BaseNode::SerializeEntity(grpc_channelz_v2_Entity* entity, grpc_channelz_v2_Entity_set_id(entity, uuid()); grpc_channelz_v2_Entity_set_kind( entity, StdStringToUpbString(EntityTypeToKind(type_))); + std::vector> parent_nodes; { MutexLock lock(&parent_mu_); - auto* parents = - grpc_channelz_v2_Entity_resize_parents(entity, parents_.size(), arena); - for (const auto& parent : parents_) { - *parents++ = parent->uuid(); - } + parent_nodes.assign(parents_.begin(), parents_.end()); + } + auto* parents = grpc_channelz_v2_Entity_resize_parents( + entity, parent_nodes.size(), arena); + for (const auto& parent : parent_nodes) { + *parents++ = parent->uuid(); } grpc_channelz_v2_Entity_set_orphaned(entity, orphaned_index_ != 0); diff --git a/deps/grpc/src/core/channelz/channelz.h b/deps/grpc/src/core/channelz/channelz.h index cbcfefbbc48..3c36d516e16 100644 --- a/deps/grpc/src/core/channelz/channelz.h +++ b/deps/grpc/src/core/channelz/channelz.h @@ -35,10 +35,6 @@ #include #include -#include "absl/base/thread_annotations.h" -#include "absl/container/flat_hash_set.h" -#include "absl/container/inlined_vector.h" -#include "absl/strings/string_view.h" #include "src/core/channelz/channel_trace.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/util/dual_ref_counted.h" @@ -53,6 +49,10 @@ #include "src/core/util/useful.h" #include "src/proto/grpc/channelz/v2/channelz.upb.h" #include "src/proto/grpc/channelz/v2/service.upb.h" +#include "absl/base/thread_annotations.h" +#include "absl/container/flat_hash_set.h" +#include "absl/container/inlined_vector.h" +#include "absl/strings/string_view.h" // Channel arg key for channelz node. #define GRPC_ARG_CHANNELZ_CHANNEL_NODE \ @@ -130,6 +130,8 @@ class BaseNode : public DualRefCounted { kSocket, kCall, kResourceQuota, + kMetricsDomain, + kMetricsDomainStorage, }; static absl::string_view EntityTypeString(EntityType type) { @@ -150,6 +152,10 @@ class BaseNode : public DualRefCounted { return "call"; case EntityType::kResourceQuota: return "resource_quota"; + case EntityType::kMetricsDomain: + return "metrics_domain"; + case EntityType::kMetricsDomainStorage: + return "metrics_domain_storage"; } return "unknown"; } @@ -172,6 +178,10 @@ class BaseNode : public DualRefCounted { return "call"; case EntityType::kResourceQuota: return "resource_quota"; + case EntityType::kMetricsDomain: + return "metrics_domain"; + case EntityType::kMetricsDomainStorage: + return "metrics_domain_storage"; } } @@ -184,6 +194,10 @@ class BaseNode : public DualRefCounted { if (kind == "socket") return EntityType::kSocket; if (kind == "call") return EntityType::kCall; if (kind == "resource_quota") return EntityType::kResourceQuota; + if (kind == "metrics_domain") return EntityType::kMetricsDomain; + if (kind == "metrics_domain_storage") { + return EntityType::kMetricsDomainStorage; + } return std::nullopt; } @@ -788,8 +802,7 @@ class ListenSocketNode final : public BaseNode { class CallNode final : public BaseNode { public: - explicit CallNode(std::string name) - : BaseNode(EntityType::kCall, 0, std::move(name)) { + explicit CallNode() : BaseNode(EntityType::kCall, 0, std::string()) { NodeConstructed(); } @@ -806,6 +819,28 @@ class ResourceQuotaNode final : public BaseNode { Json RenderJson() override { return Json::FromString("ResourceQuota"); } }; +class MetricsDomainNode final : public BaseNode { + public: + explicit MetricsDomainNode(std::string name) + : BaseNode(EntityType::kMetricsDomain, 0, std::move(name)) { + NodeConstructed(); + } + + Json RenderJson() override { return Json::FromString("MetricsDomain"); } +}; + +class MetricsDomainStorageNode final : public BaseNode { + public: + explicit MetricsDomainStorageNode(std::string name) + : BaseNode(EntityType::kMetricsDomainStorage, 0, std::move(name)) { + NodeConstructed(); + } + + Json RenderJson() override { + return Json::FromString("MetricsDomainStorage"); + } +}; + } // namespace channelz } // namespace grpc_core diff --git a/deps/grpc/src/core/channelz/channelz_registry.cc b/deps/grpc/src/core/channelz/channelz_registry.cc index b0f92226231..d2822389d43 100644 --- a/deps/grpc/src/core/channelz/channelz_registry.cc +++ b/deps/grpc/src/core/channelz/channelz_registry.cc @@ -33,8 +33,6 @@ #include #include -#include "absl/log/check.h" -#include "absl/log/log.h" #include "src/core/channelz/channelz.h" #include "src/core/config/config_vars.h" #include "src/core/lib/iomgr/exec_ctx.h" @@ -43,6 +41,8 @@ #include "src/core/util/json/json_writer.h" #include "src/core/util/shared_bit_gen.h" #include "src/core/util/sync.h" +#include "absl/log/check.h" +#include "absl/log/log.h" namespace grpc_core { namespace channelz { diff --git a/deps/grpc/src/core/channelz/channelz_registry.h b/deps/grpc/src/core/channelz/channelz_registry.h index 1bf8e059f0a..1cc01cdf4c0 100644 --- a/deps/grpc/src/core/channelz/channelz_registry.h +++ b/deps/grpc/src/core/channelz/channelz_registry.h @@ -21,16 +21,18 @@ #include +#include #include #include #include -#include "absl/container/btree_map.h" -#include "absl/functional/function_ref.h" #include "src/core/channelz/channelz.h" #include "src/core/util/json/json_writer.h" #include "src/core/util/ref_counted_ptr.h" #include "src/core/util/sync.h" +#include "absl/container/btree_map.h" +#include "absl/container/flat_hash_set.h" +#include "absl/functional/function_ref.h" namespace grpc_core { namespace channelz { @@ -115,6 +117,11 @@ class ChannelzRegistry final { max_results); } + static std::vector> GetDescendants( + BaseNode* root, size_t max_results) { + return Default()->InternalGetDescendants(root, max_results); + } + static WeakRefCountedPtr GetNode(intptr_t uuid) { return Default()->InternalGet(uuid); } @@ -250,6 +257,39 @@ class ChannelzRegistry final { max_results); } + std::vector> InternalGetDescendants( + BaseNode* root, size_t max_results) { + std::vector> descendants; + if (root == nullptr || max_results == 0) return descendants; + + // To prevent duplicate nodes and to prevent infinite loops. + absl::flat_hash_set visited; + + descendants.reserve(max_results); + visited.insert(root->uuid()); + descendants.push_back(root->WeakRef()); + + size_t next_id = 0; + + // BFS to find all descendants. + do { + BaseNode* current_node = descendants[next_id].get(); + + auto [children, _] = InternalGetChildren( + current_node, current_node->uuid(), max_results - descendants.size()); + + for (const auto& child : children) { + if (visited.insert(child->uuid()).second) { + descendants.push_back(child); + } + } + + ++next_id; + } while (descendants.size() < max_results && next_id < descendants.size()); + + return descendants; + } + std::tuple>, bool> InternalGetNodes( intptr_t start_node, size_t max_results) { return QueryNodes( diff --git a/deps/grpc/src/core/channelz/property_list.h b/deps/grpc/src/core/channelz/property_list.h index 5a339ece7cf..8ea4936b264 100644 --- a/deps/grpc/src/core/channelz/property_list.h +++ b/deps/grpc/src/core/channelz/property_list.h @@ -20,10 +20,6 @@ #include #include -#include "absl/container/flat_hash_map.h" -#include "absl/status/status.h" -#include "absl/strings/string_view.h" -#include "absl/time/time.h" #include "google/protobuf/any.upb.h" #include "src/core/util/json/json.h" #include "src/core/util/string.h" @@ -33,6 +29,10 @@ #include "src/proto/grpc/channelz/v2/property_list.upb.h" #include "upb/mem/arena.h" #include "upb/text/encode.h" +#include "absl/container/flat_hash_map.h" +#include "absl/status/status.h" +#include "absl/strings/string_view.h" +#include "absl/time/time.h" namespace grpc_core::channelz { @@ -139,6 +139,8 @@ class PropertyList final : public OtherPropertyValue { PropertyList& Merge(PropertyList other); + bool empty() const { return property_list_.empty(); } + // TODO(ctiller): remove soon, switch to just FillUpbProto. Json::Object TakeJsonObject() override; void FillUpbProto(grpc_channelz_v2_PropertyList* proto, upb_Arena* arena); diff --git a/deps/grpc/src/core/channelz/v2tov1/convert.cc b/deps/grpc/src/core/channelz/v2tov1/convert.cc index 0090871cb88..4af35fc3d14 100644 --- a/deps/grpc/src/core/channelz/v2tov1/convert.cc +++ b/deps/grpc/src/core/channelz/v2tov1/convert.cc @@ -18,12 +18,6 @@ #include #include -#include "absl/cleanup/cleanup.h" -#include "absl/status/status.h" -#include "absl/status/statusor.h" -#include "absl/strings/escaping.h" -#include "absl/strings/str_cat.h" -#include "absl/strings/strip.h" #include "google/protobuf/any.upb.h" #include "google/protobuf/duration.upb.h" #include "google/protobuf/timestamp.upb.h" @@ -43,6 +37,12 @@ #include "upb/json/encode.h" #include "upb/mem/arena.hpp" #include "upb/reflection/def.hpp" +#include "absl/cleanup/cleanup.h" +#include "absl/status/status.h" +#include "absl/status/statusor.h" +#include "absl/strings/escaping.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/strip.h" namespace grpc_core { namespace channelz { diff --git a/deps/grpc/src/core/channelz/v2tov1/legacy_api.cc b/deps/grpc/src/core/channelz/v2tov1/legacy_api.cc index 96dc17e12b3..a9effcb55f7 100644 --- a/deps/grpc/src/core/channelz/v2tov1/legacy_api.cc +++ b/deps/grpc/src/core/channelz/v2tov1/legacy_api.cc @@ -14,16 +14,11 @@ #include #include -#include #include #include #include -#include "absl/log/log.h" -#include "absl/status/statusor.h" -#include "absl/strings/str_cat.h" -#include "absl/time/time.h" #include "src/core/channelz/channelz_registry.h" #include "src/core/channelz/v2tov1/convert.h" #include "src/core/lib/experiments/experiments.h" @@ -31,6 +26,10 @@ #include "src/core/util/json/json.h" #include "src/core/util/json/json_reader.h" #include "src/core/util/json/json_writer.h" +#include "absl/log/log.h" +#include "absl/status/statusor.h" +#include "absl/strings/str_cat.h" +#include "absl/time/time.h" // This file is a temporary compatibility layer between the v2 channelz data // model and the v1 C-API. It should be removed when the v1 C-API is removed. diff --git a/deps/grpc/src/core/channelz/v2tov1/property_list.cc b/deps/grpc/src/core/channelz/v2tov1/property_list.cc index 64bbb6307cf..371084395cb 100644 --- a/deps/grpc/src/core/channelz/v2tov1/property_list.cc +++ b/deps/grpc/src/core/channelz/v2tov1/property_list.cc @@ -15,16 +15,17 @@ #include "src/core/channelz/v2tov1/property_list.h" #include +#include #include #include -#include "absl/strings/string_view.h" #include "google/protobuf/any.upb.h" #include "google/protobuf/duration.upb.h" #include "google/protobuf/timestamp.upb.h" #include "src/core/util/upb_utils.h" #include "src/proto/grpc/channelz/v2/property_list.upb.h" #include "upb/mem/arena.hpp" +#include "absl/strings/string_view.h" namespace grpc_core { namespace channelz { diff --git a/deps/grpc/src/core/channelz/ztrace_collector.h b/deps/grpc/src/core/channelz/ztrace_collector.h index b2da2d98e58..32c93001c7f 100644 --- a/deps/grpc/src/core/channelz/ztrace_collector.h +++ b/deps/grpc/src/core/channelz/ztrace_collector.h @@ -19,10 +19,9 @@ #include #include +#include #include -#include "absl/container/flat_hash_set.h" -#include "absl/status/status.h" #include "google/protobuf/any.upb.h" #include "google/protobuf/any.upbdefs.h" #include "google/protobuf/timestamp.upb.h" @@ -31,6 +30,7 @@ #include "src/core/lib/debug/trace.h" #include "src/core/util/function_signature.h" #include "src/core/util/json/json_writer.h" +#include "src/core/util/latent_see.h" #include "src/core/util/memory_usage.h" #include "src/core/util/single_set_ptr.h" #include "src/core/util/string.h" @@ -39,6 +39,9 @@ #include "src/proto/grpc/channelz/v2/channelz.upb.h" #include "src/proto/grpc/channelz/v2/service.upb.h" #include "upb/mem/arena.hpp" +#include "absl/container/flat_hash_set.h" +#include "absl/meta/type_traits.h" +#include "absl/status/status.h" #ifdef GRPC_NO_ZTRACE namespace grpc_core::channelz { @@ -61,6 +64,8 @@ class StubImpl { std::unique_ptr MakeZTrace() { return std::make_unique(); } + + bool IsActive() { return false; } }; } // namespace ztrace_collector_detail @@ -163,6 +168,13 @@ class ZTraceCollector { // complexity. template void Append(X producer_or_value) { + if constexpr (ztrace_collector_detail::kIsElement) { + GRPC_LATENT_SEE_ALWAYS_ON_MARK_EXTRA_EVENT(X, producer_or_value); + } else { + using ResultType = absl::result_of_t; + GRPC_LATENT_SEE_ALWAYS_ON_MARK_EXTRA_EVENT(ResultType, + producer_or_value()); + } GRPC_TRACE_LOG(ztrace, INFO) << "ZTRACE[" << this << "]: " << [&]() { upb::Arena arena; google_protobuf_Any* any = google_protobuf_Any_new(arena.ptr()); diff --git a/deps/grpc/src/core/channelz/zviz/data.cc b/deps/grpc/src/core/channelz/zviz/data.cc index 9abb7383d72..fa356b507b7 100644 --- a/deps/grpc/src/core/channelz/zviz/data.cc +++ b/deps/grpc/src/core/channelz/zviz/data.cc @@ -18,6 +18,12 @@ #include #include +#include "src/core/channelz/zviz/environment.h" +#include "src/core/channelz/zviz/layout.h" +#include "src/core/util/no_destruct.h" +#include "src/proto/grpc/channelz/v2/channelz.pb.h" +#include "src/proto/grpc/channelz/v2/promise.pb.h" +#include "src/proto/grpc/channelz/v2/property_list.pb.h" #include "absl/container/flat_hash_map.h" #include "absl/strings/match.h" #include "absl/strings/str_cat.h" @@ -25,12 +31,6 @@ #include "absl/strings/string_view.h" #include "absl/strings/strip.h" #include "absl/types/span.h" -#include "src/core/channelz/zviz/environment.h" -#include "src/core/channelz/zviz/layout.h" -#include "src/core/util/no_destruct.h" -#include "src/proto/grpc/channelz/v2/channelz.pb.h" -#include "src/proto/grpc/channelz/v2/promise.pb.h" -#include "src/proto/grpc/channelz/v2/property_list.pb.h" namespace grpc_zviz { diff --git a/deps/grpc/src/core/channelz/zviz/entity.cc b/deps/grpc/src/core/channelz/zviz/entity.cc index 6bdae906c27..e929a884262 100644 --- a/deps/grpc/src/core/channelz/zviz/entity.cc +++ b/deps/grpc/src/core/channelz/zviz/entity.cc @@ -14,10 +14,10 @@ #include "src/core/channelz/zviz/entity.h" -#include "absl/strings/str_cat.h" #include "src/core/channelz/zviz/data.h" #include "src/core/channelz/zviz/strings.h" #include "src/core/channelz/zviz/trace.h" +#include "absl/strings/str_cat.h" namespace grpc_zviz { diff --git a/deps/grpc/src/core/channelz/zviz/environment.h b/deps/grpc/src/core/channelz/zviz/environment.h index 9f0898cd249..b21978599ad 100644 --- a/deps/grpc/src/core/channelz/zviz/environment.h +++ b/deps/grpc/src/core/channelz/zviz/environment.h @@ -18,9 +18,9 @@ #include #include +#include "src/proto/grpc/channelz/v2/channelz.pb.h" #include "absl/status/statusor.h" #include "absl/strings/string_view.h" -#include "src/proto/grpc/channelz/v2/channelz.pb.h" namespace grpc_zviz { @@ -33,7 +33,9 @@ class Environment { int64_t entity_id) = 0; struct GetChildrenResult { std::vector entities; - bool end; + // If >0, this is the first ID of the next page of results. + // If 0, this is the last page of results. + int64_t next_id_or_end; }; virtual absl::StatusOr GetChildrenPaginated( int64_t /*entity_id*/, absl::string_view /*kind*/, int64_t /*start*/, diff --git a/deps/grpc/src/core/channelz/zviz/format_entity_list.cc b/deps/grpc/src/core/channelz/zviz/format_entity_list.cc index b63db29ba98..d3a371f2c89 100644 --- a/deps/grpc/src/core/channelz/zviz/format_entity_list.cc +++ b/deps/grpc/src/core/channelz/zviz/format_entity_list.cc @@ -17,10 +17,10 @@ #include #include -#include "absl/strings/string_view.h" -#include "absl/strings/strip.h" #include "src/core/channelz/zviz/layout.h" #include "src/core/channelz/zviz/property_list.h" +#include "absl/strings/string_view.h" +#include "absl/strings/strip.h" namespace grpc_zviz { diff --git a/deps/grpc/src/core/channelz/zviz/format_entity_list.h b/deps/grpc/src/core/channelz/zviz/format_entity_list.h index 6083ffaf6b1..237828c3351 100644 --- a/deps/grpc/src/core/channelz/zviz/format_entity_list.h +++ b/deps/grpc/src/core/channelz/zviz/format_entity_list.h @@ -17,10 +17,10 @@ #include -#include "absl/types/span.h" #include "src/core/channelz/zviz/environment.h" #include "src/core/channelz/zviz/layout.h" #include "src/proto/grpc/channelz/v2/channelz.pb.h" +#include "absl/types/span.h" namespace grpc_zviz { diff --git a/deps/grpc/src/core/channelz/zviz/html.h b/deps/grpc/src/core/channelz/zviz/html.h index 5ae9819a545..85891c4e3c3 100644 --- a/deps/grpc/src/core/channelz/zviz/html.h +++ b/deps/grpc/src/core/channelz/zviz/html.h @@ -20,10 +20,10 @@ #include #include +#include "src/core/util/grpc_check.h" #include "absl/container/flat_hash_map.h" #include "absl/functional/function_ref.h" #include "absl/strings/string_view.h" -#include "src/core/util/grpc_check.h" namespace grpc_zviz::html { std::string HtmlEscape(absl::string_view text); diff --git a/deps/grpc/src/core/channelz/zviz/layout.h b/deps/grpc/src/core/channelz/zviz/layout.h index 1356c95b127..9fe76d1f612 100644 --- a/deps/grpc/src/core/channelz/zviz/layout.h +++ b/deps/grpc/src/core/channelz/zviz/layout.h @@ -17,10 +17,10 @@ #include -#include "absl/strings/str_cat.h" #include "google/protobuf/duration.pb.h" #include "google/protobuf/timestamp.pb.h" #include "src/core/channelz/zviz/environment.h" +#include "absl/strings/str_cat.h" namespace grpc_zviz::layout { diff --git a/deps/grpc/src/core/channelz/zviz/property_list.cc b/deps/grpc/src/core/channelz/zviz/property_list.cc index d0f78bf7299..40a186abcf5 100644 --- a/deps/grpc/src/core/channelz/zviz/property_list.cc +++ b/deps/grpc/src/core/channelz/zviz/property_list.cc @@ -18,12 +18,12 @@ #include #include +#include "src/proto/grpc/channelz/v2/channelz.pb.h" +#include "src/proto/grpc/channelz/v2/property_list.pb.h" #include "absl/strings/str_cat.h" #include "absl/strings/str_split.h" #include "absl/strings/string_view.h" #include "absl/time/time.h" -#include "src/proto/grpc/channelz/v2/channelz.pb.h" -#include "src/proto/grpc/channelz/v2/property_list.pb.h" namespace grpc_zviz { diff --git a/deps/grpc/src/core/channelz/zviz/property_list.h b/deps/grpc/src/core/channelz/zviz/property_list.h index 05698efdbe8..5e429256e9e 100644 --- a/deps/grpc/src/core/channelz/zviz/property_list.h +++ b/deps/grpc/src/core/channelz/zviz/property_list.h @@ -18,9 +18,9 @@ #include #include -#include "absl/strings/string_view.h" #include "src/proto/grpc/channelz/v2/channelz.pb.h" #include "src/proto/grpc/channelz/v2/property_list.pb.h" +#include "absl/strings/string_view.h" namespace grpc_zviz { diff --git a/deps/grpc/src/core/client_channel/backup_poller.cc b/deps/grpc/src/core/client_channel/backup_poller.cc index 39ad86c9f18..3e6cc3b1c2b 100644 --- a/deps/grpc/src/core/client_channel/backup_poller.cc +++ b/deps/grpc/src/core/client_channel/backup_poller.cc @@ -23,8 +23,6 @@ #include #include -#include "absl/log/log.h" -#include "absl/status/status.h" #include "src/core/config/config_vars.h" #include "src/core/lib/iomgr/closure.h" #include "src/core/lib/iomgr/error.h" @@ -34,6 +32,8 @@ #include "src/core/lib/iomgr/timer.h" #include "src/core/util/memory.h" #include "src/core/util/time.h" +#include "absl/log/log.h" +#include "absl/status/status.h" #define DEFAULT_POLL_INTERVAL_MS 5000 diff --git a/deps/grpc/src/core/client_channel/buffered_call.cc b/deps/grpc/src/core/client_channel/buffered_call.cc new file mode 100644 index 00000000000..82b779a4f0c --- /dev/null +++ b/deps/grpc/src/core/client_channel/buffered_call.cc @@ -0,0 +1,140 @@ +// +// Copyright 2015 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 "src/core/client_channel/buffered_call.h" + +namespace grpc_core { + +BufferedCall::BufferedCall(CallCombiner* call_combiner, TraceFlag* tracer) + : call_combiner_(call_combiner), tracer_(tracer) { + if (GRPC_TRACE_FLAG_ENABLED_OBJ(*tracer_)) { + LOG(INFO) << "BufferedCall " << this << ": created"; + } +} + +BufferedCall::~BufferedCall() { + // Make sure there are no remaining pending batches. + for (size_t i = 0; i < GPR_ARRAY_SIZE(pending_batches_); ++i) { + GRPC_CHECK_EQ(pending_batches_[i], nullptr); + } +} + +size_t BufferedCall::GetBatchIndex(grpc_transport_stream_op_batch* batch) { + // Note: It is important the send_initial_metadata be the first entry + // here, since the code in CheckResolution() assumes it will be. + if (batch->send_initial_metadata) return 0; + if (batch->send_message) return 1; + if (batch->send_trailing_metadata) return 2; + if (batch->recv_initial_metadata) return 3; + if (batch->recv_message) return 4; + if (batch->recv_trailing_metadata) return 5; + GPR_UNREACHABLE_CODE(return (size_t)-1); +} + +// This is called via the call combiner, so access to calld is synchronized. +void BufferedCall::EnqueueBatch(grpc_transport_stream_op_batch* batch) { + const size_t idx = GetBatchIndex(batch); + if (GRPC_TRACE_FLAG_ENABLED_OBJ(*tracer_)) { + LOG(INFO) << "BufferedCall " << this << ": adding pending batch at index " + << idx; + } + grpc_transport_stream_op_batch*& pending = pending_batches_[idx]; + GRPC_CHECK_EQ(pending, nullptr); + pending = batch; +} + +// This is called via the call combiner, so access to calld is synchronized. +void BufferedCall::FailPendingBatchInCallCombiner(void* arg, + grpc_error_handle error) { + grpc_transport_stream_op_batch* batch = + static_cast(arg); + auto* call = static_cast(batch->handler_private.extra_arg); + // Note: This will release the call combiner. + grpc_transport_stream_op_batch_finish_with_failure(batch, error, + call->call_combiner_); +} + +// This is called via the call combiner, so access to calld is synchronized. +void BufferedCall::Fail( + grpc_error_handle error, + YieldCallCombinerPredicate yield_call_combiner_predicate) { + GRPC_CHECK(!error.ok()); + if (GRPC_TRACE_FLAG_ENABLED_OBJ(*tracer_)) { + size_t num_batches = 0; + for (size_t i = 0; i < GPR_ARRAY_SIZE(pending_batches_); ++i) { + if (pending_batches_[i] != nullptr) ++num_batches; + } + LOG(INFO) << "BufferedCall " << this << ": failing " << num_batches + << " pending batches: " << StatusToString(error); + } + CallCombinerClosureList closures; + for (size_t i = 0; i < GPR_ARRAY_SIZE(pending_batches_); ++i) { + grpc_transport_stream_op_batch*& batch = pending_batches_[i]; + if (batch != nullptr) { + batch->handler_private.extra_arg = this; + GRPC_CLOSURE_INIT(&batch->handler_private.closure, + FailPendingBatchInCallCombiner, batch, nullptr); + closures.Add(&batch->handler_private.closure, error, + "BufferedCall::Fail"); + batch = nullptr; + } + } + if (yield_call_combiner_predicate(closures)) { + closures.RunClosures(call_combiner_); + } else { + closures.RunClosuresWithoutYielding(call_combiner_); + } +} + +// This is called via the call combiner, so access to calld is synchronized. +void BufferedCall::ResumePendingBatchInCallCombiner( + void* arg, grpc_error_handle /*ignored*/) { + grpc_transport_stream_op_batch* batch = + static_cast(arg); + auto* call = static_cast(batch->handler_private.extra_arg); + // Note: This will release the call combiner. + call->start_batch_(batch); +} + +// This is called via the call combiner, so access to calld is synchronized. +void BufferedCall::Resume( + absl::AnyInvocable start_batch) { + if (GRPC_TRACE_FLAG_ENABLED_OBJ(*tracer_)) { + size_t num_batches = 0; + for (size_t i = 0; i < GPR_ARRAY_SIZE(pending_batches_); ++i) { + if (pending_batches_[i] != nullptr) ++num_batches; + } + LOG(INFO) << "BufferedCall " << this << ": starting " << num_batches + << " pending batches"; + } + start_batch_ = std::move(start_batch); + CallCombinerClosureList closures; + for (size_t i = 0; i < GPR_ARRAY_SIZE(pending_batches_); ++i) { + grpc_transport_stream_op_batch*& batch = pending_batches_[i]; + if (batch != nullptr) { + batch->handler_private.extra_arg = this; + GRPC_CLOSURE_INIT(&batch->handler_private.closure, + ResumePendingBatchInCallCombiner, batch, nullptr); + closures.Add(&batch->handler_private.closure, absl::OkStatus(), + "resuming pending batch from client channel call"); + batch = nullptr; + } + } + // Note: This will release the call combiner. + closures.RunClosures(call_combiner_); +} + +} // namespace grpc_core diff --git a/deps/grpc/src/core/client_channel/buffered_call.h b/deps/grpc/src/core/client_channel/buffered_call.h new file mode 100644 index 00000000000..395348d0c02 --- /dev/null +++ b/deps/grpc/src/core/client_channel/buffered_call.h @@ -0,0 +1,104 @@ +// +// Copyright 2015 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. +// + +#ifndef GRPC_SRC_CORE_CLIENT_CHANNEL_BUFFERED_CALL_H +#define GRPC_SRC_CORE_CLIENT_CHANNEL_BUFFERED_CALL_H + +#include "src/core/call/metadata_batch.h" +#include "src/core/lib/channel/channel_stack.h" +#include "src/core/lib/debug/trace.h" +#include "src/core/lib/iomgr/call_combiner.h" +#include "absl/functional/any_invocable.h" + +// Max number of batches that can be pending on a call at any given +// time. This includes one batch for each of the following ops: +// recv_initial_metadata +// send_initial_metadata +// recv_message +// send_message +// recv_trailing_metadata +// send_trailing_metadata +#define MAX_PENDING_BATCHES 6 + +namespace grpc_core { + +// Handles queuing of stream batches for a v1 call. +class BufferedCall { + public: + BufferedCall(CallCombiner* call_combiner, TraceFlag* tracer); + ~BufferedCall(); + + // Enqueues a batch. + // Must be called from within the call combiner. + void EnqueueBatch(grpc_transport_stream_op_batch* batch); + + // Resumes all queued batches by passing them to start_batch(). + // Must be called from within the call combiner. + void Resume( + absl::AnyInvocable start_batch); + + // A predicate type and some useful implementations for Fail(). + typedef bool (*YieldCallCombinerPredicate)( + const CallCombinerClosureList& closures); + static bool YieldCallCombiner(const CallCombinerClosureList& /*closures*/) { + return true; + } + static bool NoYieldCallCombiner(const CallCombinerClosureList& /*closures*/) { + return false; + } + static bool YieldCallCombinerIfPendingBatchesFound( + const CallCombinerClosureList& closures) { + return closures.size() > 0; + } + // Fails all queued batches. + // Must be called from within the call combiner. + // If yield_call_combiner_predicate returns true, assumes responsibility for + // yielding the call combiner. + void Fail(grpc_error_handle error, + YieldCallCombinerPredicate yield_call_combiner_predicate); + + grpc_metadata_batch* send_initial_metadata() const { + return pending_batches_[0] + ->payload->send_initial_metadata.send_initial_metadata; + } + + private: + // Returns the index into pending_batches_ to be used for batch. + static size_t GetBatchIndex(grpc_transport_stream_op_batch* batch); + + static void FailPendingBatchInCallCombiner(void* arg, + grpc_error_handle error); + static void ResumePendingBatchInCallCombiner(void* arg, + grpc_error_handle ignored); + + CallCombiner* const call_combiner_; + TraceFlag* tracer_; + + // Batches are added to this list when received from above. + // They are removed when we are done handling the batch (i.e., when + // either we have invoked all of the batch's callbacks or we have + // passed the batch down to the next call and are not intercepting any of + // its callbacks). + grpc_transport_stream_op_batch* pending_batches_[MAX_PENDING_BATCHES] = {}; + + // A function that starts a batch on the next call. Set by calling + // Resume(). + absl::AnyInvocable start_batch_; +}; + +} // namespace grpc_core + +#endif // GRPC_SRC_CORE_CLIENT_CHANNEL_BUFFERED_CALL_H diff --git a/deps/grpc/src/core/client_channel/client_channel.cc b/deps/grpc/src/core/client_channel/client_channel.cc index f1c79017fdd..67336025ed9 100644 --- a/deps/grpc/src/core/client_channel/client_channel.cc +++ b/deps/grpc/src/core/client_channel/client_channel.cc @@ -36,15 +36,6 @@ #include #include -#include "absl/cleanup/cleanup.h" -#include "absl/log/log.h" -#include "absl/status/status.h" -#include "absl/status/statusor.h" -#include "absl/strings/cord.h" -#include "absl/strings/numbers.h" -#include "absl/strings/str_cat.h" -#include "absl/strings/str_join.h" -#include "absl/strings/string_view.h" #include "src/core/call/call_spine.h" #include "src/core/call/client_call.h" #include "src/core/call/metadata_batch.h" @@ -94,6 +85,15 @@ #include "src/core/util/sync.h" #include "src/core/util/useful.h" #include "src/core/util/work_serializer.h" +#include "absl/cleanup/cleanup.h" +#include "absl/log/log.h" +#include "absl/status/status.h" +#include "absl/status/statusor.h" +#include "absl/strings/cord.h" +#include "absl/strings/numbers.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/str_join.h" +#include "absl/strings/string_view.h" namespace grpc_core { @@ -142,7 +142,8 @@ class ClientChannel::SubchannelWrapper : public SubchannelInterfaceWithCallDestination { public: SubchannelWrapper(WeakRefCountedPtr client_channel, - RefCountedPtr subchannel); + RefCountedPtr subchannel, + uint32_t max_connections_per_subchannel); ~SubchannelWrapper() override; void Orphaned() override; @@ -165,7 +166,6 @@ class ClientChannel::SubchannelWrapper ABSL_EXCLUSIVE_LOCKS_REQUIRED(*client_channel_->work_serializer_); void CancelDataWatcher(DataWatcherInterface* watcher) override ABSL_EXCLUSIVE_LOCKS_REQUIRED(*client_channel_->work_serializer_); - void ThrottleKeepaliveTime(int new_keepalive_time); std::string address() const override { return subchannel_->address(); } private: @@ -191,6 +191,7 @@ class ClientChannel::SubchannelWrapper WeakRefCountedPtr client_channel_; RefCountedPtr subchannel_; + const uint32_t max_connections_per_subchannel_; // Maps from the address of the watcher passed to us by the LB policy // to the address of the WrapperWatcher that we passed to the underlying // subchannel. This is needed so that when the LB policy calls @@ -242,6 +243,23 @@ class ClientChannel::SubchannelWrapper::WatcherWrapper }); } + void OnKeepaliveUpdate(Duration new_keepalive_time) override { + GRPC_TRACE_LOG(client_channel, INFO) + << "client_channel=" << subchannel_wrapper_->client_channel_.get() + << ": keepalive update for subchannel wrapper " + << subchannel_wrapper_.get() << "; hopping into work_serializer"; + auto self = RefAsSubclass(); + subchannel_wrapper_->client_channel_->work_serializer_->Run( + [self, new_keepalive_time]() ABSL_EXCLUSIVE_LOCKS_REQUIRED( + *self->subchannel_wrapper_->client_channel_->work_serializer_) { + self->ApplyKeepaliveThrottlingInWorkSerializer(new_keepalive_time); + }); + } + + uint32_t max_connections_per_subchannel() const override { + return subchannel_wrapper_->max_connections_per_subchannel_; + } + grpc_pollset_set* interested_parties() override { return nullptr; } private: @@ -257,32 +275,37 @@ class ClientChannel::SubchannelWrapper::WatcherWrapper << subchannel_wrapper_->subchannel_.get() << " watcher=" << watcher_.get() << " state=" << ConnectivityStateName(state) << " status=" << status; - auto keepalive_throttling = status.GetPayload(kKeepaliveThrottlingKey); - if (keepalive_throttling.has_value()) { - int new_keepalive_time = -1; - if (absl::SimpleAtoi(std::string(keepalive_throttling.value()), - &new_keepalive_time)) { - if (new_keepalive_time > - subchannel_wrapper_->client_channel_->keepalive_time_) { - subchannel_wrapper_->client_channel_->keepalive_time_ = - new_keepalive_time; - GRPC_TRACE_LOG(client_channel, INFO) - << "client_channel=" << subchannel_wrapper_->client_channel_.get() - << ": throttling keepalive time to " - << subchannel_wrapper_->client_channel_->keepalive_time_; - // Propagate the new keepalive time to all subchannels. This is so - // that new transports created by any subchannel (and not just the - // subchannel that received the GOAWAY), use the new keepalive time. - for (auto* subchannel_wrapper : - subchannel_wrapper_->client_channel_->subchannel_wrappers_) { - subchannel_wrapper->ThrottleKeepaliveTime(new_keepalive_time); + if (!IsTransportStateWatcherEnabled()) { + auto keepalive_throttling = status.GetPayload(kKeepaliveThrottlingKey); + if (keepalive_throttling.has_value()) { + int new_keepalive_time_ms = -1; + if (absl::SimpleAtoi(std::string(keepalive_throttling.value()), + &new_keepalive_time_ms)) { + Duration new_keepalive_time = + Duration::Milliseconds(new_keepalive_time_ms); + if (new_keepalive_time > + subchannel_wrapper_->client_channel_->keepalive_time_) { + subchannel_wrapper_->client_channel_->keepalive_time_ = + new_keepalive_time; + GRPC_TRACE_LOG(client_channel, INFO) + << "client_channel=" + << subchannel_wrapper_->client_channel_.get() + << ": throttling keepalive time to " + << subchannel_wrapper_->client_channel_->keepalive_time_; + // Propagate the new keepalive time to all subchannels. This is so + // that new transports created by any subchannel (and not just the + // subchannel that received the GOAWAY), use the new keepalive time. + for (auto& [subchannel, _] : + subchannel_wrapper_->client_channel_->subchannel_map_) { + subchannel->ThrottleKeepaliveTime(new_keepalive_time); + } } + } else { + LOG(ERROR) << "client_channel=" + << subchannel_wrapper_->client_channel_.get() + << ": Illegal keepalive throttling value " + << std::string(keepalive_throttling.value()); } - } else { - LOG(ERROR) << "client_channel=" - << subchannel_wrapper_->client_channel_.get() - << ": Illegal keepalive throttling value " - << std::string(keepalive_throttling.value()); } } // Propagate status only in state TF. @@ -294,6 +317,28 @@ class ClientChannel::SubchannelWrapper::WatcherWrapper state == GRPC_CHANNEL_TRANSIENT_FAILURE ? status : absl::OkStatus()); } + void ApplyKeepaliveThrottlingInWorkSerializer(Duration new_keepalive_time) + ABSL_EXCLUSIVE_LOCKS_REQUIRED( + *subchannel_wrapper_->client_channel_->work_serializer_) { + if (new_keepalive_time > + subchannel_wrapper_->client_channel_->keepalive_time_) { + subchannel_wrapper_->client_channel_->keepalive_time_ = + new_keepalive_time; + GRPC_TRACE_LOG(client_channel, INFO) + << "client_channel=" << subchannel_wrapper_->client_channel_.get() + << ": throttling keepalive time to " + << subchannel_wrapper_->client_channel_->keepalive_time_; + // Propagate the new keepalive time to all subchannels. This is so + // that new transports created by any subchannel (and not just the + // subchannel that received the GOAWAY), use the new keepalive time. + for (auto& [subchannel, _] : + subchannel_wrapper_->client_channel_->subchannel_map_) { + if (subchannel_wrapper_->subchannel_ == subchannel) continue; + subchannel->ThrottleKeepaliveTime(new_keepalive_time); + } + } + } + std::unique_ptr watcher_; WeakRefCountedPtr subchannel_wrapper_; @@ -301,34 +346,32 @@ class ClientChannel::SubchannelWrapper::WatcherWrapper ClientChannel::SubchannelWrapper::SubchannelWrapper( WeakRefCountedPtr client_channel, - RefCountedPtr subchannel) + RefCountedPtr subchannel, + uint32_t max_connections_per_subchannel) : SubchannelInterfaceWithCallDestination( GRPC_TRACE_FLAG_ENABLED(client_channel) ? "SubchannelWrapper" : nullptr), client_channel_(std::move(client_channel)), - subchannel_(std::move(subchannel)) { + subchannel_(std::move(subchannel)), + max_connections_per_subchannel_(max_connections_per_subchannel) { GRPC_TRACE_LOG(client_channel, INFO) << "client_channel=" << client_channel_.get() << ": creating subchannel wrapper " << this << " for subchannel " - << subchannel_.get(); + << subchannel_.get() + << ", max_connections_per_subchannel=" << max_connections_per_subchannel; #ifndef NDEBUG DCHECK(client_channel_->work_serializer_->RunningInWorkSerializer()); #endif - if (client_channel_->channelz_node_ != nullptr) { + auto& subchannel_wrappers = + client_channel_->subchannel_map_[subchannel_.get()]; + if (subchannel_wrappers.empty() && + client_channel_->channelz_node_ != nullptr) { auto* subchannel_node = subchannel_->channelz_node(); if (subchannel_node != nullptr) { - auto it = - client_channel_->subchannel_refcount_map_.find(subchannel_.get()); - if (it == client_channel_->subchannel_refcount_map_.end()) { - subchannel_node->AddParent(client_channel_->channelz_node_); - it = client_channel_->subchannel_refcount_map_ - .emplace(subchannel_.get(), 0) - .first; - } - ++it->second; + subchannel_node->AddParent(client_channel_->channelz_node_); } } - client_channel_->subchannel_wrappers_.insert(this); + subchannel_wrappers.insert(this); } ClientChannel::SubchannelWrapper::~SubchannelWrapper() { @@ -346,20 +389,20 @@ void ClientChannel::SubchannelWrapper::Orphaned() { client_channel_->work_serializer_->Run( [self]() ABSL_EXCLUSIVE_LOCKS_REQUIRED( *self->client_channel_->work_serializer_) { - self->client_channel_->subchannel_wrappers_.erase(self.get()); - if (self->client_channel_->channelz_node_ != nullptr) { - auto* subchannel_node = self->subchannel_->channelz_node(); - if (subchannel_node != nullptr) { - auto it = self->client_channel_->subchannel_refcount_map_.find( - self->subchannel_.get()); - CHECK(it != self->client_channel_->subchannel_refcount_map_.end()); - --it->second; - if (it->second == 0) { + auto it = self->client_channel_->subchannel_map_.find( + self->subchannel_.get()); + GRPC_CHECK(it != self->client_channel_->subchannel_map_.end()); + auto& subchannel_wrappers = it->second; + subchannel_wrappers.erase(self.get()); + if (subchannel_wrappers.empty()) { + if (self->client_channel_->channelz_node_ != nullptr) { + auto* subchannel_node = self->subchannel_->channelz_node(); + if (subchannel_node != nullptr) { subchannel_node->RemoveParent( self->client_channel_->channelz_node_); - self->client_channel_->subchannel_refcount_map_.erase(it); } } + self->client_channel_->subchannel_map_.erase(it); } if (IsSubchannelWrapperCleanupOnOrphanEnabled()) { // We need to make sure that the internal subchannel gets unreffed @@ -411,11 +454,6 @@ void ClientChannel::SubchannelWrapper::CancelDataWatcher( if (it != data_watchers_.end()) data_watchers_.erase(it); } -void ClientChannel::SubchannelWrapper::ThrottleKeepaliveTime( - int new_keepalive_time) { - subchannel_->ThrottleKeepaliveTime(new_keepalive_time); -} - // // ClientChannel::ClientChannelControlHelper // @@ -437,6 +475,17 @@ class ClientChannel::ClientChannelControlHelper ABSL_EXCLUSIVE_LOCKS_REQUIRED(*client_channel_->work_serializer_) { // If shutting down, do nothing. if (client_channel_->resolver_ == nullptr) return nullptr; + // Determine max_connections_per_subchannel. + const uint32_t cap = + args.GetInt(GRPC_ARG_MAX_CONNECTIONS_PER_SUBCHANNEL_CAP).value_or(10); + uint32_t max_connections_per_subchannel = + args.GetInt(GRPC_ARG_MAX_CONNECTIONS_PER_SUBCHANNEL) + .value_or( + per_address_args.GetInt(GRPC_ARG_MAX_CONNECTIONS_PER_SUBCHANNEL) + .value_or(1)); + max_connections_per_subchannel = + std::min(max_connections_per_subchannel, cap); + // Modify args for subchannel. ChannelArgs subchannel_args = Subchannel::MakeSubchannelArgs( args, per_address_args, client_channel_->subchannel_pool_, client_channel_->default_authority_); @@ -448,8 +497,8 @@ class ClientChannel::ClientChannelControlHelper // Make sure the subchannel has updated keepalive time. subchannel->ThrottleKeepaliveTime(client_channel_->keepalive_time_); // Create and return wrapper for the subchannel. - return MakeRefCounted(client_channel_, - std::move(subchannel)); + return MakeRefCounted( + client_channel_, std::move(subchannel), max_connections_per_subchannel); } void UpdateState( @@ -643,9 +692,7 @@ ClientChannel::ClientChannel( // Set initial keepalive time. auto keepalive_arg = channel_args_.GetInt(GRPC_ARG_KEEPALIVE_TIME_MS); if (keepalive_arg.has_value()) { - keepalive_time_ = Clamp(*keepalive_arg, 1, INT_MAX); - } else { - keepalive_time_ = -1; // unset + keepalive_time_ = Duration::Milliseconds(Clamp(*keepalive_arg, 1, INT_MAX)); } } @@ -1112,6 +1159,12 @@ void ClientChannel::OnResolverResultChangedLocked(Resolver::Result result) { static_cast( service_config->GetGlobalParsedConfig( service_config_parser_index_)); + // Set max_connections_per_subchannel from service config. + if (parsed_service_config->max_connections_per_subchannel() != 0) { + result.args = result.args.Set( + GRPC_ARG_MAX_CONNECTIONS_PER_SUBCHANNEL, + parsed_service_config->max_connections_per_subchannel()); + } // Choose LB policy config. RefCountedPtr lb_policy_config = ChooseLbPolicy(result, parsed_service_config); @@ -1287,7 +1340,7 @@ void ClientChannel::UpdateServiceConfigInDataPlaneLocked( if (enable_retries) { RetryInterceptor::UpdateBlackboard(*saved_service_config_, blackboard_.get(), new_blackboard.get()); - builder.Add(); + builder.Add(nullptr); } blackboard_ = std::move(new_blackboard); // Create call destination. @@ -1403,7 +1456,7 @@ absl::Status ClientChannel::ApplyServiceConfigToCall( const Timestamp per_method_deadline = Timestamp::FromCycleCounterRoundUp(call->start_time()) + method_params->timeout(); - call->UpdateDeadline(per_method_deadline); + call->UpdateDeadline(per_method_deadline).IgnoreError(); } // If the service config set wait_for_ready and the application // did not explicitly set it, use the value from the service config. diff --git a/deps/grpc/src/core/client_channel/client_channel.h b/deps/grpc/src/core/client_channel/client_channel.h index 8076a00f6c2..55e5f438c4a 100644 --- a/deps/grpc/src/core/client_channel/client_channel.h +++ b/deps/grpc/src/core/client_channel/client_channel.h @@ -19,9 +19,6 @@ #include -#include "absl/status/status.h" -#include "absl/status/statusor.h" -#include "absl/strings/string_view.h" #include "src/core/call/metadata.h" #include "src/core/client_channel/client_channel_factory.h" #include "src/core/client_channel/config_selector.h" @@ -34,6 +31,9 @@ #include "src/core/resolver/resolver.h" #include "src/core/service_config/service_config.h" #include "src/core/util/single_set_ptr.h" +#include "absl/status/status.h" +#include "absl/status/statusor.h" +#include "absl/strings/string_view.h" namespace grpc_core { @@ -222,15 +222,12 @@ class ClientChannel : public Channel { ABSL_GUARDED_BY(*work_serializer_); RefCountedPtr subchannel_pool_ ABSL_GUARDED_BY(*work_serializer_); - // The number of SubchannelWrapper instances referencing a given Subchannel. - std::map subchannel_refcount_map_ - ABSL_GUARDED_BY(*work_serializer_); - // The set of SubchannelWrappers that currently exist. - // No need to hold a ref, since the set is updated in the control-plane + // The set of SubchannelWrapper instances referencing a given Subchannel. + // No need to hold refs, since the map is updated in the control-plane // work_serializer when the SubchannelWrappers are created and destroyed. - absl::flat_hash_set subchannel_wrappers_ - ABSL_GUARDED_BY(*work_serializer_); - int keepalive_time_ ABSL_GUARDED_BY(*work_serializer_) = -1; + absl::flat_hash_map> + subchannel_map_ ABSL_GUARDED_BY(*work_serializer_); + Duration keepalive_time_ ABSL_GUARDED_BY(*work_serializer_); absl::Status disconnect_error_ ABSL_GUARDED_BY(*work_serializer_); // diff --git a/deps/grpc/src/core/client_channel/client_channel_factory.h b/deps/grpc/src/core/client_channel/client_channel_factory.h index 9e8ca146e0e..58e044ad115 100644 --- a/deps/grpc/src/core/client_channel/client_channel_factory.h +++ b/deps/grpc/src/core/client_channel/client_channel_factory.h @@ -19,11 +19,11 @@ #include -#include "absl/strings/string_view.h" #include "src/core/client_channel/subchannel.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/iomgr/resolved_address.h" #include "src/core/util/ref_counted_ptr.h" +#include "absl/strings/string_view.h" namespace grpc_core { diff --git a/deps/grpc/src/core/client_channel/client_channel_filter.cc b/deps/grpc/src/core/client_channel/client_channel_filter.cc index 6ec723bb99f..270dc734993 100644 --- a/deps/grpc/src/core/client_channel/client_channel_filter.cc +++ b/deps/grpc/src/core/client_channel/client_channel_filter.cc @@ -37,15 +37,6 @@ #include #include -#include "absl/cleanup/cleanup.h" -#include "absl/log/log.h" -#include "absl/status/status.h" -#include "absl/status/statusor.h" -#include "absl/strings/cord.h" -#include "absl/strings/numbers.h" -#include "absl/strings/str_cat.h" -#include "absl/strings/str_join.h" -#include "absl/strings/string_view.h" #include "src/core/call/metadata_batch.h" #include "src/core/call/status_util.h" #include "src/core/channelz/channel_trace.h" @@ -103,6 +94,15 @@ #include "src/core/util/unique_type_name.h" #include "src/core/util/useful.h" #include "src/core/util/work_serializer.h" +#include "absl/cleanup/cleanup.h" +#include "absl/log/log.h" +#include "absl/status/status.h" +#include "absl/status/statusor.h" +#include "absl/strings/cord.h" +#include "absl/strings/numbers.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/str_join.h" +#include "absl/strings/string_view.h" // // Client channel filter @@ -118,6 +118,15 @@ using internal::ClientChannelMethodParsedConfig; class ClientChannelFilter::CallData { public: + static grpc_error_handle Init(grpc_call_element* elem, + const grpc_call_element_args* args); + static void Destroy(grpc_call_element* elem, + const grpc_call_final_info* final_info, + grpc_closure* then_schedule_closure); + static void StartTransportStreamOpBatch( + grpc_call_element* elem, grpc_transport_stream_op_batch* batch); + static void SetPollent(grpc_call_element* elem, grpc_polling_entity* pollent); + // Removes the call from the channel's list of calls queued // for name resolution. void RemoveCallFromResolverQueuedCallsLocked() @@ -125,16 +134,21 @@ class ClientChannelFilter::CallData { // Called by the channel for each queued call when a new resolution // result becomes available. - virtual void RetryCheckResolutionLocked() - ABSL_EXCLUSIVE_LOCKS_REQUIRED(&ClientChannelFilter::resolution_mu_) = 0; + void RetryCheckResolutionLocked() + ABSL_EXCLUSIVE_LOCKS_REQUIRED(&ClientChannelFilter::resolution_mu_); + + private: + class ResolverQueuedCallCanceller; + + CallData(grpc_call_element* elem, const grpc_call_element_args& args); - RefCountedPtr dynamic_filters() const { - return dynamic_filters_; + ClientChannelFilter* chand() const { + return static_cast(elem_->channel_data); } - protected: - CallData() = default; - virtual ~CallData() = default; + grpc_metadata_batch* send_initial_metadata() { + return buffered_call_.send_initial_metadata(); + } // Checks whether a resolver result is available. The following // outcomes are possible: @@ -148,13 +162,6 @@ class ClientChannelFilter::CallData { // stored in the call context and an OK status will be returned. std::optional CheckResolution(bool was_queued); - private: - // Accessors for data stored in the subclass. - virtual ClientChannelFilter* chand() const = 0; - virtual Arena* arena() const = 0; - virtual grpc_polling_entity* pollent() = 0; - virtual grpc_metadata_batch* send_initial_metadata() = 0; - // Helper function for CheckResolution(). Returns true if the call // can continue (i.e., there is a valid resolution result, or there is // an invalid resolution result but the call is not wait_for_ready). @@ -166,10 +173,6 @@ class ClientChannelFilter::CallData { void AddCallToResolverQueuedCallsLocked() ABSL_EXCLUSIVE_LOCKS_REQUIRED(&ClientChannelFilter::resolution_mu_); - // Called when adding the call to the resolver queue. - virtual void OnAddToQueueLocked() - ABSL_EXCLUSIVE_LOCKS_REQUIRED(&ClientChannelFilter::resolution_mu_) {} - // Applies service config to the call. Must be invoked once we know // that the resolver has returned results to the channel. // If an error is returned, the error indicates the status with which @@ -179,90 +182,19 @@ class ClientChannelFilter::CallData { // Called to reset the deadline based on the service config obtained // from the resolver. - virtual void ResetDeadline(Duration timeout) = 0; - - RefCountedPtr dynamic_filters_; -}; - -class ClientChannelFilter::FilterBasedCallData final - : public ClientChannelFilter::CallData { - public: - static grpc_error_handle Init(grpc_call_element* elem, - const grpc_call_element_args* args); - static void Destroy(grpc_call_element* elem, - const grpc_call_final_info* final_info, - grpc_closure* then_schedule_closure); - static void StartTransportStreamOpBatch( - grpc_call_element* elem, grpc_transport_stream_op_batch* batch); - static void SetPollent(grpc_call_element* elem, grpc_polling_entity* pollent); - - private: - class ResolverQueuedCallCanceller; - - FilterBasedCallData(grpc_call_element* elem, - const grpc_call_element_args& args); - ~FilterBasedCallData() override; - - grpc_call_element* elem() const { return elem_; } - grpc_call_stack* owning_call() const { return owning_call_; } - CallCombiner* call_combiner() const { return call_combiner_; } - - ClientChannelFilter* chand() const override { - return static_cast(elem()->channel_data); - } - Arena* arena() const override { return arena_; } - grpc_polling_entity* pollent() override { return pollent_; } - grpc_metadata_batch* send_initial_metadata() override { - return pending_batches_[0] - ->payload->send_initial_metadata.send_initial_metadata; - } - - // Returns the index into pending_batches_ to be used for batch. - static size_t GetBatchIndex(grpc_transport_stream_op_batch* batch); - void PendingBatchesAdd(grpc_transport_stream_op_batch* batch); - static void FailPendingBatchInCallCombiner(void* arg, - grpc_error_handle error); - // A predicate type and some useful implementations for PendingBatchesFail(). - typedef bool (*YieldCallCombinerPredicate)( - const CallCombinerClosureList& closures); - static bool YieldCallCombiner(const CallCombinerClosureList& /*closures*/) { - return true; - } - static bool NoYieldCallCombiner(const CallCombinerClosureList& /*closures*/) { - return false; + void ResetDeadline(Duration timeout) { + const Timestamp per_method_deadline = + Timestamp::FromCycleCounterRoundUp(call_start_time_) + timeout; + arena_->GetContext() + ->UpdateDeadline(per_method_deadline) + .IgnoreError(); } - static bool YieldCallCombinerIfPendingBatchesFound( - const CallCombinerClosureList& closures) { - return closures.size() > 0; - } - // Fails all pending batches. - // If yield_call_combiner_predicate returns true, assumes responsibility for - // yielding the call combiner. - void PendingBatchesFail( - grpc_error_handle error, - YieldCallCombinerPredicate yield_call_combiner_predicate); - static void ResumePendingBatchInCallCombiner(void* arg, - grpc_error_handle ignored); - // Resumes all pending batches on dynamic_call_. - void PendingBatchesResume(); // Called to check for a resolution result, both when the call is // initially started and when it is queued and the channel gets a new // resolution result. void TryCheckResolution(bool was_queued); - void OnAddToQueueLocked() override - ABSL_EXCLUSIVE_LOCKS_REQUIRED(&ClientChannelFilter::resolution_mu_); - - void RetryCheckResolutionLocked() override - ABSL_EXCLUSIVE_LOCKS_REQUIRED(&ClientChannelFilter::resolution_mu_); - - void ResetDeadline(Duration timeout) override { - const Timestamp per_method_deadline = - Timestamp::FromCycleCounterRoundUp(call_start_time_) + timeout; - arena_->GetContext()->UpdateDeadline(per_method_deadline); - } - void CreateDynamicCall(); static void RecvTrailingMetadataReadyForConfigSelectorCommitCallback( @@ -285,14 +217,10 @@ class ClientChannelFilter::FilterBasedCallData final grpc_closure* original_recv_trailing_metadata_ready_ = nullptr; grpc_closure recv_trailing_metadata_ready_; + RefCountedPtr dynamic_filters_; RefCountedPtr dynamic_call_; - // Batches are added to this list when received from above. - // They are removed when we are done handling the batch (i.e., when - // either we have invoked all of the batch's callbacks or we have - // passed the batch down to the LB call and are not intercepting any of - // its callbacks). - grpc_transport_stream_op_batch* pending_batches_[MAX_PENDING_BATCHES] = {}; + BufferedCall buffered_call_; // Set when we get a cancel_stream op. grpc_error_handle cancel_error_; @@ -303,12 +231,12 @@ class ClientChannelFilter::FilterBasedCallData final // const grpc_channel_filter ClientChannelFilter::kFilter = { - ClientChannelFilter::FilterBasedCallData::StartTransportStreamOpBatch, + ClientChannelFilter::CallData::StartTransportStreamOpBatch, ClientChannelFilter::StartTransportOp, - sizeof(ClientChannelFilter::FilterBasedCallData), - ClientChannelFilter::FilterBasedCallData::Init, - ClientChannelFilter::FilterBasedCallData::SetPollent, - ClientChannelFilter::FilterBasedCallData::Destroy, + sizeof(ClientChannelFilter::CallData), + ClientChannelFilter::CallData::Init, + ClientChannelFilter::CallData::SetPollent, + ClientChannelFilter::CallData::Destroy, sizeof(ClientChannelFilter), ClientChannelFilter::Init, grpc_channel_stack_no_post_init, @@ -421,7 +349,7 @@ class DynamicTerminationFilter::CallData final { grpc_call_stack* owning_call_; CallCombiner* call_combiner_; - OrphanablePtr lb_call_; + OrphanablePtr lb_call_; }; const grpc_channel_filter DynamicTerminationFilter::kFilterVtable = { @@ -483,32 +411,31 @@ class ClientChannelFilter::SubchannelWrapper final : public SubchannelInterface { public: SubchannelWrapper(ClientChannelFilter* chand, - RefCountedPtr subchannel) + RefCountedPtr subchannel, + uint32_t max_connections_per_subchannel) : SubchannelInterface(GRPC_TRACE_FLAG_ENABLED(client_channel) ? "SubchannelWrapper" : nullptr), chand_(chand), - subchannel_(std::move(subchannel)) { + subchannel_(std::move(subchannel)), + max_connections_per_subchannel_(max_connections_per_subchannel) { GRPC_TRACE_LOG(client_channel, INFO) << "chand=" << chand << ": creating subchannel wrapper " << this - << " for subchannel " << subchannel_.get(); + << " for subchannel " << subchannel_.get() + << ", max_connections_per_subchannel=" + << max_connections_per_subchannel; GRPC_CHANNEL_STACK_REF(chand_->owning_stack_, "SubchannelWrapper"); #ifndef NDEBUG GRPC_DCHECK(chand_->work_serializer_->RunningInWorkSerializer()); #endif - if (chand_->channelz_node_ != nullptr) { + auto& subchannel_wrappers = chand_->subchannel_map_[subchannel_.get()]; + if (subchannel_wrappers.empty() && chand_->channelz_node_ != nullptr) { auto* subchannel_node = subchannel_->channelz_node(); if (subchannel_node != nullptr) { - auto it = chand_->subchannel_refcount_map_.find(subchannel_.get()); - if (it == chand_->subchannel_refcount_map_.end()) { - subchannel_node->AddParent(chand_->channelz_node_); - it = chand_->subchannel_refcount_map_.emplace(subchannel_.get(), 0) - .first; - } - ++it->second; + subchannel_node->AddParent(chand_->channelz_node_); } } - chand_->subchannel_wrappers_.insert(this); + subchannel_wrappers.insert(this); } ~SubchannelWrapper() override { @@ -523,37 +450,37 @@ class ClientChannelFilter::SubchannelWrapper final // WorkSerializer. // Ref held by callback. WeakRef(DEBUG_LOCATION, "subchannel map cleanup").release(); - chand_->work_serializer_->Run([this]() ABSL_EXCLUSIVE_LOCKS_REQUIRED( - *chand_->work_serializer_) { - chand_->subchannel_wrappers_.erase(this); - if (chand_->channelz_node_ != nullptr) { - auto* subchannel_node = subchannel_->channelz_node(); - if (subchannel_node != nullptr) { - auto it = chand_->subchannel_refcount_map_.find(subchannel_.get()); - GRPC_CHECK(it != chand_->subchannel_refcount_map_.end()); - --it->second; - if (it->second == 0) { - subchannel_node->RemoveParent(chand_->channelz_node_); - chand_->subchannel_refcount_map_.erase(it); + chand_->work_serializer_->Run( + [this]() ABSL_EXCLUSIVE_LOCKS_REQUIRED(*chand_->work_serializer_) { + auto it = chand_->subchannel_map_.find(subchannel_.get()); + GRPC_CHECK(it != chand_->subchannel_map_.end()); + auto& subchannel_wrappers = it->second; + subchannel_wrappers.erase(this); + if (subchannel_wrappers.empty()) { + if (chand_->channelz_node_ != nullptr) { + auto* subchannel_node = subchannel_->channelz_node(); + if (subchannel_node != nullptr) { + subchannel_node->RemoveParent(chand_->channelz_node_); + } + } + chand_->subchannel_map_.erase(it); } - } - } - if (IsSubchannelWrapperCleanupOnOrphanEnabled()) { - // We need to make sure that the internal subchannel gets unreffed - // inside of the WorkSerializer, so that updates to the local - // subchannel pool are properly synchronized. To that end, we - // drop our ref to the internal subchannel here. We also cancel - // any watchers that were not properly cancelled, in case any of - // them are holding a ref to the internal subchannel. - for (const auto& [_, watcher] : watcher_map_) { - subchannel_->CancelConnectivityStateWatch(watcher); - } - watcher_map_.clear(); - data_watchers_.clear(); - subchannel_.reset(); - } - WeakUnref(DEBUG_LOCATION, "subchannel map cleanup"); - }); + if (IsSubchannelWrapperCleanupOnOrphanEnabled()) { + // We need to make sure that the internal subchannel gets unreffed + // inside of the WorkSerializer, so that updates to the local + // subchannel pool are properly synchronized. To that end, we + // drop our ref to the internal subchannel here. We also cancel + // any watchers that were not properly cancelled, in case any of + // them are holding a ref to the internal subchannel. + for (const auto& [_, watcher] : watcher_map_) { + subchannel_->CancelConnectivityStateWatch(watcher); + } + watcher_map_.clear(); + data_watchers_.clear(); + subchannel_.reset(); + } + WeakUnref(DEBUG_LOCATION, "subchannel map cleanup"); + }); } void WatchConnectivityState( @@ -598,10 +525,6 @@ class ClientChannelFilter::SubchannelWrapper final if (it != data_watchers_.end()) data_watchers_.erase(it); } - void ThrottleKeepaliveTime(int new_keepalive_time) { - subchannel_->ThrottleKeepaliveTime(new_keepalive_time); - } - std::string address() const override { return subchannel_->address(); } private: @@ -644,6 +567,23 @@ class ClientChannelFilter::SubchannelWrapper final }); } + void OnKeepaliveUpdate(Duration new_keepalive_time) override { + GRPC_TRACE_LOG(client_channel, INFO) + << "chand=" << parent_->chand_ + << ": keepalive update for subchannel wrapper " << parent_.get() + << "hopping into work_serializer"; + auto self = RefAsSubclass(); + parent_->chand_->work_serializer_->Run( + [self, new_keepalive_time]() ABSL_EXCLUSIVE_LOCKS_REQUIRED( + *self->parent_->chand_->work_serializer_) { + self->ApplyKeepaliveThrottlingInWorkSerializer(new_keepalive_time); + }); + } + + uint32_t max_connections_per_subchannel() const override { + return parent_->max_connections_per_subchannel_; + } + grpc_pollset_set* interested_parties() override { return watcher_->interested_parties(); } @@ -659,29 +599,33 @@ class ClientChannelFilter::SubchannelWrapper final << parent_.get() << " subchannel " << parent_->subchannel_.get() << " watcher=" << watcher_.get() << " state=" << ConnectivityStateName(state) << " status=" << status; - auto keepalive_throttling = status.GetPayload(kKeepaliveThrottlingKey); - if (keepalive_throttling.has_value()) { - int new_keepalive_time = -1; - if (absl::SimpleAtoi(std::string(keepalive_throttling.value()), - &new_keepalive_time)) { - if (new_keepalive_time > parent_->chand_->keepalive_time_) { - parent_->chand_->keepalive_time_ = new_keepalive_time; - GRPC_TRACE_LOG(client_channel, INFO) - << "chand=" << parent_->chand_ - << ": throttling keepalive time to " - << parent_->chand_->keepalive_time_; - // Propagate the new keepalive time to all subchannels. This is so - // that new transports created by any subchannel (and not just the - // subchannel that received the GOAWAY), use the new keepalive time. - for (auto* subchannel_wrapper : - parent_->chand_->subchannel_wrappers_) { - subchannel_wrapper->ThrottleKeepaliveTime(new_keepalive_time); + if (!IsTransportStateWatcherEnabled()) { + auto keepalive_throttling = status.GetPayload(kKeepaliveThrottlingKey); + if (keepalive_throttling.has_value()) { + int new_keepalive_time_ms = -1; + if (absl::SimpleAtoi(std::string(keepalive_throttling.value()), + &new_keepalive_time_ms)) { + Duration new_keepalive_time = + Duration::Milliseconds(new_keepalive_time_ms); + if (new_keepalive_time > parent_->chand_->keepalive_time_) { + parent_->chand_->keepalive_time_ = new_keepalive_time; + GRPC_TRACE_LOG(client_channel, INFO) + << "chand=" << parent_->chand_ + << ": throttling keepalive time to " + << parent_->chand_->keepalive_time_; + // Propagate the new keepalive time to all subchannels. This is + // so that new transports created by any subchannel (and not + // just the subchannel that received the GOAWAY), use the new + // keepalive time. + for (auto& [subchannel, _] : parent_->chand_->subchannel_map_) { + subchannel->ThrottleKeepaliveTime(new_keepalive_time); + } } + } else { + LOG(ERROR) << "chand=" << parent_->chand_ + << ": Illegal keepalive throttling value " + << std::string(keepalive_throttling.value()); } - } else { - LOG(ERROR) << "chand=" << parent_->chand_ - << ": Illegal keepalive throttling value " - << std::string(keepalive_throttling.value()); } } // Propagate status only in state TF. @@ -693,6 +637,23 @@ class ClientChannelFilter::SubchannelWrapper final state == GRPC_CHANNEL_TRANSIENT_FAILURE ? status : absl::OkStatus()); } + void ApplyKeepaliveThrottlingInWorkSerializer(Duration new_keepalive_time) + ABSL_EXCLUSIVE_LOCKS_REQUIRED(*parent_->chand_->work_serializer_) { + if (new_keepalive_time > parent_->chand_->keepalive_time_) { + parent_->chand_->keepalive_time_ = new_keepalive_time; + GRPC_TRACE_LOG(client_channel, INFO) + << "chand=" << parent_->chand_ << ": throttling keepalive time to " + << parent_->chand_->keepalive_time_; + // Propagate the new keepalive time to all subchannels. This is so + // that new transports created by any subchannel (and not just the + // subchannel that received the GOAWAY), use the new keepalive time. + for (auto& [subchannel, _] : parent_->chand_->subchannel_map_) { + if (parent_->subchannel_ == subchannel) continue; + subchannel->ThrottleKeepaliveTime(new_keepalive_time); + } + } + } + std::unique_ptr watcher_; WeakRefCountedPtr parent_; @@ -718,6 +679,7 @@ class ClientChannelFilter::SubchannelWrapper final ClientChannelFilter* chand_; RefCountedPtr subchannel_; + const uint32_t max_connections_per_subchannel_; // Maps from the address of the watcher passed to us by the LB policy // to the address of the WrapperWatcher that we passed to the underlying // subchannel. This is needed so that when the LB policy calls @@ -929,6 +891,17 @@ class ClientChannelFilter::ClientChannelControlHelper final const ChannelArgs& args) override ABSL_EXCLUSIVE_LOCKS_REQUIRED(*chand_->work_serializer_) { if (chand_->resolver_ == nullptr) return nullptr; // Shutting down. + // Determine max_connections_per_subchannel. + const uint32_t cap = + args.GetInt(GRPC_ARG_MAX_CONNECTIONS_PER_SUBCHANNEL_CAP).value_or(10); + uint32_t max_connections_per_subchannel = + args.GetInt(GRPC_ARG_MAX_CONNECTIONS_PER_SUBCHANNEL) + .value_or( + per_address_args.GetInt(GRPC_ARG_MAX_CONNECTIONS_PER_SUBCHANNEL) + .value_or(1)); + max_connections_per_subchannel = + std::min(max_connections_per_subchannel, cap); + // Modify args for subchannel. ChannelArgs subchannel_args = Subchannel::MakeSubchannelArgs( args, per_address_args, chand_->subchannel_pool_, chand_->default_authority_); @@ -940,7 +913,8 @@ class ClientChannelFilter::ClientChannelControlHelper final // Make sure the subchannel has updated keepalive time. subchannel->ThrottleKeepaliveTime(chand_->keepalive_time_); // Create and return wrapper for the subchannel. - return MakeRefCounted(chand_, std::move(subchannel)); + return MakeRefCounted(chand_, std::move(subchannel), + max_connections_per_subchannel); } void UpdateState(grpc_connectivity_state state, const absl::Status& status, @@ -1098,9 +1072,7 @@ ClientChannelFilter::ClientChannelFilter(grpc_channel_element_args* args, // Set initial keepalive time. auto keepalive_arg = channel_args_.GetInt(GRPC_ARG_KEEPALIVE_TIME_MS); if (keepalive_arg.has_value()) { - keepalive_time_ = Clamp(*keepalive_arg, 1, INT_MAX); - } else { - keepalive_time_ = -1; // unset + keepalive_time_ = Duration::Milliseconds(Clamp(*keepalive_arg, 1, INT_MAX)); } // Set default authority. std::optional default_authority = @@ -1125,16 +1097,15 @@ ClientChannelFilter::~ClientChannelFilter() { grpc_pollset_set_destroy(interested_parties_); } -OrphanablePtr +OrphanablePtr ClientChannelFilter::CreateLoadBalancedCall( const grpc_call_element_args& args, grpc_polling_entity* pollent, grpc_closure* on_call_destruction_complete, absl::AnyInvocable on_commit, bool is_transparent_retry) { promise_detail::Context arena_ctx(args.arena); - return OrphanablePtr( - args.arena->New( - this, args, pollent, on_call_destruction_complete, - std::move(on_commit), is_transparent_retry)); + return OrphanablePtr(args.arena->New( + this, args, pollent, on_call_destruction_complete, std::move(on_commit), + is_transparent_retry)); } void ClientChannelFilter::ReprocessQueuedResolverCalls() { @@ -1289,6 +1260,12 @@ void ClientChannelFilter::OnResolverResultChangedLocked( static_cast( service_config->GetGlobalParsedConfig( service_config_parser_index_)); + // Set max_connections_per_subchannel from service config. + if (parsed_service_config->max_connections_per_subchannel() != 0) { + result.args = result.args.Set( + GRPC_ARG_MAX_CONNECTIONS_PER_SUBCHANNEL, + parsed_service_config->max_connections_per_subchannel()); + } // Choose LB policy config. RefCountedPtr lb_policy_config = ChooseLbPolicy(result, parsed_service_config); @@ -1781,6 +1758,52 @@ void ClientChannelFilter::RemoveConnectivityWatcher( new ConnectivityWatcherRemover(this, watcher); } +// +// ClientChannelFilter::CallData::ResolverQueuedCallCanceller +// + +// A class to handle the call combiner cancellation callback for a +// queued pick. +class ClientChannelFilter::CallData::ResolverQueuedCallCanceller final { + public: + explicit ResolverQueuedCallCanceller(CallData* calld) : calld_(calld) { + GRPC_CALL_STACK_REF(calld->owning_call_, "ResolverQueuedCallCanceller"); + GRPC_CLOSURE_INIT(&closure_, &CancelLocked, this, + grpc_schedule_on_exec_ctx); + calld->call_combiner_->SetNotifyOnCancel(&closure_); + } + + private: + static void CancelLocked(void* arg, grpc_error_handle error) { + auto* self = static_cast(arg); + auto* calld = self->calld_; + auto* chand = calld->chand(); + { + MutexLock lock(&chand->resolution_mu_); + GRPC_TRACE_LOG(client_channel_call, INFO) + << "chand=" << chand << " calld=" << calld + << ": cancelling resolver queued pick: " + "error=" + << StatusToString(error) << " self=" << self + << " calld->resolver_pick_canceller=" + << calld->resolver_call_canceller_; + if (calld->resolver_call_canceller_ == self && !error.ok()) { + // Remove pick from list of queued picks. + calld->RemoveCallFromResolverQueuedCallsLocked(); + chand->resolver_queued_calls_.erase(calld); + // Fail pending batches on the call. + calld->buffered_call_.Fail( + error, BufferedCall::YieldCallCombinerIfPendingBatchesFound); + } + } + GRPC_CALL_STACK_UNREF(calld->owning_call_, "ResolvingQueuedCallCanceller"); + delete self; + } + + CallData* calld_; + grpc_closure closure_; +}; + // // CallData implementation // @@ -1790,7 +1813,7 @@ void ClientChannelFilter::CallData::RemoveCallFromResolverQueuedCallsLocked() { << "chand=" << chand() << " calld=" << this << ": removing from resolver queued picks list"; // Remove call's pollent from channel's interested_parties. - grpc_polling_entity_del_from_pollset_set(pollent(), + grpc_polling_entity_del_from_pollset_set(pollent_, chand()->interested_parties_); // Note: There's no need to actually remove the call from the queue // here, because that will be done in @@ -1802,14 +1825,15 @@ void ClientChannelFilter::CallData::AddCallToResolverQueuedCallsLocked() { GRPC_TRACE_LOG(client_channel_call, INFO) << "chand=" << chand() << " calld=" << this << ": adding to resolver queued picks list; pollent=" - << grpc_polling_entity_string(pollent()); + << grpc_polling_entity_string(pollent_); // Add call's pollent to channel's interested_parties, so that I/O // can be done under the call's CQ. - grpc_polling_entity_add_to_pollset_set(pollent(), + grpc_polling_entity_add_to_pollset_set(pollent_, chand()->interested_parties_); // Add to queue. chand()->resolver_queued_calls_.insert(this); - OnAddToQueueLocked(); + // Register call combiner cancellation callback. + resolver_call_canceller_ = new ResolverQueuedCallCanceller(this); } grpc_error_handle ClientChannelFilter::CallData::ApplyServiceConfigToCallLocked( @@ -1824,12 +1848,12 @@ grpc_error_handle ClientChannelFilter::CallData::ApplyServiceConfigToCallLocked( // itself in the call context, so that it can be accessed by filters // below us in the stack, and it will be cleaned up when the call ends. auto* service_config_call_data = - arena()->New(arena()); + arena_->New(arena_); // Use the ConfigSelector to determine the config for the call. absl::Status call_config_status = (*config_selector) ->GetCallConfig( - {send_initial_metadata(), arena(), service_config_call_data}); + {send_initial_metadata(), arena_, service_config_call_data}); if (!call_config_status.ok()) { return absl_status_to_grpc_error( MaybeRewriteIllegalStatusCode(call_config_status, "ConfigSelector")); @@ -1880,7 +1904,7 @@ std::optional ClientChannelFilter::CallData::CheckResolution( } // If the call was queued, add trace annotation. if (was_queued) { - auto* call_tracer = arena()->GetContext(); + auto* call_tracer = arena_->GetContext(); if (call_tracer != nullptr) { call_tracer->RecordAnnotation("Delayed name resolution complete."); } @@ -1918,42 +1942,32 @@ bool ClientChannelFilter::CallData::CheckResolutionLocked( return true; } -// -// FilterBasedCallData implementation -// - -ClientChannelFilter::FilterBasedCallData::FilterBasedCallData( - grpc_call_element* elem, const grpc_call_element_args& args) +ClientChannelFilter::CallData::CallData(grpc_call_element* elem, + const grpc_call_element_args& args) : call_start_time_(args.start_time), deadline_(args.deadline), arena_(args.arena), elem_(elem), owning_call_(args.call_stack), - call_combiner_(args.call_combiner) { + call_combiner_(args.call_combiner), + buffered_call_(call_combiner_, &client_channel_call_trace) { GRPC_TRACE_LOG(client_channel_call, INFO) << "chand=" << chand() << " calld=" << this << ": created call"; } -ClientChannelFilter::FilterBasedCallData::~FilterBasedCallData() { - // Make sure there are no remaining pending batches. - for (size_t i = 0; i < GPR_ARRAY_SIZE(pending_batches_); ++i) { - GRPC_CHECK_EQ(pending_batches_[i], nullptr); - } -} - -grpc_error_handle ClientChannelFilter::FilterBasedCallData::Init( +grpc_error_handle ClientChannelFilter::CallData::Init( grpc_call_element* elem, const grpc_call_element_args* args) { - new (elem->call_data) FilterBasedCallData(elem, *args); + new (elem->call_data) CallData(elem, *args); return absl::OkStatus(); } -void ClientChannelFilter::FilterBasedCallData::Destroy( +void ClientChannelFilter::CallData::Destroy( grpc_call_element* elem, const grpc_call_final_info* /*final_info*/, grpc_closure* then_schedule_closure) { - auto* calld = static_cast(elem->call_data); + auto* calld = static_cast(elem->call_data); RefCountedPtr dynamic_call = std::move(calld->dynamic_call_); - calld->~FilterBasedCallData(); + calld->~CallData(); if (GPR_LIKELY(dynamic_call != nullptr)) { dynamic_call->SetAfterCallStackDestroy(then_schedule_closure); } else { @@ -1962,9 +1976,9 @@ void ClientChannelFilter::FilterBasedCallData::Destroy( } } -void ClientChannelFilter::FilterBasedCallData::StartTransportStreamOpBatch( +void ClientChannelFilter::CallData::StartTransportStreamOpBatch( grpc_call_element* elem, grpc_transport_stream_op_batch* batch) { - auto* calld = static_cast(elem->call_data); + auto* calld = static_cast(elem->call_data); auto* chand = static_cast(elem->channel_data); if (GRPC_TRACE_FLAG_ENABLED(client_channel_call) && !GRPC_TRACE_FLAG_ENABLED(channel)) { @@ -2003,7 +2017,7 @@ void ClientChannelFilter::FilterBasedCallData::StartTransportStreamOpBatch( << StatusToString(calld->cancel_error_); // Note: This will release the call combiner. grpc_transport_stream_op_batch_finish_with_failure( - batch, calld->cancel_error_, calld->call_combiner()); + batch, calld->cancel_error_, calld->call_combiner_); return; } // Handle cancellation. @@ -2018,14 +2032,15 @@ void ClientChannelFilter::FilterBasedCallData::StartTransportStreamOpBatch( << "chand=" << chand << " calld=" << calld << ": recording cancel_error=" << StatusToString(calld->cancel_error_); // Fail all pending batches. - calld->PendingBatchesFail(calld->cancel_error_, NoYieldCallCombiner); + calld->buffered_call_.Fail(calld->cancel_error_, + BufferedCall::NoYieldCallCombiner); // Note: This will release the call combiner. grpc_transport_stream_op_batch_finish_with_failure( - batch, calld->cancel_error_, calld->call_combiner()); + batch, calld->cancel_error_, calld->call_combiner_); return; } // Add the batch to the pending list. - calld->PendingBatchesAdd(batch); + calld->buffered_call_.EnqueueBatch(batch); // For batches containing a send_initial_metadata op, acquire the // channel's resolution mutex to apply the service config to the call, // after which we will create a dynamic call. @@ -2053,188 +2068,29 @@ void ClientChannelFilter::FilterBasedCallData::StartTransportStreamOpBatch( GRPC_TRACE_LOG(client_channel_call, INFO) << "chand=" << chand << " calld=" << calld << ": saved batch, yielding call combiner"; - GRPC_CALL_COMBINER_STOP(calld->call_combiner(), + GRPC_CALL_COMBINER_STOP(calld->call_combiner_, "batch does not include send_initial_metadata"); } } -void ClientChannelFilter::FilterBasedCallData::SetPollent( - grpc_call_element* elem, grpc_polling_entity* pollent) { - auto* calld = static_cast(elem->call_data); +void ClientChannelFilter::CallData::SetPollent(grpc_call_element* elem, + grpc_polling_entity* pollent) { + auto* calld = static_cast(elem->call_data); calld->pollent_ = pollent; } -size_t ClientChannelFilter::FilterBasedCallData::GetBatchIndex( - grpc_transport_stream_op_batch* batch) { - // Note: It is important the send_initial_metadata be the first entry - // here, since the code in CheckResolution() assumes it will be. - if (batch->send_initial_metadata) return 0; - if (batch->send_message) return 1; - if (batch->send_trailing_metadata) return 2; - if (batch->recv_initial_metadata) return 3; - if (batch->recv_message) return 4; - if (batch->recv_trailing_metadata) return 5; - GPR_UNREACHABLE_CODE(return (size_t)-1); -} - -// This is called via the call combiner, so access to calld is synchronized. -void ClientChannelFilter::FilterBasedCallData::PendingBatchesAdd( - grpc_transport_stream_op_batch* batch) { - const size_t idx = GetBatchIndex(batch); - GRPC_TRACE_LOG(client_channel_call, INFO) - << "chand=" << chand() << " calld=" << this - << ": adding pending batch at index " << idx; - grpc_transport_stream_op_batch*& pending = pending_batches_[idx]; - GRPC_CHECK_EQ(pending, nullptr); - pending = batch; -} - -// This is called via the call combiner, so access to calld is synchronized. -void ClientChannelFilter::FilterBasedCallData::FailPendingBatchInCallCombiner( - void* arg, grpc_error_handle error) { - grpc_transport_stream_op_batch* batch = - static_cast(arg); - auto* calld = - static_cast(batch->handler_private.extra_arg); - // Note: This will release the call combiner. - grpc_transport_stream_op_batch_finish_with_failure(batch, error, - calld->call_combiner()); -} - -// This is called via the call combiner, so access to calld is synchronized. -void ClientChannelFilter::FilterBasedCallData::PendingBatchesFail( - grpc_error_handle error, - YieldCallCombinerPredicate yield_call_combiner_predicate) { - GRPC_CHECK(!error.ok()); - if (GRPC_TRACE_FLAG_ENABLED(client_channel_call)) { - size_t num_batches = 0; - for (size_t i = 0; i < GPR_ARRAY_SIZE(pending_batches_); ++i) { - if (pending_batches_[i] != nullptr) ++num_batches; - } - LOG(INFO) << "chand=" << chand() << " calld=" << this << ": failing " - << num_batches << " pending batches: " << StatusToString(error); - } - CallCombinerClosureList closures; - for (size_t i = 0; i < GPR_ARRAY_SIZE(pending_batches_); ++i) { - grpc_transport_stream_op_batch*& batch = pending_batches_[i]; - if (batch != nullptr) { - batch->handler_private.extra_arg = this; - GRPC_CLOSURE_INIT(&batch->handler_private.closure, - FailPendingBatchInCallCombiner, batch, - grpc_schedule_on_exec_ctx); - closures.Add(&batch->handler_private.closure, error, - "PendingBatchesFail"); - batch = nullptr; - } - } - if (yield_call_combiner_predicate(closures)) { - closures.RunClosures(call_combiner()); - } else { - closures.RunClosuresWithoutYielding(call_combiner()); - } -} - -// This is called via the call combiner, so access to calld is synchronized. -void ClientChannelFilter::FilterBasedCallData::ResumePendingBatchInCallCombiner( - void* arg, grpc_error_handle /*ignored*/) { - grpc_transport_stream_op_batch* batch = - static_cast(arg); - auto* calld = - static_cast(batch->handler_private.extra_arg); - // Note: This will release the call combiner. - calld->dynamic_call_->StartTransportStreamOpBatch(batch); -} - -// This is called via the call combiner, so access to calld is synchronized. -void ClientChannelFilter::FilterBasedCallData::PendingBatchesResume() { - // Retries not enabled; send down batches as-is. - if (GRPC_TRACE_FLAG_ENABLED(client_channel_call)) { - size_t num_batches = 0; - for (size_t i = 0; i < GPR_ARRAY_SIZE(pending_batches_); ++i) { - if (pending_batches_[i] != nullptr) ++num_batches; - } - LOG(INFO) << "chand=" << chand() << " calld=" << this << ": starting " - << num_batches - << " pending batches on dynamic_call=" << dynamic_call_.get(); - } - CallCombinerClosureList closures; - for (size_t i = 0; i < GPR_ARRAY_SIZE(pending_batches_); ++i) { - grpc_transport_stream_op_batch*& batch = pending_batches_[i]; - if (batch != nullptr) { - batch->handler_private.extra_arg = this; - GRPC_CLOSURE_INIT(&batch->handler_private.closure, - ResumePendingBatchInCallCombiner, batch, nullptr); - closures.Add(&batch->handler_private.closure, absl::OkStatus(), - "resuming pending batch from client channel call"); - batch = nullptr; - } - } - // Note: This will release the call combiner. - closures.RunClosures(call_combiner()); -} - -// A class to handle the call combiner cancellation callback for a -// queued pick. -class ClientChannelFilter::FilterBasedCallData::ResolverQueuedCallCanceller - final { - public: - explicit ResolverQueuedCallCanceller(FilterBasedCallData* calld) - : calld_(calld) { - GRPC_CALL_STACK_REF(calld->owning_call(), "ResolverQueuedCallCanceller"); - GRPC_CLOSURE_INIT(&closure_, &CancelLocked, this, - grpc_schedule_on_exec_ctx); - calld->call_combiner()->SetNotifyOnCancel(&closure_); - } - - private: - static void CancelLocked(void* arg, grpc_error_handle error) { - auto* self = static_cast(arg); - auto* calld = self->calld_; - auto* chand = calld->chand(); - { - MutexLock lock(&chand->resolution_mu_); - GRPC_TRACE_LOG(client_channel_call, INFO) - << "chand=" << chand << " calld=" << calld - << ": cancelling resolver queued pick: " - "error=" - << StatusToString(error) << " self=" << self - << " calld->resolver_pick_canceller=" - << calld->resolver_call_canceller_; - if (calld->resolver_call_canceller_ == self && !error.ok()) { - // Remove pick from list of queued picks. - calld->RemoveCallFromResolverQueuedCallsLocked(); - chand->resolver_queued_calls_.erase(calld); - // Fail pending batches on the call. - calld->PendingBatchesFail(error, - YieldCallCombinerIfPendingBatchesFound); - } - } - GRPC_CALL_STACK_UNREF(calld->owning_call(), "ResolvingQueuedCallCanceller"); - delete self; - } - - FilterBasedCallData* calld_; - grpc_closure closure_; -}; - -void ClientChannelFilter::FilterBasedCallData::TryCheckResolution( - bool was_queued) { +void ClientChannelFilter::CallData::TryCheckResolution(bool was_queued) { auto result = CheckResolution(was_queued); if (result.has_value()) { if (!result->ok()) { - PendingBatchesFail(*result, YieldCallCombiner); + buffered_call_.Fail(*result, BufferedCall::YieldCallCombiner); return; } CreateDynamicCall(); } } -void ClientChannelFilter::FilterBasedCallData::OnAddToQueueLocked() { - // Register call combiner cancellation callback. - resolver_call_canceller_ = new ResolverQueuedCallCanceller(this); -} - -void ClientChannelFilter::FilterBasedCallData::RetryCheckResolutionLocked() { +void ClientChannelFilter::CallData::RetryCheckResolutionLocked() { // Lame the call combiner canceller. resolver_call_canceller_ = nullptr; // Do an async callback to resume call processing, so that we're not @@ -2245,10 +2101,10 @@ void ClientChannelFilter::FilterBasedCallData::RetryCheckResolutionLocked() { }); } -void ClientChannelFilter::FilterBasedCallData::CreateDynamicCall() { - DynamicFilters::Call::Args args = {dynamic_filters(), pollent_, - call_start_time_, deadline_, - arena(), call_combiner()}; +void ClientChannelFilter::CallData::CreateDynamicCall() { + DynamicFilters::Call::Args args = {dynamic_filters_, pollent_, + call_start_time_, deadline_, + arena_, call_combiner_}; grpc_error_handle error; DynamicFilters* channel_stack = args.channel_stack.get(); GRPC_TRACE_LOG(client_channel_call, INFO) @@ -2259,18 +2115,21 @@ void ClientChannelFilter::FilterBasedCallData::CreateDynamicCall() { GRPC_TRACE_LOG(client_channel_call, INFO) << "chand=" << chand() << " calld=" << this << ": failed to create dynamic call: error=" << StatusToString(error); - PendingBatchesFail(error, YieldCallCombiner); + buffered_call_.Fail(error, BufferedCall::YieldCallCombiner); return; } - PendingBatchesResume(); + buffered_call_.Resume( + [dynamic_call = dynamic_call_](grpc_transport_stream_op_batch* batch) { + dynamic_call->StartTransportStreamOpBatch(batch); + }); } -void ClientChannelFilter::FilterBasedCallData:: +void ClientChannelFilter::CallData:: RecvTrailingMetadataReadyForConfigSelectorCommitCallback( void* arg, grpc_error_handle error) { - auto* calld = static_cast(arg); + auto* calld = static_cast(arg); auto* chand = calld->chand(); - auto* service_config_call_data = GetServiceConfigCallData(calld->arena()); + auto* service_config_call_data = GetServiceConfigCallData(calld->arena_); GRPC_TRACE_LOG(client_channel_call, INFO) << "chand=" << chand << " calld=" << calld << ": got recv_trailing_metadata_ready: error=" << StatusToString(error) @@ -2319,7 +2178,7 @@ ClientChannelFilter::LoadBalancedCall::LbCallState::GetCallAttribute( CallAttemptTracer* ClientChannelFilter::LoadBalancedCall::LbCallState::GetCallAttemptTracer() const { - return lb_call_->call_attempt_tracer(); + return lb_call_->call_attempt_tracer_; } // @@ -2367,6 +2226,61 @@ class ClientChannelFilter::LoadBalancedCall::BackendMetricAccessor final grpc_metadata_batch* recv_trailing_metadata_; }; +// +// ClientChannelFilter::LoadBalancedCall::LbQueuedCallCanceller +// + +// A class to handle the call combiner cancellation callback for a +// queued pick. +// TODO(roth): When we implement hedging support, we won't be able to +// register a call combiner cancellation closure for each LB pick, +// because there may be multiple LB picks happening in parallel. +// Instead, we will probably need to maintain a list in the CallData +// object of pending LB picks to be cancelled when the closure runs. +class ClientChannelFilter::LoadBalancedCall::LbQueuedCallCanceller final { + public: + explicit LbQueuedCallCanceller(RefCountedPtr lb_call) + : lb_call_(std::move(lb_call)) { + GRPC_CALL_STACK_REF(lb_call_->owning_call_, "LbQueuedCallCanceller"); + GRPC_CLOSURE_INIT(&closure_, &CancelLocked, this, nullptr); + lb_call_->call_combiner_->SetNotifyOnCancel(&closure_); + } + + private: + static void CancelLocked(void* arg, grpc_error_handle error) { + auto* self = static_cast(arg); + auto* lb_call = self->lb_call_.get(); + auto* chand = lb_call->chand_; + { + MutexLock lock(&chand->lb_mu_); + GRPC_TRACE_LOG(client_channel_lb_call, INFO) + << "chand=" << chand << " lb_call=" << lb_call + << ": cancelling queued pick: error=" << StatusToString(error) + << " self=" << self + << " calld->pick_canceller=" << lb_call->lb_call_canceller_; + if (lb_call->lb_call_canceller_ == self && !error.ok()) { + lb_call->Commit(); + // Remove pick from list of queued picks. + lb_call->RemoveCallFromLbQueuedCallsLocked(); + // Remove from queued picks list. + chand->lb_queued_calls_.erase(self->lb_call_); + // Fail pending batches on the call. + lb_call->buffered_call_.Fail( + error, BufferedCall::YieldCallCombinerIfPendingBatchesFound); + } + } + // Unref lb_call before unreffing the call stack, since unreffing + // the call stack may destroy the arena in which lb_call is allocated. + auto* owning_call = lb_call->owning_call_; + self->lb_call_.reset(); + GRPC_CALL_STACK_UNREF(owning_call, "LbQueuedCallCanceller"); + delete self; + } + + RefCountedPtr lb_call_; + grpc_closure closure_; +}; + // // ClientChannelFilter::LoadBalancedCall // @@ -2386,16 +2300,22 @@ CallAttemptTracer* CreateCallAttemptTracer(Arena* arena, } // namespace ClientChannelFilter::LoadBalancedCall::LoadBalancedCall( - ClientChannelFilter* chand, Arena* arena, + ClientChannelFilter* chand, const grpc_call_element_args& args, + grpc_polling_entity* pollent, grpc_closure* on_call_destruction_complete, absl::AnyInvocable on_commit, bool is_transparent_retry) : InternallyRefCounted(GRPC_TRACE_FLAG_ENABLED(client_channel_lb_call) ? "LoadBalancedCall" : nullptr), chand_(chand), call_attempt_tracer_( - CreateCallAttemptTracer(arena, is_transparent_retry)), + CreateCallAttemptTracer(args.arena, is_transparent_retry)), + owning_call_(args.call_stack), + call_combiner_(args.call_combiner), + pollent_(pollent), + on_call_destruction_complete_(on_call_destruction_complete), + arena_(args.arena), on_commit_(std::move(on_commit)), - arena_(arena) { + buffered_call_(call_combiner_, &client_channel_lb_call_trace) { GRPC_TRACE_LOG(client_channel_lb_call, INFO) << "chand=" << chand_ << " lb_call=" << this << ": created"; } @@ -2404,6 +2324,22 @@ ClientChannelFilter::LoadBalancedCall::~LoadBalancedCall() { if (backend_metric_data_ != nullptr) { backend_metric_data_->BackendMetricData::~BackendMetricData(); } + if (on_call_destruction_complete_ != nullptr) { + ExecCtx::Run(DEBUG_LOCATION, on_call_destruction_complete_, + absl::OkStatus()); + } +} + +void ClientChannelFilter::LoadBalancedCall::Orphan() { + // If the recv_trailing_metadata op was never started, then notify + // about call completion here, as best we can. We assume status + // CANCELLED in this case. + if (recv_trailing_metadata_ == nullptr) { + RecordCallCompletion(absl::CancelledError("call cancelled"), nullptr, + nullptr, ""); + } + RecordLatency(); + Unref(); } void ClientChannelFilter::LoadBalancedCall::RecordCallCompletion( @@ -2411,8 +2347,8 @@ void ClientChannelFilter::LoadBalancedCall::RecordCallCompletion( grpc_transport_stream_stats* transport_stream_stats, absl::string_view peer_address) { // If we have a tracer, notify it. - if (call_attempt_tracer() != nullptr) { - call_attempt_tracer()->RecordReceivedTrailingMetadata( + if (call_attempt_tracer_ != nullptr) { + call_attempt_tracer_->RecordReceivedTrailingMetadata( status, recv_trailing_metadata, transport_stream_stats); } // If the LB policy requested a callback for trailing metadata, invoke @@ -2429,8 +2365,8 @@ void ClientChannelFilter::LoadBalancedCall::RecordCallCompletion( void ClientChannelFilter::LoadBalancedCall::RecordLatency() { // Compute latency and report it to the tracer. - if (call_attempt_tracer() != nullptr) { - call_attempt_tracer()->RecordEnd(); + if (call_attempt_tracer_ != nullptr) { + call_attempt_tracer_->RecordEnd(); } } @@ -2440,7 +2376,7 @@ void ClientChannelFilter::LoadBalancedCall:: << "chand=" << chand_ << " lb_call=" << this << ": removing from queued picks list"; // Remove pollset_set linkage. - grpc_polling_entity_del_from_pollset_set(pollent(), + grpc_polling_entity_del_from_pollset_set(pollent_, chand_->interested_parties_); // Note: There's no need to actually remove the call from the queue // here, because that will be done in either @@ -2454,11 +2390,12 @@ void ClientChannelFilter::LoadBalancedCall::AddCallToLbQueuedCallsLocked() { << ": adding to queued picks list"; // Add call's pollent to channel's interested_parties, so that I/O // can be done under the call's CQ. - grpc_polling_entity_add_to_pollset_set(pollent(), - chand_->interested_parties_); + grpc_polling_entity_add_to_pollset_set(pollent_, chand_->interested_parties_); // Add to queue. chand_->lb_queued_calls_.insert(Ref()); - OnAddToQueueLocked(); + // Register call combiner cancellation callback. + lb_call_canceller_ = + new LbQueuedCallCanceller(RefAsSubclass()); } std::optional @@ -2506,8 +2443,8 @@ ClientChannelFilter::LoadBalancedCall::PickSubchannel(bool was_queued) { } // Pick is complete. // If it was queued, add a trace annotation. - if (was_queued && call_attempt_tracer() != nullptr) { - call_attempt_tracer()->RecordAnnotation("Delayed LB pick complete."); + if (was_queued && call_attempt_tracer_ != nullptr) { + call_attempt_tracer_->RecordAnnotation("Delayed LB pick complete."); } // If the pick failed, fail the call. if (!error.ok()) { @@ -2562,9 +2499,6 @@ bool ClientChannelFilter::LoadBalancedCall::PickSubchannelImpl( } lb_subchannel_call_tracker_ = std::move(complete_pick->subchannel_call_tracker); - if (lb_subchannel_call_tracker_ != nullptr) { - lb_subchannel_call_tracker_->Start(); - } // Handle metadata mutations. MetadataMutationHandler::Apply(complete_pick->metadata_mutations, send_initial_metadata()); @@ -2609,177 +2543,28 @@ bool ClientChannelFilter::LoadBalancedCall::PickSubchannelImpl( }); } -// -// ClientChannelFilter::FilterBasedLoadBalancedCall -// - -ClientChannelFilter::FilterBasedLoadBalancedCall::FilterBasedLoadBalancedCall( - ClientChannelFilter* chand, const grpc_call_element_args& args, - grpc_polling_entity* pollent, grpc_closure* on_call_destruction_complete, - absl::AnyInvocable on_commit, bool is_transparent_retry) - : LoadBalancedCall(chand, args.arena, std::move(on_commit), - is_transparent_retry), - owning_call_(args.call_stack), - call_combiner_(args.call_combiner), - pollent_(pollent), - on_call_destruction_complete_(on_call_destruction_complete) {} - -ClientChannelFilter::FilterBasedLoadBalancedCall:: - ~FilterBasedLoadBalancedCall() { - // Make sure there are no remaining pending batches. - for (size_t i = 0; i < GPR_ARRAY_SIZE(pending_batches_); ++i) { - GRPC_CHECK_EQ(pending_batches_[i], nullptr); - } - if (on_call_destruction_complete_ != nullptr) { - ExecCtx::Run(DEBUG_LOCATION, on_call_destruction_complete_, - absl::OkStatus()); - } -} - -void ClientChannelFilter::FilterBasedLoadBalancedCall::Orphan() { - // If the recv_trailing_metadata op was never started, then notify - // about call completion here, as best we can. We assume status - // CANCELLED in this case. - if (recv_trailing_metadata_ == nullptr) { - RecordCallCompletion(absl::CancelledError("call cancelled"), nullptr, - nullptr, ""); - } - RecordLatency(); - // Delegate to parent. - LoadBalancedCall::Orphan(); -} - -size_t ClientChannelFilter::FilterBasedLoadBalancedCall::GetBatchIndex( - grpc_transport_stream_op_batch* batch) { - // Note: It is important the send_initial_metadata be the first entry - // here, since the code in PickSubchannelImpl() assumes it will be. - if (batch->send_initial_metadata) return 0; - if (batch->send_message) return 1; - if (batch->send_trailing_metadata) return 2; - if (batch->recv_initial_metadata) return 3; - if (batch->recv_message) return 4; - if (batch->recv_trailing_metadata) return 5; - GPR_UNREACHABLE_CODE(return (size_t)-1); -} - -// This is called via the call combiner, so access to calld is synchronized. -void ClientChannelFilter::FilterBasedLoadBalancedCall::PendingBatchesAdd( +void ClientChannelFilter::LoadBalancedCall::StartTransportStreamOpBatch( grpc_transport_stream_op_batch* batch) { - const size_t idx = GetBatchIndex(batch); - GRPC_TRACE_LOG(client_channel_lb_call, INFO) - << "chand=" << chand() << " lb_call=" << this - << ": adding pending batch at index " << idx; - GRPC_CHECK_EQ(pending_batches_[idx], nullptr); - pending_batches_[idx] = batch; -} - -// This is called via the call combiner, so access to calld is synchronized. -void ClientChannelFilter::FilterBasedLoadBalancedCall:: - FailPendingBatchInCallCombiner(void* arg, grpc_error_handle error) { - grpc_transport_stream_op_batch* batch = - static_cast(arg); - auto* self = static_cast( - batch->handler_private.extra_arg); - // Note: This will release the call combiner. - grpc_transport_stream_op_batch_finish_with_failure(batch, error, - self->call_combiner_); -} - -// This is called via the call combiner, so access to calld is synchronized. -void ClientChannelFilter::FilterBasedLoadBalancedCall::PendingBatchesFail( - grpc_error_handle error, - YieldCallCombinerPredicate yield_call_combiner_predicate) { - GRPC_CHECK(!error.ok()); - failure_error_ = error; - if (GRPC_TRACE_FLAG_ENABLED(client_channel_lb_call)) { - size_t num_batches = 0; - for (size_t i = 0; i < GPR_ARRAY_SIZE(pending_batches_); ++i) { - if (pending_batches_[i] != nullptr) ++num_batches; - } - LOG(INFO) << "chand=" << chand() << " lb_call=" << this << ": failing " - << num_batches << " pending batches: " << StatusToString(error); - } - CallCombinerClosureList closures; - for (size_t i = 0; i < GPR_ARRAY_SIZE(pending_batches_); ++i) { - grpc_transport_stream_op_batch*& batch = pending_batches_[i]; - if (batch != nullptr) { - batch->handler_private.extra_arg = this; - GRPC_CLOSURE_INIT(&batch->handler_private.closure, - FailPendingBatchInCallCombiner, batch, - grpc_schedule_on_exec_ctx); - closures.Add(&batch->handler_private.closure, error, - "PendingBatchesFail"); - batch = nullptr; - } - } - if (yield_call_combiner_predicate(closures)) { - closures.RunClosures(call_combiner_); - } else { - closures.RunClosuresWithoutYielding(call_combiner_); - } -} - -// This is called via the call combiner, so access to calld is synchronized. -void ClientChannelFilter::FilterBasedLoadBalancedCall:: - ResumePendingBatchInCallCombiner(void* arg, grpc_error_handle /*ignored*/) { - grpc_transport_stream_op_batch* batch = - static_cast(arg); - SubchannelCall* subchannel_call = - static_cast(batch->handler_private.extra_arg); - // Note: This will release the call combiner. - subchannel_call->StartTransportStreamOpBatch(batch); -} - -// This is called via the call combiner, so access to calld is synchronized. -void ClientChannelFilter::FilterBasedLoadBalancedCall::PendingBatchesResume() { - if (GRPC_TRACE_FLAG_ENABLED(client_channel_lb_call)) { - size_t num_batches = 0; - for (size_t i = 0; i < GPR_ARRAY_SIZE(pending_batches_); ++i) { - if (pending_batches_[i] != nullptr) ++num_batches; - } - LOG(INFO) << "chand=" << chand() << " lb_call=" << this << ": starting " - << num_batches << " pending batches on subchannel_call=" - << subchannel_call_.get(); - } - CallCombinerClosureList closures; - for (size_t i = 0; i < GPR_ARRAY_SIZE(pending_batches_); ++i) { - grpc_transport_stream_op_batch*& batch = pending_batches_[i]; - if (batch != nullptr) { - batch->handler_private.extra_arg = subchannel_call_.get(); - GRPC_CLOSURE_INIT(&batch->handler_private.closure, - ResumePendingBatchInCallCombiner, batch, - grpc_schedule_on_exec_ctx); - closures.Add(&batch->handler_private.closure, absl::OkStatus(), - "resuming pending batch from LB call"); - batch = nullptr; - } - } - // Note: This will release the call combiner. - closures.RunClosures(call_combiner_); -} - -void ClientChannelFilter::FilterBasedLoadBalancedCall:: - StartTransportStreamOpBatch(grpc_transport_stream_op_batch* batch) { if (GRPC_TRACE_FLAG_ENABLED(client_channel_lb_call) || GRPC_TRACE_FLAG_ENABLED(channel)) { - LOG(INFO) << "chand=" << chand() << " lb_call=" << this + LOG(INFO) << "chand=" << chand_ << " lb_call=" << this << ": batch started from above: " << grpc_transport_stream_op_batch_string(batch, false) - << ", call_attempt_tracer()=" << call_attempt_tracer(); + << ", call_attempt_tracer_=" << call_attempt_tracer_; } // Handle call tracing. - if (call_attempt_tracer() != nullptr) { + if (call_attempt_tracer_ != nullptr) { // Record send ops in tracer. if (batch->cancel_stream) { - call_attempt_tracer()->RecordCancel( + call_attempt_tracer_->RecordCancel( batch->payload->cancel_stream.cancel_error); } if (batch->send_initial_metadata) { - call_attempt_tracer()->RecordSendInitialMetadata( + call_attempt_tracer_->RecordSendInitialMetadata( batch->payload->send_initial_metadata.send_initial_metadata); } if (batch->send_trailing_metadata) { - call_attempt_tracer()->RecordSendTrailingMetadata( + call_attempt_tracer_->RecordSendTrailingMetadata( batch->payload->send_trailing_metadata.send_trailing_metadata); } // Intercept recv ops. @@ -2814,7 +2599,7 @@ void ClientChannelFilter::FilterBasedLoadBalancedCall:: // streaming calls). if (subchannel_call_ != nullptr) { GRPC_TRACE_LOG(client_channel_lb_call, INFO) - << "chand=" << chand() << " lb_call=" << this + << "chand=" << chand_ << " lb_call=" << this << ": starting batch on subchannel_call=" << subchannel_call_.get(); subchannel_call_->StartTransportStreamOpBatch(batch); return; @@ -2824,7 +2609,7 @@ void ClientChannelFilter::FilterBasedLoadBalancedCall:: // If we've previously been cancelled, immediately fail any new batches. if (GPR_UNLIKELY(!cancel_error_.ok())) { GRPC_TRACE_LOG(client_channel_lb_call, INFO) - << "chand=" << chand() << " lb_call=" << this + << "chand=" << chand_ << " lb_call=" << this << ": failing batch with error: " << StatusToString(cancel_error_); // Note: This will release the call combiner. grpc_transport_stream_op_batch_finish_with_failure(batch, cancel_error_, @@ -2840,17 +2625,17 @@ void ClientChannelFilter::FilterBasedLoadBalancedCall:: // error to the caller when the first batch does get passed down. cancel_error_ = batch->payload->cancel_stream.cancel_error; GRPC_TRACE_LOG(client_channel_lb_call, INFO) - << "chand=" << chand() << " lb_call=" << this + << "chand=" << chand_ << " lb_call=" << this << ": recording cancel_error=" << StatusToString(cancel_error_).c_str(); // Fail all pending batches. - PendingBatchesFail(cancel_error_, NoYieldCallCombiner); + buffered_call_.Fail(cancel_error_, BufferedCall::NoYieldCallCombiner); // Note: This will release the call combiner. grpc_transport_stream_op_batch_finish_with_failure(batch, cancel_error_, call_combiner_); return; } // Add the batch to the pending list. - PendingBatchesAdd(batch); + buffered_call_.EnqueueBatch(batch); // For batches containing a send_initial_metadata op, acquire the // channel's LB mutex to pick a subchannel. if (GPR_LIKELY(batch->send_initial_metadata)) { @@ -2858,22 +2643,22 @@ void ClientChannelFilter::FilterBasedLoadBalancedCall:: } else { // For all other batches, release the call combiner. GRPC_TRACE_LOG(client_channel_lb_call, INFO) - << "chand=" << chand() << " lb_call=" << this + << "chand=" << chand_ << " lb_call=" << this << ": saved batch, yielding call combiner"; GRPC_CALL_COMBINER_STOP(call_combiner_, "batch does not include send_initial_metadata"); } } -void ClientChannelFilter::FilterBasedLoadBalancedCall::RecvInitialMetadataReady( +void ClientChannelFilter::LoadBalancedCall::RecvInitialMetadataReady( void* arg, grpc_error_handle error) { - auto* self = static_cast(arg); + auto* self = static_cast(arg); GRPC_TRACE_LOG(client_channel_lb_call, INFO) - << "chand=" << self->chand() << " lb_call=" << self + << "chand=" << self->chand_ << " lb_call=" << self << ": got recv_initial_metadata_ready: error=" << StatusToString(error); if (error.ok()) { // recv_initial_metadata_flags is not populated for clients - self->call_attempt_tracer()->RecordReceivedInitialMetadata( + self->call_attempt_tracer_->RecordReceivedInitialMetadata( self->recv_initial_metadata_); auto* peer_string = self->recv_initial_metadata_->get_pointer(PeerString()); if (peer_string != nullptr) self->peer_string_ = peer_string->Ref(); @@ -2882,27 +2667,28 @@ void ClientChannelFilter::FilterBasedLoadBalancedCall::RecvInitialMetadataReady( error); } -void ClientChannelFilter::FilterBasedLoadBalancedCall:: - RecvTrailingMetadataReady(void* arg, grpc_error_handle error) { - auto* self = static_cast(arg); +void ClientChannelFilter::LoadBalancedCall::RecvTrailingMetadataReady( + void* arg, grpc_error_handle error) { + auto* self = static_cast(arg); GRPC_TRACE_LOG(client_channel_lb_call, INFO) - << "chand=" << self->chand() << " lb_call=" << self + << "chand=" << self->chand_ << " lb_call=" << self << ": got recv_trailing_metadata_ready: error=" << StatusToString(error) - << " call_attempt_tracer()=" << self->call_attempt_tracer() - << " lb_subchannel_call_tracker_=" << self->lb_subchannel_call_tracker() + << " call_attempt_tracer_=" << self->call_attempt_tracer_ + << " lb_subchannel_call_tracker_=" + << self->lb_subchannel_call_tracker_.get() << " failure_error_=" << StatusToString(self->failure_error_); // Check if we have a tracer or an LB callback to invoke. - if (self->call_attempt_tracer() != nullptr || - self->lb_subchannel_call_tracker() != nullptr) { + if (self->call_attempt_tracer_ != nullptr || + self->lb_subchannel_call_tracker_ != nullptr) { // Get the call's status. absl::Status status; if (!error.ok()) { // Get status from error. grpc_status_code code; std::string message; - grpc_error_get_status( - error, self->arena()->GetContext()->deadline(), &code, &message, - /*http_error=*/nullptr, /*error_string=*/nullptr); + grpc_error_get_status(error, self->arena_->GetContext()->deadline(), + &code, &message, + /*http_error=*/nullptr, /*error_string=*/nullptr); status = absl::Status(static_cast(code), message); } else { // Get status from headers. @@ -2933,78 +2719,18 @@ void ClientChannelFilter::FilterBasedLoadBalancedCall:: error); } -// A class to handle the call combiner cancellation callback for a -// queued pick. -// TODO(roth): When we implement hedging support, we won't be able to -// register a call combiner cancellation closure for each LB pick, -// because there may be multiple LB picks happening in parallel. -// Instead, we will probably need to maintain a list in the CallData -// object of pending LB picks to be cancelled when the closure runs. -class ClientChannelFilter::FilterBasedLoadBalancedCall::LbQueuedCallCanceller - final { - public: - explicit LbQueuedCallCanceller( - RefCountedPtr lb_call) - : lb_call_(std::move(lb_call)) { - GRPC_CALL_STACK_REF(lb_call_->owning_call_, "LbQueuedCallCanceller"); - GRPC_CLOSURE_INIT(&closure_, &CancelLocked, this, nullptr); - lb_call_->call_combiner_->SetNotifyOnCancel(&closure_); - } - - private: - static void CancelLocked(void* arg, grpc_error_handle error) { - auto* self = static_cast(arg); - auto* lb_call = self->lb_call_.get(); - auto* chand = lb_call->chand(); - { - MutexLock lock(&chand->lb_mu_); - GRPC_TRACE_LOG(client_channel_lb_call, INFO) - << "chand=" << chand << " lb_call=" << lb_call - << ": cancelling queued pick: error=" << StatusToString(error) - << " self=" << self - << " calld->pick_canceller=" << lb_call->lb_call_canceller_; - if (lb_call->lb_call_canceller_ == self && !error.ok()) { - lb_call->Commit(); - // Remove pick from list of queued picks. - lb_call->RemoveCallFromLbQueuedCallsLocked(); - // Remove from queued picks list. - chand->lb_queued_calls_.erase(self->lb_call_); - // Fail pending batches on the call. - lb_call->PendingBatchesFail(error, - YieldCallCombinerIfPendingBatchesFound); - } - } - // Unref lb_call before unreffing the call stack, since unreffing - // the call stack may destroy the arena in which lb_call is allocated. - auto* owning_call = lb_call->owning_call_; - self->lb_call_.reset(); - GRPC_CALL_STACK_UNREF(owning_call, "LbQueuedCallCanceller"); - delete self; - } - - RefCountedPtr lb_call_; - grpc_closure closure_; -}; - -void ClientChannelFilter::FilterBasedLoadBalancedCall::TryPick( - bool was_queued) { +void ClientChannelFilter::LoadBalancedCall::TryPick(bool was_queued) { auto result = PickSubchannel(was_queued); if (result.has_value()) { if (!result->ok()) { - PendingBatchesFail(*result, YieldCallCombiner); + buffered_call_.Fail(*result, BufferedCall::YieldCallCombiner); return; } CreateSubchannelCall(); } } -void ClientChannelFilter::FilterBasedLoadBalancedCall::OnAddToQueueLocked() { - // Register call combiner cancellation callback. - lb_call_canceller_ = - new LbQueuedCallCanceller(RefAsSubclass()); -} - -void ClientChannelFilter::FilterBasedLoadBalancedCall::RetryPickLocked() { +void ClientChannelFilter::LoadBalancedCall::RetryPickLocked() { // Lame the call combiner canceller. lb_call_canceller_ = nullptr; // Do an async callback to resume call processing, so that we're not @@ -3033,17 +2759,17 @@ void ClientChannelFilter::FilterBasedLoadBalancedCall::RetryPickLocked() { absl::OkStatus()); } -void ClientChannelFilter::FilterBasedLoadBalancedCall::CreateSubchannelCall() { +void ClientChannelFilter::LoadBalancedCall::CreateSubchannelCall() { SubchannelCall::Args call_args = { - connected_subchannel()->Ref(), pollent_, /*start_time=*/0, - arena()->GetContext()->deadline(), + connected_subchannel_->Ref(), pollent_, /*start_time=*/0, + arena_->GetContext()->deadline(), // TODO(roth): When we implement hedging support, we will probably // need to use a separate call arena for each subchannel call. - arena(), call_combiner_}; + arena_, call_combiner_}; grpc_error_handle error; subchannel_call_ = SubchannelCall::Create(std::move(call_args), &error); GRPC_TRACE_LOG(client_channel_lb_call, INFO) - << "chand=" << chand() << " lb_call=" << this + << "chand=" << chand_ << " lb_call=" << this << ": create subchannel_call=" << subchannel_call_.get() << ": error=" << StatusToString(error); if (on_call_destruction_complete_ != nullptr) { @@ -3051,9 +2777,13 @@ void ClientChannelFilter::FilterBasedLoadBalancedCall::CreateSubchannelCall() { on_call_destruction_complete_ = nullptr; } if (GPR_UNLIKELY(!error.ok())) { - PendingBatchesFail(error, YieldCallCombiner); + buffered_call_.Fail(error, BufferedCall::YieldCallCombiner); } else { - PendingBatchesResume(); + buffered_call_.Resume([subchannel_call = subchannel_call_]( + grpc_transport_stream_op_batch* batch) { + // Note: This will release the call combiner. + subchannel_call->StartTransportStreamOpBatch(batch); + }); } } diff --git a/deps/grpc/src/core/client_channel/client_channel_filter.h b/deps/grpc/src/core/client_channel/client_channel_filter.h index 55c3d78d029..5c260ecdceb 100644 --- a/deps/grpc/src/core/client_channel/client_channel_filter.h +++ b/deps/grpc/src/core/client_channel/client_channel_filter.h @@ -29,13 +29,9 @@ #include #include -#include "absl/base/thread_annotations.h" -#include "absl/container/flat_hash_set.h" -#include "absl/functional/any_invocable.h" -#include "absl/status/status.h" -#include "absl/strings/string_view.h" #include "src/core/call/metadata_batch.h" #include "src/core/channelz/channelz.h" +#include "src/core/client_channel/buffered_call.h" #include "src/core/client_channel/client_channel_args.h" #include "src/core/client_channel/client_channel_factory.h" #include "src/core/client_channel/config_selector.h" @@ -67,6 +63,12 @@ #include "src/core/util/time.h" #include "src/core/util/time_precise.h" #include "src/core/util/work_serializer.h" +#include "absl/base/thread_annotations.h" +#include "absl/container/flat_hash_map.h" +#include "absl/container/flat_hash_set.h" +#include "absl/functional/any_invocable.h" +#include "absl/status/status.h" +#include "absl/strings/string_view.h" // // Client channel filter @@ -79,16 +81,6 @@ // Calls on a disconnected client channel are queued until a connection is // established. -// Max number of batches that can be pending on a call at any given -// time. This includes one batch for each of the following ops: -// recv_initial_metadata -// send_initial_metadata -// recv_message -// send_message -// recv_trailing_metadata -// send_trailing_metadata -#define MAX_PENDING_BATCHES 6 - namespace grpc_core { class ClientChannelFilter final { @@ -96,7 +88,6 @@ class ClientChannelFilter final { static const grpc_channel_filter kFilter; class LoadBalancedCall; - class FilterBasedLoadBalancedCall; // Flag that this object gets stored in channel args as a raw pointer. struct RawPointerChannelArgTag {}; @@ -143,14 +134,13 @@ class ClientChannelFilter final { void RemoveConnectivityWatcher( AsyncConnectivityStateWatcherInterface* watcher); - OrphanablePtr CreateLoadBalancedCall( + OrphanablePtr CreateLoadBalancedCall( const grpc_call_element_args& args, grpc_polling_entity* pollent, grpc_closure* on_call_destruction_complete, absl::AnyInvocable on_commit, bool is_transparent_retry); private: class CallData; - class FilterBasedCallData; class ResolverResultHandler; class SubchannelWrapper; class ClientChannelControlHelper; @@ -318,15 +308,12 @@ class ClientChannelFilter final { ABSL_GUARDED_BY(*work_serializer_); RefCountedPtr subchannel_pool_ ABSL_GUARDED_BY(*work_serializer_); - // The number of SubchannelWrapper instances referencing a given Subchannel. - std::map subchannel_refcount_map_ - ABSL_GUARDED_BY(*work_serializer_); - // The set of SubchannelWrappers that currently exist. - // No need to hold a ref, since the map is updated in the control-plane + // The set of SubchannelWrapper instances referencing a given Subchannel. + // No need to hold refs, since the map is updated in the control-plane // work_serializer when the SubchannelWrappers are created and destroyed. - absl::flat_hash_set subchannel_wrappers_ - ABSL_GUARDED_BY(*work_serializer_); - int keepalive_time_ ABSL_GUARDED_BY(*work_serializer_) = -1; + absl::flat_hash_map> + subchannel_map_ ABSL_GUARDED_BY(*work_serializer_); + Duration keepalive_time_ ABSL_GUARDED_BY(*work_serializer_); grpc_error_handle disconnect_error_ ABSL_GUARDED_BY(*work_serializer_); // @@ -352,15 +339,26 @@ class ClientChannelFilter final { // TODO(roth): As part of simplifying cancellation in the filter stack, // this should no longer need to be ref-counted. -class ClientChannelFilter::LoadBalancedCall +class ClientChannelFilter::LoadBalancedCall final : public InternallyRefCounted { public: - LoadBalancedCall(ClientChannelFilter* chand, Arena* arena, + // If on_call_destruction_complete is non-null, then it will be + // invoked once the LoadBalancedCall is completely destroyed. + // If it is null, then the caller is responsible for checking whether + // the LB call has a subchannel call and ensuring that the + // on_call_destruction_complete closure passed down from the surface + // is not invoked until after the subchannel call stack is destroyed. + LoadBalancedCall(ClientChannelFilter* chand, + const grpc_call_element_args& args, + grpc_polling_entity* pollent, + grpc_closure* on_call_destruction_complete, absl::AnyInvocable on_commit, bool is_transparent_retry); ~LoadBalancedCall() override; - void Orphan() override { Unref(); } + void Orphan() override; + + void StartTransportStreamOpBatch(grpc_transport_stream_op_batch* batch); // Called by channel when removing a call from the list of queued calls. void RemoveCallFromLbQueuedCallsLocked() @@ -368,22 +366,22 @@ class ClientChannelFilter::LoadBalancedCall // Called by the channel for each queued call when a new picker // becomes available. - virtual void RetryPickLocked() - ABSL_EXCLUSIVE_LOCKS_REQUIRED(&ClientChannelFilter::lb_mu_) = 0; + void RetryPickLocked() + ABSL_EXCLUSIVE_LOCKS_REQUIRED(&ClientChannelFilter::lb_mu_); - protected: - ClientChannelFilter* chand() const { return chand_; } - CallAttemptTracer* call_attempt_tracer() const { - return call_attempt_tracer_; - } - ConnectedSubchannel* connected_subchannel() const { - return connected_subchannel_.get(); + RefCountedPtr subchannel_call() const { + return subchannel_call_; } - LoadBalancingPolicy::SubchannelCallTrackerInterface* - lb_subchannel_call_tracker() const { - return lb_subchannel_call_tracker_.get(); + + private: + class LbCallState; + class Metadata; + class BackendMetricAccessor; + class LbQueuedCallCanceller; + + grpc_metadata_batch* send_initial_metadata() const { + return buffered_call_.send_initial_metadata(); } - Arena* arena() const { return arena_; } void Commit() { auto on_commit = std::move(on_commit_); @@ -409,14 +407,6 @@ class ClientChannelFilter::LoadBalancedCall void RecordLatency(); - private: - class LbCallState; - class Metadata; - class BackendMetricAccessor; - - virtual grpc_polling_entity* pollent() = 0; - virtual grpc_metadata_batch* send_initial_metadata() const = 0; - // Helper function for performing an LB pick with a specified picker. // Returns true if the pick is complete. bool PickSubchannelImpl(LoadBalancingPolicy::SubchannelPicker* picker, @@ -425,94 +415,6 @@ class ClientChannelFilter::LoadBalancedCall void AddCallToLbQueuedCallsLocked() ABSL_EXCLUSIVE_LOCKS_REQUIRED(&ClientChannelFilter::lb_mu_); - // Called when adding the call to the LB queue. - virtual void OnAddToQueueLocked() - ABSL_EXCLUSIVE_LOCKS_REQUIRED(&ClientChannelFilter::lb_mu_) = 0; - - ClientChannelFilter* chand_; - // When we start a new attempt for a call, we might not have cleaned up the - // previous attempt yet leading to a situation where we have two active call - // attempt tracers, and so we cannot rely on the arena to give us the right - // tracer when performing cleanup. - CallAttemptTracer* call_attempt_tracer_; - - absl::AnyInvocable on_commit_; - - RefCountedPtr connected_subchannel_; - const BackendMetricData* backend_metric_data_ = nullptr; - std::unique_ptr - lb_subchannel_call_tracker_; - Arena* const arena_; -}; - -class ClientChannelFilter::FilterBasedLoadBalancedCall final - : public ClientChannelFilter::LoadBalancedCall { - public: - // If on_call_destruction_complete is non-null, then it will be - // invoked once the LoadBalancedCall is completely destroyed. - // If it is null, then the caller is responsible for checking whether - // the LB call has a subchannel call and ensuring that the - // on_call_destruction_complete closure passed down from the surface - // is not invoked until after the subchannel call stack is destroyed. - FilterBasedLoadBalancedCall(ClientChannelFilter* chand, - const grpc_call_element_args& args, - grpc_polling_entity* pollent, - grpc_closure* on_call_destruction_complete, - absl::AnyInvocable on_commit, - bool is_transparent_retry); - ~FilterBasedLoadBalancedCall() override; - - void Orphan() override; - - void StartTransportStreamOpBatch(grpc_transport_stream_op_batch* batch); - - RefCountedPtr subchannel_call() const { - return subchannel_call_; - } - - private: - class LbQueuedCallCanceller; - - // Work-around for Windows compilers that don't allow nested classes - // to access protected members of the enclosing class's parent class. - using LoadBalancedCall::chand; - using LoadBalancedCall::Commit; - - grpc_polling_entity* pollent() override { return pollent_; } - grpc_metadata_batch* send_initial_metadata() const override { - return pending_batches_[0] - ->payload->send_initial_metadata.send_initial_metadata; - } - - // Returns the index into pending_batches_ to be used for batch. - static size_t GetBatchIndex(grpc_transport_stream_op_batch* batch); - void PendingBatchesAdd(grpc_transport_stream_op_batch* batch); - static void FailPendingBatchInCallCombiner(void* arg, - grpc_error_handle error); - // A predicate type and some useful implementations for PendingBatchesFail(). - typedef bool (*YieldCallCombinerPredicate)( - const CallCombinerClosureList& closures); - static bool YieldCallCombiner(const CallCombinerClosureList& /*closures*/) { - return true; - } - static bool NoYieldCallCombiner(const CallCombinerClosureList& /*closures*/) { - return false; - } - static bool YieldCallCombinerIfPendingBatchesFound( - const CallCombinerClosureList& closures) { - return closures.size() > 0; - } - // Fails all pending batches. - // If yield_call_combiner_predicate returns true, assumes responsibility for - // yielding the call combiner. - void PendingBatchesFail( - grpc_error_handle error, - YieldCallCombinerPredicate yield_call_combiner_predicate); - static void ResumePendingBatchInCallCombiner(void* arg, - grpc_error_handle ignored); - // Resumes all pending batches on subchannel_call_. - void PendingBatchesResume(); - static void SendInitialMetadataOnComplete(void* arg, grpc_error_handle error); static void RecvInitialMetadataReady(void* arg, grpc_error_handle error); static void RecvTrailingMetadataReady(void* arg, grpc_error_handle error); @@ -521,14 +423,15 @@ class ClientChannelFilter::FilterBasedLoadBalancedCall final // and when it is queued and the channel gets a new picker. void TryPick(bool was_queued); - void OnAddToQueueLocked() override - ABSL_EXCLUSIVE_LOCKS_REQUIRED(&ClientChannelFilter::lb_mu_); - - void RetryPickLocked() override - ABSL_EXCLUSIVE_LOCKS_REQUIRED(&ClientChannelFilter::lb_mu_); - void CreateSubchannelCall(); + ClientChannelFilter* chand_; + // When we start a new attempt for a call, we might not have cleaned up the + // previous attempt yet leading to a situation where we have two active call + // attempt tracers, and so we cannot rely on the arena to give us the right + // tracer when performing cleanup. + CallAttemptTracer* call_attempt_tracer_; + // TODO(roth): Instead of duplicating these fields in every filter // that uses any one of them, we should store them in the call // context. This will save per-call memory overhead. @@ -536,6 +439,15 @@ class ClientChannelFilter::FilterBasedLoadBalancedCall final CallCombiner* call_combiner_; grpc_polling_entity* pollent_; grpc_closure* on_call_destruction_complete_; + Arena* const arena_; + + absl::AnyInvocable on_commit_; + + RefCountedPtr connected_subchannel_; + const BackendMetricData* backend_metric_data_ = nullptr; + std::unique_ptr + lb_subchannel_call_tracker_; + std::optional peer_string_; // Set when we get a cancel_stream op. @@ -560,12 +472,7 @@ class ClientChannelFilter::FilterBasedLoadBalancedCall final grpc_closure recv_trailing_metadata_ready_; grpc_closure* original_recv_trailing_metadata_ready_ = nullptr; - // Batches are added to this list when received from above. - // They are removed when we are done handling the batch (i.e., when - // either we have invoked all of the batch's callbacks or we have - // passed the batch down to the subchannel call and are not - // intercepting any of its callbacks). - grpc_transport_stream_op_batch* pending_batches_[MAX_PENDING_BATCHES] = {}; + BufferedCall buffered_call_; }; } // namespace grpc_core diff --git a/deps/grpc/src/core/client_channel/client_channel_internal.h b/deps/grpc/src/core/client_channel/client_channel_internal.h index 5c276b7c7a1..392cfc18d85 100644 --- a/deps/grpc/src/core/client_channel/client_channel_internal.h +++ b/deps/grpc/src/core/client_channel/client_channel_internal.h @@ -21,7 +21,6 @@ #include -#include "absl/functional/any_invocable.h" #include "src/core/call/call_destination.h" #include "src/core/lib/resource_quota/arena.h" #include "src/core/load_balancing/lb_policy.h" @@ -30,6 +29,7 @@ #include "src/core/util/down_cast.h" #include "src/core/util/grpc_check.h" #include "src/core/util/unique_type_name.h" +#include "absl/functional/any_invocable.h" // // This file contains internal interfaces used to allow various plugins @@ -41,6 +41,10 @@ #define GRPC_ARG_HEALTH_CHECK_SERVICE_NAME \ "grpc.internal.health_check_service_name" +// Max number of connections per subchannel. +#define GRPC_ARG_MAX_CONNECTIONS_PER_SUBCHANNEL \ + "grpc.internal.max_connections_per_subchannel" + namespace grpc_core { // Internal type for LB call state interface. Provides an interface for diff --git a/deps/grpc/src/core/client_channel/client_channel_service_config.cc b/deps/grpc/src/core/client_channel/client_channel_service_config.cc index 203662c6544..7809b8d9888 100644 --- a/deps/grpc/src/core/client_channel/client_channel_service_config.cc +++ b/deps/grpc/src/core/client_channel/client_channel_service_config.cc @@ -22,11 +22,12 @@ #include #include +#include "src/core/load_balancing/lb_policy_registry.h" +#include "src/core/util/env.h" #include "absl/status/status.h" #include "absl/status/statusor.h" #include "absl/strings/ascii.h" #include "absl/strings/str_cat.h" -#include "src/core/load_balancing/lb_policy_registry.h" // As per the retry design, we do not allow more than 5 retry attempts. #define MAX_MAX_RETRY_ATTEMPTS 5 @@ -34,6 +35,27 @@ namespace grpc_core { namespace internal { +namespace { + +bool ConnectionScalingEnabled() { + auto value = + GetEnv("GRPC_EXPERIMENTAL_MAX_CONCURRENT_STREAMS_CONNECTION_SCALING"); + if (!value.has_value()) return false; + bool parsed_value; + bool parse_succeeded = gpr_parse_bool_value(value->c_str(), &parsed_value); + return parse_succeeded && parsed_value; +} + +class ConnectionScalingJsonArgs final : public JsonArgs { + public: + bool IsEnabled(absl::string_view key) const override { + if (key == "connection_scaling") return ConnectionScalingEnabled(); + return true; + } +}; + +} // namespace + // // ClientChannelGlobalParsedConfig::HealthCheckConfig // @@ -48,6 +70,21 @@ ClientChannelGlobalParsedConfig::HealthCheckConfig::JsonLoader( return loader; } +// +// ClientChannelGlobalParsedConfig::ConnectionScaling +// + +const JsonLoaderInterface* +ClientChannelGlobalParsedConfig::ConnectionScaling::JsonLoader( + const JsonArgs&) { + static const auto* loader = + JsonObjectLoader() + .OptionalField("maxConnectionsPerSubchannel", + &ConnectionScaling::max_connections_per_subchannel) + .Finish(); + return loader; +} + // // ClientChannelGlobalParsedConfig // @@ -63,6 +100,9 @@ const JsonLoaderInterface* ClientChannelGlobalParsedConfig::JsonLoader( &ClientChannelGlobalParsedConfig::parsed_deprecated_lb_policy_) .OptionalField("healthCheckConfig", &ClientChannelGlobalParsedConfig::health_check_config_) + .OptionalField("connectionScaling", + &ClientChannelGlobalParsedConfig::connection_scaling_, + "connection_scaling") .Finish(); return loader; } @@ -138,14 +178,14 @@ ClientChannelServiceConfigParser::ParseGlobalParams(const ChannelArgs& /*args*/, const Json& json, ValidationErrors* errors) { return LoadFromJson>( - json, JsonArgs(), errors); + json, ConnectionScalingJsonArgs(), errors); } std::unique_ptr ClientChannelServiceConfigParser::ParsePerMethodParams( const ChannelArgs& /*args*/, const Json& json, ValidationErrors* errors) { return LoadFromJson>( - json, JsonArgs(), errors); + json, ConnectionScalingJsonArgs(), errors); } } // namespace internal diff --git a/deps/grpc/src/core/client_channel/client_channel_service_config.h b/deps/grpc/src/core/client_channel/client_channel_service_config.h index 6ec1b8500c5..39d356cd72f 100644 --- a/deps/grpc/src/core/client_channel/client_channel_service_config.h +++ b/deps/grpc/src/core/client_channel/client_channel_service_config.h @@ -24,7 +24,6 @@ #include #include -#include "absl/strings/string_view.h" #include "src/core/config/core_configuration.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/load_balancing/lb_policy.h" @@ -35,6 +34,7 @@ #include "src/core/util/ref_counted_ptr.h" #include "src/core/util/time.h" #include "src/core/util/validation_errors.h" +#include "absl/strings/string_view.h" namespace grpc_core { namespace internal { @@ -54,6 +54,10 @@ class ClientChannelGlobalParsedConfig final return health_check_config_.service_name; } + uint32_t max_connections_per_subchannel() const { + return connection_scaling_.max_connections_per_subchannel; + } + static const JsonLoaderInterface* JsonLoader(const JsonArgs&); void JsonPostLoad(const Json& json, const JsonArgs&, ValidationErrors* errors); @@ -65,9 +69,16 @@ class ClientChannelGlobalParsedConfig final static const JsonLoaderInterface* JsonLoader(const JsonArgs&); }; + struct ConnectionScaling { + uint32_t max_connections_per_subchannel = 0; + + static const JsonLoaderInterface* JsonLoader(const JsonArgs&); + }; + RefCountedPtr parsed_lb_config_; std::string parsed_deprecated_lb_policy_; HealthCheckConfig health_check_config_; + ConnectionScaling connection_scaling_; }; class ClientChannelMethodParsedConfig final diff --git a/deps/grpc/src/core/client_channel/config_selector.h b/deps/grpc/src/core/client_channel/config_selector.h index dc13ff0a8af..89dd2380979 100644 --- a/deps/grpc/src/core/client_channel/config_selector.h +++ b/deps/grpc/src/core/client_channel/config_selector.h @@ -24,8 +24,6 @@ #include #include -#include "absl/status/status.h" -#include "absl/strings/string_view.h" #include "src/core/call/interception_chain.h" #include "src/core/call/metadata_batch.h" #include "src/core/client_channel/client_channel_internal.h" @@ -39,6 +37,8 @@ #include "src/core/util/ref_counted_ptr.h" #include "src/core/util/unique_type_name.h" #include "src/core/util/useful.h" +#include "absl/status/status.h" +#include "absl/strings/string_view.h" // Channel arg key for ConfigSelector. #define GRPC_ARG_CONFIG_SELECTOR "grpc.internal.config_selector" diff --git a/deps/grpc/src/core/client_channel/connector.h b/deps/grpc/src/core/client_channel/connector.h index 6a0deb89300..cd878d2ec1e 100644 --- a/deps/grpc/src/core/client_channel/connector.h +++ b/deps/grpc/src/core/client_channel/connector.h @@ -53,6 +53,8 @@ class SubchannelConnector : public InternallyRefCounted { Transport* transport = nullptr; // Channel args to be passed to filters. ChannelArgs channel_args; + // Initial MAX_CONCURRENT_STREAMS value. + uint32_t max_concurrent_streams; void Reset() { if (transport != nullptr) { diff --git a/deps/grpc/src/core/client_channel/dynamic_filters.cc b/deps/grpc/src/core/client_channel/dynamic_filters.cc index 1f798a2aa33..70abb90a1aa 100644 --- a/deps/grpc/src/core/client_channel/dynamic_filters.cc +++ b/deps/grpc/src/core/client_channel/dynamic_filters.cc @@ -22,8 +22,6 @@ #include #include -#include "absl/log/log.h" -#include "absl/status/statusor.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/channel_stack.h" #include "src/core/lib/channel/channel_stack_builder_impl.h" @@ -33,6 +31,8 @@ #include "src/core/util/alloc.h" #include "src/core/util/grpc_check.h" #include "src/core/util/status_helper.h" +#include "absl/log/log.h" +#include "absl/status/statusor.h" // Conversion between call and call stack. #define CALL_TO_CALL_STACK(call) \ diff --git a/deps/grpc/src/core/client_channel/global_subchannel_pool.h b/deps/grpc/src/core/client_channel/global_subchannel_pool.h index 34b5ba34569..42cf63d2878 100644 --- a/deps/grpc/src/core/client_channel/global_subchannel_pool.h +++ b/deps/grpc/src/core/client_channel/global_subchannel_pool.h @@ -23,10 +23,10 @@ #include -#include "absl/base/thread_annotations.h" #include "src/core/client_channel/subchannel_pool_interface.h" #include "src/core/util/ref_counted_ptr.h" #include "src/core/util/sync.h" +#include "absl/base/thread_annotations.h" namespace grpc_core { diff --git a/deps/grpc/src/core/client_channel/lb_metadata.h b/deps/grpc/src/core/client_channel/lb_metadata.h index e8cd44b29dd..87604061107 100644 --- a/deps/grpc/src/core/client_channel/lb_metadata.h +++ b/deps/grpc/src/core/client_channel/lb_metadata.h @@ -21,9 +21,9 @@ #include #include -#include "absl/strings/string_view.h" #include "src/core/call/metadata_batch.h" #include "src/core/load_balancing/lb_policy.h" +#include "absl/strings/string_view.h" namespace grpc_core { diff --git a/deps/grpc/src/core/client_channel/load_balanced_call_destination.cc b/deps/grpc/src/core/client_channel/load_balanced_call_destination.cc index 60c2b885255..35e1c5bf5d5 100644 --- a/deps/grpc/src/core/client_channel/load_balanced_call_destination.cc +++ b/deps/grpc/src/core/client_channel/load_balanced_call_destination.cc @@ -14,7 +14,6 @@ #include "src/core/client_channel/load_balanced_call_destination.h" -#include "absl/log/log.h" #include "src/core/call/status_util.h" #include "src/core/client_channel/client_channel.h" #include "src/core/client_channel/client_channel_internal.h" @@ -23,6 +22,7 @@ #include "src/core/config/core_configuration.h" #include "src/core/lib/promise/loop.h" #include "src/core/telemetry/call_tracer.h" +#include "absl/log/log.h" namespace grpc_core { @@ -135,11 +135,9 @@ LoopCtl>> PickSubchannel( "pick"; return Continue{}; } - // If the LB policy returned a call tracker, inform it that the - // call is starting and add it to context, so that we can notify - // it when the call finishes. + // If the LB policy returned a call tracker, add it to context, so + // that we can notify it when the call finishes. if (complete_pick->subchannel_call_tracker != nullptr) { - complete_pick->subchannel_call_tracker->Start(); SetContext(complete_pick->subchannel_call_tracker.release()); } // Apply metadata mutations, if any. diff --git a/deps/grpc/src/core/client_channel/load_balanced_call_destination.h b/deps/grpc/src/core/client_channel/load_balanced_call_destination.h index 4ddb5310572..6329d58ecdd 100644 --- a/deps/grpc/src/core/client_channel/load_balanced_call_destination.h +++ b/deps/grpc/src/core/client_channel/load_balanced_call_destination.h @@ -15,11 +15,11 @@ #ifndef GRPC_SRC_CORE_CLIENT_CHANNEL_LOAD_BALANCED_CALL_DESTINATION_H #define GRPC_SRC_CORE_CLIENT_CHANNEL_LOAD_BALANCED_CALL_DESTINATION_H -#include "absl/functional/any_invocable.h" #include "src/core/call/call_destination.h" #include "src/core/client_channel/client_channel.h" #include "src/core/lib/promise/context.h" #include "src/core/load_balancing/lb_policy.h" +#include "absl/functional/any_invocable.h" namespace grpc_core { diff --git a/deps/grpc/src/core/client_channel/retry_filter.cc b/deps/grpc/src/core/client_channel/retry_filter.cc index 865da6afe2d..ac494396b27 100644 --- a/deps/grpc/src/core/client_channel/retry_filter.cc +++ b/deps/grpc/src/core/client_channel/retry_filter.cc @@ -22,8 +22,6 @@ #include #include -#include "absl/status/statusor.h" -#include "absl/strings/strip.h" #include "src/core/client_channel/client_channel_filter.h" #include "src/core/client_channel/retry_filter_legacy_call_data.h" #include "src/core/client_channel/retry_service_config.h" @@ -35,6 +33,8 @@ #include "src/core/service_config/service_config_call_data.h" #include "src/core/util/ref_counted_ptr.h" #include "src/core/util/uri.h" +#include "absl/status/statusor.h" +#include "absl/strings/strip.h" // // Retry filter diff --git a/deps/grpc/src/core/client_channel/retry_filter_legacy_call_data.cc b/deps/grpc/src/core/client_channel/retry_filter_legacy_call_data.cc index fb3707e3f11..62a7c93163f 100644 --- a/deps/grpc/src/core/client_channel/retry_filter_legacy_call_data.cc +++ b/deps/grpc/src/core/client_channel/retry_filter_legacy_call_data.cc @@ -20,9 +20,6 @@ #include #include -#include "absl/log/log.h" -#include "absl/status/status.h" -#include "absl/strings/str_cat.h" #include "src/core/call/metadata_batch.h" #include "src/core/call/status_util.h" #include "src/core/client_channel/client_channel_internal.h" @@ -50,6 +47,9 @@ #include "src/core/util/status_helper.h" #include "src/core/util/time.h" #include "src/core/util/useful.h" +#include "absl/log/log.h" +#include "absl/status/status.h" +#include "absl/strings/str_cat.h" namespace grpc_core { @@ -293,9 +293,8 @@ namespace { void StartBatchInCallCombiner(void* arg, grpc_error_handle /*ignored*/) { grpc_transport_stream_op_batch* batch = static_cast(arg); - auto* lb_call = - static_cast( - batch->handler_private.extra_arg); + auto* lb_call = static_cast( + batch->handler_private.extra_arg); // Note: This will release the call combiner. lb_call->StartTransportStreamOpBatch(batch); } @@ -1626,7 +1625,7 @@ void RetryFilter::LegacyCallData::StartTransportStreamOpBatch( call_attempt_->StartRetriableBatches(); } -OrphanablePtr +OrphanablePtr RetryFilter::LegacyCallData::CreateLoadBalancedCall( absl::AnyInvocable on_commit, bool is_transparent_retry) { grpc_call_element_args args = {owning_call_, nullptr, diff --git a/deps/grpc/src/core/client_channel/retry_filter_legacy_call_data.h b/deps/grpc/src/core/client_channel/retry_filter_legacy_call_data.h index c36ebd5ece5..f5e4ff1b617 100644 --- a/deps/grpc/src/core/client_channel/retry_filter_legacy_call_data.h +++ b/deps/grpc/src/core/client_channel/retry_filter_legacy_call_data.h @@ -25,8 +25,6 @@ #include #include -#include "absl/container/inlined_vector.h" -#include "absl/functional/any_invocable.h" #include "src/core/call/metadata_batch.h" #include "src/core/client_channel/client_channel_filter.h" #include "src/core/client_channel/retry_filter.h" @@ -47,6 +45,8 @@ #include "src/core/util/ref_counted.h" #include "src/core/util/ref_counted_ptr.h" #include "src/core/util/time.h" +#include "absl/container/inlined_vector.h" +#include "absl/functional/any_invocable.h" namespace grpc_core { @@ -252,7 +252,7 @@ class RetryFilter::LegacyCallData final { void MaybeCancelPerAttemptRecvTimer(); LegacyCallData* calld_; - OrphanablePtr lb_call_; + OrphanablePtr lb_call_; bool lb_call_committed_ = false; grpc_closure on_per_attempt_recv_timer_; @@ -362,9 +362,8 @@ class RetryFilter::LegacyCallData final { void AddClosureToStartTransparentRetry(CallCombinerClosureList* closures); static void StartTransparentRetry(void* arg, grpc_error_handle error); - OrphanablePtr - CreateLoadBalancedCall(absl::AnyInvocable on_commit, - bool is_transparent_retry); + OrphanablePtr CreateLoadBalancedCall( + absl::AnyInvocable on_commit, bool is_transparent_retry); void CreateCallAttempt(bool is_transparent_retry); @@ -391,8 +390,7 @@ class RetryFilter::LegacyCallData final { // LB call used when we've committed to a call attempt and the retry // state for that attempt is no longer needed. This provides a fast // path for long-running streaming calls that minimizes overhead. - OrphanablePtr - committed_call_; + OrphanablePtr committed_call_; // When are are not yet fully committed to a particular call (i.e., // either we might still retry or we have committed to the call but diff --git a/deps/grpc/src/core/client_channel/retry_service_config.cc b/deps/grpc/src/core/client_channel/retry_service_config.cc index 01f58765ab2..05b1d0e3427 100644 --- a/deps/grpc/src/core/client_channel/retry_service_config.cc +++ b/deps/grpc/src/core/client_channel/retry_service_config.cc @@ -27,13 +27,13 @@ #include #include -#include "absl/log/log.h" -#include "absl/strings/numbers.h" -#include "absl/strings/str_cat.h" #include "src/core/call/status_util.h" #include "src/core/config/core_configuration.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/util/json/json_channel_args.h" +#include "absl/log/log.h" +#include "absl/strings/numbers.h" +#include "absl/strings/str_cat.h" // As per the retry design, we do not allow more than 5 retry attempts. #define MAX_MAX_RETRY_ATTEMPTS 5 diff --git a/deps/grpc/src/core/client_channel/retry_service_config.h b/deps/grpc/src/core/client_channel/retry_service_config.h index e5ed4ec6e7a..d0c7778f68b 100644 --- a/deps/grpc/src/core/client_channel/retry_service_config.h +++ b/deps/grpc/src/core/client_channel/retry_service_config.h @@ -24,7 +24,6 @@ #include #include -#include "absl/strings/string_view.h" #include "src/core/call/status_util.h" #include "src/core/config/core_configuration.h" #include "src/core/lib/channel/channel_args.h" @@ -34,6 +33,7 @@ #include "src/core/util/json/json_object_loader.h" #include "src/core/util/time.h" #include "src/core/util/validation_errors.h" +#include "absl/strings/string_view.h" namespace grpc_core { namespace internal { diff --git a/deps/grpc/src/core/client_channel/subchannel.cc b/deps/grpc/src/core/client_channel/subchannel.cc index e71e39b4d5b..bf7b827e280 100644 --- a/deps/grpc/src/core/client_channel/subchannel.cc +++ b/deps/grpc/src/core/client_channel/subchannel.cc @@ -29,11 +29,6 @@ #include #include -#include "absl/log/log.h" -#include "absl/status/statusor.h" -#include "absl/strings/cord.h" -#include "absl/strings/str_cat.h" -#include "absl/strings/string_view.h" #include "src/core/call/interception_chain.h" #include "src/core/channelz/channel_trace.h" #include "src/core/channelz/channelz.h" @@ -70,6 +65,11 @@ #include "src/core/util/status_helper.h" #include "src/core/util/sync.h" #include "src/core/util/useful.h" +#include "absl/log/log.h" +#include "absl/status/statusor.h" +#include "absl/strings/cord.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/string_view.h" // Backoff parameters. #define GRPC_SUBCHANNEL_INITIAL_CONNECT_BACKOFF_SECONDS 1 @@ -422,12 +422,6 @@ class Subchannel::ConnectedSubchannelStateWatcher final << ": Connected subchannel " << connected_subchannel.get() << " reports " << ConnectivityStateName(new_state) << ": " << status; - if (c->channelz_node() != nullptr) { - if (connected_subchannel->channelz_node() != nullptr) { - connected_subchannel->channelz_node()->RemoveParent( - c->channelz_node()); - } - } // If the subchannel was created from an endpoint, then we report // TRANSIENT_FAILURE here instead of IDLE. The subchannel will never // leave TRANSIENT_FAILURE state, because there is no way for us to @@ -451,6 +445,68 @@ class Subchannel::ConnectedSubchannelStateWatcher final WeakRefCountedPtr subchannel_; }; +// +// Subchannel::ConnectionStateWatcher +// + +class Subchannel::ConnectionStateWatcher final + : public Transport::StateWatcher { + public: + explicit ConnectionStateWatcher(WeakRefCountedPtr subchannel) + : subchannel_(std::move(subchannel)) {} + + ~ConnectionStateWatcher() override { + subchannel_.reset(DEBUG_LOCATION, "state_watcher"); + } + + void OnDisconnect(absl::Status status, + DisconnectInfo disconnect_info) override { + MutexLock lock(&subchannel_->mu_); + // Handle keepalive update. + if (disconnect_info.keepalive_time.has_value()) { + subchannel_->ThrottleKeepaliveTimeLocked(*disconnect_info.keepalive_time); + subchannel_->watcher_list_.NotifyOnKeepaliveUpdateLocked( + *disconnect_info.keepalive_time); + } + // We shouldn't ever see OnDisconnect() more than once for a given + // connection, but we'll be defensive just in case: if the connected + // subchannel has already been cleared, then this becomes a no-op. + RefCountedPtr connected_subchannel = + std::move(subchannel_->connected_subchannel_); + if (connected_subchannel == nullptr) return; + GRPC_TRACE_LOG(subchannel, INFO) + << "subchannel " << subchannel_.get() << " " + << subchannel_->key_.ToString() << ": connected subchannel " + << connected_subchannel.get() << " reports disconnection: " << status; + // If the subchannel was created from an endpoint, then we report + // TRANSIENT_FAILURE here instead of IDLE. The subchannel will never + // leave TRANSIENT_FAILURE state, because there is no way for us to + // establish a new connection. Otherwise, we report IDLE here. + if (subchannel_->created_from_endpoint_) { + subchannel_->SetConnectivityStateLocked(GRPC_CHANNEL_TRANSIENT_FAILURE, + status); + } else { + subchannel_->SetConnectivityStateLocked(GRPC_CHANNEL_IDLE, + absl::OkStatus()); + } + subchannel_->backoff_.Reset(); + } + + void OnPeerMaxConcurrentStreamsUpdate( + uint32_t /*max_concurrent_streams*/, + std::unique_ptr /*on_done*/) + override { + // TODO(roth): Implement this as part of adding connection scaling. + } + + grpc_pollset_set* interested_parties() const override { + return subchannel_->pollset_set_; + } + + private: + WeakRefCountedPtr subchannel_; +}; + // // Subchannel::ConnectivityStateWatcherList // @@ -474,6 +530,27 @@ void Subchannel::ConnectivityStateWatcherList::NotifyLocked( } } +void Subchannel::ConnectivityStateWatcherList::NotifyOnKeepaliveUpdateLocked( + Duration new_keepalive_time) { + for (const auto& watcher : watchers_) { + subchannel_->work_serializer_.Run([watcher, new_keepalive_time]() { + watcher->OnKeepaliveUpdate(new_keepalive_time); + }); + } +} + +uint32_t +Subchannel::ConnectivityStateWatcherList::GetMaxConnectionsPerSubchannel() + const { + uint32_t max_connections_per_subchannel = 1; + for (const auto& watcher : watchers_) { + max_connections_per_subchannel = + std::max(max_connections_per_subchannel, + watcher->max_connections_per_subchannel()); + } + return max_connections_per_subchannel; +} + // // Subchannel // @@ -610,15 +687,19 @@ RefCountedPtr Subchannel::Create( return registered; } -void Subchannel::ThrottleKeepaliveTime(int new_keepalive_time) { +void Subchannel::ThrottleKeepaliveTime(Duration new_keepalive_time) { MutexLock lock(&mu_); + ThrottleKeepaliveTimeLocked(new_keepalive_time); +} + +void Subchannel::ThrottleKeepaliveTimeLocked(Duration new_keepalive_time) { // Only update the value if the new keepalive time is larger. if (new_keepalive_time > keepalive_time_) { keepalive_time_ = new_keepalive_time; GRPC_TRACE_LOG(subchannel, INFO) << "subchannel " << this << " " << key_.ToString() << ": throttling keepalive time to " << new_keepalive_time; - args_ = args_.Set(GRPC_ARG_KEEPALIVE_TIME_MS, new_keepalive_time); + args_ = args_.Set(GRPC_ARG_KEEPALIVE_TIME_MS, new_keepalive_time.millis()); } } @@ -821,6 +902,11 @@ void Subchannel::OnConnectingFinishedLocked(grpc_error_handle error) { bool Subchannel::PublishTransportLocked() { auto socket_node = connecting_result_.transport->GetSocketNode(); + if (IsTransportStateWatcherEnabled()) { + connecting_result_.transport->StartWatch( + MakeRefCounted( + WeakRef(DEBUG_LOCATION, "state_watcher"))); + } if (connecting_result_.transport->filter_stack_transport() != nullptr) { // Construct channel stack. // Builder takes ownership of transport. @@ -890,10 +976,11 @@ bool Subchannel::PublishTransportLocked() { socket_node->AddParent(channelz_node_.get()); } } - // Start watching connected subchannel. - connected_subchannel_->StartWatch( - pollset_set_, MakeOrphanable( - WeakRef(DEBUG_LOCATION, "state_watcher"))); + if (!IsTransportStateWatcherEnabled()) { + connected_subchannel_->StartWatch( + pollset_set_, MakeOrphanable( + WeakRef(DEBUG_LOCATION, "state_watcher"))); + } // Report initial state. SetConnectivityStateLocked(GRPC_CHANNEL_READY, absl::Status()); return true; @@ -919,6 +1006,8 @@ ChannelArgs Subchannel::MakeSubchannelArgs( // uniqueness. .Remove(GRPC_ARG_HEALTH_CHECK_SERVICE_NAME) .Remove(GRPC_ARG_INHIBIT_HEALTH_CHECKING) + .Remove(GRPC_ARG_MAX_CONNECTIONS_PER_SUBCHANNEL) + .Remove(GRPC_ARG_MAX_CONNECTIONS_PER_SUBCHANNEL_CAP) .Remove(GRPC_ARG_CHANNELZ_CHANNEL_NODE) // Remove all keys with the no-subchannel prefix. .RemoveAllKeysWithPrefix(GRPC_ARG_NO_SUBCHANNEL_PREFIX); diff --git a/deps/grpc/src/core/client_channel/subchannel.h b/deps/grpc/src/core/client_channel/subchannel.h index b11d54143a9..fea0afbc904 100644 --- a/deps/grpc/src/core/client_channel/subchannel.h +++ b/deps/grpc/src/core/client_channel/subchannel.h @@ -26,9 +26,6 @@ #include #include -#include "absl/base/thread_annotations.h" -#include "absl/container/flat_hash_set.h" -#include "absl/status/status.h" #include "src/core/call/metadata_batch.h" #include "src/core/client_channel/connector.h" #include "src/core/client_channel/subchannel_pool_interface.h" @@ -57,6 +54,9 @@ #include "src/core/util/time_precise.h" #include "src/core/util/unique_type_name.h" #include "src/core/util/work_serializer.h" +#include "absl/base/thread_annotations.h" +#include "absl/container/flat_hash_set.h" +#include "absl/status/status.h" /** This arg is intended for internal use only, primarily * for passing endpoint information during subchannel creation or connection. @@ -71,6 +71,7 @@ class ConnectedSubchannel : public RefCounted { public: const ChannelArgs& args() const { return args_; } + // TODO(roth): Remove this when transport_state_watcher experiment is removed. virtual void StartWatch( grpc_pollset_set* interested_parties, OrphanablePtr watcher) = 0; @@ -167,8 +168,6 @@ class SubchannelCall final { // (SubchannelWrapper) that "converts" between the two. class Subchannel final : public DualRefCounted { public: - // TODO(roth): Once we remove pollset_set, consider whether this can - // just use the normal AsyncConnectivityStateWatcherInterface API. class ConnectivityStateWatcherInterface : public RefCounted { public: @@ -178,6 +177,11 @@ class Subchannel final : public DualRefCounted { virtual void OnConnectivityStateChange(grpc_connectivity_state state, const absl::Status& status) = 0; + // Invoked to report updated keepalive time. + virtual void OnKeepaliveUpdate(Duration keepalive_time) = 0; + + virtual uint32_t max_connections_per_subchannel() const = 0; + virtual grpc_pollset_set* interested_parties() = 0; }; @@ -208,7 +212,8 @@ class Subchannel final : public DualRefCounted { // Throttles keepalive time to \a new_keepalive_time iff \a new_keepalive_time // is larger than the subchannel's current keepalive time. The updated value // will have an affect when the subchannel creates a new ConnectedSubchannel. - void ThrottleKeepaliveTime(int new_keepalive_time) ABSL_LOCKS_EXCLUDED(mu_); + void ThrottleKeepaliveTime(Duration new_keepalive_time) + ABSL_LOCKS_EXCLUDED(mu_); grpc_pollset_set* pollset_set() const { return pollset_set_; } @@ -302,10 +307,15 @@ class Subchannel final : public DualRefCounted { void NotifyLocked(grpc_connectivity_state state, const absl::Status& status); + // Notifies all watchers about a keepalive update. + void NotifyOnKeepaliveUpdateLocked(Duration new_keepalive_time); + void Clear() { watchers_.clear(); } bool empty() const { return watchers_.empty(); } + uint32_t GetMaxConnectionsPerSubchannel() const; + private: Subchannel* subchannel_; absl::flat_hash_set, @@ -314,13 +324,19 @@ class Subchannel final : public DualRefCounted { watchers_; }; + // TODO(roth): Remove this when transport_state_watcher experiment is removed. class ConnectedSubchannelStateWatcher; + class ConnectionStateWatcher; + // Sets the subchannel's connectivity state to \a state. void SetConnectivityStateLocked(grpc_connectivity_state state, const absl::Status& status) ABSL_EXCLUSIVE_LOCKS_REQUIRED(mu_); + void ThrottleKeepaliveTimeLocked(Duration new_keepalive_time) + ABSL_EXCLUSIVE_LOCKS_REQUIRED(mu_); + // Methods for connection. void OnRetryTimer() ABSL_LOCKS_EXCLUDED(mu_); void OnRetryTimerLocked() ABSL_EXCLUSIVE_LOCKS_REQUIRED(mu_); @@ -383,8 +399,8 @@ class Subchannel final : public DualRefCounted { grpc_event_engine::experimental::EventEngine::TaskHandle retry_timer_handle_ ABSL_GUARDED_BY(mu_); - // Keepalive time period (-1 for unset) - int keepalive_time_ ABSL_GUARDED_BY(mu_) = -1; + // Keepalive time period + Duration keepalive_time_ ABSL_GUARDED_BY(mu_); // Data producer map. std::map data_producer_map_ diff --git a/deps/grpc/src/core/client_channel/subchannel_pool_interface.cc b/deps/grpc/src/core/client_channel/subchannel_pool_interface.cc index 22d2fb080d0..acb58fc336c 100644 --- a/deps/grpc/src/core/client_channel/subchannel_pool_interface.cc +++ b/deps/grpc/src/core/client_channel/subchannel_pool_interface.cc @@ -21,11 +21,11 @@ #include #include +#include "src/core/lib/address_utils/sockaddr_utils.h" +#include "src/core/lib/channel/channel_args.h" #include "absl/status/status.h" #include "absl/status/statusor.h" #include "absl/strings/str_cat.h" -#include "src/core/lib/address_utils/sockaddr_utils.h" -#include "src/core/lib/channel/channel_args.h" // The subchannel pool to reuse subchannels. #define GRPC_ARG_SUBCHANNEL_POOL "grpc.internal.subchannel_pool" diff --git a/deps/grpc/src/core/client_channel/subchannel_pool_interface.h b/deps/grpc/src/core/client_channel/subchannel_pool_interface.h index 5324c40eeed..111abcc73ce 100644 --- a/deps/grpc/src/core/client_channel/subchannel_pool_interface.h +++ b/deps/grpc/src/core/client_channel/subchannel_pool_interface.h @@ -23,13 +23,13 @@ #include -#include "absl/strings/string_view.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/debug/trace.h" #include "src/core/lib/iomgr/resolved_address.h" #include "src/core/util/ref_counted.h" #include "src/core/util/ref_counted_ptr.h" #include "src/core/util/useful.h" +#include "absl/strings/string_view.h" namespace grpc_core { diff --git a/deps/grpc/src/core/client_channel/subchannel_stream_client.cc b/deps/grpc/src/core/client_channel/subchannel_stream_client.cc index 7c054687d28..59cb1d1ce1b 100644 --- a/deps/grpc/src/core/client_channel/subchannel_stream_client.cc +++ b/deps/grpc/src/core/client_channel/subchannel_stream_client.cc @@ -23,7 +23,6 @@ #include -#include "absl/log/log.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/resource_quota/resource_quota.h" @@ -34,6 +33,7 @@ #include "src/core/util/sync.h" #include "src/core/util/time.h" #include "src/core/util/time_precise.h" +#include "absl/log/log.h" #define SUBCHANNEL_STREAM_INITIAL_CONNECT_BACKOFF_SECONDS 1 #define SUBCHANNEL_STREAM_RECONNECT_BACKOFF_MULTIPLIER 1.6 diff --git a/deps/grpc/src/core/client_channel/subchannel_stream_client.h b/deps/grpc/src/core/client_channel/subchannel_stream_client.h index 28f2d3b2cc1..99571d6425f 100644 --- a/deps/grpc/src/core/client_channel/subchannel_stream_client.h +++ b/deps/grpc/src/core/client_channel/subchannel_stream_client.h @@ -27,9 +27,6 @@ #include #include -#include "absl/base/thread_annotations.h" -#include "absl/status/status.h" -#include "absl/strings/string_view.h" #include "src/core/call/metadata_batch.h" #include "src/core/client_channel/subchannel.h" #include "src/core/lib/iomgr/call_combiner.h" @@ -46,6 +43,9 @@ #include "src/core/util/orphanable.h" #include "src/core/util/ref_counted_ptr.h" #include "src/core/util/sync.h" +#include "absl/base/thread_annotations.h" +#include "absl/status/status.h" +#include "absl/strings/string_view.h" namespace grpc_core { diff --git a/deps/grpc/src/core/config/config_vars.cc b/deps/grpc/src/core/config/config_vars.cc index c6362fc43b1..b8cd2695638 100644 --- a/deps/grpc/src/core/config/config_vars.cc +++ b/deps/grpc/src/core/config/config_vars.cc @@ -20,10 +20,10 @@ #include +#include "src/core/config/load_config.h" #include "absl/flags/flag.h" #include "absl/strings/escaping.h" #include "absl/types/optional.h" -#include "src/core/config/load_config.h" #ifndef GPR_DEFAULT_LOG_VERBOSITY_STRING #define GPR_DEFAULT_LOG_VERBOSITY_STRING "" @@ -86,6 +86,9 @@ ABSL_FLAG( "EXPERIMENTAL: If non-zero, extend the lifetime of channelz nodes past the " "underlying object lifetime, up to this many nodes. The value may be " "adjusted slightly to account for implementation limits."); +ABSL_FLAG(absl::optional, grpc_channelz_call_tracer, {}, + "EXPERIMENTAL: If true, channelz will allow inspecting calls as well " + "as channels."); ABSL_FLAG(absl::optional, grpc_experimental_target_memory_pressure, {}, "EXPERIMENTAL: The target pressure for the memory quota pressure " "controller. This is a value between 0 and 1."); @@ -131,6 +134,9 @@ ConfigVars::ConfigVars(const Overrides& overrides) LoadConfig(FLAGS_grpc_cpp_experimental_disable_reflection, "GRPC_CPP_EXPERIMENTAL_DISABLE_REFLECTION", overrides.cpp_experimental_disable_reflection, false)), + channelz_call_tracer_(LoadConfig(FLAGS_grpc_channelz_call_tracer, + "GRPC_CHANNELZ_CALL_TRACER", + overrides.channelz_call_tracer, false)), dns_resolver_(LoadConfig(FLAGS_grpc_dns_resolver, "GRPC_DNS_RESOLVER", overrides.dns_resolver, "")), verbosity_(LoadConfig(FLAGS_grpc_verbosity, "GRPC_VERBOSITY", @@ -184,10 +190,10 @@ std::string ConfigVars::ToString() const { ", cpp_experimental_disable_reflection: ", CppExperimentalDisableReflection() ? "true" : "false", ", channelz_max_orphaned_nodes: ", ChannelzMaxOrphanedNodes(), + ", channelz_call_tracer: ", ChannelzCallTracer() ? "true" : "false", ", experimental_target_memory_pressure: ", ExperimentalTargetMemoryPressure(), ", experimental_memory_pressure_threshold: ", ExperimentalMemoryPressureThreshold()); } - } // namespace grpc_core diff --git a/deps/grpc/src/core/config/config_vars.h b/deps/grpc/src/core/config/config_vars.h index 39cee2d7a99..e2e9ed3ab72 100644 --- a/deps/grpc/src/core/config/config_vars.h +++ b/deps/grpc/src/core/config/config_vars.h @@ -43,6 +43,7 @@ class GPR_DLL ConfigVars { absl::optional use_system_roots_over_language_callback; absl::optional not_use_system_ssl_roots; absl::optional cpp_experimental_disable_reflection; + absl::optional channelz_call_tracer; absl::optional dns_resolver; absl::optional verbosity; absl::optional poll_strategy; @@ -118,6 +119,9 @@ class GPR_DLL ConfigVars { int32_t ChannelzMaxOrphanedNodes() const { return channelz_max_orphaned_nodes_; } + // EXPERIMENTAL: If true, channelz will allow inspecting calls as well as + // channels. + bool ChannelzCallTracer() const { return channelz_call_tracer_; } // EXPERIMENTAL: The target pressure for the memory quota pressure controller. // This is a value between 0 and 1. double ExperimentalTargetMemoryPressure() const { @@ -143,6 +147,7 @@ class GPR_DLL ConfigVars { bool use_system_roots_over_language_callback_; bool not_use_system_ssl_roots_; bool cpp_experimental_disable_reflection_; + bool channelz_call_tracer_; std::string dns_resolver_; std::string verbosity_; std::string poll_strategy_; diff --git a/deps/grpc/src/core/config/config_vars.yaml b/deps/grpc/src/core/config/config_vars.yaml index a4c70c82519..5867a7e6fcc 100644 --- a/deps/grpc/src/core/config/config_vars.yaml +++ b/deps/grpc/src/core/config/config_vars.yaml @@ -134,6 +134,12 @@ description: "EXPERIMENTAL: \ If non-zero, extend the lifetime of channelz nodes past the underlying object lifetime, up to this many nodes. \ The value may be adjusted slightly to account for implementation limits." +- name: channelz_call_tracer + type: bool + default: false + fuzz: true + description: "EXPERIMENTAL: \ + If true, channelz will allow inspecting calls as well as channels." - name: experimental_target_memory_pressure type: double default: 0.95 diff --git a/deps/grpc/src/core/config/core_configuration.h b/deps/grpc/src/core/config/core_configuration.h index 60a733da4a7..a169f3efc26 100644 --- a/deps/grpc/src/core/config/core_configuration.h +++ b/deps/grpc/src/core/config/core_configuration.h @@ -20,7 +20,6 @@ #include -#include "absl/functional/any_invocable.h" #include "src/core/credentials/call/call_creds_registry.h" #include "src/core/credentials/transport/channel_creds_registry.h" #include "src/core/credentials/transport/tls/certificate_provider_registry.h" @@ -35,6 +34,7 @@ #include "src/core/transport/endpoint_transport.h" #include "src/core/util/debug_location.h" #include "src/core/util/grpc_check.h" +#include "absl/functional/any_invocable.h" namespace grpc_core { diff --git a/deps/grpc/src/core/config/load_config.cc b/deps/grpc/src/core/config/load_config.cc index 1119128ff03..f17eba63425 100644 --- a/deps/grpc/src/core/config/load_config.cc +++ b/deps/grpc/src/core/config/load_config.cc @@ -19,11 +19,11 @@ #include +#include "src/core/util/env.h" #include "absl/flags/marshalling.h" #include "absl/log/check.h" #include "absl/strings/numbers.h" #include "absl/strings/str_join.h" -#include "src/core/util/env.h" namespace grpc_core { diff --git a/deps/grpc/src/core/credentials/call/call_credentials.h b/deps/grpc/src/core/credentials/call/call_credentials.h index 7d2c4e4a3d4..bebe0dde078 100644 --- a/deps/grpc/src/core/credentials/call/call_credentials.h +++ b/deps/grpc/src/core/credentials/call/call_credentials.h @@ -28,8 +28,6 @@ #include #include -#include "absl/status/statusor.h" -#include "absl/strings/string_view.h" #include "src/core/credentials/transport/security_connector.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/promise/arena_promise.h" @@ -41,6 +39,8 @@ #include "src/core/util/ref_counted.h" #include "src/core/util/ref_counted_ptr.h" #include "src/core/util/unique_type_name.h" +#include "absl/status/statusor.h" +#include "absl/strings/string_view.h" // --- Constants. --- diff --git a/deps/grpc/src/core/credentials/call/call_creds_registry.h b/deps/grpc/src/core/credentials/call/call_creds_registry.h index dee6b3d7792..558d376099f 100644 --- a/deps/grpc/src/core/credentials/call/call_creds_registry.h +++ b/deps/grpc/src/core/credentials/call/call_creds_registry.h @@ -22,12 +22,12 @@ #include #include -#include "absl/strings/string_view.h" #include "src/core/util/json/json.h" #include "src/core/util/json/json_args.h" #include "src/core/util/ref_counted.h" #include "src/core/util/ref_counted_ptr.h" #include "src/core/util/validation_errors.h" +#include "absl/strings/string_view.h" struct grpc_call_credentials; diff --git a/deps/grpc/src/core/credentials/call/call_creds_registry_init.cc b/deps/grpc/src/core/credentials/call/call_creds_registry_init.cc index 637d3aef138..345d7f6f3f7 100644 --- a/deps/grpc/src/core/credentials/call/call_creds_registry_init.cc +++ b/deps/grpc/src/core/credentials/call/call_creds_registry_init.cc @@ -22,8 +22,6 @@ #include #include -#include "absl/strings/str_cat.h" -#include "absl/strings/string_view.h" #include "src/core/config/core_configuration.h" #include "src/core/credentials/call/call_credentials.h" #include "src/core/credentials/call/call_creds_registry.h" @@ -34,6 +32,8 @@ #include "src/core/util/json/json_object_loader.h" #include "src/core/util/ref_counted_ptr.h" #include "src/core/util/validation_errors.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/string_view.h" namespace grpc_core { diff --git a/deps/grpc/src/core/credentials/call/call_creds_util.cc b/deps/grpc/src/core/credentials/call/call_creds_util.cc index b535784085b..15ea350b06b 100644 --- a/deps/grpc/src/core/credentials/call/call_creds_util.cc +++ b/deps/grpc/src/core/credentials/call/call_creds_util.cc @@ -20,14 +20,14 @@ #include #include -#include "absl/log/log.h" -#include "absl/strings/str_cat.h" -#include "absl/strings/string_view.h" #include "src/core/call/metadata_batch.h" #include "src/core/credentials/transport/security_connector.h" #include "src/core/transport/auth_context.h" #include "src/core/util/grpc_check.h" #include "src/core/util/ref_counted_ptr.h" +#include "absl/log/log.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/string_view.h" namespace grpc_core { diff --git a/deps/grpc/src/core/credentials/call/composite/composite_call_credentials.cc b/deps/grpc/src/core/credentials/call/composite/composite_call_credentials.cc index f7043e6f526..7675b651dd5 100644 --- a/deps/grpc/src/core/credentials/call/composite/composite_call_credentials.cc +++ b/deps/grpc/src/core/credentials/call/composite/composite_call_credentials.cc @@ -22,13 +22,13 @@ #include #include -#include "absl/strings/str_cat.h" -#include "absl/strings/str_join.h" #include "src/core/call/metadata_batch.h" #include "src/core/lib/debug/trace.h" #include "src/core/lib/promise/try_seq.h" #include "src/core/util/grpc_check.h" #include "src/core/util/ref_counted_ptr.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/str_join.h" grpc_core::ArenaPromise> grpc_composite_call_credentials::GetRequestMetadata( diff --git a/deps/grpc/src/core/credentials/call/composite/composite_call_credentials.h b/deps/grpc/src/core/credentials/call/composite/composite_call_credentials.h index 97677619013..5070d3e11c3 100644 --- a/deps/grpc/src/core/credentials/call/composite/composite_call_credentials.h +++ b/deps/grpc/src/core/credentials/call/composite/composite_call_credentials.h @@ -29,7 +29,6 @@ #include #include -#include "absl/status/statusor.h" #include "src/core/credentials/call/call_credentials.h" #include "src/core/credentials/transport/security_connector.h" #include "src/core/lib/channel/channel_args.h" @@ -38,6 +37,7 @@ #include "src/core/util/ref_counted_ptr.h" #include "src/core/util/unique_type_name.h" #include "src/core/util/useful.h" +#include "absl/status/statusor.h" class grpc_composite_call_credentials : public grpc_call_credentials { public: diff --git a/deps/grpc/src/core/credentials/call/external/aws_external_account_credentials.cc b/deps/grpc/src/core/credentials/call/external/aws_external_account_credentials.cc index 4fe33ef75fb..b582f936115 100644 --- a/deps/grpc/src/core/credentials/call/external/aws_external_account_credentials.cc +++ b/deps/grpc/src/core/credentials/call/external/aws_external_account_credentials.cc @@ -28,12 +28,6 @@ #include #include -#include "absl/status/status.h" -#include "absl/status/statusor.h" -#include "absl/strings/str_cat.h" -#include "absl/strings/str_format.h" -#include "absl/strings/str_replace.h" -#include "absl/strings/string_view.h" #include "src/core/credentials/transport/transport_credentials.h" #include "src/core/lib/iomgr/closure.h" #include "src/core/util/env.h" @@ -43,6 +37,12 @@ #include "src/core/util/json/json_reader.h" #include "src/core/util/json/json_writer.h" #include "src/core/util/uri.h" +#include "absl/status/status.h" +#include "absl/status/statusor.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/str_format.h" +#include "absl/strings/str_replace.h" +#include "absl/strings/string_view.h" namespace grpc_core { diff --git a/deps/grpc/src/core/credentials/call/external/aws_external_account_credentials.h b/deps/grpc/src/core/credentials/call/external/aws_external_account_credentials.h index 6b2f1b30f85..f33825527ad 100644 --- a/deps/grpc/src/core/credentials/call/external/aws_external_account_credentials.h +++ b/deps/grpc/src/core/credentials/call/external/aws_external_account_credentials.h @@ -24,7 +24,6 @@ #include #include -#include "absl/strings/string_view.h" #include "src/core/credentials/call/external/aws_request_signer.h" #include "src/core/credentials/call/external/external_account_credentials.h" #include "src/core/lib/iomgr/error.h" @@ -32,6 +31,7 @@ #include "src/core/util/http_client/parser.h" #include "src/core/util/orphanable.h" #include "src/core/util/ref_counted_ptr.h" +#include "absl/strings/string_view.h" namespace grpc_core { diff --git a/deps/grpc/src/core/credentials/call/external/external_account_credentials.cc b/deps/grpc/src/core/credentials/call/external/external_account_credentials.cc index 6fd765abd6a..523e27f82eb 100644 --- a/deps/grpc/src/core/credentials/call/external/external_account_credentials.cc +++ b/deps/grpc/src/core/credentials/call/external/external_account_credentials.cc @@ -29,6 +29,18 @@ #include #include +#include "src/core/credentials/call/external/aws_external_account_credentials.h" +#include "src/core/credentials/call/external/file_external_account_credentials.h" +#include "src/core/credentials/call/external/url_external_account_credentials.h" +#include "src/core/credentials/call/json_util.h" +#include "src/core/credentials/transport/transport_credentials.h" +#include "src/core/util/grpc_check.h" +#include "src/core/util/http_client/httpcli_ssl_credentials.h" +#include "src/core/util/http_client/parser.h" +#include "src/core/util/json/json_reader.h" +#include "src/core/util/json/json_writer.h" +#include "src/core/util/status_helper.h" +#include "src/core/util/uri.h" #include "absl/log/log.h" #include "absl/status/status.h" #include "absl/status/statusor.h" @@ -42,18 +54,6 @@ #include "absl/strings/strip.h" #include "absl/time/clock.h" #include "absl/time/time.h" -#include "src/core/credentials/call/external/aws_external_account_credentials.h" -#include "src/core/credentials/call/external/file_external_account_credentials.h" -#include "src/core/credentials/call/external/url_external_account_credentials.h" -#include "src/core/credentials/call/json_util.h" -#include "src/core/credentials/transport/transport_credentials.h" -#include "src/core/util/grpc_check.h" -#include "src/core/util/http_client/httpcli_ssl_credentials.h" -#include "src/core/util/http_client/parser.h" -#include "src/core/util/json/json_reader.h" -#include "src/core/util/json/json_writer.h" -#include "src/core/util/status_helper.h" -#include "src/core/util/uri.h" #define EXTERNAL_ACCOUNT_CREDENTIALS_GRANT_TYPE \ "urn:ietf:params:oauth:grant-type:token-exchange" diff --git a/deps/grpc/src/core/credentials/call/external/external_account_credentials.h b/deps/grpc/src/core/credentials/call/external/external_account_credentials.h index ee5c69494b6..04223c0c4bb 100644 --- a/deps/grpc/src/core/credentials/call/external/external_account_credentials.h +++ b/deps/grpc/src/core/credentials/call/external/external_account_credentials.h @@ -26,7 +26,6 @@ #include #include -#include "absl/strings/string_view.h" #include "src/core/credentials/call/oauth2/oauth2_credentials.h" #include "src/core/credentials/call/token_fetcher/token_fetcher_credentials.h" #include "src/core/lib/iomgr/closure.h" @@ -38,6 +37,7 @@ #include "src/core/util/orphanable.h" #include "src/core/util/ref_counted_ptr.h" #include "src/core/util/time.h" +#include "absl/strings/string_view.h" namespace grpc_core { diff --git a/deps/grpc/src/core/credentials/call/external/file_external_account_credentials.cc b/deps/grpc/src/core/credentials/call/external/file_external_account_credentials.cc index 1bf73fd8ce2..41b17afd6bc 100644 --- a/deps/grpc/src/core/credentials/call/external/file_external_account_credentials.cc +++ b/deps/grpc/src/core/credentials/call/external/file_external_account_credentials.cc @@ -22,14 +22,14 @@ #include #include -#include "absl/status/status.h" -#include "absl/status/statusor.h" -#include "absl/strings/string_view.h" #include "src/core/lib/slice/slice.h" #include "src/core/lib/slice/slice_internal.h" #include "src/core/util/json/json.h" #include "src/core/util/json/json_reader.h" #include "src/core/util/load_file.h" +#include "absl/status/status.h" +#include "absl/status/statusor.h" +#include "absl/strings/string_view.h" namespace grpc_core { diff --git a/deps/grpc/src/core/credentials/call/external/file_external_account_credentials.h b/deps/grpc/src/core/credentials/call/external/file_external_account_credentials.h index bf64194f43c..ecb59e60548 100644 --- a/deps/grpc/src/core/credentials/call/external/file_external_account_credentials.h +++ b/deps/grpc/src/core/credentials/call/external/file_external_account_credentials.h @@ -23,10 +23,10 @@ #include #include -#include "absl/strings/string_view.h" #include "src/core/credentials/call/external/external_account_credentials.h" #include "src/core/lib/iomgr/error.h" #include "src/core/util/ref_counted_ptr.h" +#include "absl/strings/string_view.h" namespace grpc_core { diff --git a/deps/grpc/src/core/credentials/call/external/url_external_account_credentials.cc b/deps/grpc/src/core/credentials/call/external/url_external_account_credentials.cc index 58a19d4c231..dbe50201a07 100644 --- a/deps/grpc/src/core/credentials/call/external/url_external_account_credentials.cc +++ b/deps/grpc/src/core/credentials/call/external/url_external_account_credentials.cc @@ -27,12 +27,6 @@ #include #include -#include "absl/status/status.h" -#include "absl/status/statusor.h" -#include "absl/strings/str_cat.h" -#include "absl/strings/str_format.h" -#include "absl/strings/str_split.h" -#include "absl/strings/string_view.h" #include "src/core/credentials/call/call_credentials.h" #include "src/core/credentials/transport/transport_credentials.h" #include "src/core/lib/iomgr/closure.h" @@ -42,6 +36,12 @@ #include "src/core/util/http_client/parser.h" #include "src/core/util/json/json.h" #include "src/core/util/json/json_reader.h" +#include "absl/status/status.h" +#include "absl/status/statusor.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/str_format.h" +#include "absl/strings/str_split.h" +#include "absl/strings/string_view.h" namespace grpc_core { diff --git a/deps/grpc/src/core/credentials/call/external/url_external_account_credentials.h b/deps/grpc/src/core/credentials/call/external/url_external_account_credentials.h index f07e5b0caf3..d5b6d7419f3 100644 --- a/deps/grpc/src/core/credentials/call/external/url_external_account_credentials.h +++ b/deps/grpc/src/core/credentials/call/external/url_external_account_credentials.h @@ -24,13 +24,13 @@ #include #include -#include "absl/strings/string_view.h" #include "src/core/credentials/call/external/external_account_credentials.h" #include "src/core/lib/iomgr/error.h" #include "src/core/util/http_client/httpcli.h" #include "src/core/util/orphanable.h" #include "src/core/util/ref_counted_ptr.h" #include "src/core/util/uri.h" +#include "absl/strings/string_view.h" namespace grpc_core { diff --git a/deps/grpc/src/core/credentials/call/gcp_service_account_identity/gcp_service_account_identity_credentials.cc b/deps/grpc/src/core/credentials/call/gcp_service_account_identity/gcp_service_account_identity_credentials.cc index 725ae313005..c55de108a6f 100644 --- a/deps/grpc/src/core/credentials/call/gcp_service_account_identity/gcp_service_account_identity_credentials.cc +++ b/deps/grpc/src/core/credentials/call/gcp_service_account_identity/gcp_service_account_identity_credentials.cc @@ -16,19 +16,20 @@ #include "src/core/credentials/call/gcp_service_account_identity/gcp_service_account_identity_credentials.h" -#include "absl/functional/any_invocable.h" -#include "absl/status/status.h" -#include "absl/status/statusor.h" -#include "absl/strings/str_cat.h" -#include "absl/strings/string_view.h" #include "src/core/call/metadata.h" #include "src/core/credentials/call/jwt_util.h" +#include "src/core/credentials/call/token_fetcher/token_fetcher_credentials.h" #include "src/core/credentials/transport/transport_credentials.h" #include "src/core/lib/iomgr/error.h" #include "src/core/lib/transport/status_conversion.h" #include "src/core/util/ref_counted_ptr.h" #include "src/core/util/status_helper.h" #include "src/core/util/uri.h" +#include "absl/functional/any_invocable.h" +#include "absl/status/status.h" +#include "absl/status/statusor.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/string_view.h" namespace grpc_core { @@ -36,78 +37,30 @@ namespace grpc_core { // JwtTokenFetcherCallCredentials // -// State held for a pending HTTP request. -class JwtTokenFetcherCallCredentials::HttpFetchRequest final - : public TokenFetcherCredentials::FetchRequest { - public: - HttpFetchRequest( - JwtTokenFetcherCallCredentials* creds, Timestamp deadline, - absl::AnyInvocable< - void(absl::StatusOr>)> - on_done) - : on_done_(std::move(on_done)) { - GRPC_CLOSURE_INIT(&on_http_response_, OnHttpResponse, this, nullptr); - Ref().release(); // Ref held by HTTP request callback. - http_request_ = creds->StartHttpRequest(creds->pollent(), deadline, - &response_, &on_http_response_); - } - - ~HttpFetchRequest() override { grpc_http_response_destroy(&response_); } - - void Orphan() override { - http_request_.reset(); - Unref(); - } - - private: - static void OnHttpResponse(void* arg, grpc_error_handle error) { - RefCountedPtr self(static_cast(arg)); - if (!error.ok()) { - // TODO(roth): It shouldn't be necessary to explicitly set the - // status to UNAVAILABLE here. Once the HTTP client code is - // migrated to stop using legacy grpc_error APIs to create - // statuses, we should be able to just propagate the status as-is. - self->on_done_(absl::UnavailableError(StatusToString(error))); - return; - } - if (self->response_.status != 200) { - grpc_status_code status_code = - grpc_http2_status_to_grpc_status(self->response_.status); - if (status_code != GRPC_STATUS_UNAVAILABLE) { - status_code = GRPC_STATUS_UNAUTHENTICATED; - } - self->on_done_(absl::Status(static_cast(status_code), - absl::StrCat("JWT fetch failed with status ", - self->response_.status))); - return; - } - // Return token object. - absl::string_view body(self->response_.body, self->response_.body_length); - auto expiration_time = GetJwtExpirationTime(body); - if (!expiration_time.ok()) { - self->on_done_(expiration_time.status()); - return; - } - self->on_done_(MakeRefCounted( - Slice::FromCopiedString(absl::StrCat("Bearer ", body)), - *expiration_time)); - } - - OrphanablePtr http_request_; - grpc_closure on_http_response_; - grpc_http_response response_; - absl::AnyInvocable>)> - on_done_; -}; - OrphanablePtr JwtTokenFetcherCallCredentials::FetchToken( Timestamp deadline, absl::AnyInvocable< void(absl::StatusOr>)> on_done) { - return MakeOrphanable(this, deadline, std::move(on_done)); + return MakeOrphanable( + this, deadline, + [on_done = std::move(on_done)]( + absl::StatusOr response) mutable { + if (!response.ok()) { + on_done(response.status()); + return; + } + absl::string_view body(response->body, response->body_length); + auto expiration_time = GetJwtExpirationTime(body); + if (!expiration_time.ok()) { + on_done(expiration_time.status()); + return; + } + on_done(MakeRefCounted( + Slice::FromCopiedString(absl::StrCat("Bearer ", body)), + *expiration_time)); + }); } // diff --git a/deps/grpc/src/core/credentials/call/gcp_service_account_identity/gcp_service_account_identity_credentials.h b/deps/grpc/src/core/credentials/call/gcp_service_account_identity/gcp_service_account_identity_credentials.h index 83c21327bf8..bf1f00de99f 100644 --- a/deps/grpc/src/core/credentials/call/gcp_service_account_identity/gcp_service_account_identity_credentials.h +++ b/deps/grpc/src/core/credentials/call/gcp_service_account_identity/gcp_service_account_identity_credentials.h @@ -40,20 +40,13 @@ namespace grpc_core { // A base class for JWT token fetching credentials. // Subclasses must implement StartHttpRequest(). -class JwtTokenFetcherCallCredentials : public TokenFetcherCredentials { +class JwtTokenFetcherCallCredentials : public HttpTokenFetcherCredentials { public: OrphanablePtr FetchToken( Timestamp deadline, absl::AnyInvocable< void(absl::StatusOr>)> on_done) final; - - private: - class HttpFetchRequest; - - virtual OrphanablePtr StartHttpRequest( - grpc_polling_entity* pollent, Timestamp deadline, - grpc_http_response* response, grpc_closure* on_complete) = 0; }; // GCP service account identity call credentials. diff --git a/deps/grpc/src/core/credentials/call/iam/iam_credentials.cc b/deps/grpc/src/core/credentials/call/iam/iam_credentials.cc index 3a2b3632278..cf78f204de8 100644 --- a/deps/grpc/src/core/credentials/call/iam/iam_credentials.cc +++ b/deps/grpc/src/core/credentials/call/iam/iam_credentials.cc @@ -24,14 +24,14 @@ #include #include -#include "absl/strings/str_format.h" -#include "absl/strings/string_view.h" #include "src/core/call/metadata_batch.h" #include "src/core/lib/debug/trace.h" #include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/promise/promise.h" #include "src/core/util/grpc_check.h" #include "src/core/util/ref_counted_ptr.h" +#include "absl/strings/str_format.h" +#include "absl/strings/string_view.h" grpc_core::ArenaPromise> grpc_google_iam_credentials::GetRequestMetadata( diff --git a/deps/grpc/src/core/credentials/call/iam/iam_credentials.h b/deps/grpc/src/core/credentials/call/iam/iam_credentials.h index 0aff40a54ed..e5bd566450d 100644 --- a/deps/grpc/src/core/credentials/call/iam/iam_credentials.h +++ b/deps/grpc/src/core/credentials/call/iam/iam_credentials.h @@ -26,13 +26,13 @@ #include #include -#include "absl/status/statusor.h" #include "src/core/credentials/call/call_credentials.h" #include "src/core/lib/promise/arena_promise.h" #include "src/core/lib/slice/slice.h" #include "src/core/lib/transport/transport.h" #include "src/core/util/unique_type_name.h" #include "src/core/util/useful.h" +#include "absl/status/statusor.h" class grpc_google_iam_credentials : public grpc_call_credentials { public: diff --git a/deps/grpc/src/core/credentials/call/json_util.cc b/deps/grpc/src/core/credentials/call/json_util.cc index 9e6bc13c5ae..bdb0d7b4a4a 100644 --- a/deps/grpc/src/core/credentials/call/json_util.cc +++ b/deps/grpc/src/core/credentials/call/json_util.cc @@ -26,8 +26,8 @@ #include #include -#include "absl/strings/str_cat.h" #include "src/core/lib/iomgr/error.h" +#include "absl/strings/str_cat.h" const char* grpc_json_get_string_property(const grpc_core::Json& json, const char* prop_name, diff --git a/deps/grpc/src/core/credentials/call/jwt/json_token.cc b/deps/grpc/src/core/credentials/call/jwt/json_token.cc index 54db4438ff6..97fe15bc319 100644 --- a/deps/grpc/src/core/credentials/call/jwt/json_token.cc +++ b/deps/grpc/src/core/credentials/call/jwt/json_token.cc @@ -35,15 +35,15 @@ #include #include -#include "absl/log/log.h" -#include "absl/status/status.h" -#include "absl/status/statusor.h" -#include "absl/strings/escaping.h" #include "src/core/credentials/call/json_util.h" #include "src/core/lib/iomgr/error.h" #include "src/core/util/grpc_check.h" #include "src/core/util/json/json_reader.h" #include "src/core/util/json/json_writer.h" +#include "absl/log/log.h" +#include "absl/status/status.h" +#include "absl/status/statusor.h" +#include "absl/strings/escaping.h" using grpc_core::Json; diff --git a/deps/grpc/src/core/credentials/call/jwt/jwt_credentials.cc b/deps/grpc/src/core/credentials/call/jwt/jwt_credentials.cc index 3c8ab4dbfb3..a53d9a49634 100644 --- a/deps/grpc/src/core/credentials/call/jwt/jwt_credentials.cc +++ b/deps/grpc/src/core/credentials/call/jwt/jwt_credentials.cc @@ -30,9 +30,6 @@ #include #include -#include "absl/log/log.h" -#include "absl/status/status.h" -#include "absl/strings/str_cat.h" #include "src/core/call/metadata_batch.h" #include "src/core/credentials/call/call_creds_util.h" #include "src/core/lib/debug/trace.h" @@ -44,6 +41,9 @@ #include "src/core/util/json/json_writer.h" #include "src/core/util/ref_counted_ptr.h" #include "src/core/util/uri.h" +#include "absl/log/log.h" +#include "absl/status/status.h" +#include "absl/strings/str_cat.h" using grpc_core::Json; diff --git a/deps/grpc/src/core/credentials/call/jwt/jwt_credentials.h b/deps/grpc/src/core/credentials/call/jwt/jwt_credentials.h index 51b4ac54c69..75941ccc2af 100644 --- a/deps/grpc/src/core/credentials/call/jwt/jwt_credentials.h +++ b/deps/grpc/src/core/credentials/call/jwt/jwt_credentials.h @@ -29,10 +29,6 @@ #include #include -#include "absl/status/statusor.h" -#include "absl/strings/str_format.h" -#include "absl/strings/string_view.h" -#include "absl/time/time.h" #include "src/core/credentials/call/call_credentials.h" #include "src/core/credentials/call/jwt/json_token.h" #include "src/core/lib/promise/arena_promise.h" @@ -41,6 +37,10 @@ #include "src/core/util/ref_counted_ptr.h" #include "src/core/util/unique_type_name.h" #include "src/core/util/useful.h" +#include "absl/status/statusor.h" +#include "absl/strings/str_format.h" +#include "absl/strings/string_view.h" +#include "absl/time/time.h" class grpc_service_account_jwt_access_credentials : public grpc_call_credentials { diff --git a/deps/grpc/src/core/credentials/call/jwt/jwt_verifier.cc b/deps/grpc/src/core/credentials/call/jwt/jwt_verifier.cc index 24093fdf080..b8e871730ba 100644 --- a/deps/grpc/src/core/credentials/call/jwt/jwt_verifier.cc +++ b/deps/grpc/src/core/credentials/call/jwt/jwt_verifier.cc @@ -45,11 +45,6 @@ #include #include -#include "absl/log/log.h" -#include "absl/status/status.h" -#include "absl/status/statusor.h" -#include "absl/strings/escaping.h" -#include "absl/strings/string_view.h" #include "src/core/credentials/call/call_credentials.h" // IWYU pragma: keep #include "src/core/credentials/transport/transport_credentials.h" // IWYU pragma: keep #include "src/core/lib/iomgr/closure.h" @@ -70,6 +65,11 @@ #include "src/core/util/orphanable.h" #include "src/core/util/string.h" #include "src/core/util/uri.h" +#include "absl/log/log.h" +#include "absl/status/status.h" +#include "absl/status/statusor.h" +#include "absl/strings/escaping.h" +#include "absl/strings/string_view.h" using grpc_core::Json; diff --git a/deps/grpc/src/core/credentials/call/jwt_token_file/jwt_token_file_call_credentials.cc b/deps/grpc/src/core/credentials/call/jwt_token_file/jwt_token_file_call_credentials.cc index d694b2ee260..74bc48a574c 100644 --- a/deps/grpc/src/core/credentials/call/jwt_token_file/jwt_token_file_call_credentials.cc +++ b/deps/grpc/src/core/credentials/call/jwt_token_file/jwt_token_file_call_credentials.cc @@ -16,10 +16,10 @@ #include "src/core/credentials/call/jwt_token_file/jwt_token_file_call_credentials.h" -#include "absl/status/status.h" -#include "absl/strings/str_cat.h" #include "src/core/credentials/call/jwt_util.h" #include "src/core/util/load_file.h" +#include "absl/status/status.h" +#include "absl/strings/str_cat.h" namespace grpc_core { diff --git a/deps/grpc/src/core/credentials/call/jwt_token_file/jwt_token_file_call_credentials.h b/deps/grpc/src/core/credentials/call/jwt_token_file/jwt_token_file_call_credentials.h index 4de8b911f98..4f8ca55c23c 100644 --- a/deps/grpc/src/core/credentials/call/jwt_token_file/jwt_token_file_call_credentials.h +++ b/deps/grpc/src/core/credentials/call/jwt_token_file/jwt_token_file_call_credentials.h @@ -22,15 +22,15 @@ #include -#include "absl/functional/any_invocable.h" -#include "absl/status/statusor.h" -#include "absl/strings/string_view.h" #include "src/core/credentials/call/call_credentials.h" #include "src/core/credentials/call/token_fetcher/token_fetcher_credentials.h" #include "src/core/util/orphanable.h" #include "src/core/util/ref_counted_ptr.h" #include "src/core/util/time.h" #include "src/core/util/unique_type_name.h" +#include "absl/functional/any_invocable.h" +#include "absl/status/statusor.h" +#include "absl/strings/string_view.h" namespace grpc_core { diff --git a/deps/grpc/src/core/credentials/call/jwt_util.cc b/deps/grpc/src/core/credentials/call/jwt_util.cc index 7c5f6fd41e0..c3ea58da0c3 100644 --- a/deps/grpc/src/core/credentials/call/jwt_util.cc +++ b/deps/grpc/src/core/credentials/call/jwt_util.cc @@ -21,13 +21,13 @@ #include #include -#include "absl/status/status.h" -#include "absl/strings/escaping.h" -#include "absl/strings/str_split.h" #include "src/core/util/json/json.h" #include "src/core/util/json/json_args.h" #include "src/core/util/json/json_object_loader.h" #include "src/core/util/json/json_reader.h" +#include "absl/status/status.h" +#include "absl/strings/escaping.h" +#include "absl/strings/str_split.h" namespace grpc_core { diff --git a/deps/grpc/src/core/credentials/call/jwt_util.h b/deps/grpc/src/core/credentials/call/jwt_util.h index a1a96c20ebc..d300a09178c 100644 --- a/deps/grpc/src/core/credentials/call/jwt_util.h +++ b/deps/grpc/src/core/credentials/call/jwt_util.h @@ -17,9 +17,9 @@ #ifndef GRPC_SRC_CORE_CREDENTIALS_CALL_JWT_UTIL_H #define GRPC_SRC_CORE_CREDENTIALS_CALL_JWT_UTIL_H +#include "src/core/util/time.h" #include "absl/status/statusor.h" #include "absl/strings/string_view.h" -#include "src/core/util/time.h" namespace grpc_core { diff --git a/deps/grpc/src/core/credentials/call/oauth2/oauth2_credentials.cc b/deps/grpc/src/core/credentials/call/oauth2/oauth2_credentials.cc index c059ff42718..6e22abbfc4e 100644 --- a/deps/grpc/src/core/credentials/call/oauth2/oauth2_credentials.cc +++ b/deps/grpc/src/core/credentials/call/oauth2/oauth2_credentials.cc @@ -35,15 +35,9 @@ #include #include -#include "absl/log/log.h" -#include "absl/status/status.h" -#include "absl/strings/numbers.h" -#include "absl/strings/str_cat.h" -#include "absl/strings/str_format.h" -#include "absl/strings/str_join.h" -#include "absl/strings/string_view.h" #include "src/core/call/metadata_batch.h" #include "src/core/credentials/call/json_util.h" +#include "src/core/credentials/call/token_fetcher/token_fetcher_credentials.h" #include "src/core/credentials/transport/transport_credentials.h" #include "src/core/lib/debug/trace.h" #include "src/core/lib/iomgr/error.h" @@ -61,6 +55,13 @@ #include "src/core/util/ref_counted_ptr.h" #include "src/core/util/status_helper.h" #include "src/core/util/uri.h" +#include "absl/log/log.h" +#include "absl/status/status.h" +#include "absl/strings/numbers.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/str_format.h" +#include "absl/strings/str_join.h" +#include "absl/strings/string_view.h" using grpc_core::Json; @@ -211,58 +212,6 @@ grpc_oauth2_token_fetcher_credentials_parse_server_response( namespace grpc_core { -// State held for a pending HTTP request. -class Oauth2TokenFetcherCredentials::HttpFetchRequest final - : public TokenFetcherCredentials::FetchRequest { - public: - HttpFetchRequest( - Oauth2TokenFetcherCredentials* creds, Timestamp deadline, - absl::AnyInvocable< - void(absl::StatusOr>)> - on_done) - : on_done_(std::move(on_done)) { - GRPC_CLOSURE_INIT(&on_http_response_, OnHttpResponse, this, nullptr); - Ref().release(); // Ref held by HTTP request callback. - http_request_ = creds->StartHttpRequest(creds->pollent(), deadline, - &response_, &on_http_response_); - } - - ~HttpFetchRequest() override { grpc_http_response_destroy(&response_); } - - void Orphan() override { - http_request_.reset(); - Unref(); - } - - private: - static void OnHttpResponse(void* arg, grpc_error_handle error) { - RefCountedPtr self(static_cast(arg)); - if (!error.ok()) { - self->on_done_(std::move(error)); - return; - } - // Parse oauth2 token. - std::optional access_token_value; - Duration token_lifetime; - grpc_credentials_status status = - grpc_oauth2_token_fetcher_credentials_parse_server_response( - &self->response_, &access_token_value, &token_lifetime); - if (status != GRPC_CREDENTIALS_OK) { - self->on_done_(absl::UnavailableError("error parsing oauth2 token")); - return; - } - self->on_done_(MakeRefCounted(std::move(*access_token_value), - Timestamp::Now() + token_lifetime)); - } - - OrphanablePtr http_request_; - grpc_closure on_http_response_; - grpc_http_response response_; - absl::AnyInvocable>)> - on_done_; -}; - std::string Oauth2TokenFetcherCredentials::debug_string() { return "OAuth2TokenFetcherCredentials"; } @@ -278,7 +227,27 @@ Oauth2TokenFetcherCredentials::FetchToken( absl::AnyInvocable< void(absl::StatusOr>)> on_done) { - return MakeOrphanable(this, deadline, std::move(on_done)); + return MakeOrphanable( + this, deadline, + [on_done = std::move(on_done)]( + absl::StatusOr response) mutable { + if (!response.ok()) { + on_done(response.status()); + return; + } + // Parse oauth2 token. + std::optional access_token_value; + Duration token_lifetime; + grpc_credentials_status status = + grpc_oauth2_token_fetcher_credentials_parse_server_response( + &(*response), &access_token_value, &token_lifetime); + if (status != GRPC_CREDENTIALS_OK) { + on_done(absl::UnavailableError("error parsing oauth2 token")); + return; + } + on_done(MakeRefCounted(std::move(*access_token_value), + Timestamp::Now() + token_lifetime)); + }); } } // namespace grpc_core diff --git a/deps/grpc/src/core/credentials/call/oauth2/oauth2_credentials.h b/deps/grpc/src/core/credentials/call/oauth2/oauth2_credentials.h index a29ddff6d49..eab7499b5fd 100644 --- a/deps/grpc/src/core/credentials/call/oauth2/oauth2_credentials.h +++ b/deps/grpc/src/core/credentials/call/oauth2/oauth2_credentials.h @@ -30,8 +30,6 @@ #include #include -#include "absl/status/statusor.h" -#include "absl/strings/string_view.h" #include "src/core/credentials/call/call_credentials.h" #include "src/core/credentials/call/token_fetcher/token_fetcher_credentials.h" #include "src/core/lib/iomgr/closure.h" @@ -51,6 +49,8 @@ #include "src/core/util/unique_type_name.h" #include "src/core/util/uri.h" #include "src/core/util/useful.h" +#include "absl/status/statusor.h" +#include "absl/strings/string_view.h" // Constants. #define GRPC_STS_POST_MINIMAL_BODY_FORMAT_STRING \ @@ -90,7 +90,7 @@ namespace grpc_core { // A base class for oauth2 token fetching credentials. // Subclasses must implement StartHttpRequest(). -class Oauth2TokenFetcherCredentials : public TokenFetcherCredentials { +class Oauth2TokenFetcherCredentials : public HttpTokenFetcherCredentials { public: std::string debug_string() override; @@ -102,13 +102,7 @@ class Oauth2TokenFetcherCredentials : public TokenFetcherCredentials { void(absl::StatusOr>)> on_done) final; - virtual OrphanablePtr StartHttpRequest( - grpc_polling_entity* pollent, Timestamp deadline, - grpc_http_response* response, grpc_closure* on_complete) = 0; - private: - class HttpFetchRequest; - int cmp_impl(const grpc_call_credentials* other) const override { // TODO(yashykt): Check if we can do something better here return QsortCompare(static_cast(this), other); diff --git a/deps/grpc/src/core/credentials/call/plugin/plugin_credentials.cc b/deps/grpc/src/core/credentials/call/plugin/plugin_credentials.cc index 9be5604ffe0..d7050c255da 100644 --- a/deps/grpc/src/core/credentials/call/plugin/plugin_credentials.cc +++ b/deps/grpc/src/core/credentials/call/plugin/plugin_credentials.cc @@ -24,10 +24,6 @@ #include #include -#include "absl/log/log.h" -#include "absl/status/status.h" -#include "absl/strings/str_cat.h" -#include "absl/strings/string_view.h" #include "src/core/call/metadata_batch.h" #include "src/core/lib/iomgr/error.h" #include "src/core/lib/iomgr/exec_ctx.h" @@ -36,6 +32,10 @@ #include "src/core/lib/slice/slice_internal.h" #include "src/core/lib/surface/validate_metadata.h" #include "src/core/util/grpc_check.h" +#include "absl/log/log.h" +#include "absl/status/status.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/string_view.h" grpc_plugin_credentials::~grpc_plugin_credentials() { if (plugin_.state != nullptr && plugin_.destroy != nullptr) { diff --git a/deps/grpc/src/core/credentials/call/plugin/plugin_credentials.h b/deps/grpc/src/core/credentials/call/plugin/plugin_credentials.h index cf5fd6eb361..0bc7331bb7c 100644 --- a/deps/grpc/src/core/credentials/call/plugin/plugin_credentials.h +++ b/deps/grpc/src/core/credentials/call/plugin/plugin_credentials.h @@ -31,8 +31,6 @@ #include #include -#include "absl/container/inlined_vector.h" -#include "absl/status/statusor.h" #include "src/core/credentials/call/call_credentials.h" #include "src/core/credentials/call/call_creds_util.h" #include "src/core/lib/debug/trace.h" @@ -45,6 +43,8 @@ #include "src/core/util/ref_counted_ptr.h" #include "src/core/util/unique_type_name.h" #include "src/core/util/useful.h" +#include "absl/container/inlined_vector.h" +#include "absl/status/statusor.h" // This type is forward declared as a C struct and we cannot define it as a // class. Otherwise, compiler will complain about type mismatch due to diff --git a/deps/grpc/src/core/credentials/call/token_fetcher/token_fetcher_credentials.cc b/deps/grpc/src/core/credentials/call/token_fetcher/token_fetcher_credentials.cc index 19d8af614ee..cdb5792290b 100644 --- a/deps/grpc/src/core/credentials/call/token_fetcher/token_fetcher_credentials.cc +++ b/deps/grpc/src/core/credentials/call/token_fetcher/token_fetcher_credentials.cc @@ -24,6 +24,7 @@ #include "src/core/lib/promise/context.h" #include "src/core/lib/promise/poll.h" #include "src/core/lib/promise/promise.h" +#include "src/core/lib/transport/status_conversion.h" namespace grpc_core { @@ -301,4 +302,49 @@ TokenFetcherCredentials::GetRequestMetadata( }; } +// +// HttpTokenFetcherCredentials +// + +HttpTokenFetcherCredentials::HttpFetchRequest::HttpFetchRequest( + HttpTokenFetcherCredentials* creds, Timestamp deadline, + absl::AnyInvocable)> on_done) + : on_done_(std::move(on_done)) { + GRPC_CLOSURE_INIT(&on_http_response_, OnHttpResponse, this, nullptr); + Ref().release(); // Ref held by HTTP request callback. + http_request_ = creds->StartHttpRequest(creds->pollent(), deadline, + &response_, &on_http_response_); +} + +void HttpTokenFetcherCredentials::HttpFetchRequest::Orphan() { + http_request_.reset(); + Unref(); +} + +void HttpTokenFetcherCredentials::HttpFetchRequest::OnHttpResponse( + void* arg, grpc_error_handle error) { + RefCountedPtr self(static_cast(arg)); + if (!error.ok()) { + // TODO(roth): It shouldn't be necessary to explicitly set the + // status to UNAVAILABLE here. Once the HTTP client code is + // migrated to stop using legacy grpc_error APIs to create + // statuses, we should be able to just propagate the status as-is. + self->on_done_(absl::UnavailableError(StatusToString(error))); + return; + } + if (self->response_.status != 200) { + grpc_status_code status_code = + grpc_http2_status_to_grpc_status(self->response_.status); + if (status_code != GRPC_STATUS_UNAVAILABLE) { + status_code = GRPC_STATUS_UNAUTHENTICATED; + } + self->on_done_( + absl::Status(static_cast(status_code), + absl::StrCat("HTTP token fetch failed with status ", + self->response_.status))); + return; + } + self->on_done_(self->response_); +} + } // namespace grpc_core diff --git a/deps/grpc/src/core/credentials/call/token_fetcher/token_fetcher_credentials.h b/deps/grpc/src/core/credentials/call/token_fetcher/token_fetcher_credentials.h index 4cd66203c4a..5f02c25197d 100644 --- a/deps/grpc/src/core/credentials/call/token_fetcher/token_fetcher_credentials.h +++ b/deps/grpc/src/core/credentials/call/token_fetcher/token_fetcher_credentials.h @@ -24,9 +24,6 @@ #include #include -#include "absl/container/flat_hash_set.h" -#include "absl/functional/any_invocable.h" -#include "absl/status/statusor.h" #include "src/core/call/metadata.h" #include "src/core/credentials/call/call_credentials.h" #include "src/core/lib/iomgr/polling_entity.h" @@ -39,6 +36,9 @@ #include "src/core/util/sync.h" #include "src/core/util/time.h" #include "src/core/util/useful.h" +#include "absl/container/flat_hash_set.h" +#include "absl/functional/any_invocable.h" +#include "absl/status/statusor.h" namespace grpc_core { @@ -176,6 +176,35 @@ class TokenFetcherCredentials : public grpc_call_credentials { grpc_polling_entity pollent_ ABSL_GUARDED_BY(&mu_); }; +// A base class for fetching tokens via an HTTP request. +class HttpTokenFetcherCredentials : public TokenFetcherCredentials { + public: + virtual OrphanablePtr StartHttpRequest( + grpc_polling_entity* pollent, Timestamp deadline, + grpc_http_response* response, grpc_closure* on_complete) = 0; + + protected: + // State held for a pending HTTP request. + class HttpFetchRequest : public TokenFetcherCredentials::FetchRequest { + public: + // The given callback should assume the http response status has already + // been checked and handle the token parsing. + HttpFetchRequest( + HttpTokenFetcherCredentials* creds, Timestamp deadline, + absl::AnyInvocable)> on_done); + ~HttpFetchRequest() override { grpc_http_response_destroy(&response_); } + + void Orphan() override; + + private: + static void OnHttpResponse(void* arg, grpc_error_handle error); + OrphanablePtr http_request_; + grpc_closure on_http_response_; + grpc_http_response response_; + absl::AnyInvocable)> on_done_; + }; +}; + } // namespace grpc_core #endif // GRPC_SRC_CORE_CREDENTIALS_CALL_TOKEN_FETCHER_TOKEN_FETCHER_CREDENTIALS_H diff --git a/deps/grpc/src/core/credentials/transport/alts/alts_credentials.cc b/deps/grpc/src/core/credentials/transport/alts/alts_credentials.cc index fbfffc9d2fa..1866fd0c9f8 100644 --- a/deps/grpc/src/core/credentials/transport/alts/alts_credentials.cc +++ b/deps/grpc/src/core/credentials/transport/alts/alts_credentials.cc @@ -25,10 +25,10 @@ #include -#include "absl/log/log.h" #include "src/core/credentials/transport/alts/alts_security_connector.h" #include "src/core/credentials/transport/alts/check_gcp_environment.h" #include "src/core/credentials/transport/alts/grpc_alts_credentials_options.h" +#include "absl/log/log.h" #define GRPC_ALTS_HANDSHAKER_SERVICE_URL "dns:///metadata.google.internal.:8080" @@ -90,7 +90,7 @@ grpc_channel_credentials* grpc_alts_credentials_create_customized( const grpc_alts_credentials_options* options, const char* handshaker_service_url, bool enable_untrusted_alts) { if (!enable_untrusted_alts && !grpc_alts_is_running_on_gcp()) { - VLOG(1) << "ALTS creds ignored. Not running on GCP and untrusted ALTS " + VLOG(2) << "ALTS creds ignored. Not running on GCP and untrusted ALTS " "is not enabled."; return nullptr; } @@ -101,7 +101,7 @@ grpc_server_credentials* grpc_alts_server_credentials_create_customized( const grpc_alts_credentials_options* options, const char* handshaker_service_url, bool enable_untrusted_alts) { if (!enable_untrusted_alts && !grpc_alts_is_running_on_gcp()) { - VLOG(1) << "ALTS server creds ignored. Not running on GCP and untrusted " + VLOG(2) << "ALTS server creds ignored. Not running on GCP and untrusted " "ALTS is not enabled."; return nullptr; } diff --git a/deps/grpc/src/core/credentials/transport/alts/alts_security_connector.cc b/deps/grpc/src/core/credentials/transport/alts/alts_security_connector.cc index 49ed7a2a2b6..246309ee846 100644 --- a/deps/grpc/src/core/credentials/transport/alts/alts_security_connector.cc +++ b/deps/grpc/src/core/credentials/transport/alts/alts_security_connector.cc @@ -31,9 +31,6 @@ #include #include -#include "absl/log/log.h" -#include "absl/status/status.h" -#include "absl/strings/string_view.h" #include "src/core/credentials/transport/alts/alts_credentials.h" #include "src/core/credentials/transport/transport_credentials.h" #include "src/core/handshaker/handshaker.h" @@ -54,6 +51,9 @@ #include "src/core/util/debug_location.h" #include "src/core/util/grpc_check.h" #include "src/core/util/ref_counted_ptr.h" +#include "absl/log/log.h" +#include "absl/status/status.h" +#include "absl/strings/string_view.h" void grpc_alts_set_rpc_protocol_versions( grpc_gcp_rpc_protocol_versions* rpc_versions) { diff --git a/deps/grpc/src/core/credentials/transport/alts/check_gcp_environment_no_op.cc b/deps/grpc/src/core/credentials/transport/alts/check_gcp_environment_no_op.cc index c9bf0ebf92a..a284a10b5b5 100644 --- a/deps/grpc/src/core/credentials/transport/alts/check_gcp_environment_no_op.cc +++ b/deps/grpc/src/core/credentials/transport/alts/check_gcp_environment_no_op.cc @@ -20,9 +20,9 @@ #if !defined(GPR_LINUX) && !defined(GPR_WINDOWS) -#include "absl/log/log.h" #include "src/core/credentials/transport/alts/check_gcp_environment.h" #include "src/core/util/crash.h" +#include "absl/log/log.h" bool grpc_alts_is_running_on_gcp() { VLOG(2) << "ALTS: Platforms other than Linux and Windows are not supported"; diff --git a/deps/grpc/src/core/credentials/transport/alts/grpc_alts_credentials_client_options.cc b/deps/grpc/src/core/credentials/transport/alts/grpc_alts_credentials_client_options.cc index 807f1f2f24e..2d30b3a805f 100644 --- a/deps/grpc/src/core/credentials/transport/alts/grpc_alts_credentials_client_options.cc +++ b/deps/grpc/src/core/credentials/transport/alts/grpc_alts_credentials_client_options.cc @@ -25,9 +25,9 @@ #include #include -#include "absl/log/log.h" #include "src/core/credentials/transport/alts/grpc_alts_credentials_options.h" #include "src/core/tsi/alts/handshaker/transport_security_common_api.h" +#include "absl/log/log.h" static grpc_alts_credentials_options* alts_client_options_copy( const grpc_alts_credentials_options* options); diff --git a/deps/grpc/src/core/credentials/transport/alts/grpc_alts_credentials_options.h b/deps/grpc/src/core/credentials/transport/alts/grpc_alts_credentials_options.h index c1fa98b76a2..f5894c902f9 100644 --- a/deps/grpc/src/core/credentials/transport/alts/grpc_alts_credentials_options.h +++ b/deps/grpc/src/core/credentials/transport/alts/grpc_alts_credentials_options.h @@ -27,8 +27,8 @@ #include #include -#include "absl/status/statusor.h" #include "src/core/tsi/alts/handshaker/transport_security_common_api.h" +#include "absl/status/statusor.h" namespace grpc::alts { diff --git a/deps/grpc/src/core/credentials/transport/channel_creds_registry.h b/deps/grpc/src/core/credentials/transport/channel_creds_registry.h index 3d0981947fa..16ae8314b9c 100644 --- a/deps/grpc/src/core/credentials/transport/channel_creds_registry.h +++ b/deps/grpc/src/core/credentials/transport/channel_creds_registry.h @@ -24,12 +24,12 @@ #include #include -#include "absl/strings/string_view.h" #include "src/core/util/json/json.h" #include "src/core/util/json/json_args.h" #include "src/core/util/ref_counted.h" #include "src/core/util/ref_counted_ptr.h" #include "src/core/util/validation_errors.h" +#include "absl/strings/string_view.h" struct grpc_channel_credentials; diff --git a/deps/grpc/src/core/credentials/transport/channel_creds_registry_init.cc b/deps/grpc/src/core/credentials/transport/channel_creds_registry_init.cc index 79448e44e59..5ea3b0393e3 100644 --- a/deps/grpc/src/core/credentials/transport/channel_creds_registry_init.cc +++ b/deps/grpc/src/core/credentials/transport/channel_creds_registry_init.cc @@ -28,7 +28,6 @@ #include #include -#include "absl/strings/string_view.h" #include "src/core/config/core_configuration.h" #include "src/core/credentials/call/call_credentials.h" #include "src/core/credentials/transport/channel_creds_registry.h" @@ -43,6 +42,7 @@ #include "src/core/util/ref_counted_ptr.h" #include "src/core/util/time.h" #include "src/core/util/validation_errors.h" +#include "absl/strings/string_view.h" namespace grpc_core { diff --git a/deps/grpc/src/core/credentials/transport/composite/composite_channel_credentials.cc b/deps/grpc/src/core/credentials/transport/composite/composite_channel_credentials.cc index 7d66d04d567..6529eae3e94 100644 --- a/deps/grpc/src/core/credentials/transport/composite/composite_channel_credentials.cc +++ b/deps/grpc/src/core/credentials/transport/composite/composite_channel_credentials.cc @@ -22,14 +22,14 @@ #include #include -#include "absl/strings/str_cat.h" -#include "absl/strings/str_join.h" #include "src/core/call/metadata_batch.h" #include "src/core/credentials/call/composite/composite_call_credentials.h" #include "src/core/lib/debug/trace.h" #include "src/core/lib/promise/try_seq.h" #include "src/core/util/grpc_check.h" #include "src/core/util/ref_counted_ptr.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/str_join.h" grpc_core::UniqueTypeName grpc_composite_channel_credentials::Type() { static grpc_core::UniqueTypeName::Factory kFactory("Composite"); diff --git a/deps/grpc/src/core/credentials/transport/composite/composite_channel_credentials.h b/deps/grpc/src/core/credentials/transport/composite/composite_channel_credentials.h index de0fd19d2d2..add5fc1e10c 100644 --- a/deps/grpc/src/core/credentials/transport/composite/composite_channel_credentials.h +++ b/deps/grpc/src/core/credentials/transport/composite/composite_channel_credentials.h @@ -28,7 +28,6 @@ #include #include -#include "absl/status/statusor.h" #include "src/core/credentials/call/call_credentials.h" #include "src/core/credentials/transport/security_connector.h" #include "src/core/credentials/transport/transport_credentials.h" @@ -38,6 +37,7 @@ #include "src/core/util/ref_counted_ptr.h" #include "src/core/util/unique_type_name.h" #include "src/core/util/useful.h" +#include "absl/status/statusor.h" class grpc_composite_channel_credentials : public grpc_channel_credentials { public: diff --git a/deps/grpc/src/core/credentials/transport/fake/fake_credentials.cc b/deps/grpc/src/core/credentials/transport/fake/fake_credentials.cc index 465732bbea9..95b17f9f424 100644 --- a/deps/grpc/src/core/credentials/transport/fake/fake_credentials.cc +++ b/deps/grpc/src/core/credentials/transport/fake/fake_credentials.cc @@ -24,13 +24,13 @@ #include #include -#include "absl/strings/string_view.h" #include "src/core/call/metadata_batch.h" #include "src/core/credentials/transport/fake/fake_security_connector.h" #include "src/core/credentials/transport/security_connector.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/promise/promise.h" #include "src/core/util/ref_counted_ptr.h" +#include "absl/strings/string_view.h" // -- Fake transport security credentials. -- diff --git a/deps/grpc/src/core/credentials/transport/fake/fake_credentials.h b/deps/grpc/src/core/credentials/transport/fake/fake_credentials.h index a10852bea6b..e845a798626 100644 --- a/deps/grpc/src/core/credentials/transport/fake/fake_credentials.h +++ b/deps/grpc/src/core/credentials/transport/fake/fake_credentials.h @@ -27,7 +27,6 @@ #include -#include "absl/status/statusor.h" #include "src/core/credentials/transport/security_connector.h" #include "src/core/credentials/transport/transport_credentials.h" #include "src/core/lib/channel/channel_args.h" @@ -37,6 +36,7 @@ #include "src/core/util/ref_counted_ptr.h" #include "src/core/util/unique_type_name.h" #include "src/core/util/useful.h" +#include "absl/status/statusor.h" #define GRPC_ARG_FAKE_SECURITY_EXPECTED_TARGETS \ "grpc.fake_security.expected_targets" diff --git a/deps/grpc/src/core/credentials/transport/fake/fake_security_connector.cc b/deps/grpc/src/core/credentials/transport/fake/fake_security_connector.cc index 7caf0b3767b..1c4de4f131e 100644 --- a/deps/grpc/src/core/credentials/transport/fake/fake_security_connector.cc +++ b/deps/grpc/src/core/credentials/transport/fake/fake_security_connector.cc @@ -30,11 +30,6 @@ #include #include -#include "absl/log/log.h" -#include "absl/status/status.h" -#include "absl/strings/str_cat.h" -#include "absl/strings/str_format.h" -#include "absl/strings/string_view.h" #include "src/core/credentials/transport/fake/fake_credentials.h" #include "src/core/credentials/transport/transport_credentials.h" #include "src/core/handshaker/handshaker.h" @@ -58,6 +53,11 @@ #include "src/core/util/ref_counted_ptr.h" #include "src/core/util/string.h" #include "src/core/util/useful.h" +#include "absl/log/log.h" +#include "absl/status/status.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/str_format.h" +#include "absl/strings/string_view.h" namespace { class grpc_fake_channel_security_connector final diff --git a/deps/grpc/src/core/credentials/transport/google_default/credentials_generic.cc b/deps/grpc/src/core/credentials/transport/google_default/credentials_generic.cc index 89206d2297d..e4bac743680 100644 --- a/deps/grpc/src/core/credentials/transport/google_default/credentials_generic.cc +++ b/deps/grpc/src/core/credentials/transport/google_default/credentials_generic.cc @@ -21,11 +21,11 @@ #include #include -#include "absl/log/log.h" -#include "absl/strings/str_cat.h" #include "src/core/credentials/call/call_credentials.h" #include "src/core/credentials/transport/google_default/google_default_credentials.h" #include "src/core/util/env.h" +#include "absl/log/log.h" +#include "absl/strings/str_cat.h" std::string grpc_get_well_known_google_credentials_file_path_impl(void) { auto base = grpc_core::GetEnv(GRPC_GOOGLE_CREDENTIALS_PATH_ENV_VAR); diff --git a/deps/grpc/src/core/credentials/transport/google_default/google_default_credentials.cc b/deps/grpc/src/core/credentials/transport/google_default/google_default_credentials.cc index 033c221f316..520faea1f58 100644 --- a/deps/grpc/src/core/credentials/transport/google_default/google_default_credentials.cc +++ b/deps/grpc/src/core/credentials/transport/google_default/google_default_credentials.cc @@ -33,11 +33,6 @@ #include #include -#include "absl/log/log.h" -#include "absl/status/statusor.h" -#include "absl/strings/match.h" -#include "absl/strings/str_cat.h" -#include "absl/strings/string_view.h" #include "src/core/credentials/call/external/external_account_credentials.h" #include "src/core/credentials/call/jwt/json_token.h" #include "src/core/credentials/call/jwt/jwt_credentials.h" @@ -73,6 +68,11 @@ #include "src/core/util/sync.h" #include "src/core/util/time.h" #include "src/core/util/uri.h" +#include "absl/log/log.h" +#include "absl/status/statusor.h" +#include "absl/strings/match.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/string_view.h" using grpc_core::Json; @@ -159,12 +159,6 @@ grpc_google_default_channel_credentials::create_security_connector( return sc; } -grpc_core::ChannelArgs -grpc_google_default_channel_credentials::update_arguments( - grpc_core::ChannelArgs args) { - return args.SetIfUnset(GRPC_ARG_DNS_ENABLE_SRV_QUERIES, true); -} - grpc_core::UniqueTypeName grpc_google_default_channel_credentials::Type() { static grpc_core::UniqueTypeName::Factory kFactory("GoogleDefault"); return kFactory.Create(); diff --git a/deps/grpc/src/core/credentials/transport/google_default/google_default_credentials.h b/deps/grpc/src/core/credentials/transport/google_default/google_default_credentials.h index ce9d005d5fe..80f2ccaa0fa 100644 --- a/deps/grpc/src/core/credentials/transport/google_default/google_default_credentials.h +++ b/deps/grpc/src/core/credentials/transport/google_default/google_default_credentials.h @@ -63,8 +63,6 @@ class grpc_google_default_channel_credentials grpc_core::RefCountedPtr call_creds, const char* target, grpc_core::ChannelArgs* args) override; - grpc_core::ChannelArgs update_arguments(grpc_core::ChannelArgs args) override; - static grpc_core::UniqueTypeName Type(); grpc_core::UniqueTypeName type() const override { return Type(); } diff --git a/deps/grpc/src/core/credentials/transport/insecure/insecure_security_connector.h b/deps/grpc/src/core/credentials/transport/insecure/insecure_security_connector.h index 7407c6ef198..4988aad2aa6 100644 --- a/deps/grpc/src/core/credentials/transport/insecure/insecure_security_connector.h +++ b/deps/grpc/src/core/credentials/transport/insecure/insecure_security_connector.h @@ -26,8 +26,6 @@ #include -#include "absl/status/status.h" -#include "absl/strings/string_view.h" #include "src/core/credentials/transport/security_connector.h" #include "src/core/credentials/transport/transport_credentials.h" #include "src/core/handshaker/handshaker.h" @@ -39,6 +37,8 @@ #include "src/core/lib/promise/arena_promise.h" #include "src/core/tsi/transport_security_interface.h" #include "src/core/util/ref_counted_ptr.h" +#include "absl/status/status.h" +#include "absl/strings/string_view.h" namespace grpc_core { diff --git a/deps/grpc/src/core/credentials/transport/local/local_security_connector.cc b/deps/grpc/src/core/credentials/transport/local/local_security_connector.cc index 9191ac1df51..8cb24b6b237 100644 --- a/deps/grpc/src/core/credentials/transport/local/local_security_connector.cc +++ b/deps/grpc/src/core/credentials/transport/local/local_security_connector.cc @@ -29,11 +29,6 @@ #include #include -#include "absl/log/log.h" -#include "absl/status/status.h" -#include "absl/status/statusor.h" -#include "absl/strings/match.h" -#include "absl/strings/string_view.h" #include "src/core/client_channel/client_channel_filter.h" #include "src/core/credentials/transport/local/local_credentials.h" #include "src/core/credentials/transport/transport_credentials.h" @@ -62,6 +57,11 @@ #include "src/core/util/grpc_check.h" #include "src/core/util/ref_counted_ptr.h" #include "src/core/util/uri.h" +#include "absl/log/log.h" +#include "absl/status/status.h" +#include "absl/status/statusor.h" +#include "absl/strings/match.h" +#include "absl/strings/string_view.h" #define GRPC_UDS_URI_PATTERN "unix:" #define GRPC_ABSTRACT_UDS_URI_PATTERN "unix-abstract:" diff --git a/deps/grpc/src/core/credentials/transport/security_connector.cc b/deps/grpc/src/core/credentials/transport/security_connector.cc index 1a52ef30b10..f98b022e368 100644 --- a/deps/grpc/src/core/credentials/transport/security_connector.cc +++ b/deps/grpc/src/core/credentials/transport/security_connector.cc @@ -23,12 +23,12 @@ #include -#include "absl/log/log.h" #include "src/core/credentials/transport/transport_credentials.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/util/debug_location.h" #include "src/core/util/grpc_check.h" #include "src/core/util/useful.h" +#include "absl/log/log.h" grpc_channel_security_connector::grpc_channel_security_connector( absl::string_view url_scheme, diff --git a/deps/grpc/src/core/credentials/transport/security_connector.h b/deps/grpc/src/core/credentials/transport/security_connector.h index 53ebeabc1b4..8493a9d9403 100644 --- a/deps/grpc/src/core/credentials/transport/security_connector.h +++ b/deps/grpc/src/core/credentials/transport/security_connector.h @@ -26,8 +26,6 @@ #include -#include "absl/status/status.h" -#include "absl/strings/string_view.h" #include "src/core/handshaker/handshaker.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/debug/trace.h" @@ -40,6 +38,8 @@ #include "src/core/util/ref_counted.h" #include "src/core/util/ref_counted_ptr.h" #include "src/core/util/unique_type_name.h" +#include "absl/status/status.h" +#include "absl/strings/string_view.h" // --- URL schemes. --- diff --git a/deps/grpc/src/core/credentials/transport/ssl/ssl_credentials.cc b/deps/grpc/src/core/credentials/transport/ssl/ssl_credentials.cc index d519eccb590..8d6411ed419 100644 --- a/deps/grpc/src/core/credentials/transport/ssl/ssl_credentials.cc +++ b/deps/grpc/src/core/credentials/transport/ssl/ssl_credentials.cc @@ -28,7 +28,6 @@ #include #include -#include "absl/log/log.h" #include "src/core/credentials/transport/tls/ssl_utils.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/debug/trace.h" @@ -36,6 +35,7 @@ #include "src/core/tsi/ssl_transport_security.h" #include "src/core/tsi/transport_security_interface.h" #include "src/core/util/grpc_check.h" +#include "absl/log/log.h" // // SSL Channel Credentials. diff --git a/deps/grpc/src/core/credentials/transport/ssl/ssl_security_connector.cc b/deps/grpc/src/core/credentials/transport/ssl/ssl_security_connector.cc index 185a5a90d89..54e0961382d 100644 --- a/deps/grpc/src/core/credentials/transport/ssl/ssl_security_connector.cc +++ b/deps/grpc/src/core/credentials/transport/ssl/ssl_security_connector.cc @@ -26,11 +26,6 @@ #include #include -#include "absl/log/log.h" -#include "absl/status/status.h" -#include "absl/strings/str_cat.h" -#include "absl/strings/str_format.h" -#include "absl/strings/string_view.h" #include "src/core/credentials/transport/ssl/ssl_credentials.h" #include "src/core/credentials/transport/tls/ssl_utils.h" #include "src/core/credentials/transport/transport_credentials.h" @@ -53,6 +48,11 @@ #include "src/core/util/host_port.h" #include "src/core/util/ref_counted_ptr.h" #include "src/core/util/sync.h" +#include "absl/log/log.h" +#include "absl/status/status.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/str_format.h" +#include "absl/strings/string_view.h" namespace { grpc_error_handle ssl_check_peer( diff --git a/deps/grpc/src/core/credentials/transport/tls/certificate_provider_factory.h b/deps/grpc/src/core/credentials/transport/tls/certificate_provider_factory.h index 15f48a27aff..c23b9657b11 100644 --- a/deps/grpc/src/core/credentials/transport/tls/certificate_provider_factory.h +++ b/deps/grpc/src/core/credentials/transport/tls/certificate_provider_factory.h @@ -25,12 +25,12 @@ #include -#include "absl/strings/string_view.h" #include "src/core/util/json/json.h" #include "src/core/util/json/json_args.h" #include "src/core/util/ref_counted.h" #include "src/core/util/ref_counted_ptr.h" #include "src/core/util/validation_errors.h" +#include "absl/strings/string_view.h" namespace grpc_core { diff --git a/deps/grpc/src/core/credentials/transport/tls/certificate_provider_registry.cc b/deps/grpc/src/core/credentials/transport/tls/certificate_provider_registry.cc index a33da9815c1..4a0de3cdc9b 100644 --- a/deps/grpc/src/core/credentials/transport/tls/certificate_provider_registry.cc +++ b/deps/grpc/src/core/credentials/transport/tls/certificate_provider_registry.cc @@ -23,8 +23,8 @@ #include #include -#include "absl/log/log.h" #include "src/core/util/grpc_check.h" +#include "absl/log/log.h" namespace grpc_core { diff --git a/deps/grpc/src/core/credentials/transport/tls/certificate_provider_registry.h b/deps/grpc/src/core/credentials/transport/tls/certificate_provider_registry.h index e76fd6dcb79..36b92ec384a 100644 --- a/deps/grpc/src/core/credentials/transport/tls/certificate_provider_registry.h +++ b/deps/grpc/src/core/credentials/transport/tls/certificate_provider_registry.h @@ -25,8 +25,8 @@ #include #include -#include "absl/strings/string_view.h" #include "src/core/credentials/transport/tls/certificate_provider_factory.h" +#include "absl/strings/string_view.h" namespace grpc_core { diff --git a/deps/grpc/src/core/credentials/transport/tls/grpc_tls_certificate_distributor.cc b/deps/grpc/src/core/credentials/transport/tls/grpc_tls_certificate_distributor.cc index 274cd7292fa..5a427d7bda5 100644 --- a/deps/grpc/src/core/credentials/transport/tls/grpc_tls_certificate_distributor.cc +++ b/deps/grpc/src/core/credentials/transport/tls/grpc_tls_certificate_distributor.cc @@ -20,10 +20,10 @@ #include #include -#include "absl/status/status.h" #include "src/core/credentials/transport/tls/spiffe_utils.h" #include "src/core/tsi/ssl_transport_security.h" #include "src/core/util/grpc_check.h" +#include "absl/status/status.h" bool grpc_tls_certificate_distributor::CertificateInfo::AreRootsEmpty() { return IsRootCertInfoEmpty(roots.get()); diff --git a/deps/grpc/src/core/credentials/transport/tls/grpc_tls_certificate_distributor.h b/deps/grpc/src/core/credentials/transport/tls/grpc_tls_certificate_distributor.h index 125035f861d..cf79878dd28 100644 --- a/deps/grpc/src/core/credentials/transport/tls/grpc_tls_certificate_distributor.h +++ b/deps/grpc/src/core/credentials/transport/tls/grpc_tls_certificate_distributor.h @@ -27,14 +27,14 @@ #include #include -#include "absl/base/thread_annotations.h" -#include "absl/strings/string_view.h" #include "src/core/credentials/transport/tls/spiffe_utils.h" #include "src/core/credentials/transport/tls/ssl_utils.h" #include "src/core/lib/iomgr/error.h" #include "src/core/tsi/ssl_transport_security.h" #include "src/core/util/ref_counted.h" #include "src/core/util/sync.h" +#include "absl/base/thread_annotations.h" +#include "absl/strings/string_view.h" struct grpc_tls_identity_pairs { grpc_core::PemKeyCertPairList pem_key_cert_pairs; diff --git a/deps/grpc/src/core/credentials/transport/tls/grpc_tls_certificate_match.cc b/deps/grpc/src/core/credentials/transport/tls/grpc_tls_certificate_match.cc index b0cb79f7182..66301e81d44 100644 --- a/deps/grpc/src/core/credentials/transport/tls/grpc_tls_certificate_match.cc +++ b/deps/grpc/src/core/credentials/transport/tls/grpc_tls_certificate_match.cc @@ -21,10 +21,10 @@ #include #include +#include "src/core/credentials/transport/tls/grpc_tls_certificate_provider.h" #include "absl/status/status.h" #include "absl/status/statusor.h" #include "absl/strings/string_view.h" -#include "src/core/credentials/transport/tls/grpc_tls_certificate_provider.h" namespace grpc_core { diff --git a/deps/grpc/src/core/credentials/transport/tls/grpc_tls_certificate_provider.cc b/deps/grpc/src/core/credentials/transport/tls/grpc_tls_certificate_provider.cc index 9810ea3994d..2ae07676cfd 100644 --- a/deps/grpc/src/core/credentials/transport/tls/grpc_tls_certificate_provider.cc +++ b/deps/grpc/src/core/credentials/transport/tls/grpc_tls_certificate_provider.cc @@ -27,9 +27,6 @@ #include #include -#include "absl/log/log.h" -#include "absl/status/status.h" -#include "absl/strings/string_view.h" #include "src/core/credentials/transport/tls/spiffe_utils.h" #include "src/core/credentials/transport/tls/ssl_utils.h" #include "src/core/lib/debug/trace.h" @@ -43,6 +40,9 @@ #include "src/core/util/match.h" #include "src/core/util/stat.h" #include "src/core/util/status_helper.h" +#include "absl/log/log.h" +#include "absl/status/status.h" +#include "absl/strings/string_view.h" namespace grpc_core { namespace { diff --git a/deps/grpc/src/core/credentials/transport/tls/grpc_tls_certificate_provider.h b/deps/grpc/src/core/credentials/transport/tls/grpc_tls_certificate_provider.h index 072960e303e..d46f61853eb 100644 --- a/deps/grpc/src/core/credentials/transport/tls/grpc_tls_certificate_provider.h +++ b/deps/grpc/src/core/credentials/transport/tls/grpc_tls_certificate_provider.h @@ -26,9 +26,6 @@ #include #include -#include "absl/base/thread_annotations.h" -#include "absl/status/statusor.h" -#include "absl/strings/string_view.h" #include "src/core/credentials/transport/tls/grpc_tls_certificate_distributor.h" #include "src/core/credentials/transport/tls/spiffe_utils.h" #include "src/core/credentials/transport/tls/ssl_utils.h" @@ -39,6 +36,9 @@ #include "src/core/util/thd.h" #include "src/core/util/unique_type_name.h" #include "src/core/util/useful.h" +#include "absl/base/thread_annotations.h" +#include "absl/status/statusor.h" +#include "absl/strings/string_view.h" // Interface for a grpc_tls_certificate_provider that handles the process to // fetch credentials and validation contexts. Implementations are free to rely diff --git a/deps/grpc/src/core/credentials/transport/tls/grpc_tls_certificate_verifier.cc b/deps/grpc/src/core/credentials/transport/tls/grpc_tls_certificate_verifier.cc index 260a20baa66..e29cffbd5a7 100644 --- a/deps/grpc/src/core/credentials/transport/tls/grpc_tls_certificate_verifier.cc +++ b/deps/grpc/src/core/credentials/transport/tls/grpc_tls_certificate_verifier.cc @@ -24,12 +24,12 @@ #include #include -#include "absl/strings/string_view.h" #include "src/core/credentials/transport/tls/tls_utils.h" #include "src/core/lib/debug/trace.h" #include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/util/grpc_check.h" #include "src/core/util/host_port.h" +#include "absl/strings/string_view.h" namespace grpc_core { diff --git a/deps/grpc/src/core/credentials/transport/tls/grpc_tls_certificate_verifier.h b/deps/grpc/src/core/credentials/transport/tls/grpc_tls_certificate_verifier.h index ff3771e7a6e..9863fee8731 100644 --- a/deps/grpc/src/core/credentials/transport/tls/grpc_tls_certificate_verifier.h +++ b/deps/grpc/src/core/credentials/transport/tls/grpc_tls_certificate_verifier.h @@ -25,13 +25,13 @@ #include #include -#include "absl/base/thread_annotations.h" -#include "absl/status/status.h" #include "src/core/util/grpc_check.h" #include "src/core/util/ref_counted.h" #include "src/core/util/sync.h" #include "src/core/util/unique_type_name.h" #include "src/core/util/useful.h" +#include "absl/base/thread_annotations.h" +#include "absl/status/status.h" // An abstraction of the verifier that all verifier subclasses should extend. struct grpc_tls_certificate_verifier diff --git a/deps/grpc/src/core/credentials/transport/tls/grpc_tls_credentials_options.cc b/deps/grpc/src/core/credentials/transport/tls/grpc_tls_credentials_options.cc index 5da5bcd8830..361b12acedf 100644 --- a/deps/grpc/src/core/credentials/transport/tls/grpc_tls_credentials_options.cc +++ b/deps/grpc/src/core/credentials/transport/tls/grpc_tls_credentials_options.cc @@ -23,12 +23,12 @@ #include -#include "absl/log/log.h" #include "src/core/lib/debug/trace.h" #include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/tsi/ssl_transport_security.h" #include "src/core/util/debug_location.h" #include "src/core/util/grpc_check.h" +#include "absl/log/log.h" /// -- Wrapper APIs declared in grpc_security.h -- * diff --git a/deps/grpc/src/core/credentials/transport/tls/grpc_tls_crl_provider.cc b/deps/grpc/src/core/credentials/transport/tls/grpc_tls_crl_provider.cc index a882cf392f8..7bd4c5ab0b4 100644 --- a/deps/grpc/src/core/credentials/transport/tls/grpc_tls_crl_provider.cc +++ b/deps/grpc/src/core/credentials/transport/tls/grpc_tls_crl_provider.cc @@ -33,6 +33,11 @@ #include #include +#include "src/core/lib/event_engine/default_event_engine.h" +#include "src/core/lib/iomgr/exec_ctx.h" +#include "src/core/lib/slice/slice.h" +#include "src/core/util/directory_reader.h" +#include "src/core/util/load_file.h" #include "absl/container/flat_hash_map.h" #include "absl/log/log.h" #include "absl/status/status.h" @@ -40,11 +45,6 @@ #include "absl/strings/str_cat.h" #include "absl/strings/str_join.h" #include "absl/types/span.h" -#include "src/core/lib/event_engine/default_event_engine.h" -#include "src/core/lib/iomgr/exec_ctx.h" -#include "src/core/lib/slice/slice.h" -#include "src/core/util/directory_reader.h" -#include "src/core/util/load_file.h" namespace grpc_core { namespace experimental { diff --git a/deps/grpc/src/core/credentials/transport/tls/grpc_tls_crl_provider.h b/deps/grpc/src/core/credentials/transport/tls/grpc_tls_crl_provider.h index f3f2fe4030b..ef4f147f965 100644 --- a/deps/grpc/src/core/credentials/transport/tls/grpc_tls_crl_provider.h +++ b/deps/grpc/src/core/credentials/transport/tls/grpc_tls_crl_provider.h @@ -31,14 +31,14 @@ #include #include +#include "src/core/util/directory_reader.h" +#include "src/core/util/sync.h" +#include "src/core/util/time.h" #include "absl/base/thread_annotations.h" #include "absl/container/flat_hash_map.h" #include "absl/status/status.h" #include "absl/status/statusor.h" #include "absl/strings/string_view.h" -#include "src/core/util/directory_reader.h" -#include "src/core/util/sync.h" -#include "src/core/util/time.h" namespace grpc_core { namespace experimental { diff --git a/deps/grpc/src/core/credentials/transport/tls/load_system_roots_supported.cc b/deps/grpc/src/core/credentials/transport/tls/load_system_roots_supported.cc index b66b80e375e..4f9a0e61a21 100644 --- a/deps/grpc/src/core/credentials/transport/tls/load_system_roots_supported.cc +++ b/deps/grpc/src/core/credentials/transport/tls/load_system_roots_supported.cc @@ -33,13 +33,13 @@ #include #include -#include "absl/log/log.h" #include "src/core/config/config_vars.h" #include "src/core/credentials/transport/tls/load_system_roots.h" #include "src/core/credentials/transport/tls/load_system_roots_supported.h" #include "src/core/lib/iomgr/error.h" #include "src/core/util/load_file.h" #include "src/core/util/useful.h" +#include "absl/log/log.h" namespace grpc_core { namespace { diff --git a/deps/grpc/src/core/credentials/transport/tls/spiffe_utils.cc b/deps/grpc/src/core/credentials/transport/tls/spiffe_utils.cc index 4d9b16d449d..23001df2845 100644 --- a/deps/grpc/src/core/credentials/transport/tls/spiffe_utils.cc +++ b/deps/grpc/src/core/credentials/transport/tls/spiffe_utils.cc @@ -22,20 +22,21 @@ #include -#include "absl/strings/match.h" -#include "absl/strings/str_cat.h" -#include "absl/strings/str_format.h" -#include "absl/strings/str_split.h" #include "src/core/tsi/ssl_transport_security_utils.h" #include "src/core/util/json/json_object_loader.h" #include "src/core/util/json/json_reader.h" #include "src/core/util/load_file.h" #include "src/core/util/status_helper.h" +#include "absl/strings/match.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/str_format.h" +#include "absl/strings/str_split.h" namespace grpc_core { namespace { constexpr absl::string_view kAllowedUse = "x509-svid"; -constexpr absl::string_view kAllowedKty = "RSA"; +constexpr absl::string_view kRsaKty = "RSA"; +constexpr absl::string_view kEcKty = "EC"; constexpr absl::string_view kCertificatePrefix = "-----BEGIN CERTIFICATE-----\n"; constexpr absl::string_view kCertificateSuffix = "\n-----END CERTIFICATE-----"; @@ -192,9 +193,10 @@ void SpiffeBundleKey::JsonPostLoad(const Json& json, const JsonArgs& args, LoadJsonObjectField(json.object(), args, "kty", errors); { ValidationErrors::ScopedField field(errors, ".kty"); - if (kty.has_value() && *kty != kAllowedKty) { - errors->AddError(absl::StrFormat("value must be \"%s\", got \"%s\"", - kAllowedKty, *kty)); + if (kty.has_value() && *kty != kRsaKty && *kty != kEcKty) { + errors->AddError( + absl::StrFormat("value must be one of \"%s\", \"%s\", got \"%s\"", + kEcKty, kRsaKty, *kty)); } } auto x5c = LoadJsonObjectField>(json.object(), args, diff --git a/deps/grpc/src/core/credentials/transport/tls/spiffe_utils.h b/deps/grpc/src/core/credentials/transport/tls/spiffe_utils.h index 1c4f011e472..9bf4b6dd59f 100644 --- a/deps/grpc/src/core/credentials/transport/tls/spiffe_utils.h +++ b/deps/grpc/src/core/credentials/transport/tls/spiffe_utils.h @@ -24,10 +24,10 @@ #include -#include "absl/status/statusor.h" -#include "absl/strings/string_view.h" #include "src/core/util/json/json.h" #include "src/core/util/json/json_object_loader.h" +#include "absl/status/statusor.h" +#include "absl/strings/string_view.h" namespace grpc_core { diff --git a/deps/grpc/src/core/credentials/transport/tls/ssl_utils.cc b/deps/grpc/src/core/credentials/transport/tls/ssl_utils.cc index 5073b2401eb..e4a088f3a45 100644 --- a/deps/grpc/src/core/credentials/transport/tls/ssl_utils.cc +++ b/deps/grpc/src/core/credentials/transport/tls/ssl_utils.cc @@ -33,10 +33,6 @@ #include #include -#include "absl/log/log.h" -#include "absl/strings/match.h" -#include "absl/strings/str_cat.h" -#include "absl/strings/str_split.h" #include "src/core/config/config_vars.h" #include "src/core/credentials/transport/tls/load_system_roots.h" #include "src/core/ext/transport/chttp2/alpn/alpn.h" @@ -49,6 +45,10 @@ #include "src/core/util/load_file.h" #include "src/core/util/ref_counted_ptr.h" #include "src/core/util/useful.h" +#include "absl/log/log.h" +#include "absl/strings/match.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/str_split.h" // -- Constants. -- diff --git a/deps/grpc/src/core/credentials/transport/tls/ssl_utils.h b/deps/grpc/src/core/credentials/transport/tls/ssl_utils.h index 4257d8a609a..fcd98573932 100644 --- a/deps/grpc/src/core/credentials/transport/tls/ssl_utils.h +++ b/deps/grpc/src/core/credentials/transport/tls/ssl_utils.h @@ -31,8 +31,6 @@ #include #include -#include "absl/status/status.h" -#include "absl/strings/string_view.h" #include "src/core/credentials/transport/security_connector.h" #include "src/core/credentials/transport/tls/spiffe_utils.h" #include "src/core/lib/iomgr/error.h" @@ -40,6 +38,8 @@ #include "src/core/tsi/ssl_transport_security.h" #include "src/core/tsi/transport_security_interface.h" #include "src/core/util/ref_counted_ptr.h" +#include "absl/status/status.h" +#include "absl/strings/string_view.h" // --- Util --- diff --git a/deps/grpc/src/core/credentials/transport/tls/tls_credentials.cc b/deps/grpc/src/core/credentials/transport/tls/tls_credentials.cc index 49f0fe92395..dcf98d71736 100644 --- a/deps/grpc/src/core/credentials/transport/tls/tls_credentials.cc +++ b/deps/grpc/src/core/credentials/transport/tls/tls_credentials.cc @@ -28,13 +28,13 @@ #include #include -#include "absl/log/log.h" #include "src/core/credentials/transport/tls/grpc_tls_certificate_verifier.h" #include "src/core/credentials/transport/tls/grpc_tls_credentials_options.h" #include "src/core/credentials/transport/tls/tls_security_connector.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/tsi/ssl/session_cache/ssl_session_cache.h" #include "src/core/util/useful.h" +#include "absl/log/log.h" namespace { diff --git a/deps/grpc/src/core/credentials/transport/tls/tls_security_connector.cc b/deps/grpc/src/core/credentials/transport/tls/tls_security_connector.cc index 8683c74f5d0..4e022e6e504 100644 --- a/deps/grpc/src/core/credentials/transport/tls/tls_security_connector.cc +++ b/deps/grpc/src/core/credentials/transport/tls/tls_security_connector.cc @@ -29,10 +29,6 @@ #include #include -#include "absl/functional/bind_front.h" -#include "absl/log/log.h" -#include "absl/strings/str_cat.h" -#include "absl/strings/string_view.h" #include "src/core/credentials/transport/tls/grpc_tls_certificate_verifier.h" #include "src/core/credentials/transport/tls/grpc_tls_credentials_options.h" #include "src/core/credentials/transport/tls/ssl_utils.h" @@ -47,6 +43,10 @@ #include "src/core/util/grpc_check.h" #include "src/core/util/host_port.h" #include "src/core/util/status_helper.h" +#include "absl/functional/bind_front.h" +#include "absl/log/log.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/string_view.h" namespace grpc_core { diff --git a/deps/grpc/src/core/credentials/transport/tls/tls_security_connector.h b/deps/grpc/src/core/credentials/transport/tls/tls_security_connector.h index 4e58ef13bf5..9efdc235e03 100644 --- a/deps/grpc/src/core/credentials/transport/tls/tls_security_connector.h +++ b/deps/grpc/src/core/credentials/transport/tls/tls_security_connector.h @@ -28,9 +28,6 @@ #include #include -#include "absl/base/thread_annotations.h" -#include "absl/status/status.h" -#include "absl/strings/string_view.h" #include "src/core/credentials/transport/security_connector.h" #include "src/core/credentials/transport/tls/grpc_tls_certificate_distributor.h" #include "src/core/credentials/transport/tls/ssl_utils.h" @@ -46,6 +43,9 @@ #include "src/core/tsi/transport_security_interface.h" #include "src/core/util/ref_counted_ptr.h" #include "src/core/util/sync.h" +#include "absl/base/thread_annotations.h" +#include "absl/status/status.h" +#include "absl/strings/string_view.h" using TlsSessionKeyLogger = tsi::TlsSessionKeyLoggerCache::TlsSessionKeyLogger; diff --git a/deps/grpc/src/core/credentials/transport/transport_credentials.cc b/deps/grpc/src/core/credentials/transport/transport_credentials.cc index 642ead69b3c..a527c1aebb3 100644 --- a/deps/grpc/src/core/credentials/transport/transport_credentials.cc +++ b/deps/grpc/src/core/credentials/transport/transport_credentials.cc @@ -20,12 +20,12 @@ #include #include -#include "absl/log/log.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/debug/trace.h" #include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/util/grpc_check.h" #include "src/core/util/useful.h" +#include "absl/log/log.h" // -- Common. -- diff --git a/deps/grpc/src/core/credentials/transport/transport_credentials.h b/deps/grpc/src/core/credentials/transport/transport_credentials.h index a18a92f6c2f..29f4660043a 100644 --- a/deps/grpc/src/core/credentials/transport/transport_credentials.h +++ b/deps/grpc/src/core/credentials/transport/transport_credentials.h @@ -28,8 +28,6 @@ #include #include -#include "absl/status/statusor.h" -#include "absl/strings/string_view.h" #include "src/core/credentials/call/call_credentials.h" #include "src/core/credentials/transport/security_connector.h" #include "src/core/lib/channel/channel_args.h" @@ -41,6 +39,8 @@ #include "src/core/util/ref_counted.h" #include "src/core/util/ref_counted_ptr.h" #include "src/core/util/unique_type_name.h" +#include "absl/status/statusor.h" +#include "absl/strings/string_view.h" // --- Constants. --- diff --git a/deps/grpc/src/core/credentials/transport/xds/xds_credentials.h b/deps/grpc/src/core/credentials/transport/xds/xds_credentials.h index eedf55ddc34..41c569a20df 100644 --- a/deps/grpc/src/core/credentials/transport/xds/xds_credentials.h +++ b/deps/grpc/src/core/credentials/transport/xds/xds_credentials.h @@ -30,7 +30,6 @@ #include #include -#include "absl/status/status.h" #include "src/core/credentials/transport/security_connector.h" #include "src/core/credentials/transport/tls/grpc_tls_certificate_verifier.h" #include "src/core/credentials/transport/transport_credentials.h" @@ -39,6 +38,7 @@ #include "src/core/util/ref_counted_ptr.h" #include "src/core/util/unique_type_name.h" #include "src/core/xds/grpc/xds_certificate_provider.h" +#include "absl/status/status.h" namespace grpc_core { diff --git a/deps/grpc/src/core/ext/filters/backend_metrics/backend_metric_filter.cc b/deps/grpc/src/core/ext/filters/backend_metrics/backend_metric_filter.cc index 328140720c3..1df0f0685aa 100644 --- a/deps/grpc/src/core/ext/filters/backend_metrics/backend_metric_filter.cc +++ b/deps/grpc/src/core/ext/filters/backend_metrics/backend_metric_filter.cc @@ -24,8 +24,6 @@ #include #include -#include "absl/log/log.h" -#include "absl/strings/string_view.h" #include "src/core/call/metadata_batch.h" #include "src/core/config/core_configuration.h" #include "src/core/lib/channel/channel_stack.h" @@ -41,6 +39,8 @@ #include "upb/base/string_view.h" #include "upb/mem/arena.hpp" #include "xds/data/orca/v3/orca_load_report.upb.h" +#include "absl/log/log.h" +#include "absl/strings/string_view.h" namespace grpc_core { diff --git a/deps/grpc/src/core/ext/filters/backend_metrics/backend_metric_filter.h b/deps/grpc/src/core/ext/filters/backend_metrics/backend_metric_filter.h index 1d29a7f918c..5c6302e6113 100644 --- a/deps/grpc/src/core/ext/filters/backend_metrics/backend_metric_filter.h +++ b/deps/grpc/src/core/ext/filters/backend_metrics/backend_metric_filter.h @@ -20,13 +20,13 @@ #include #include -#include "absl/status/statusor.h" #include "src/core/ext/filters/backend_metrics/backend_metric_provider.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/channel_fwd.h" #include "src/core/lib/channel/promise_based_filter.h" #include "src/core/lib/promise/arena_promise.h" #include "src/core/lib/transport/transport.h" +#include "absl/status/statusor.h" namespace grpc_core { @@ -48,6 +48,9 @@ class BackendMetricFilter : public ImplementChannelFilter { static inline const NoInterceptor OnClientToServerHalfClose; static inline const NoInterceptor OnServerToClientMessage; static inline const NoInterceptor OnFinalize; + channelz::PropertyList ChannelzProperties() { + return channelz::PropertyList(); + } }; }; diff --git a/deps/grpc/src/core/ext/filters/channel_idle/legacy_channel_idle_filter.cc b/deps/grpc/src/core/ext/filters/channel_idle/legacy_channel_idle_filter.cc index d6a9e081912..96b0de1139b 100644 --- a/deps/grpc/src/core/ext/filters/channel_idle/legacy_channel_idle_filter.cc +++ b/deps/grpc/src/core/ext/filters/channel_idle/legacy_channel_idle_filter.cc @@ -24,10 +24,6 @@ #include #include -#include "absl/base/thread_annotations.h" -#include "absl/meta/type_traits.h" -#include "absl/random/random.h" -#include "absl/status/statusor.h" #include "src/core/call/metadata_batch.h" #include "src/core/config/core_configuration.h" #include "src/core/ext/transport/chttp2/transport/http2_status.h" @@ -53,6 +49,10 @@ #include "src/core/util/shared_bit_gen.h" #include "src/core/util/status_helper.h" #include "src/core/util/sync.h" +#include "absl/base/thread_annotations.h" +#include "absl/meta/type_traits.h" +#include "absl/random/random.h" +#include "absl/status/statusor.h" namespace grpc_core { @@ -307,7 +307,7 @@ void RegisterLegacyChannelIdleFilters(CoreConfiguration::Builder* builder) { builder->channel_init() ->RegisterV2Filter(GRPC_SERVER_CHANNEL) - .FloatToTopIf(IsMaxAgeFilterFloatToTopEnabled()) + .FloatToTop() .ExcludeFromMinimalStack() .If([](const ChannelArgs& channel_args) { return LegacyMaxAgeFilter::Config::FromChannelArgs(channel_args) diff --git a/deps/grpc/src/core/ext/filters/channel_idle/legacy_channel_idle_filter.h b/deps/grpc/src/core/ext/filters/channel_idle/legacy_channel_idle_filter.h index b903b41f766..8b70e8ee9fa 100644 --- a/deps/grpc/src/core/ext/filters/channel_idle/legacy_channel_idle_filter.h +++ b/deps/grpc/src/core/ext/filters/channel_idle/legacy_channel_idle_filter.h @@ -20,8 +20,6 @@ #include -#include "absl/status/status.h" -#include "absl/status/statusor.h" #include "src/core/ext/filters/channel_idle/idle_filter_state.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/channel_fwd.h" @@ -35,6 +33,8 @@ #include "src/core/util/ref_counted_ptr.h" #include "src/core/util/single_set_ptr.h" #include "src/core/util/time.h" +#include "absl/status/status.h" +#include "absl/status/statusor.h" namespace grpc_core { diff --git a/deps/grpc/src/core/ext/filters/fault_injection/fault_injection_filter.cc b/deps/grpc/src/core/ext/filters/fault_injection/fault_injection_filter.cc index 4098d55c352..7e0c5e4824c 100644 --- a/deps/grpc/src/core/ext/filters/fault_injection/fault_injection_filter.cc +++ b/deps/grpc/src/core/ext/filters/fault_injection/fault_injection_filter.cc @@ -28,13 +28,6 @@ #include #include -#include "absl/log/log.h" -#include "absl/meta/type_traits.h" -#include "absl/status/status.h" -#include "absl/status/statusor.h" -#include "absl/strings/numbers.h" -#include "absl/strings/str_cat.h" -#include "absl/strings/string_view.h" #include "src/core/call/metadata_batch.h" #include "src/core/call/status_util.h" #include "src/core/config/core_configuration.h" @@ -47,6 +40,13 @@ #include "src/core/lib/transport/transport.h" #include "src/core/service_config/service_config_call_data.h" #include "src/core/util/time.h" +#include "absl/log/log.h" +#include "absl/meta/type_traits.h" +#include "absl/status/status.h" +#include "absl/status/statusor.h" +#include "absl/strings/numbers.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/string_view.h" namespace grpc_core { diff --git a/deps/grpc/src/core/ext/filters/fault_injection/fault_injection_filter.h b/deps/grpc/src/core/ext/filters/fault_injection/fault_injection_filter.h index bacac5e37b0..0567df55ba5 100644 --- a/deps/grpc/src/core/ext/filters/fault_injection/fault_injection_filter.h +++ b/deps/grpc/src/core/ext/filters/fault_injection/fault_injection_filter.h @@ -22,15 +22,15 @@ #include -#include "absl/base/thread_annotations.h" -#include "absl/random/random.h" -#include "absl/status/statusor.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/channel_fwd.h" #include "src/core/lib/channel/promise_based_filter.h" #include "src/core/lib/promise/arena_promise.h" #include "src/core/lib/transport/transport.h" #include "src/core/util/sync.h" +#include "absl/base/thread_annotations.h" +#include "absl/random/random.h" +#include "absl/status/statusor.h" namespace grpc_core { @@ -61,6 +61,9 @@ class FaultInjectionFilter static inline const NoInterceptor OnClientToServerHalfClose; static inline const NoInterceptor OnServerToClientMessage; static inline const NoInterceptor OnFinalize; + channelz::PropertyList ChannelzProperties() { + return channelz::PropertyList(); + } }; private: diff --git a/deps/grpc/src/core/ext/filters/fault_injection/fault_injection_service_config_parser.h b/deps/grpc/src/core/ext/filters/fault_injection/fault_injection_service_config_parser.h index 7c9928d3d5a..29b913339bb 100644 --- a/deps/grpc/src/core/ext/filters/fault_injection/fault_injection_service_config_parser.h +++ b/deps/grpc/src/core/ext/filters/fault_injection/fault_injection_service_config_parser.h @@ -27,7 +27,6 @@ #include #include -#include "absl/strings/string_view.h" #include "src/core/config/core_configuration.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/service_config/service_config_parser.h" @@ -36,6 +35,7 @@ #include "src/core/util/json/json_object_loader.h" #include "src/core/util/time.h" #include "src/core/util/validation_errors.h" +#include "absl/strings/string_view.h" // Channel arg key for enabling parsing fault injection via method config. #define GRPC_ARG_PARSE_FAULT_INJECTION_METHOD_CONFIG \ diff --git a/deps/grpc/src/core/ext/filters/gcp_authentication/gcp_authentication_filter.cc b/deps/grpc/src/core/ext/filters/gcp_authentication/gcp_authentication_filter.cc index c59c3668b42..3a4978eb70c 100644 --- a/deps/grpc/src/core/ext/filters/gcp_authentication/gcp_authentication_filter.cc +++ b/deps/grpc/src/core/ext/filters/gcp_authentication/gcp_authentication_filter.cc @@ -20,7 +20,6 @@ #include #include -#include "absl/strings/str_cat.h" #include "src/core/call/security_context.h" #include "src/core/config/core_configuration.h" #include "src/core/credentials/call/gcp_service_account_identity/gcp_service_account_identity_credentials.h" @@ -33,6 +32,7 @@ #include "src/core/service_config/service_config.h" #include "src/core/service_config/service_config_call_data.h" #include "src/core/util/grpc_check.h" +#include "absl/strings/str_cat.h" namespace grpc_core { diff --git a/deps/grpc/src/core/ext/filters/gcp_authentication/gcp_authentication_filter.h b/deps/grpc/src/core/ext/filters/gcp_authentication/gcp_authentication_filter.h index 8d5a71eefbb..a8fcf3e5f7d 100644 --- a/deps/grpc/src/core/ext/filters/gcp_authentication/gcp_authentication_filter.h +++ b/deps/grpc/src/core/ext/filters/gcp_authentication/gcp_authentication_filter.h @@ -20,9 +20,6 @@ #include #include -#include "absl/status/status.h" -#include "absl/status/statusor.h" -#include "absl/strings/string_view.h" #include "src/core/credentials/call/call_credentials.h" #include "src/core/ext/filters/gcp_authentication/gcp_authentication_service_config_parser.h" #include "src/core/filter/blackboard.h" @@ -34,6 +31,9 @@ #include "src/core/util/lru_cache.h" #include "src/core/util/ref_counted_ptr.h" #include "src/core/util/sync.h" +#include "absl/status/status.h" +#include "absl/status/statusor.h" +#include "absl/strings/string_view.h" namespace grpc_core { @@ -75,6 +75,9 @@ class GcpAuthenticationFilter static inline const NoInterceptor OnServerToClientMessage; static inline const NoInterceptor OnServerTrailingMetadata; static inline const NoInterceptor OnFinalize; + channelz::PropertyList ChannelzProperties() { + return channelz::PropertyList(); + } }; private: diff --git a/deps/grpc/src/core/ext/filters/gcp_authentication/gcp_authentication_service_config_parser.h b/deps/grpc/src/core/ext/filters/gcp_authentication/gcp_authentication_service_config_parser.h index e1c35cf781a..270353d7554 100644 --- a/deps/grpc/src/core/ext/filters/gcp_authentication/gcp_authentication_service_config_parser.h +++ b/deps/grpc/src/core/ext/filters/gcp_authentication/gcp_authentication_service_config_parser.h @@ -24,7 +24,6 @@ #include #include -#include "absl/strings/string_view.h" #include "src/core/config/core_configuration.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/service_config/service_config_parser.h" @@ -32,6 +31,7 @@ #include "src/core/util/json/json_args.h" #include "src/core/util/json/json_object_loader.h" #include "src/core/util/validation_errors.h" +#include "absl/strings/string_view.h" // Channel arg key for enabling parsing fault injection via method config. #define GRPC_ARG_PARSE_GCP_AUTHENTICATION_METHOD_CONFIG \ diff --git a/deps/grpc/src/core/ext/filters/http/client/http_client_filter.cc b/deps/grpc/src/core/ext/filters/http/client/http_client_filter.cc index 6f0aaa7497d..c8507a54a2e 100644 --- a/deps/grpc/src/core/ext/filters/http/client/http_client_filter.cc +++ b/deps/grpc/src/core/ext/filters/http/client/http_client_filter.cc @@ -30,12 +30,6 @@ #include #include -#include "absl/status/status.h" -#include "absl/status/statusor.h" -#include "absl/strings/str_cat.h" -#include "absl/strings/str_format.h" -#include "absl/strings/str_join.h" -#include "absl/strings/string_view.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/channel_stack.h" #include "src/core/lib/promise/context.h" @@ -48,6 +42,12 @@ #include "src/core/lib/transport/status_conversion.h" #include "src/core/lib/transport/transport.h" #include "src/core/util/latent_see.h" +#include "absl/status/status.h" +#include "absl/status/statusor.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/str_format.h" +#include "absl/strings/str_join.h" +#include "absl/strings/string_view.h" namespace grpc_core { diff --git a/deps/grpc/src/core/ext/filters/http/client/http_client_filter.h b/deps/grpc/src/core/ext/filters/http/client/http_client_filter.h index 8c82c0cd556..f3af2f0a2bf 100644 --- a/deps/grpc/src/core/ext/filters/http/client/http_client_filter.h +++ b/deps/grpc/src/core/ext/filters/http/client/http_client_filter.h @@ -20,13 +20,13 @@ #include -#include "absl/status/statusor.h" #include "src/core/call/metadata_batch.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/channel_fwd.h" #include "src/core/lib/channel/promise_based_filter.h" #include "src/core/lib/slice/slice.h" #include "src/core/lib/transport/transport.h" +#include "absl/status/statusor.h" namespace grpc_core { @@ -51,6 +51,9 @@ class HttpClientFilter : public ImplementChannelFilter { static inline const NoInterceptor OnClientToServerHalfClose; static inline const NoInterceptor OnServerToClientMessage; static inline const NoInterceptor OnFinalize; + channelz::PropertyList ChannelzProperties() { + return channelz::PropertyList(); + } }; private: diff --git a/deps/grpc/src/core/ext/filters/http/client_authority_filter.cc b/deps/grpc/src/core/ext/filters/http/client_authority_filter.cc index 73c3149fd8e..d026d2adc9d 100644 --- a/deps/grpc/src/core/ext/filters/http/client_authority_filter.cc +++ b/deps/grpc/src/core/ext/filters/http/client_authority_filter.cc @@ -25,14 +25,14 @@ #include #include -#include "absl/status/status.h" -#include "absl/strings/string_view.h" #include "src/core/call/metadata_batch.h" #include "src/core/config/core_configuration.h" #include "src/core/filter/auth/auth_filters.h" #include "src/core/lib/channel/channel_stack.h" #include "src/core/lib/surface/channel_stack_type.h" #include "src/core/util/latent_see.h" +#include "absl/status/status.h" +#include "absl/strings/string_view.h" namespace grpc_core { diff --git a/deps/grpc/src/core/ext/filters/http/client_authority_filter.h b/deps/grpc/src/core/ext/filters/http/client_authority_filter.h index b40cf7ae987..bb636fd4471 100644 --- a/deps/grpc/src/core/ext/filters/http/client_authority_filter.h +++ b/deps/grpc/src/core/ext/filters/http/client_authority_filter.h @@ -23,13 +23,13 @@ #include -#include "absl/status/statusor.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/channel_fwd.h" #include "src/core/lib/channel/promise_based_filter.h" #include "src/core/lib/promise/arena_promise.h" #include "src/core/lib/slice/slice.h" #include "src/core/lib/transport/transport.h" +#include "absl/status/statusor.h" namespace grpc_core { @@ -56,6 +56,9 @@ class ClientAuthorityFilter final static inline const NoInterceptor OnClientToServerHalfClose; static inline const NoInterceptor OnServerToClientMessage; static inline const NoInterceptor OnFinalize; + channelz::PropertyList ChannelzProperties() { + return channelz::PropertyList(); + } }; private: diff --git a/deps/grpc/src/core/ext/filters/http/http_filters_plugin.cc b/deps/grpc/src/core/ext/filters/http/http_filters_plugin.cc index a684ef0fc9e..9a5fcf9cef7 100644 --- a/deps/grpc/src/core/ext/filters/http/http_filters_plugin.cc +++ b/deps/grpc/src/core/ext/filters/http/http_filters_plugin.cc @@ -18,7 +18,6 @@ #include -#include "absl/strings/match.h" #include "src/core/config/core_configuration.h" #include "src/core/ext/filters/http/client/http_client_filter.h" #include "src/core/ext/filters/http/message_compress/compression_filter.h" @@ -28,6 +27,7 @@ #include "src/core/lib/experiments/experiments.h" #include "src/core/lib/surface/channel_stack_type.h" #include "src/core/lib/transport/transport.h" +#include "absl/strings/match.h" namespace grpc_core { namespace { diff --git a/deps/grpc/src/core/ext/filters/http/message_compress/compression_filter.cc b/deps/grpc/src/core/ext/filters/http/message_compress/compression_filter.cc index 10f25c83e7a..6e0818fcec5 100644 --- a/deps/grpc/src/core/ext/filters/http/message_compress/compression_filter.cc +++ b/deps/grpc/src/core/ext/filters/http/message_compress/compression_filter.cc @@ -26,9 +26,6 @@ #include #include -#include "absl/status/status.h" -#include "absl/strings/str_cat.h" -#include "absl/strings/str_format.h" #include "src/core/call/metadata_batch.h" #include "src/core/ext/filters/message_size/message_size_filter.h" #include "src/core/lib/channel/channel_args.h" @@ -49,6 +46,9 @@ #include "src/core/telemetry/call_tracer.h" #include "src/core/util/grpc_check.h" #include "src/core/util/latent_see.h" +#include "absl/status/status.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/str_format.h" namespace grpc_core { diff --git a/deps/grpc/src/core/ext/filters/http/message_compress/compression_filter.h b/deps/grpc/src/core/ext/filters/http/message_compress/compression_filter.h index d73131e9d81..fe5f75bba25 100644 --- a/deps/grpc/src/core/ext/filters/http/message_compress/compression_filter.h +++ b/deps/grpc/src/core/ext/filters/http/message_compress/compression_filter.h @@ -27,8 +27,6 @@ #include #include -#include "absl/status/statusor.h" -#include "absl/strings/string_view.h" #include "src/core/call/metadata_batch.h" #include "src/core/channelz/property_list.h" #include "src/core/lib/channel/channel_args.h" @@ -37,6 +35,8 @@ #include "src/core/lib/compression/compression_internal.h" #include "src/core/lib/promise/arena_promise.h" #include "src/core/lib/transport/transport.h" +#include "absl/status/statusor.h" +#include "absl/strings/string_view.h" namespace grpc_core { @@ -157,6 +157,15 @@ class ClientCompressionFilter final static inline const NoInterceptor OnClientToServerHalfClose; static inline const NoInterceptor OnServerTrailingMetadata; static inline const NoInterceptor OnFinalize; + channelz::PropertyList ChannelzProperties() { + return channelz::PropertyList() + .Set("compression_algorithm", + CompressionAlgorithmAsString(compression_algorithm_)) + .Set("max_recv_message_length", + decompress_args_.max_recv_message_length.value_or(0)) + .Set("decompression_algorithm", + CompressionAlgorithmAsString(decompress_args_.algorithm)); + } private: grpc_compression_algorithm compression_algorithm_; @@ -210,6 +219,16 @@ class ServerCompressionFilter final static inline const NoInterceptor OnServerTrailingMetadata; static inline const NoInterceptor OnFinalize; + channelz::PropertyList ChannelzProperties() { + return channelz::PropertyList() + .Set("compression_algorithm", + CompressionAlgorithmAsString(compression_algorithm_)) + .Set("max_recv_message_length", + decompress_args_.max_recv_message_length.value_or(0)) + .Set("decompression_algorithm", + CompressionAlgorithmAsString(decompress_args_.algorithm)); + } + private: ChannelCompression::DecompressArgs decompress_args_; grpc_compression_algorithm compression_algorithm_; diff --git a/deps/grpc/src/core/ext/filters/http/server/http_server_filter.cc b/deps/grpc/src/core/ext/filters/http/server/http_server_filter.cc index fa0a472398a..39ceb73694b 100644 --- a/deps/grpc/src/core/ext/filters/http/server/http_server_filter.cc +++ b/deps/grpc/src/core/ext/filters/http/server/http_server_filter.cc @@ -27,9 +27,6 @@ #include #include -#include "absl/base/attributes.h" -#include "absl/log/log.h" -#include "absl/strings/string_view.h" #include "src/core/call/metadata_batch.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/channel_stack.h" @@ -44,6 +41,9 @@ #include "src/core/lib/slice/percent_encoding.h" #include "src/core/lib/slice/slice.h" #include "src/core/util/latent_see.h" +#include "absl/base/attributes.h" +#include "absl/log/log.h" +#include "absl/strings/string_view.h" namespace grpc_core { diff --git a/deps/grpc/src/core/ext/filters/http/server/http_server_filter.h b/deps/grpc/src/core/ext/filters/http/server/http_server_filter.h index a287515fd5f..7d800b7c383 100644 --- a/deps/grpc/src/core/ext/filters/http/server/http_server_filter.h +++ b/deps/grpc/src/core/ext/filters/http/server/http_server_filter.h @@ -21,11 +21,11 @@ #include -#include "absl/status/statusor.h" #include "src/core/channelz/property_list.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/channel_fwd.h" #include "src/core/lib/channel/promise_based_filter.h" +#include "absl/status/statusor.h" namespace grpc_core { @@ -66,6 +66,9 @@ class HttpServerFilter final : public ImplementChannelFilter, static inline const NoInterceptor OnClientToServerHalfClose; static inline const NoInterceptor OnServerToClientMessage; static inline const NoInterceptor OnFinalize; + channelz::PropertyList ChannelzProperties() { + return channelz::PropertyList(); + } }; private: diff --git a/deps/grpc/src/core/ext/filters/load_reporting/server_load_reporting_filter.cc b/deps/grpc/src/core/ext/filters/load_reporting/server_load_reporting_filter.cc index a71c1d70c0b..017dc37c552 100644 --- a/deps/grpc/src/core/ext/filters/load_reporting/server_load_reporting_filter.cc +++ b/deps/grpc/src/core/ext/filters/load_reporting/server_load_reporting_filter.cc @@ -32,13 +32,6 @@ #include #include -#include "absl/container/inlined_vector.h" -#include "absl/log/log.h" -#include "absl/status/status.h" -#include "absl/strings/ascii.h" -#include "absl/strings/str_cat.h" -#include "absl/strings/str_format.h" -#include "absl/strings/string_view.h" #include "opencensus/stats/stats.h" #include "opencensus/tags/tag_key.h" #include "src/core/call/call_finalization.h" @@ -61,6 +54,13 @@ #include "src/core/util/latent_see.h" #include "src/core/util/uri.h" #include "src/cpp/server/load_reporter/constants.h" +#include "absl/container/inlined_vector.h" +#include "absl/log/log.h" +#include "absl/status/status.h" +#include "absl/strings/ascii.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/str_format.h" +#include "absl/strings/string_view.h" // IWYU pragma: no_include "opencensus/stats/recording.h" diff --git a/deps/grpc/src/core/ext/filters/load_reporting/server_load_reporting_filter.h b/deps/grpc/src/core/ext/filters/load_reporting/server_load_reporting_filter.h index 2d0f2e20237..261e0e377cb 100644 --- a/deps/grpc/src/core/ext/filters/load_reporting/server_load_reporting_filter.h +++ b/deps/grpc/src/core/ext/filters/load_reporting/server_load_reporting_filter.h @@ -24,11 +24,11 @@ #include -#include "absl/status/statusor.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/promise_based_filter.h" #include "src/core/lib/promise/arena_promise.h" #include "src/core/lib/transport/transport.h" +#include "absl/status/statusor.h" namespace grpc_core { @@ -58,6 +58,9 @@ class ServerLoadReportingFilter static inline const NoInterceptor OnServerToClientMessage; void OnFinalize(const grpc_call_final_info* final_info, ServerLoadReportingFilter* filter); + channelz::PropertyList ChannelzProperties() const { + return channelz::PropertyList(); + } private: std::string client_ip_and_lr_token_; diff --git a/deps/grpc/src/core/ext/filters/logging/logging_filter.cc b/deps/grpc/src/core/ext/filters/logging/logging_filter.cc index 567405381c1..754722a67af 100644 --- a/deps/grpc/src/core/ext/filters/logging/logging_filter.cc +++ b/deps/grpc/src/core/ext/filters/logging/logging_filter.cc @@ -34,16 +34,6 @@ #include #include -#include "absl/log/log.h" -#include "absl/numeric/int128.h" -#include "absl/random/random.h" -#include "absl/random/uniform_int_distribution.h" -#include "absl/status/statusor.h" -#include "absl/strings/numbers.h" -#include "absl/strings/str_cat.h" -#include "absl/strings/str_split.h" -#include "absl/strings/string_view.h" -#include "absl/strings/strip.h" #include "src/core/call/metadata_batch.h" #include "src/core/client_channel/client_channel_filter.h" #include "src/core/config/core_configuration.h" @@ -67,6 +57,16 @@ #include "src/core/util/latent_see.h" #include "src/core/util/time.h" #include "src/core/util/uri.h" +#include "absl/log/log.h" +#include "absl/numeric/int128.h" +#include "absl/random/random.h" +#include "absl/random/uniform_int_distribution.h" +#include "absl/status/statusor.h" +#include "absl/strings/numbers.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/str_split.h" +#include "absl/strings/string_view.h" +#include "absl/strings/strip.h" namespace grpc_core { diff --git a/deps/grpc/src/core/ext/filters/logging/logging_filter.h b/deps/grpc/src/core/ext/filters/logging/logging_filter.h index 78140c75f16..dcf0d235774 100644 --- a/deps/grpc/src/core/ext/filters/logging/logging_filter.h +++ b/deps/grpc/src/core/ext/filters/logging/logging_filter.h @@ -24,13 +24,13 @@ #include #include -#include "absl/status/statusor.h" #include "src/core/ext/filters/logging/logging_sink.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/channel_fwd.h" #include "src/core/lib/channel/promise_based_filter.h" #include "src/core/lib/promise/arena_promise.h" #include "src/core/lib/transport/transport.h" +#include "absl/status/statusor.h" namespace grpc_core { diff --git a/deps/grpc/src/core/ext/filters/logging/logging_sink.h b/deps/grpc/src/core/ext/filters/logging/logging_sink.h index 8b7914e0110..7519374c441 100644 --- a/deps/grpc/src/core/ext/filters/logging/logging_sink.h +++ b/deps/grpc/src/core/ext/filters/logging/logging_sink.h @@ -25,10 +25,10 @@ #include #include +#include "src/core/util/time.h" #include "absl/numeric/int128.h" #include "absl/strings/str_cat.h" #include "absl/strings/string_view.h" -#include "src/core/util/time.h" namespace grpc_core { diff --git a/deps/grpc/src/core/ext/filters/message_size/message_size_filter.cc b/deps/grpc/src/core/ext/filters/message_size/message_size_filter.cc index 4b041fd1372..28ab4e378a4 100644 --- a/deps/grpc/src/core/ext/filters/message_size/message_size_filter.cc +++ b/deps/grpc/src/core/ext/filters/message_size/message_size_filter.cc @@ -24,8 +24,6 @@ #include #include -#include "absl/log/log.h" -#include "absl/strings/str_format.h" #include "src/core/call/metadata_batch.h" #include "src/core/config/core_configuration.h" #include "src/core/lib/channel/channel_args.h" @@ -42,6 +40,8 @@ #include "src/core/lib/transport/transport.h" #include "src/core/service_config/service_config_call_data.h" #include "src/core/util/latent_see.h" +#include "absl/log/log.h" +#include "absl/strings/str_format.h" namespace grpc_core { diff --git a/deps/grpc/src/core/ext/filters/message_size/message_size_filter.h b/deps/grpc/src/core/ext/filters/message_size/message_size_filter.h index 4ff2dbbe5b1..53893bd0fb1 100644 --- a/deps/grpc/src/core/ext/filters/message_size/message_size_filter.h +++ b/deps/grpc/src/core/ext/filters/message_size/message_size_filter.h @@ -24,8 +24,6 @@ #include #include -#include "absl/status/statusor.h" -#include "absl/strings/string_view.h" #include "src/core/config/core_configuration.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/channel_fwd.h" @@ -37,6 +35,8 @@ #include "src/core/util/json/json_args.h" #include "src/core/util/json/json_object_loader.h" #include "src/core/util/validation_errors.h" +#include "absl/status/statusor.h" +#include "absl/strings/string_view.h" namespace grpc_core { @@ -106,6 +106,9 @@ class ServerMessageSizeFilter final static inline const NoInterceptor OnClientToServerHalfClose; ServerMetadataHandle OnServerToClientMessage( const Message& message, ServerMessageSizeFilter* filter); + channelz::PropertyList ChannelzProperties() { + return channelz::PropertyList(); + } }; private: @@ -135,6 +138,9 @@ class ClientMessageSizeFilter final ServerMetadataHandle OnClientToServerMessage(const Message& message); static inline const NoInterceptor OnClientToServerHalfClose; ServerMetadataHandle OnServerToClientMessage(const Message& message); + channelz::PropertyList ChannelzProperties() { + return channelz::PropertyList(); + } private: MessageSizeParsedConfig limits_; diff --git a/deps/grpc/src/core/ext/filters/rbac/rbac_filter.cc b/deps/grpc/src/core/ext/filters/rbac/rbac_filter.cc index 1573e263add..f5602d24999 100644 --- a/deps/grpc/src/core/ext/filters/rbac/rbac_filter.cc +++ b/deps/grpc/src/core/ext/filters/rbac/rbac_filter.cc @@ -23,7 +23,6 @@ #include #include -#include "absl/status/status.h" #include "src/core/call/metadata_batch.h" #include "src/core/config/core_configuration.h" #include "src/core/ext/filters/rbac/rbac_service_config_parser.h" @@ -38,6 +37,7 @@ #include "src/core/service_config/service_config_call_data.h" #include "src/core/transport/auth_context.h" #include "src/core/util/latent_see.h" +#include "absl/status/status.h" namespace grpc_core { diff --git a/deps/grpc/src/core/ext/filters/rbac/rbac_filter.h b/deps/grpc/src/core/ext/filters/rbac/rbac_filter.h index e7f95d344af..0a719a29416 100644 --- a/deps/grpc/src/core/ext/filters/rbac/rbac_filter.h +++ b/deps/grpc/src/core/ext/filters/rbac/rbac_filter.h @@ -20,13 +20,13 @@ #include #include -#include "absl/status/statusor.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/channel_fwd.h" #include "src/core/lib/channel/promise_based_filter.h" #include "src/core/lib/promise/arena_promise.h" #include "src/core/lib/security/authorization/evaluate_args.h" #include "src/core/lib/transport/transport.h" +#include "absl/status/statusor.h" namespace grpc_core { @@ -58,6 +58,9 @@ class RbacFilter : public ImplementChannelFilter { static inline const NoInterceptor OnClientToServerHalfClose; static inline const NoInterceptor OnServerToClientMessage; static inline const NoInterceptor OnFinalize; + channelz::PropertyList ChannelzProperties() { + return channelz::PropertyList(); + } }; private: diff --git a/deps/grpc/src/core/ext/filters/rbac/rbac_service_config_parser.cc b/deps/grpc/src/core/ext/filters/rbac/rbac_service_config_parser.cc index fff63d17cef..27b0b4c03c5 100644 --- a/deps/grpc/src/core/ext/filters/rbac/rbac_service_config_parser.cc +++ b/deps/grpc/src/core/ext/filters/rbac/rbac_service_config_parser.cc @@ -25,14 +25,14 @@ #include #include -#include "absl/status/status.h" -#include "absl/status/statusor.h" -#include "absl/strings/str_cat.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/security/authorization/audit_logging.h" #include "src/core/util/json/json_args.h" #include "src/core/util/json/json_object_loader.h" #include "src/core/util/matchers.h" +#include "absl/status/status.h" +#include "absl/status/statusor.h" +#include "absl/strings/str_cat.h" namespace grpc_core { diff --git a/deps/grpc/src/core/ext/filters/rbac/rbac_service_config_parser.h b/deps/grpc/src/core/ext/filters/rbac/rbac_service_config_parser.h index b62db1bdc2b..6202c569f91 100644 --- a/deps/grpc/src/core/ext/filters/rbac/rbac_service_config_parser.h +++ b/deps/grpc/src/core/ext/filters/rbac/rbac_service_config_parser.h @@ -25,7 +25,6 @@ #include #include -#include "absl/strings/string_view.h" #include "src/core/config/core_configuration.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/security/authorization/grpc_authorization_engine.h" @@ -33,6 +32,7 @@ #include "src/core/service_config/service_config_parser.h" #include "src/core/util/json/json.h" #include "src/core/util/validation_errors.h" +#include "absl/strings/string_view.h" namespace grpc_core { diff --git a/deps/grpc/src/core/ext/filters/stateful_session/stateful_session_filter.cc b/deps/grpc/src/core/ext/filters/stateful_session/stateful_session_filter.cc index 49fa402647f..53cb0d7d0fa 100644 --- a/deps/grpc/src/core/ext/filters/stateful_session/stateful_session_filter.cc +++ b/deps/grpc/src/core/ext/filters/stateful_session/stateful_session_filter.cc @@ -27,13 +27,6 @@ #include #include -#include "absl/strings/escaping.h" -#include "absl/strings/match.h" -#include "absl/strings/str_cat.h" -#include "absl/strings/str_join.h" -#include "absl/strings/str_split.h" -#include "absl/strings/string_view.h" -#include "absl/strings/strip.h" #include "src/core/call/metadata_batch.h" #include "src/core/config/core_configuration.h" #include "src/core/ext/filters/stateful_session/stateful_session_service_config_parser.h" @@ -51,6 +44,13 @@ #include "src/core/util/grpc_check.h" #include "src/core/util/latent_see.h" #include "src/core/util/time.h" +#include "absl/strings/escaping.h" +#include "absl/strings/match.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/str_join.h" +#include "absl/strings/str_split.h" +#include "absl/strings/string_view.h" +#include "absl/strings/strip.h" namespace grpc_core { diff --git a/deps/grpc/src/core/ext/filters/stateful_session/stateful_session_filter.h b/deps/grpc/src/core/ext/filters/stateful_session/stateful_session_filter.h index f07e73d875e..6d242ce045a 100644 --- a/deps/grpc/src/core/ext/filters/stateful_session/stateful_session_filter.h +++ b/deps/grpc/src/core/ext/filters/stateful_session/stateful_session_filter.h @@ -22,8 +22,6 @@ #include -#include "absl/status/statusor.h" -#include "absl/strings/string_view.h" #include "src/core/ext/filters/stateful_session/stateful_session_service_config_parser.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/channel_fwd.h" @@ -33,6 +31,8 @@ #include "src/core/service_config/service_config_call_data.h" #include "src/core/util/ref_counted_string.h" #include "src/core/util/unique_type_name.h" +#include "absl/status/statusor.h" +#include "absl/strings/string_view.h" namespace grpc_core { @@ -89,6 +89,17 @@ class StatefulSessionFilter static inline const NoInterceptor OnClientToServerHalfClose; static inline const NoInterceptor OnServerToClientMessage; static inline const NoInterceptor OnFinalize; + channelz::PropertyList ChannelzProperties() { + return channelz::PropertyList() + .Set("cluster_name", cluster_name_) + .Set("override_host_attribute_cookie_address_list", + override_host_attribute_->cookie_address_list()) + .Set("override_host_attribute_actual_address_list", + override_host_attribute_->actual_address_list()) + .Set("cookie_address_list", cookie_address_list_) + .Set("cluster_changed", cluster_changed_) + .Set("perform_filtering", perform_filtering_); + } private: const StatefulSessionMethodParsedConfig::CookieConfig* cookie_config_; diff --git a/deps/grpc/src/core/ext/filters/stateful_session/stateful_session_service_config_parser.h b/deps/grpc/src/core/ext/filters/stateful_session/stateful_session_service_config_parser.h index 06e0b11c26b..6c1e3ca4983 100644 --- a/deps/grpc/src/core/ext/filters/stateful_session/stateful_session_service_config_parser.h +++ b/deps/grpc/src/core/ext/filters/stateful_session/stateful_session_service_config_parser.h @@ -25,7 +25,6 @@ #include #include -#include "absl/strings/string_view.h" #include "src/core/config/core_configuration.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/service_config/service_config_parser.h" @@ -34,6 +33,7 @@ #include "src/core/util/json/json_object_loader.h" #include "src/core/util/time.h" #include "src/core/util/validation_errors.h" +#include "absl/strings/string_view.h" // Channel arg key for enabling parsing fault injection via method config. #define GRPC_ARG_PARSE_STATEFUL_SESSION_METHOD_CONFIG \ diff --git a/deps/grpc/src/core/ext/transport/chaotic_good/chaotic_good.cc b/deps/grpc/src/core/ext/transport/chaotic_good/chaotic_good.cc index b1c1b23585e..f93db7dea3d 100644 --- a/deps/grpc/src/core/ext/transport/chaotic_good/chaotic_good.cc +++ b/deps/grpc/src/core/ext/transport/chaotic_good/chaotic_good.cc @@ -14,10 +14,10 @@ #include "src/core/ext/transport/chaotic_good/chaotic_good.h" -#include "absl/strings/string_view.h" #include "src/core/config/core_configuration.h" #include "src/core/ext/transport/chaotic_good/client/chaotic_good_connector.h" #include "src/core/ext/transport/chaotic_good/server/chaotic_good_server.h" +#include "absl/strings/string_view.h" namespace grpc_core::chaotic_good { diff --git a/deps/grpc/src/core/ext/transport/chaotic_good/client/chaotic_good_connector.cc b/deps/grpc/src/core/ext/transport/chaotic_good/client/chaotic_good_connector.cc index 0f24ef45587..678070ca8dc 100644 --- a/deps/grpc/src/core/ext/transport/chaotic_good/client/chaotic_good_connector.cc +++ b/deps/grpc/src/core/ext/transport/chaotic_good/client/chaotic_good_connector.cc @@ -21,10 +21,6 @@ #include #include -#include "absl/log/log.h" -#include "absl/random/bit_gen_ref.h" -#include "absl/status/status.h" -#include "absl/status/statusor.h" #include "src/core/client_channel/client_channel_factory.h" #include "src/core/client_channel/client_channel_filter.h" #include "src/core/config/core_configuration.h" @@ -69,6 +65,10 @@ #include "src/core/util/no_destruct.h" #include "src/core/util/ref_counted_ptr.h" #include "src/core/util/time.h" +#include "absl/log/log.h" +#include "absl/random/bit_gen_ref.h" +#include "absl/status/status.h" +#include "absl/status/statusor.h" using grpc_event_engine::experimental::EventEngine; @@ -212,6 +212,8 @@ auto ConnectChaoticGood(EventEngine::ResolvedAddress addr, void ChaoticGoodConnector::Connect(const Args& args, Result* result, grpc_closure* notify) { + // TODO(ctiller): Figure out a better value to use here. + result->max_concurrent_streams = std::numeric_limits::max(); auto event_engine = args.channel_args.GetObjectRef(); auto arena = SimpleArenaAllocator(0)->MakeArena(); auto result_notifier = std::make_unique(args, result, notify); @@ -229,7 +231,10 @@ void ChaoticGoodConnector::Connect(const Args& args, Result* result, return TrySeq( ConnectChaoticGood( resolved_addr, result_notifier_ptr->args.channel_args, - Timestamp::Now() + Duration::FromSecondsAsDouble(kTimeoutSecs), + IsChaoticGoodConnectDeadlineEnabled() + ? result_notifier_ptr->args.deadline + : Timestamp::Now() + + Duration::FromSecondsAsDouble(kTimeoutSecs), std::move(client_settings)), [resolved_addr, result_notifier_ptr](ConnectChaoticGoodResult result) { diff --git a/deps/grpc/src/core/ext/transport/chaotic_good/client/chaotic_good_connector.h b/deps/grpc/src/core/ext/transport/chaotic_good/client/chaotic_good_connector.h index 8bdfc787b33..91f9ad1d6f0 100644 --- a/deps/grpc/src/core/ext/transport/chaotic_good/client/chaotic_good_connector.h +++ b/deps/grpc/src/core/ext/transport/chaotic_good/client/chaotic_good_connector.h @@ -22,9 +22,6 @@ #include #include -#include "absl/random/random.h" -#include "absl/status/status.h" -#include "absl/status/statusor.h" #include "src/core/client_channel/connector.h" #include "src/core/ext/transport/chaotic_good/config.h" #include "src/core/handshaker/handshaker.h" @@ -44,6 +41,9 @@ #include "src/core/util/notification.h" #include "src/core/util/ref_counted_ptr.h" #include "src/core/util/sync.h" +#include "absl/random/random.h" +#include "absl/status/status.h" +#include "absl/status/statusor.h" namespace grpc_core { namespace chaotic_good { diff --git a/deps/grpc/src/core/ext/transport/chaotic_good/client_transport.cc b/deps/grpc/src/core/ext/transport/chaotic_good/client_transport.cc index 4405736b3d0..a9c122f21d7 100644 --- a/deps/grpc/src/core/ext/transport/chaotic_good/client_transport.cc +++ b/deps/grpc/src/core/ext/transport/chaotic_good/client_transport.cc @@ -26,11 +26,6 @@ #include #include -#include "absl/log/log.h" -#include "absl/random/bit_gen_ref.h" -#include "absl/random/random.h" -#include "absl/status/status.h" -#include "absl/status/statusor.h" #include "src/core/ext/transport/chaotic_good/frame.h" #include "src/core/ext/transport/chaotic_good/frame_header.h" #include "src/core/ext/transport/chaotic_good/frame_transport.h" @@ -47,13 +42,22 @@ #include "src/core/lib/transport/promise_endpoint.h" #include "src/core/util/grpc_check.h" #include "src/core/util/ref_counted_ptr.h" +#include "absl/log/log.h" +#include "absl/random/bit_gen_ref.h" +#include "absl/random/random.h" +#include "absl/status/status.h" +#include "absl/status/statusor.h" namespace grpc_core { namespace chaotic_good { +using grpc_event_engine::experimental::EventEngine; + ChaoticGoodClientTransport::StreamDispatch::StreamDispatch( - MpscSender outgoing_frames) - : outgoing_frames_(std::move(outgoing_frames)) {} + MpscSender outgoing_frames, + std::shared_ptr event_engine) + : outgoing_frames_(std::move(outgoing_frames)), + event_engine_(std::move(event_engine)) {} RefCountedPtr ChaoticGoodClientTransport::StreamDispatch::LookupStream(uint32_t stream_id) { @@ -172,6 +176,14 @@ void ChaoticGoodClientTransport::StreamDispatch::OnFrameTransportClosed( state_tracker_.SetState(GRPC_CHANNEL_SHUTDOWN, absl::UnavailableError("transport closed"), "transport closed"); + if (watcher_ != nullptr) { + event_engine_->Run([watcher = std::move(watcher_), status]() mutable { + ExecCtx exec_ctx; + // TODO(ctiller): Provide better disconnect info here. + watcher->OnDisconnect(std::move(status), {}); + watcher.reset(); // While ExecCtx is in scope. + }); + } lock.Release(); for (auto& pair : stream_map) { auto stream = std::move(pair.second); @@ -219,6 +231,21 @@ void ChaoticGoodClientTransport::StreamDispatch::StopConnectivityWatch( state_tracker_.RemoveWatcher(watcher); } +void ChaoticGoodClientTransport::StreamDispatch::StartWatch( + RefCountedPtr watcher) { + MutexLock lock(&mu_); + GRPC_CHECK(watcher_ == nullptr); + watcher_ = std::move(watcher); + // TODO(ctiller): Report MAX_CONCURRENT_STREAMS to watcher here, and + // whenever the peer's setting changes. +} + +void ChaoticGoodClientTransport::StreamDispatch::StopWatch( + RefCountedPtr watcher) { + MutexLock lock(&mu_); + if (watcher_ == watcher) watcher_.reset(); +} + ChaoticGoodClientTransport::ChaoticGoodClientTransport( const ChannelArgs& args, OrphanablePtr frame_transport, MessageChunker message_chunker) @@ -231,13 +258,12 @@ ChaoticGoodClientTransport::ChaoticGoodClientTransport( frame_transport_(std::move(frame_transport)) { GRPC_CHECK(ctx_ != nullptr); auto party_arena = SimpleArenaAllocator(0)->MakeArena(); - party_arena->SetContext( - ctx_->event_engine.get()); + party_arena->SetContext(ctx_->event_engine.get()); party_ = Party::Make(std::move(party_arena)); MpscReceiver outgoing_frames{256 * 1024 * 1024}; outgoing_frames_ = outgoing_frames.MakeSender(); - stream_dispatch_ = - MakeRefCounted(outgoing_frames.MakeSender()); + stream_dispatch_ = MakeRefCounted( + outgoing_frames.MakeSender(), ctx_->event_engine); frame_transport_->Start(party_.get(), std::move(outgoing_frames), stream_dispatch_); SourceConstructed(); diff --git a/deps/grpc/src/core/ext/transport/chaotic_good/client_transport.h b/deps/grpc/src/core/ext/transport/chaotic_good/client_transport.h index 61e3613885e..12ba33b80e3 100644 --- a/deps/grpc/src/core/ext/transport/chaotic_good/client_transport.h +++ b/deps/grpc/src/core/ext/transport/chaotic_good/client_transport.h @@ -33,10 +33,6 @@ #include #include -#include "absl/base/thread_annotations.h" -#include "absl/container/flat_hash_map.h" -#include "absl/random/random.h" -#include "absl/status/status.h" #include "src/core/call/metadata_batch.h" // IWYU pragma: keep #include "src/core/ext/transport/chaotic_good/config.h" #include "src/core/ext/transport/chaotic_good/frame.h" @@ -62,6 +58,10 @@ #include "src/core/lib/transport/promise_endpoint.h" #include "src/core/lib/transport/transport.h" #include "src/core/util/sync.h" +#include "absl/base/thread_annotations.h" +#include "absl/container/flat_hash_map.h" +#include "absl/random/random.h" +#include "absl/status/status.h" namespace grpc_core { namespace chaotic_good { @@ -89,6 +89,13 @@ class ChaoticGoodClientTransport final : public ClientTransport, void StartCall(CallHandler call_handler) override; + void StartWatch(RefCountedPtr watcher) override { + stream_dispatch_->StartWatch(std::move(watcher)); + } + void StopWatch(RefCountedPtr watcher) override { + stream_dispatch_->StopWatch(std::move(watcher)); + } + private: struct Stream : public RefCounted { explicit Stream(CallHandler call) @@ -103,7 +110,9 @@ class ChaoticGoodClientTransport final : public ClientTransport, class StreamDispatch final : public FrameTransportSink { public: - explicit StreamDispatch(MpscSender outgoing_frames); + StreamDispatch(MpscSender outgoing_frames, + std::shared_ptr + event_engine); void OnIncomingFrame(IncomingFrame incoming_frame) override; void OnFrameTransportClosed(absl::Status status) override; @@ -115,6 +124,9 @@ class ChaoticGoodClientTransport final : public ClientTransport, OrphanablePtr watcher); void StopConnectivityWatch(ConnectivityStateWatcherInterface* watcher); + void StartWatch(RefCountedPtr watcher); + void StopWatch(RefCountedPtr watcher); + private: template void DispatchFrame(IncomingFrame incoming_frame); @@ -142,7 +154,9 @@ class ChaoticGoodClientTransport final : public ClientTransport, StreamMap stream_map_ ABSL_GUARDED_BY(mu_); ConnectivityStateTracker state_tracker_ ABSL_GUARDED_BY(mu_){ "chaotic_good_client", GRPC_CHANNEL_READY}; + RefCountedPtr watcher_ ABSL_GUARDED_BY(mu_); MpscSender outgoing_frames_; + std::shared_ptr event_engine_; }; auto CallOutboundLoop(uint32_t stream_id, CallHandler call_handler); diff --git a/deps/grpc/src/core/ext/transport/chaotic_good/config.h b/deps/grpc/src/core/ext/transport/chaotic_good/config.h index be245ded28a..853d8e1c490 100644 --- a/deps/grpc/src/core/ext/transport/chaotic_good/config.h +++ b/deps/grpc/src/core/ext/transport/chaotic_good/config.h @@ -17,13 +17,13 @@ #include -#include "absl/container/flat_hash_set.h" #include "src/core/ext/transport/chaotic_good/chaotic_good_frame.pb.h" #include "src/core/ext/transport/chaotic_good/message_chunker.h" #include "src/core/ext/transport/chaotic_good/pending_connection.h" #include "src/core/ext/transport/chaotic_good/tcp_frame_transport.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/event_engine/extensions/tcp_trace.h" +#include "absl/container/flat_hash_set.h" namespace grpc_core { namespace chaotic_good { diff --git a/deps/grpc/src/core/ext/transport/chaotic_good/control_endpoint.h b/deps/grpc/src/core/ext/transport/chaotic_good/control_endpoint.h index cdb1211403a..51d9ea08b0a 100644 --- a/deps/grpc/src/core/ext/transport/chaotic_good/control_endpoint.h +++ b/deps/grpc/src/core/ext/transport/chaotic_good/control_endpoint.h @@ -15,13 +15,13 @@ #ifndef GRPC_SRC_CORE_EXT_TRANSPORT_CHAOTIC_GOOD_CONTROL_ENDPOINT_H #define GRPC_SRC_CORE_EXT_TRANSPORT_CHAOTIC_GOOD_CONTROL_ENDPOINT_H -#include "absl/cleanup/cleanup.h" #include "src/core/ext/transport/chaotic_good/tcp_ztrace_collector.h" #include "src/core/ext/transport/chaotic_good/transport_context.h" #include "src/core/lib/promise/party.h" #include "src/core/lib/transport/promise_endpoint.h" #include "src/core/util/ref_counted_ptr.h" #include "src/core/util/sync.h" +#include "absl/cleanup/cleanup.h" namespace grpc_core { namespace chaotic_good { diff --git a/deps/grpc/src/core/ext/transport/chaotic_good/data_endpoints.cc b/deps/grpc/src/core/ext/transport/chaotic_good/data_endpoints.cc index 64a9c6cc342..e0173f7c492 100644 --- a/deps/grpc/src/core/ext/transport/chaotic_good/data_endpoints.cc +++ b/deps/grpc/src/core/ext/transport/chaotic_good/data_endpoints.cc @@ -24,12 +24,6 @@ #include #include -#include "absl/cleanup/cleanup.h" -#include "absl/container/inlined_vector.h" -#include "absl/log/log.h" -#include "absl/strings/numbers.h" -#include "absl/strings/str_split.h" -#include "absl/time/time.h" #include "src/core/channelz/property_list.h" #include "src/core/ext/transport/chaotic_good/tcp_frame_header.h" #include "src/core/ext/transport/chaotic_good/tcp_ztrace_collector.h" @@ -49,6 +43,12 @@ #include "src/core/util/ref_counted.h" #include "src/core/util/shared_bit_gen.h" #include "src/core/util/string.h" +#include "absl/cleanup/cleanup.h" +#include "absl/container/inlined_vector.h" +#include "absl/log/log.h" +#include "absl/strings/numbers.h" +#include "absl/strings/str_split.h" +#include "absl/time/time.h" namespace grpc_core { namespace chaotic_good { @@ -879,7 +879,12 @@ Endpoint::Endpoint(uint32_t id, uint32_t encode_alignment, auto* epte = grpc_event_engine::experimental::QueryExtension< grpc_event_engine::experimental::TcpTraceExtension>( endpoint->GetEventEngineEndpoint().get()); - if (epte != nullptr) { + if (epte != nullptr && + ep_ctx->transport_ctx->stats_plugin_group != nullptr) { + epte->EnableTcpTelemetry( + ep_ctx->transport_ctx->stats_plugin_group + ->GetCollectionScope(), + /*is_control_endpoint=*/false); epte->SetTcpTracer(std::make_shared( ep_ctx->transport_ctx->stats_plugin_group)); } diff --git a/deps/grpc/src/core/ext/transport/chaotic_good/frame.cc b/deps/grpc/src/core/ext/transport/chaotic_good/frame.cc index a49bfbf30d4..cfef9bea8ee 100644 --- a/deps/grpc/src/core/ext/transport/chaotic_good/frame.cc +++ b/deps/grpc/src/core/ext/transport/chaotic_good/frame.cc @@ -23,8 +23,6 @@ #include #include -#include "absl/status/status.h" -#include "absl/status/statusor.h" #include "src/core/ext/transport/chaotic_good/chaotic_good_frame.pb.h" #include "src/core/ext/transport/chaotic_good/frame_header.h" #include "src/core/lib/promise/context.h" @@ -36,6 +34,8 @@ #include "src/core/util/grpc_check.h" #include "src/core/util/no_destruct.h" #include "src/core/util/status_helper.h" +#include "absl/status/status.h" +#include "absl/status/statusor.h" namespace grpc_core { namespace chaotic_good { diff --git a/deps/grpc/src/core/ext/transport/chaotic_good/frame.h b/deps/grpc/src/core/ext/transport/chaotic_good/frame.h index f3d013c1230..7de5035d9a8 100644 --- a/deps/grpc/src/core/ext/transport/chaotic_good/frame.h +++ b/deps/grpc/src/core/ext/transport/chaotic_good/frame.h @@ -22,8 +22,6 @@ #include #include -#include "absl/random/bit_gen_ref.h" -#include "absl/status/status.h" #include "src/core/call/message.h" #include "src/core/call/metadata.h" #include "src/core/ext/transport/chaotic_good/chaotic_good_frame.pb.h" @@ -31,6 +29,8 @@ #include "src/core/lib/resource_quota/arena.h" #include "src/core/lib/slice/slice_buffer.h" #include "src/core/util/match.h" +#include "absl/random/bit_gen_ref.h" +#include "absl/status/status.h" namespace grpc_core { namespace chaotic_good { diff --git a/deps/grpc/src/core/ext/transport/chaotic_good/frame_header.h b/deps/grpc/src/core/ext/transport/chaotic_good/frame_header.h index f3f54ccbc28..76b5de09255 100644 --- a/deps/grpc/src/core/ext/transport/chaotic_good/frame_header.h +++ b/deps/grpc/src/core/ext/transport/chaotic_good/frame_header.h @@ -20,9 +20,9 @@ #include -#include "absl/status/statusor.h" #include "src/core/channelz/property_list.h" #include "src/core/util/bitset.h" +#include "absl/status/statusor.h" namespace grpc_core { namespace chaotic_good { diff --git a/deps/grpc/src/core/ext/transport/chaotic_good/message_reassembly.h b/deps/grpc/src/core/ext/transport/chaotic_good/message_reassembly.h index 208fc09bb7e..305d243039b 100644 --- a/deps/grpc/src/core/ext/transport/chaotic_good/message_reassembly.h +++ b/deps/grpc/src/core/ext/transport/chaotic_good/message_reassembly.h @@ -15,9 +15,9 @@ #ifndef GRPC_SRC_CORE_EXT_TRANSPORT_CHAOTIC_GOOD_MESSAGE_REASSEMBLY_H #define GRPC_SRC_CORE_EXT_TRANSPORT_CHAOTIC_GOOD_MESSAGE_REASSEMBLY_H -#include "absl/log/log.h" #include "src/core/call/call_spine.h" #include "src/core/ext/transport/chaotic_good/frame.h" +#include "absl/log/log.h" namespace grpc_core { namespace chaotic_good { diff --git a/deps/grpc/src/core/ext/transport/chaotic_good/pending_connection.h b/deps/grpc/src/core/ext/transport/chaotic_good/pending_connection.h index 90c0f7df802..bf532b0cedc 100644 --- a/deps/grpc/src/core/ext/transport/chaotic_good/pending_connection.h +++ b/deps/grpc/src/core/ext/transport/chaotic_good/pending_connection.h @@ -17,10 +17,11 @@ #include -#include "absl/status/statusor.h" +#include "src/core/lib/channel/channel_args.h" #include "src/core/lib/promise/promise.h" #include "src/core/lib/transport/promise_endpoint.h" #include "src/core/util/dual_ref_counted.h" +#include "absl/status/statusor.h" namespace grpc_core { namespace chaotic_good { @@ -50,7 +51,8 @@ class PendingConnection { class ServerConnectionFactory : public DualRefCounted { public: using DualRefCounted::DualRefCounted; - virtual PendingConnection RequestDataConnection() = 0; + virtual PendingConnection RequestDataConnection( + const ChannelArgs& handshake_result_args) = 0; }; class ClientConnectionFactory : public DualRefCounted { diff --git a/deps/grpc/src/core/ext/transport/chaotic_good/scheduler.cc b/deps/grpc/src/core/ext/transport/chaotic_good/scheduler.cc index cc33bdddaf2..fe10d61c82a 100644 --- a/deps/grpc/src/core/ext/transport/chaotic_good/scheduler.cc +++ b/deps/grpc/src/core/ext/transport/chaotic_good/scheduler.cc @@ -22,13 +22,13 @@ #include #include +#include "src/core/ext/transport/chaotic_good/send_rate.h" +#include "src/core/ext/transport/chaotic_good/tcp_ztrace_collector.h" +#include "src/core/util/shared_bit_gen.h" #include "absl/log/log.h" #include "absl/strings/numbers.h" #include "absl/strings/str_split.h" #include "absl/strings/string_view.h" -#include "src/core/ext/transport/chaotic_good/send_rate.h" -#include "src/core/ext/transport/chaotic_good/tcp_ztrace_collector.h" -#include "src/core/util/shared_bit_gen.h" namespace grpc_core::chaotic_good { diff --git a/deps/grpc/src/core/ext/transport/chaotic_good/scheduler.h b/deps/grpc/src/core/ext/transport/chaotic_good/scheduler.h index d98365153cd..bd87ebaec33 100644 --- a/deps/grpc/src/core/ext/transport/chaotic_good/scheduler.h +++ b/deps/grpc/src/core/ext/transport/chaotic_good/scheduler.h @@ -19,9 +19,9 @@ #include #include -#include "absl/strings/string_view.h" #include "src/core/ext/transport/chaotic_good/send_rate.h" #include "src/core/ext/transport/chaotic_good/tcp_ztrace_collector.h" +#include "absl/strings/string_view.h" namespace grpc_core::chaotic_good { diff --git a/deps/grpc/src/core/ext/transport/chaotic_good/send_rate.cc b/deps/grpc/src/core/ext/transport/chaotic_good/send_rate.cc index 4f23d726ad3..1e5f43cc9ec 100644 --- a/deps/grpc/src/core/ext/transport/chaotic_good/send_rate.cc +++ b/deps/grpc/src/core/ext/transport/chaotic_good/send_rate.cc @@ -14,8 +14,8 @@ #include "src/core/ext/transport/chaotic_good/send_rate.h" -#include "absl/log/log.h" #include "src/core/util/grpc_check.h" +#include "absl/log/log.h" namespace grpc_core { namespace chaotic_good { diff --git a/deps/grpc/src/core/ext/transport/chaotic_good/server/chaotic_good_server.cc b/deps/grpc/src/core/ext/transport/chaotic_good/server/chaotic_good_server.cc index a0a22efffa3..db4bf535a52 100644 --- a/deps/grpc/src/core/ext/transport/chaotic_good/server/chaotic_good_server.cc +++ b/deps/grpc/src/core/ext/transport/chaotic_good/server/chaotic_good_server.cc @@ -26,10 +26,6 @@ #include #include -#include "absl/log/log.h" -#include "absl/random/bit_gen_ref.h" -#include "absl/status/status.h" -#include "absl/status/statusor.h" #include "src/core/call/metadata.h" #include "src/core/call/metadata_batch.h" #include "src/core/ext/transport/chaotic_good/frame.h" @@ -67,12 +63,17 @@ #include "src/core/lib/transport/promise_endpoint.h" #include "src/core/server/server.h" #include "src/core/telemetry/metrics.h" +#include "src/core/transport/auth_context.h" #include "src/core/util/grpc_check.h" #include "src/core/util/orphanable.h" #include "src/core/util/ref_counted_ptr.h" #include "src/core/util/status_helper.h" #include "src/core/util/sync.h" #include "src/core/util/time.h" +#include "absl/log/log.h" +#include "absl/random/bit_gen_ref.h" +#include "absl/status/status.h" +#include "absl/status/statusor.h" namespace grpc_core { namespace chaotic_good { @@ -242,10 +243,9 @@ absl::Status ChaoticGoodServerListener::BindExternal(std::string addr, grpc_event_engine::experimental::SliceBuffer::TakeCSliceBuffer( pending_read->data.raw.slice_buffer); } - GRPC_CHECK( - GRPC_LOG_IF_ERROR("listener_handle_external_connection", - listener_supports_fd_->HandleExternalConnection( - listener_fd, fd, &pending_data))); + GRPC_LOG_IF_ERROR("listener_handle_external_connection", + listener_supports_fd_->HandleExternalConnection( + listener_fd, fd, &pending_data)); } private: @@ -330,7 +330,8 @@ ChaoticGoodServerListener::DataConnectionListener::DataConnectionListener( connect_timeout_(connect_timeout) {} PendingConnection -ChaoticGoodServerListener::DataConnectionListener::RequestDataConnection() { +ChaoticGoodServerListener::DataConnectionListener::RequestDataConnection( + const ChannelArgs& handshake_result_args) { MutexLock lock(&mu_); std::string connection_id; while (true) { @@ -348,38 +349,70 @@ ChaoticGoodServerListener::DataConnectionListener::RequestDataConnection() { [connection_id, self = WeakRefAsSubclass()]() { self->ConnectionTimeout(connection_id); }); - pending_connections_.emplace(connection_id, - PendingConnectionInfo{latch, timeout_task}); + pending_connections_.emplace( + connection_id, + PendingConnectionInfo{ + latch, timeout_task, + handshake_result_args.GetObjectRef()}); return PendingConnection(connection_id, Map(latch->Wait(), [latch](auto x) { return x; })); } -ChaoticGoodServerListener::DataConnectionListener::PromiseEndpointLatchPtr +std::optional< + ChaoticGoodServerListener::DataConnectionListener::PendingConnectionInfo> ChaoticGoodServerListener::DataConnectionListener::Extract( absl::string_view id) { MutexLock lock(&mu_); auto ex = pending_connections_.extract(id); - if (!ex.empty()) { - event_engine_->Cancel(ex.mapped().timeout); - return std::move(ex.mapped().latch); + if (ex.empty()) { + return std::nullopt; } - return nullptr; + + event_engine_->Cancel(ex.mapped().timeout); + return ex.mapped(); } void ChaoticGoodServerListener::DataConnectionListener::ConnectionTimeout( absl::string_view id) { - auto latch = Extract(id); - if (latch != nullptr) { - latch->Set(absl::DeadlineExceededError("Connection timeout")); + std::optional pending_connection = Extract(id); + if (pending_connection == std::nullopt) { + GRPC_TRACE_LOG(chaotic_good, ERROR) + << "ConnectionTimeout: connection not found"; + return; } + pending_connection->latch->Set( + absl::DeadlineExceededError("Connection timeout")); } void ChaoticGoodServerListener::DataConnectionListener::FinishDataConnection( - absl::string_view id, PromiseEndpoint endpoint) { - auto latch = Extract(id); - if (latch != nullptr) { - latch->Set(std::move(endpoint)); + absl::string_view id, PromiseEndpoint endpoint, + RefCountedPtr auth_context) { + auto pending_connection = Extract(id); + if (pending_connection == std::nullopt) { + GRPC_TRACE_LOG(chaotic_good, ERROR) << "FinishDataConnection: connection " + "not found"; + return; + } + + if (pending_connection->control_endpoint_auth_context == nullptr) { + GRPC_TRACE_LOG(chaotic_good, INFO) + << "Control endpoint auth context is null, skipping auth context " + "comparison"; + } else { + // Compare the auth context with the one from the control endpoint. + // If they are different, drop the connection. + std::optional is_same_peer = auth_context->CompareAuthContext( + pending_connection->control_endpoint_auth_context.get()); + if (is_same_peer.has_value() && !is_same_peer.value()) { + GRPC_TRACE_LOG(chaotic_good, ERROR) + << "FinishDataConnection: auth context mismatch"; + pending_connection->latch->Set( + absl::UnauthenticatedError("Auth context mismatch")); + return; + } } + + pending_connection->latch->Set(std::move(endpoint)); } void ChaoticGoodServerListener::DataConnectionListener::Orphaned() { @@ -491,7 +524,8 @@ auto ChaoticGoodServerListener::ActiveConnection::HandshakingState:: ->data_connection_listener_; for (int i = 0; i < num_data_connections; i++) { config.ServerAddPendingDataEndpoint( - data_connection_listener.RequestDataConnection()); + data_connection_listener.RequestDataConnection( + self->connection_->handshake_result_args())); } self->data_.emplace(std::move(config)); } @@ -555,7 +589,9 @@ auto ChaoticGoodServerListener::ActiveConnection::HandshakingState:: self->connection_->listener_->data_connection_listener_ ->FinishDataConnection( std::get(self->data_).connection_id, - std::move(self->connection_->endpoint_)); + std::move(self->connection_->endpoint_), + self->connection_->handshake_result_args_ + ->GetObjectRef()); return absl::OkStatus(); }); } diff --git a/deps/grpc/src/core/ext/transport/chaotic_good/server/chaotic_good_server.h b/deps/grpc/src/core/ext/transport/chaotic_good/server/chaotic_good_server.h index 153a98fffeb..be57373efea 100644 --- a/deps/grpc/src/core/ext/transport/chaotic_good/server/chaotic_good_server.h +++ b/deps/grpc/src/core/ext/transport/chaotic_good/server/chaotic_good_server.h @@ -24,10 +24,6 @@ #include #include -#include "absl/container/flat_hash_map.h" -#include "absl/random/random.h" -#include "absl/status/status.h" -#include "absl/status/statusor.h" #include "src/core/channelz/channel_trace.h" #include "src/core/channelz/channelz.h" #include "src/core/ext/transport/chaotic_good/config.h" @@ -46,9 +42,14 @@ #include "src/core/lib/slice/slice_internal.h" #include "src/core/lib/transport/promise_endpoint.h" #include "src/core/server/server.h" +#include "src/core/transport/auth_context.h" #include "src/core/util/shared_bit_gen.h" #include "src/core/util/sync.h" #include "src/core/util/time.h" +#include "absl/container/flat_hash_map.h" +#include "absl/random/random.h" +#include "absl/status/status.h" +#include "absl/status/statusor.h" // Channel arg: integer number of data connections to specify // Defaults to 1 if not set @@ -156,8 +157,10 @@ class ChaoticGoodServerListener final : public Server::ListenerInterface { void Orphaned() override; - PendingConnection RequestDataConnection() override; - void FinishDataConnection(absl::string_view id, PromiseEndpoint endpoint); + PendingConnection RequestDataConnection( + const ChannelArgs& handshake_result_args) override; + void FinishDataConnection(absl::string_view id, PromiseEndpoint endpoint, + RefCountedPtr auth_context); Duration connection_timeout() const { return connect_timeout_; } private: @@ -167,10 +170,11 @@ class ChaoticGoodServerListener final : public Server::ListenerInterface { struct PendingConnectionInfo { PromiseEndpointLatchPtr latch; grpc_event_engine::experimental::EventEngine::TaskHandle timeout; + RefCountedPtr control_endpoint_auth_context; }; void ConnectionTimeout(absl::string_view id); - PromiseEndpointLatchPtr Extract(absl::string_view id); + std::optional Extract(absl::string_view id); Mutex mu_; absl::flat_hash_map pending_connections_ diff --git a/deps/grpc/src/core/ext/transport/chaotic_good/server_transport.cc b/deps/grpc/src/core/ext/transport/chaotic_good/server_transport.cc index 825154da5b2..f1af9d6a42b 100644 --- a/deps/grpc/src/core/ext/transport/chaotic_good/server_transport.cc +++ b/deps/grpc/src/core/ext/transport/chaotic_good/server_transport.cc @@ -23,12 +23,6 @@ #include #include -#include "absl/cleanup/cleanup.h" -#include "absl/log/log.h" -#include "absl/random/bit_gen_ref.h" -#include "absl/random/random.h" -#include "absl/status/status.h" -#include "absl/status/statusor.h" #include "src/core/channelz/property_list.h" #include "src/core/ext/transport/chaotic_good/frame.h" #include "src/core/ext/transport/chaotic_good/frame_header.h" @@ -49,6 +43,12 @@ #include "src/core/lib/transport/promise_endpoint.h" #include "src/core/util/grpc_check.h" #include "src/core/util/ref_counted_ptr.h" +#include "absl/cleanup/cleanup.h" +#include "absl/log/log.h" +#include "absl/random/bit_gen_ref.h" +#include "absl/random/random.h" +#include "absl/status/status.h" +#include "absl/status/statusor.h" namespace grpc_core { namespace chaotic_good { diff --git a/deps/grpc/src/core/ext/transport/chaotic_good/server_transport.h b/deps/grpc/src/core/ext/transport/chaotic_good/server_transport.h index 0f11a61589e..805e7709ead 100644 --- a/deps/grpc/src/core/ext/transport/chaotic_good/server_transport.h +++ b/deps/grpc/src/core/ext/transport/chaotic_good/server_transport.h @@ -35,12 +35,6 @@ #include #include -#include "absl/base/thread_annotations.h" -#include "absl/container/flat_hash_map.h" -#include "absl/functional/any_invocable.h" -#include "absl/random/random.h" -#include "absl/status/status.h" -#include "absl/status/statusor.h" #include "src/core/call/metadata_batch.h" #include "src/core/ext/transport/chaotic_good/config.h" #include "src/core/ext/transport/chaotic_good/frame.h" @@ -73,6 +67,12 @@ #include "src/core/lib/transport/transport.h" #include "src/core/util/ref_counted_ptr.h" #include "src/core/util/sync.h" +#include "absl/base/thread_annotations.h" +#include "absl/container/flat_hash_map.h" +#include "absl/functional/any_invocable.h" +#include "absl/random/random.h" +#include "absl/status/status.h" +#include "absl/status/statusor.h" namespace grpc_core { namespace chaotic_good { @@ -94,6 +94,14 @@ class ChaoticGoodServerTransport final : public ServerTransport { RefCountedPtr GetSocketNode() const override { return frame_transport_->ctx()->socket_node; } + void StartWatch(RefCountedPtr) override { + // TODO(roth): Implement as part of migrating server side to new + // watcher API. + } + void StopWatch(RefCountedPtr) override { + // TODO(roth): Implement as part of migrating server side to new + // watcher API. + } void SetCallDestination( RefCountedPtr call_destination) override; diff --git a/deps/grpc/src/core/ext/transport/chaotic_good/tcp_frame_header.h b/deps/grpc/src/core/ext/transport/chaotic_good/tcp_frame_header.h index 589f5d49cd6..c11b408ec47 100644 --- a/deps/grpc/src/core/ext/transport/chaotic_good/tcp_frame_header.h +++ b/deps/grpc/src/core/ext/transport/chaotic_good/tcp_frame_header.h @@ -16,9 +16,9 @@ #ifndef GRPC_SRC_CORE_EXT_TRANSPORT_CHAOTIC_GOOD_TCP_FRAME_HEADER_H #define GRPC_SRC_CORE_EXT_TRANSPORT_CHAOTIC_GOOD_TCP_FRAME_HEADER_H -#include "absl/strings/str_cat.h" #include "src/core/channelz/property_list.h" #include "src/core/ext/transport/chaotic_good/frame_header.h" +#include "absl/strings/str_cat.h" namespace grpc_core::chaotic_good { diff --git a/deps/grpc/src/core/ext/transport/chaotic_good_legacy/chaotic_good_transport.h b/deps/grpc/src/core/ext/transport/chaotic_good_legacy/chaotic_good_transport.h index ee27cb51f40..db2d51bc083 100644 --- a/deps/grpc/src/core/ext/transport/chaotic_good_legacy/chaotic_good_transport.h +++ b/deps/grpc/src/core/ext/transport/chaotic_good_legacy/chaotic_good_transport.h @@ -22,7 +22,6 @@ #include #include -#include "absl/strings/escaping.h" #include "src/core/call/call_spine.h" #include "src/core/ext/transport/chaotic_good_legacy/control_endpoint.h" #include "src/core/ext/transport/chaotic_good_legacy/data_endpoints.h" @@ -39,6 +38,7 @@ #include "src/core/lib/promise/try_join.h" #include "src/core/lib/promise/try_seq.h" #include "src/core/lib/transport/promise_endpoint.h" +#include "absl/strings/escaping.h" namespace grpc_core { namespace chaotic_good_legacy { diff --git a/deps/grpc/src/core/ext/transport/chaotic_good_legacy/client/chaotic_good_connector.cc b/deps/grpc/src/core/ext/transport/chaotic_good_legacy/client/chaotic_good_connector.cc index d1bc9c4cb8c..ac3ea7a32c0 100644 --- a/deps/grpc/src/core/ext/transport/chaotic_good_legacy/client/chaotic_good_connector.cc +++ b/deps/grpc/src/core/ext/transport/chaotic_good_legacy/client/chaotic_good_connector.cc @@ -21,10 +21,6 @@ #include #include -#include "absl/log/log.h" -#include "absl/random/bit_gen_ref.h" -#include "absl/status/status.h" -#include "absl/status/statusor.h" #include "src/core/client_channel/client_channel_factory.h" #include "src/core/client_channel/client_channel_filter.h" #include "src/core/config/core_configuration.h" @@ -65,6 +61,10 @@ #include "src/core/util/no_destruct.h" #include "src/core/util/ref_counted_ptr.h" #include "src/core/util/time.h" +#include "absl/log/log.h" +#include "absl/random/bit_gen_ref.h" +#include "absl/status/status.h" +#include "absl/status/statusor.h" using grpc_event_engine::experimental::ChannelArgsEndpointConfig; using grpc_event_engine::experimental::EventEngine; @@ -216,6 +216,8 @@ auto ConnectChaoticGood(EventEngine::ResolvedAddress addr, void ChaoticGoodConnector::Connect(const Args& args, Result* result, grpc_closure* notify) { + // TODO(ctiller): Figure out a better value to use here. + result->max_concurrent_streams = std::numeric_limits::max(); auto event_engine = args.channel_args.GetObjectRef(); auto arena = SimpleArenaAllocator(0)->MakeArena(); auto result_notifier = std::make_unique(args, result, notify); diff --git a/deps/grpc/src/core/ext/transport/chaotic_good_legacy/client/chaotic_good_connector.h b/deps/grpc/src/core/ext/transport/chaotic_good_legacy/client/chaotic_good_connector.h index 7bd7124eb5c..2de1475127d 100644 --- a/deps/grpc/src/core/ext/transport/chaotic_good_legacy/client/chaotic_good_connector.h +++ b/deps/grpc/src/core/ext/transport/chaotic_good_legacy/client/chaotic_good_connector.h @@ -22,8 +22,6 @@ #include #include -#include "absl/random/random.h" -#include "absl/status/statusor.h" #include "src/core/client_channel/connector.h" #include "src/core/ext/transport/chaotic_good_legacy/config.h" #include "src/core/handshaker/handshaker.h" @@ -43,6 +41,8 @@ #include "src/core/util/notification.h" #include "src/core/util/ref_counted_ptr.h" #include "src/core/util/sync.h" +#include "absl/random/random.h" +#include "absl/status/statusor.h" namespace grpc_core { namespace chaotic_good_legacy { diff --git a/deps/grpc/src/core/ext/transport/chaotic_good_legacy/client_transport.cc b/deps/grpc/src/core/ext/transport/chaotic_good_legacy/client_transport.cc index 7e77b897a3a..88ebe411812 100644 --- a/deps/grpc/src/core/ext/transport/chaotic_good_legacy/client_transport.cc +++ b/deps/grpc/src/core/ext/transport/chaotic_good_legacy/client_transport.cc @@ -26,11 +26,6 @@ #include #include -#include "absl/log/log.h" -#include "absl/random/bit_gen_ref.h" -#include "absl/random/random.h" -#include "absl/status/status.h" -#include "absl/status/statusor.h" #include "src/core/ext/transport/chaotic_good_legacy/chaotic_good_transport.h" #include "src/core/ext/transport/chaotic_good_legacy/frame.h" #include "src/core/ext/transport/chaotic_good_legacy/frame_header.h" @@ -48,10 +43,17 @@ #include "src/core/telemetry/metrics.h" #include "src/core/util/grpc_check.h" #include "src/core/util/ref_counted_ptr.h" +#include "absl/log/log.h" +#include "absl/random/bit_gen_ref.h" +#include "absl/random/random.h" +#include "absl/status/status.h" +#include "absl/status/statusor.h" namespace grpc_core { namespace chaotic_good_legacy { +using grpc_event_engine::experimental::EventEngine; + void ChaoticGoodClientTransport::Orphan() { AbortWithError(); RefCountedPtr party; @@ -233,8 +235,7 @@ ChaoticGoodClientTransport::ChaoticGoodClientTransport( args.GetObjectRef(), config.MakeTransportOptions(), config.tracing_enabled(), socket_node_); auto party_arena = SimpleArenaAllocator(0)->MakeArena(); - party_arena->SetContext( - event_engine.get()); + party_arena->SetContext(event_engine.get()); party_ = Party::Make(std::move(party_arena)); party_->Spawn( "client-chaotic-writer", @@ -260,6 +261,15 @@ void ChaoticGoodClientTransport::AbortWithError() { state_tracker_.SetState(GRPC_CHANNEL_SHUTDOWN, absl::UnavailableError("transport closed"), "transport closed"); + if (watcher_ != nullptr) { + party_->arena()->GetContext()->Run( + [watcher = std::move(watcher_)]() mutable { + ExecCtx exec_ctx; + // TODO(ctiller): Provide better disconnect info here. + watcher->OnDisconnect(absl::UnavailableError("transport closed"), {}); + watcher.reset(); // While ExecCtx is in scope. + }); + } lock.Release(); for (auto& pair : stream_map) { auto stream = std::move(pair.second); @@ -400,6 +410,21 @@ void ChaoticGoodClientTransport::PerformOp(grpc_transport_op* op) { ExecCtx::Run(DEBUG_LOCATION, op->on_consumed, absl::OkStatus()); } +void ChaoticGoodClientTransport::StartWatch( + RefCountedPtr watcher) { + MutexLock lock(&mu_); + GRPC_CHECK(watcher_ == nullptr); + watcher_ = std::move(watcher); + // TODO(ctiller): Report MAX_CONCURRENT_STREAMS to watcher here, and + // whenever the peer's setting changes. +} + +void ChaoticGoodClientTransport::StopWatch( + RefCountedPtr watcher) { + MutexLock lock(&mu_); + if (watcher_ == watcher) watcher_.reset(); +} + void ChaoticGoodClientTransport::ChannelzDataSource::AddData( channelz::DataSink sink) { transport_->party_->ExportToChannelz("party", sink); diff --git a/deps/grpc/src/core/ext/transport/chaotic_good_legacy/client_transport.h b/deps/grpc/src/core/ext/transport/chaotic_good_legacy/client_transport.h index 1668046c37b..e84371f5d80 100644 --- a/deps/grpc/src/core/ext/transport/chaotic_good_legacy/client_transport.h +++ b/deps/grpc/src/core/ext/transport/chaotic_good_legacy/client_transport.h @@ -32,10 +32,6 @@ #include #include -#include "absl/base/thread_annotations.h" -#include "absl/container/flat_hash_map.h" -#include "absl/random/random.h" -#include "absl/status/status.h" #include "src/core/call/metadata_batch.h" // IWYU pragma: keep #include "src/core/channelz/property_list.h" #include "src/core/ext/transport/chaotic_good_legacy/chaotic_good_transport.h" @@ -61,6 +57,10 @@ #include "src/core/lib/transport/promise_endpoint.h" #include "src/core/lib/transport/transport.h" #include "src/core/util/sync.h" +#include "absl/base/thread_annotations.h" +#include "absl/container/flat_hash_map.h" +#include "absl/random/random.h" +#include "absl/status/status.h" namespace grpc_core { namespace chaotic_good_legacy { @@ -83,6 +83,8 @@ class ChaoticGoodClientTransport final : public ClientTransport { RefCountedPtr GetSocketNode() const override { return socket_node_; } + void StartWatch(RefCountedPtr watcher) override; + void StopWatch(RefCountedPtr watcher) override; void StartCall(CallHandler call_handler) override; void AbortWithError(); @@ -134,6 +136,7 @@ class ChaoticGoodClientTransport final : public ClientTransport { RefCountedPtr party_; ConnectivityStateTracker state_tracker_ ABSL_GUARDED_BY(mu_){ "chaotic_good_client", GRPC_CHANNEL_READY}; + RefCountedPtr watcher_ ABSL_GUARDED_BY(mu_); MessageChunker message_chunker_; RefCountedPtr socket_node_; std::unique_ptr channelz_data_source_; diff --git a/deps/grpc/src/core/ext/transport/chaotic_good_legacy/config.h b/deps/grpc/src/core/ext/transport/chaotic_good_legacy/config.h index fce46660a3e..5af70b36cee 100644 --- a/deps/grpc/src/core/ext/transport/chaotic_good_legacy/config.h +++ b/deps/grpc/src/core/ext/transport/chaotic_good_legacy/config.h @@ -17,13 +17,13 @@ #include -#include "absl/container/flat_hash_set.h" #include "src/core/ext/transport/chaotic_good/chaotic_good_frame.pb.h" #include "src/core/ext/transport/chaotic_good_legacy/chaotic_good_transport.h" #include "src/core/ext/transport/chaotic_good_legacy/message_chunker.h" #include "src/core/ext/transport/chaotic_good_legacy/pending_connection.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/event_engine/extensions/tcp_trace.h" +#include "absl/container/flat_hash_set.h" namespace grpc_core { namespace chaotic_good_legacy { diff --git a/deps/grpc/src/core/ext/transport/chaotic_good_legacy/control_endpoint.h b/deps/grpc/src/core/ext/transport/chaotic_good_legacy/control_endpoint.h index 64055c5d5e7..42b31f4952c 100644 --- a/deps/grpc/src/core/ext/transport/chaotic_good_legacy/control_endpoint.h +++ b/deps/grpc/src/core/ext/transport/chaotic_good_legacy/control_endpoint.h @@ -15,12 +15,12 @@ #ifndef GRPC_SRC_CORE_EXT_TRANSPORT_CHAOTIC_GOOD_LEGACY_CONTROL_ENDPOINT_H #define GRPC_SRC_CORE_EXT_TRANSPORT_CHAOTIC_GOOD_LEGACY_CONTROL_ENDPOINT_H -#include "absl/cleanup/cleanup.h" #include "src/core/ext/transport/chaotic_good_legacy/legacy_ztrace_collector.h" #include "src/core/lib/promise/map.h" #include "src/core/lib/promise/party.h" #include "src/core/lib/transport/promise_endpoint.h" #include "src/core/util/sync.h" +#include "absl/cleanup/cleanup.h" namespace grpc_core { namespace chaotic_good_legacy { diff --git a/deps/grpc/src/core/ext/transport/chaotic_good_legacy/data_endpoints.cc b/deps/grpc/src/core/ext/transport/chaotic_good_legacy/data_endpoints.cc index ba325fb21f1..335bcfd8b62 100644 --- a/deps/grpc/src/core/ext/transport/chaotic_good_legacy/data_endpoints.cc +++ b/deps/grpc/src/core/ext/transport/chaotic_good_legacy/data_endpoints.cc @@ -18,8 +18,6 @@ #include #include -#include "absl/cleanup/cleanup.h" -#include "absl/strings/escaping.h" #include "src/core/ext/transport/chaotic_good_legacy/pending_connection.h" #include "src/core/lib/event_engine/event_engine_context.h" #include "src/core/lib/event_engine/extensions/channelz.h" @@ -30,6 +28,8 @@ #include "src/core/lib/promise/seq.h" #include "src/core/lib/promise/try_seq.h" #include "src/core/telemetry/default_tcp_tracer.h" +#include "absl/cleanup/cleanup.h" +#include "absl/strings/escaping.h" namespace grpc_core { namespace chaotic_good_legacy { @@ -310,7 +310,10 @@ Endpoint::Endpoint(uint32_t id, RefCountedPtr output_buffers, auto* epte = grpc_event_engine::experimental::QueryExtension< grpc_event_engine::experimental::TcpTraceExtension>( endpoint->GetEventEngineEndpoint().get()); - if (epte != nullptr) { + if (epte != nullptr && stats_plugin_group != nullptr) { + epte->EnableTcpTelemetry( + stats_plugin_group->GetCollectionScope(), + /*is_control_endpoint=*/false); epte->SetTcpTracer(std::make_shared( std::move(stats_plugin_group))); } diff --git a/deps/grpc/src/core/ext/transport/chaotic_good_legacy/frame.cc b/deps/grpc/src/core/ext/transport/chaotic_good_legacy/frame.cc index 765c0b4824f..e7ca15d8be1 100644 --- a/deps/grpc/src/core/ext/transport/chaotic_good_legacy/frame.cc +++ b/deps/grpc/src/core/ext/transport/chaotic_good_legacy/frame.cc @@ -23,8 +23,6 @@ #include #include -#include "absl/status/status.h" -#include "absl/status/statusor.h" #include "src/core/ext/transport/chaotic_good/chaotic_good_frame.pb.h" #include "src/core/ext/transport/chaotic_good_legacy/frame_header.h" #include "src/core/lib/promise/context.h" @@ -35,6 +33,8 @@ #include "src/core/util/grpc_check.h" #include "src/core/util/no_destruct.h" #include "src/core/util/status_helper.h" +#include "absl/status/status.h" +#include "absl/status/statusor.h" namespace grpc_core { namespace chaotic_good_legacy { diff --git a/deps/grpc/src/core/ext/transport/chaotic_good_legacy/frame.h b/deps/grpc/src/core/ext/transport/chaotic_good_legacy/frame.h index 958c8153a91..bff06ddc37b 100644 --- a/deps/grpc/src/core/ext/transport/chaotic_good_legacy/frame.h +++ b/deps/grpc/src/core/ext/transport/chaotic_good_legacy/frame.h @@ -21,8 +21,6 @@ #include #include -#include "absl/random/bit_gen_ref.h" -#include "absl/status/status.h" #include "src/core/call/message.h" #include "src/core/call/metadata.h" #include "src/core/ext/transport/chaotic_good/chaotic_good_frame.pb.h" @@ -30,6 +28,8 @@ #include "src/core/lib/resource_quota/arena.h" #include "src/core/lib/slice/slice_buffer.h" #include "src/core/util/match.h" +#include "absl/random/bit_gen_ref.h" +#include "absl/status/status.h" namespace grpc_core { namespace chaotic_good_legacy { diff --git a/deps/grpc/src/core/ext/transport/chaotic_good_legacy/frame_header.h b/deps/grpc/src/core/ext/transport/chaotic_good_legacy/frame_header.h index 15a5ed348ea..45353a34c97 100644 --- a/deps/grpc/src/core/ext/transport/chaotic_good_legacy/frame_header.h +++ b/deps/grpc/src/core/ext/transport/chaotic_good_legacy/frame_header.h @@ -20,8 +20,8 @@ #include -#include "absl/status/statusor.h" #include "src/core/channelz/property_list.h" +#include "absl/status/statusor.h" namespace grpc_core { namespace chaotic_good_legacy { diff --git a/deps/grpc/src/core/ext/transport/chaotic_good_legacy/message_reassembly.h b/deps/grpc/src/core/ext/transport/chaotic_good_legacy/message_reassembly.h index 739df880380..05254b11264 100644 --- a/deps/grpc/src/core/ext/transport/chaotic_good_legacy/message_reassembly.h +++ b/deps/grpc/src/core/ext/transport/chaotic_good_legacy/message_reassembly.h @@ -15,9 +15,9 @@ #ifndef GRPC_SRC_CORE_EXT_TRANSPORT_CHAOTIC_GOOD_LEGACY_MESSAGE_REASSEMBLY_H #define GRPC_SRC_CORE_EXT_TRANSPORT_CHAOTIC_GOOD_LEGACY_MESSAGE_REASSEMBLY_H -#include "absl/log/log.h" #include "src/core/call/call_spine.h" #include "src/core/ext/transport/chaotic_good_legacy/frame.h" +#include "absl/log/log.h" namespace grpc_core { namespace chaotic_good_legacy { diff --git a/deps/grpc/src/core/ext/transport/chaotic_good_legacy/pending_connection.h b/deps/grpc/src/core/ext/transport/chaotic_good_legacy/pending_connection.h index 06644626a52..120362f50ad 100644 --- a/deps/grpc/src/core/ext/transport/chaotic_good_legacy/pending_connection.h +++ b/deps/grpc/src/core/ext/transport/chaotic_good_legacy/pending_connection.h @@ -17,10 +17,10 @@ #include -#include "absl/status/statusor.h" #include "src/core/lib/promise/promise.h" #include "src/core/lib/transport/promise_endpoint.h" #include "src/core/util/dual_ref_counted.h" +#include "absl/status/statusor.h" namespace grpc_core { namespace chaotic_good_legacy { diff --git a/deps/grpc/src/core/ext/transport/chaotic_good_legacy/server/chaotic_good_server.cc b/deps/grpc/src/core/ext/transport/chaotic_good_legacy/server/chaotic_good_server.cc index 7a9dcf7e670..26a1379e335 100644 --- a/deps/grpc/src/core/ext/transport/chaotic_good_legacy/server/chaotic_good_server.cc +++ b/deps/grpc/src/core/ext/transport/chaotic_good_legacy/server/chaotic_good_server.cc @@ -26,10 +26,6 @@ #include #include -#include "absl/log/log.h" -#include "absl/random/bit_gen_ref.h" -#include "absl/status/status.h" -#include "absl/status/statusor.h" #include "src/core/call/metadata.h" #include "src/core/call/metadata_batch.h" #include "src/core/config/core_configuration.h" @@ -70,6 +66,10 @@ #include "src/core/util/status_helper.h" #include "src/core/util/sync.h" #include "src/core/util/time.h" +#include "absl/log/log.h" +#include "absl/random/bit_gen_ref.h" +#include "absl/status/status.h" +#include "absl/status/statusor.h" namespace grpc_core { namespace chaotic_good_legacy { diff --git a/deps/grpc/src/core/ext/transport/chaotic_good_legacy/server/chaotic_good_server.h b/deps/grpc/src/core/ext/transport/chaotic_good_legacy/server/chaotic_good_server.h index 6d3d685a5e1..79d929aa182 100644 --- a/deps/grpc/src/core/ext/transport/chaotic_good_legacy/server/chaotic_good_server.h +++ b/deps/grpc/src/core/ext/transport/chaotic_good_legacy/server/chaotic_good_server.h @@ -24,10 +24,6 @@ #include #include -#include "absl/container/flat_hash_map.h" -#include "absl/random/random.h" -#include "absl/status/status.h" -#include "absl/status/statusor.h" #include "src/core/channelz/channelz.h" #include "src/core/ext/transport/chaotic_good_legacy/config.h" #include "src/core/ext/transport/chaotic_good_legacy/pending_connection.h" @@ -46,6 +42,10 @@ #include "src/core/util/shared_bit_gen.h" #include "src/core/util/sync.h" #include "src/core/util/time.h" +#include "absl/container/flat_hash_map.h" +#include "absl/random/random.h" +#include "absl/status/status.h" +#include "absl/status/statusor.h" // Channel arg: integer number of data connections to specify // Defaults to 1 if not set diff --git a/deps/grpc/src/core/ext/transport/chaotic_good_legacy/server_transport.cc b/deps/grpc/src/core/ext/transport/chaotic_good_legacy/server_transport.cc index 08b1da49a16..c4085299f7a 100644 --- a/deps/grpc/src/core/ext/transport/chaotic_good_legacy/server_transport.cc +++ b/deps/grpc/src/core/ext/transport/chaotic_good_legacy/server_transport.cc @@ -23,12 +23,6 @@ #include #include -#include "absl/cleanup/cleanup.h" -#include "absl/log/log.h" -#include "absl/random/bit_gen_ref.h" -#include "absl/random/random.h" -#include "absl/status/status.h" -#include "absl/status/statusor.h" #include "src/core/ext/transport/chaotic_good_legacy/chaotic_good_transport.h" #include "src/core/ext/transport/chaotic_good_legacy/frame.h" #include "src/core/ext/transport/chaotic_good_legacy/frame_header.h" @@ -48,6 +42,12 @@ #include "src/core/telemetry/metrics.h" #include "src/core/util/grpc_check.h" #include "src/core/util/ref_counted_ptr.h" +#include "absl/cleanup/cleanup.h" +#include "absl/log/log.h" +#include "absl/random/bit_gen_ref.h" +#include "absl/random/random.h" +#include "absl/status/status.h" +#include "absl/status/statusor.h" namespace grpc_core { namespace chaotic_good_legacy { diff --git a/deps/grpc/src/core/ext/transport/chaotic_good_legacy/server_transport.h b/deps/grpc/src/core/ext/transport/chaotic_good_legacy/server_transport.h index 6bb60a6a508..d45b9aa693e 100644 --- a/deps/grpc/src/core/ext/transport/chaotic_good_legacy/server_transport.h +++ b/deps/grpc/src/core/ext/transport/chaotic_good_legacy/server_transport.h @@ -35,12 +35,6 @@ #include #include -#include "absl/base/thread_annotations.h" -#include "absl/container/flat_hash_map.h" -#include "absl/functional/any_invocable.h" -#include "absl/random/random.h" -#include "absl/status/status.h" -#include "absl/status/statusor.h" #include "src/core/call/metadata_batch.h" #include "src/core/ext/transport/chaotic_good_legacy/chaotic_good_transport.h" #include "src/core/ext/transport/chaotic_good_legacy/config.h" @@ -71,6 +65,12 @@ #include "src/core/lib/transport/transport.h" #include "src/core/util/ref_counted_ptr.h" #include "src/core/util/sync.h" +#include "absl/base/thread_annotations.h" +#include "absl/container/flat_hash_map.h" +#include "absl/functional/any_invocable.h" +#include "absl/random/random.h" +#include "absl/status/status.h" +#include "absl/status/statusor.h" namespace grpc_core { namespace chaotic_good_legacy { @@ -92,6 +92,14 @@ class ChaoticGoodServerTransport final : public ServerTransport { RefCountedPtr GetSocketNode() const override { return socket_node_; } + void StartWatch(RefCountedPtr) override { + // TODO(roth): Implement as part of migrating server side to new + // watcher API. + } + void StopWatch(RefCountedPtr) override { + // TODO(roth): Implement as part of migrating server side to new + // watcher API. + } void SetCallDestination( RefCountedPtr call_destination) override; diff --git a/deps/grpc/src/core/ext/transport/chttp2/GEMINI.md b/deps/grpc/src/core/ext/transport/chttp2/GEMINI.md index 7972be23512..b5f89c377e4 100644 --- a/deps/grpc/src/core/ext/transport/chttp2/GEMINI.md +++ b/deps/grpc/src/core/ext/transport/chttp2/GEMINI.md @@ -79,6 +79,7 @@ and the underlying endpoint. * **Reference CHTTP2:** When implementing features in PH2, always first check the CHTTP2 implementation in this directory for reference. Use the mapping in the "Key classes in CHTTP2 and their PH2 equivalents" section below to find the PH2 counterparts. * **Asynchronous Operations:** All asynchronous operations *must* use the gRPC Promise library (`src/core/lib/promise`), particularly leveraging `Party` for concurrency. See the `Dependencies for PH2` section. * **Testing:** Any changes to PH2 code should be accompanied by relevant tests. Ensure that existing tests in `test/core/transport/chttp2/http2_client_transport_test.cc` and `test/core/transport/chttp2/http2_server_transport_test.cc` pass. Add new tests as needed to cover new functionality. +* **Test Comments:** When writing new tests, include comments within each test explaining its purpose and assertions. For large tests, add comments for each step. ### Key Differences from CHTTP2 @@ -110,6 +111,7 @@ and the underlying endpoint. * Settings Helper : `http2_settings_promises.h` * Flow Control Helper : `flow_control_manager.h` * Stream : `stream.h` representation of each HTTP2 stream in the HTTP2 transport. +* GoAway : `goaway.{h,cc}` for implementation of HTTP2 GOAWAY ## 3. Common Files (Shared by CHTTP2 and PH2) @@ -166,26 +168,31 @@ Key test files include: * **PH2 Specific Tests:** * `test/core/transport/chttp2/http2_client_transport_test.cc`: Main test suite for the PH2 client transport. * `test/core/transport/chttp2/http2_server_transport_test.cc`: Main test suite for the PH2 server transport. + * `test/core/transport/chttp2/http2_transport_test.cc`: Common to PH2 Client and Server Transport. Tests code in `http2_transport.{h,cc}`. * `test/core/transport/chttp2/frame_test.cc` - * `test/core/transport/chttp2/ping_promise_test.cc` - * `test/core/transport/chttp2/stream_data_queue_test.cc` + * `test/core/transport/chttp2/goaway_test.cc` * `test/core/transport/chttp2/header_assembler_test.cc` - * `test/core/transport/chttp2/message_assembler_test.cc` - * `test/core/transport/chttp2/keepalive_test.cc` - * `test/core/transport/chttp2/writable_streams_test.cc` * `test/core/transport/chttp2/http2_status_test.cc` + * `test/core/transport/chttp2/keepalive_test.cc` * `test/core/transport/chttp2/message_assembler_fuzz_test.cc` + * `test/core/transport/chttp2/message_assembler_test.cc` + * `test/core/transport/chttp2/ping_promise_test.cc` + * `test/core/transport/chttp2/settings_timeout_manager_test.cc` + * `test/core/transport/chttp2/settings_timeout_test.cc` * `test/core/transport/chttp2/stream_data_queue_fuzz_test.cc` + * `test/core/transport/chttp2/stream_data_queue_test.cc` * `test/core/transport/chttp2/writable_streams_fuzz_test.cc` + * `test/core/transport/chttp2/writable_streams_test.cc` * **Common Component Tests:** - * `test/core/transport/chttp2/http2_settings_test.cc` + * `test/core/transport/chttp2/flow_control_fuzzer.cc` + * `test/core/transport/chttp2/flow_control_manager_test.cc` + * `test/core/transport/chttp2/flow_control_test.cc` * `test/core/transport/chttp2/hpack_encoder_test.cc` * `test/core/transport/chttp2/hpack_parser_test.cc` - * `test/core/transport/chttp2/flow_control_test.cc` - * `test/core/transport/chttp2/flow_control_manager_test.cc` - * `test/core/transport/chttp2/write_size_policy_test.cc` + * `test/core/transport/chttp2/http2_settings_test.cc` * `test/core/transport/chttp2/write_size_policy_fuzztest.cc` + * `test/core/transport/chttp2/write_size_policy_test.cc` * **PH2 End-to-end Tests:** * `test/core/end2end/end2end_ph2_config.cc`: This file defines the test diff --git a/deps/grpc/src/core/ext/transport/chttp2/client/chttp2_connector.cc b/deps/grpc/src/core/ext/transport/chttp2/client/chttp2_connector.cc index 53bc8f8256d..9482992b897 100644 --- a/deps/grpc/src/core/ext/transport/chttp2/client/chttp2_connector.cc +++ b/deps/grpc/src/core/ext/transport/chttp2/client/chttp2_connector.cc @@ -34,10 +34,6 @@ #include #include -#include "absl/log/log.h" -#include "absl/status/status.h" -#include "absl/status/statusor.h" -#include "absl/strings/str_format.h" #include "src/core/channelz/channelz.h" #include "src/core/client_channel/client_channel_factory.h" #include "src/core/client_channel/client_channel_filter.h" @@ -48,6 +44,10 @@ #include "src/core/credentials/transport/security_connector.h" #include "src/core/credentials/transport/transport_credentials.h" #include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" +#include "absl/log/log.h" +#include "absl/status/status.h" +#include "absl/status/statusor.h" +#include "absl/strings/str_format.h" #ifndef GRPC_EXPERIMENTAL_TEMPORARILY_DISABLE_PH2 // GRPC_EXPERIMENTAL_TEMPORARILY_DISABLE_PH2 is a temporary fix to help // some customers who are having severe memory constraints. This macro @@ -93,6 +93,9 @@ namespace grpc_core { +#define GRPC_HTTP2_CONNECTOR_DLOG \ + DLOG_IF(INFO, GRPC_TRACE_FLAG_ENABLED(http2_ph2_transport)) + using ::grpc_event_engine::experimental::EventEngine; namespace { @@ -169,19 +172,24 @@ void Chttp2Connector::OnHandshakeDone(absl::StatusOr result) { result_->Reset(); NullThenSchedClosure(DEBUG_LOCATION, ¬ify_, result.status()); } else if ((*result)->endpoint != nullptr) { + GRPC_HTTP2_CONNECTOR_DLOG + << "Chttp2Connector::OnHandshakeDone handshake succeeded with endpoint"; const bool is_callv1 = !((*result)->args.GetBool(GRPC_ARG_USE_V3_STACK).value_or(false)); if (is_callv1) { + GRPC_HTTP2_CONNECTOR_DLOG + << "Chttp2Connector::OnHandshakeDone creating chttp2 transport"; result_->transport = grpc_create_chttp2_transport( (*result)->args, std::move((*result)->endpoint), true); GRPC_CHECK_NE(result_->transport, nullptr); result_->channel_args = std::move((*result)->args); - Ref().release(); // Ref held by OnReceiveSettings() - GRPC_CLOSURE_INIT(&on_receive_settings_, OnReceiveSettings, this, - grpc_schedule_on_exec_ctx); grpc_chttp2_transport_start_reading( result_->transport, (*result)->read_buffer.c_slice_buffer(), - &on_receive_settings_, args_.interested_parties, nullptr); + [self = RefAsSubclass()]( + absl::StatusOr max_concurrent_streams) { + self->OnReceiveSettings(max_concurrent_streams); + }, + args_.interested_parties, nullptr); timer_handle_ = event_engine_->RunAfter( args_.deadline - Timestamp::Now(), [self = RefAsSubclass()]() mutable { @@ -199,6 +207,8 @@ void Chttp2Connector::OnHandshakeDone(absl::StatusOr result) { } #else } else { + GRPC_HTTP2_CONNECTOR_DLOG + << "Chttp2Connector::OnHandshakeDone creating PH2 transport"; // TODO(tjagtap) : [PH2][P1] : Validate this code block thoroughly once // the ping pong test is in place. std::unique_ptr @@ -217,15 +227,18 @@ void Chttp2Connector::OnHandshakeDone(absl::StatusOr result) { (*result) ->args .GetObjectRef(); - Ref().release(); // Ref held by OnReceiveSettings() - GRPC_CLOSURE_INIT(&on_receive_settings_, OnReceiveSettings, this, - grpc_schedule_on_exec_ctx); // Http2ClientTransport does not take ownership of the channel args. - result_->transport = new http2::Http2ClientTransport( - std::move(promise_endpoint), (*result)->args, event_engine_ptr, - &on_receive_settings_); + http2::Http2ClientTransport* client_transport = + new http2::Http2ClientTransport( + std::move(promise_endpoint), (*result)->args, event_engine_ptr, + [self = RefAsSubclass()]( + absl::StatusOr max_concurrent_streams) { + self->OnReceiveSettings(max_concurrent_streams); + }); + GRPC_DCHECK_NE(client_transport, nullptr); + result_->transport = client_transport; result_->channel_args = std::move((*result)->args); - GRPC_DCHECK_NE(result_->transport, nullptr); + client_transport->SpawnTransportLoops(); timer_handle_ = event_engine_->RunAfter( args_.deadline - Timestamp::Now(), [self = RefAsSubclass()]() mutable { @@ -246,31 +259,31 @@ void Chttp2Connector::OnHandshakeDone(absl::StatusOr result) { handshake_mgr_.reset(); } -void Chttp2Connector::OnReceiveSettings(void* arg, grpc_error_handle error) { - Chttp2Connector* self = static_cast(arg); - { - MutexLock lock(&self->mu_); - if (!self->notify_error_.has_value()) { - if (!error.ok()) { - // Transport got an error while waiting on SETTINGS frame. - self->result_->Reset(); - } - self->MaybeNotify(error); - if (self->timer_handle_.has_value()) { - if (self->event_engine_->Cancel(*self->timer_handle_)) { - // If we have cancelled the timer successfully, call Notify() again - // since the timer callback will not be called now. - self->MaybeNotify(absl::OkStatus()); - } - self->timer_handle_.reset(); +void Chttp2Connector::OnReceiveSettings( + absl::StatusOr max_concurrent_streams) { + MutexLock lock(&mu_); + if (max_concurrent_streams.ok()) { + result_->max_concurrent_streams = *max_concurrent_streams; + } + if (!notify_error_.has_value()) { + if (!max_concurrent_streams.ok()) { + // Transport got an error while waiting on SETTINGS frame. + result_->Reset(); + } + MaybeNotify(max_concurrent_streams.status()); + if (timer_handle_.has_value()) { + if (event_engine_->Cancel(*timer_handle_)) { + // If we have cancelled the timer successfully, call Notify() again + // since the timer callback will not be called now. + MaybeNotify(absl::OkStatus()); } - } else { - // OnTimeout() was already invoked. Call Notify() again so that notify_ - // can be invoked. - self->MaybeNotify(absl::OkStatus()); + timer_handle_.reset(); } + } else { + // OnTimeout() was already invoked. Call Notify() again so that notify_ + // can be invoked. + MaybeNotify(absl::OkStatus()); } - self->Unref(); } void Chttp2Connector::OnTimeout() { diff --git a/deps/grpc/src/core/ext/transport/chttp2/client/chttp2_connector.h b/deps/grpc/src/core/ext/transport/chttp2/client/chttp2_connector.h index b41462bc1c8..c3b52247c42 100644 --- a/deps/grpc/src/core/ext/transport/chttp2/client/chttp2_connector.h +++ b/deps/grpc/src/core/ext/transport/chttp2/client/chttp2_connector.h @@ -24,7 +24,6 @@ #include -#include "absl/base/thread_annotations.h" #include "src/core/client_channel/connector.h" #include "src/core/handshaker/handshaker.h" #include "src/core/lib/iomgr/closure.h" @@ -32,6 +31,7 @@ #include "src/core/lib/iomgr/error.h" #include "src/core/util/ref_counted_ptr.h" #include "src/core/util/sync.h" +#include "absl/base/thread_annotations.h" namespace grpc_core { @@ -42,7 +42,7 @@ class Chttp2Connector : public SubchannelConnector { private: void OnHandshakeDone(absl::StatusOr result); - static void OnReceiveSettings(void* arg, grpc_error_handle error); + void OnReceiveSettings(absl::StatusOr max_concurrent_streams); void OnTimeout() ABSL_LOCKS_EXCLUDED(mu_); // We cannot invoke notify_ until both OnTimeout() and OnReceiveSettings() @@ -61,7 +61,6 @@ class Chttp2Connector : public SubchannelConnector { Result* result_ = nullptr; grpc_closure* notify_ = nullptr; bool shutdown_ = false; - grpc_closure on_receive_settings_; std::optional timer_handle_ ABSL_GUARDED_BY(mu_); // A raw pointer will suffice since args_ holds a copy of the ChannelArgs diff --git a/deps/grpc/src/core/ext/transport/chttp2/server/chttp2_server.cc b/deps/grpc/src/core/ext/transport/chttp2/server/chttp2_server.cc index 9e7773d6b8f..25a4add6f36 100644 --- a/deps/grpc/src/core/ext/transport/chttp2/server/chttp2_server.cc +++ b/deps/grpc/src/core/ext/transport/chttp2/server/chttp2_server.cc @@ -37,14 +37,6 @@ #include #include -#include "absl/base/thread_annotations.h" -#include "absl/log/log.h" -#include "absl/status/status.h" -#include "absl/status/statusor.h" -#include "absl/strings/str_cat.h" -#include "absl/strings/str_format.h" -#include "absl/strings/string_view.h" -#include "absl/strings/strip.h" #include "src/core/channelz/channelz.h" #include "src/core/config/core_configuration.h" #include "src/core/credentials/transport/insecure/insecure_credentials.h" @@ -91,6 +83,14 @@ #include "src/core/util/time.h" #include "src/core/util/unique_type_name.h" #include "src/core/util/uri.h" +#include "absl/base/thread_annotations.h" +#include "absl/log/log.h" +#include "absl/status/status.h" +#include "absl/status/statusor.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/str_format.h" +#include "absl/strings/string_view.h" +#include "absl/strings/strip.h" #ifdef GPR_SUPPORT_CHANNELS_FROM_FD #include "src/core/lib/iomgr/ev_posix.h" @@ -207,16 +207,14 @@ void NewChttp2ServerListener::ActiveConnection::HandshakingState:: } void NewChttp2ServerListener::ActiveConnection::HandshakingState:: - OnReceiveSettings(void* arg, grpc_error_handle /* error */) { - HandshakingState* self = static_cast(arg); - self->connection_->work_serializer_.Run( - [self] { + OnReceiveSettings() { + connection_->work_serializer_.Run( + [self = Ref()] { if (self->timer_handle_.has_value()) { self->connection_->listener_state_->event_engine()->Cancel( *self->timer_handle_); self->timer_handle_.reset(); } - self->Unref(); }, DEBUG_LOCATION); } @@ -240,15 +238,15 @@ void NewChttp2ServerListener::ActiveConnection::HandshakingState:: // handshake deadline. connection_->state_ = DownCast(transport.get())->Ref(); - Ref().release(); // Held by OnReceiveSettings(). - GRPC_CLOSURE_INIT(&on_receive_settings_, OnReceiveSettings, this, - grpc_schedule_on_exec_ctx); grpc_closure* on_close = &connection_->on_close_; // Refs held by OnClose() connection_->Ref().release(); grpc_chttp2_transport_start_reading( transport.get(), (*result)->read_buffer.c_slice_buffer(), - &on_receive_settings_, nullptr, on_close); + [self = Ref()](absl::StatusOr) { + self->OnReceiveSettings(); + }, + nullptr, on_close); timer_handle_ = connection_->listener_state_->event_engine()->RunAfter( deadline_ - Timestamp::Now(), [self = Ref()]() mutable { // HandshakingState deletion might require an active ExecCtx. diff --git a/deps/grpc/src/core/ext/transport/chttp2/server/chttp2_server.h b/deps/grpc/src/core/ext/transport/chttp2/server/chttp2_server.h index 14d62cb5135..f0f50f9ff21 100644 --- a/deps/grpc/src/core/ext/transport/chttp2/server/chttp2_server.h +++ b/deps/grpc/src/core/ext/transport/chttp2/server/chttp2_server.h @@ -83,7 +83,7 @@ class NewChttp2ServerListener : public Server::ListenerInterface { friend class grpc_core::testing::HandshakingStateTestPeer; void OnTimeoutLocked(); - static void OnReceiveSettings(void* arg, grpc_error_handle /* error */); + void OnReceiveSettings(); void OnHandshakeDoneLocked(absl::StatusOr result); RefCountedPtr const connection_; @@ -98,7 +98,6 @@ class NewChttp2ServerListener : public Server::ListenerInterface { // State for enforcing handshake timeout on receiving HTTP/2 settings. std::optional timer_handle_; - grpc_closure on_receive_settings_; }; ActiveConnection(RefCountedPtr listener_state, diff --git a/deps/grpc/src/core/ext/transport/chttp2/transport/bin_decoder.cc b/deps/grpc/src/core/ext/transport/chttp2/transport/bin_decoder.cc index 5fb71d0d13a..2a42ff9dee5 100644 --- a/deps/grpc/src/core/ext/transport/chttp2/transport/bin_decoder.cc +++ b/deps/grpc/src/core/ext/transport/chttp2/transport/bin_decoder.cc @@ -21,10 +21,10 @@ #include #include -#include "absl/base/attributes.h" -#include "absl/log/log.h" #include "src/core/lib/slice/slice.h" #include "src/core/util/grpc_check.h" +#include "absl/base/attributes.h" +#include "absl/log/log.h" static uint8_t decode_table[] = { 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, diff --git a/deps/grpc/src/core/ext/transport/chttp2/transport/chttp2_transport.cc b/deps/grpc/src/core/ext/transport/chttp2/transport/chttp2_transport.cc index 42c5ecf1015..cdfe96fabbc 100644 --- a/deps/grpc/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +++ b/deps/grpc/src/core/ext/transport/chttp2/transport/chttp2_transport.cc @@ -44,18 +44,6 @@ #include #include -#include "absl/base/attributes.h" -#include "absl/container/flat_hash_map.h" -#include "absl/hash/hash.h" -#include "absl/log/log.h" -#include "absl/meta/type_traits.h" -#include "absl/random/random.h" -#include "absl/status/status.h" -#include "absl/strings/cord.h" -#include "absl/strings/str_cat.h" -#include "absl/strings/str_format.h" -#include "absl/strings/string_view.h" -#include "absl/time/time.h" #include "src/core/call/metadata_batch.h" #include "src/core/call/metadata_info.h" #include "src/core/channelz/property_list.h" @@ -71,6 +59,7 @@ #include "src/core/ext/transport/chttp2/transport/http2_settings_manager.h" #include "src/core/ext/transport/chttp2/transport/http2_stats_collector.h" #include "src/core/ext/transport/chttp2/transport/http2_status.h" +#include "src/core/ext/transport/chttp2/transport/http2_ztrace_collector.h" #include "src/core/ext/transport/chttp2/transport/internal.h" #include "src/core/ext/transport/chttp2/transport/legacy_frame.h" #include "src/core/ext/transport/chttp2/transport/ping_abuse_policy.h" @@ -126,6 +115,18 @@ #include "src/core/util/string.h" #include "src/core/util/time.h" #include "src/core/util/useful.h" +#include "absl/base/attributes.h" +#include "absl/container/flat_hash_map.h" +#include "absl/hash/hash.h" +#include "absl/log/log.h" +#include "absl/meta/type_traits.h" +#include "absl/random/random.h" +#include "absl/status/status.h" +#include "absl/strings/cord.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/str_format.h" +#include "absl/strings/string_view.h" +#include "absl/time/time.h" using grpc_core::Json; @@ -133,8 +134,6 @@ using grpc_core::Json; #define MAX_WINDOW 0x7fffffffu #define MAX_WRITE_BUFFER_SIZE (64 * 1024 * 1024) -#define KEEPALIVE_TIME_BACKOFF_MULTIPLIER 2 - #define DEFAULT_MAX_PENDING_INDUCED_FRAMES 10000 #define GRPC_ARG_HTTP2_PING_ON_RST_STREAM_PERCENT \ @@ -723,10 +722,13 @@ grpc_chttp2_transport::grpc_chttp2_transport( auto epte = QueryExtension( grpc_event_engine::experimental::grpc_get_wrapped_event_engine_endpoint( ep.get())); - if (epte != nullptr) { + auto stats_plugin_group = channel_args.GetObjectRef< + grpc_core::GlobalStatsPluginRegistry::StatsPluginGroup>(); + if (epte != nullptr && stats_plugin_group != nullptr) { + epte->EnableTcpTelemetry(stats_plugin_group->GetCollectionScope(), + /*is_control_endpoint=*/false); epte->SetTcpTracer(std::make_shared( - channel_args.GetObjectRef< - grpc_core::GlobalStatsPluginRegistry::StatsPluginGroup>())); + std::move(stats_plugin_group))); } } @@ -858,6 +860,8 @@ static void close_transport_locked(grpc_chttp2_transport* t, t->closed_with_error = error; connectivity_state_set(t, GRPC_CHANNEL_SHUTDOWN, absl::Status(), "close_transport"); + // TODO(roth, ctiller): Provide better disconnect info here. + t->NotifyStateWatcherOnDisconnectLocked(t->closed_with_error, {}); if (t->keepalive_ping_timeout_handle != TaskHandle::kInvalid) { t->event_engine->Cancel(std::exchange(t->keepalive_ping_timeout_handle, TaskHandle::kInvalid)); @@ -907,16 +911,7 @@ static void close_transport_locked(grpc_chttp2_transport* t, grpc_core::MutexLock lock(&t->ep_destroy_mu); t->ep.reset(); } - if (t->notify_on_receive_settings != nullptr) { - if (t->interested_parties_until_recv_settings != nullptr) { - grpc_endpoint_delete_from_pollset_set( - t->ep.get(), t->interested_parties_until_recv_settings); - t->interested_parties_until_recv_settings = nullptr; - } - grpc_core::ExecCtx::Run(DEBUG_LOCATION, t->notify_on_receive_settings, - error); - t->notify_on_receive_settings = nullptr; - } + t->MaybeNotifyOnReceiveSettingsLocked(error); if (t->notify_on_close != nullptr) { grpc_core::ExecCtx::Run(DEBUG_LOCATION, t->notify_on_close, error); t->notify_on_close = nullptr; @@ -1201,7 +1196,13 @@ static void write_action( } args.set_max_frame_size(max_frame_size); args.SetDeprecatedAndDiscouragedGoogleSpecificPointer(cl); - if (!tcp_call_tracers.empty()) { + bool trace_ztrace = false; + auto now = grpc_core::Timestamp::Now(); + if (now - t->last_ztrace_time > grpc_core::Duration::Milliseconds(100)) { + t->last_ztrace_time = now; + trace_ztrace = t->http2_ztrace_collector.IsActive(); + } + if (!tcp_call_tracers.empty() || trace_ztrace) { EventEngine::Endpoint* ee_ep = grpc_event_engine::experimental::grpc_get_wrapped_event_engine_endpoint( t->ep.get()); @@ -1212,24 +1213,35 @@ static void write_action( args.set_metrics_sink(WriteEventSink( std::move(metrics_set), {WriteEvent::kSendMsg, WriteEvent::kScheduled, WriteEvent::kSent, - WriteEvent::kAcked}, + WriteEvent::kAcked, WriteEvent::kClosed}, [tcp_call_tracers = std::move(tcp_call_tracers), - telemetry_info = std::move(telemetry_info)]( + telemetry_info = std::move(telemetry_info), + ztrace_collector = + trace_ztrace ? &t->http2_ztrace_collector : nullptr]( WriteEvent event, absl::Time timestamp, std::vector metrics) { - std::vector tcp_metrics; - tcp_metrics.reserve(metrics.size()); - for (auto& metric : metrics) { - auto name = telemetry_info->GetMetricName(metric.key); - if (name.has_value()) { - tcp_metrics.push_back( - grpc_core::TcpCallTracer::TcpEventMetric{name.value(), - metric.value}); + if (!tcp_call_tracers.empty()) { + std::vector + tcp_metrics; + tcp_metrics.reserve(metrics.size()); + for (auto& metric : metrics) { + auto name = telemetry_info->GetMetricName(metric.key); + if (name.has_value()) { + tcp_metrics.push_back( + grpc_core::TcpCallTracer::TcpEventMetric{name.value(), + metric.value}); + } + } + for (auto& tracer : tcp_call_tracers) { + tracer.tcp_call_tracer->RecordEvent( + event, timestamp, tracer.byte_offset, tcp_metrics); } } - for (auto& tracer : tcp_call_tracers) { - tracer.tcp_call_tracer->RecordEvent( - event, timestamp, tracer.byte_offset, tcp_metrics); + if (ztrace_collector != nullptr) { + ztrace_collector->Append([&]() { + return grpc_core::H2TcpMetricsTrace{ + telemetry_info, event, std::move(metrics), timestamp}; + }); } })); } @@ -1359,6 +1371,9 @@ void grpc_chttp2_add_incoming_goaway(grpc_chttp2_transport* t, } } absl::Status status = grpc_error_to_absl_status(t->goaway_error); + grpc_core::Transport::StateWatcher::DisconnectInfo disconnect_info; + disconnect_info.reason = grpc_core::Transport::StateWatcher::kGoaway; + disconnect_info.http2_error_code = static_cast(goaway_error); // When a client receives a GOAWAY with error code ENHANCE_YOUR_CALM and debug // data equal to "too_many_pings", it should log the occurrence at a log level // that is enabled by default and double the configured KEEPALIVE_TIME used @@ -1378,8 +1393,12 @@ void grpc_chttp2_add_incoming_goaway(grpc_chttp2_transport* t, t->keepalive_time.millis() > max_keepalive_time_millis ? INT_MAX : t->keepalive_time.millis() * KEEPALIVE_TIME_BACKOFF_MULTIPLIER; - status.SetPayload(grpc_core::kKeepaliveThrottlingKey, - absl::Cord(std::to_string(throttled_keepalive_time))); + if (!grpc_core::IsTransportStateWatcherEnabled()) { + status.SetPayload(grpc_core::kKeepaliveThrottlingKey, + absl::Cord(std::to_string(throttled_keepalive_time))); + } + disconnect_info.keepalive_time = + grpc_core::Duration::Milliseconds(throttled_keepalive_time); } // lie: use transient failure from the transport to indicate goaway has been // received. @@ -1387,6 +1406,7 @@ void grpc_chttp2_add_incoming_goaway(grpc_chttp2_transport* t, connectivity_state_set(t, GRPC_CHANNEL_TRANSIENT_FAILURE, status, "got_goaway"); } + t->NotifyStateWatcherOnDisconnectLocked(std::move(status), disconnect_info); } static void maybe_start_some_streams(grpc_chttp2_transport* t) { @@ -1413,10 +1433,12 @@ static void maybe_start_some_streams(grpc_chttp2_transport* t) { t->next_stream_id += 2; if (t->next_stream_id >= MAX_CLIENT_STREAM_ID) { - connectivity_state_set(t, GRPC_CHANNEL_TRANSIENT_FAILURE, - absl::Status(absl::StatusCode::kUnavailable, - "Transport Stream IDs exhausted"), + absl::Status status = + absl::UnavailableError("Transport Stream IDs exhausted"); + connectivity_state_set(t, GRPC_CHANNEL_TRANSIENT_FAILURE, status, "no_more_stream_ids"); + // TODO(roth, ctiller): Provide better disconnect info here. + t->NotifyStateWatcherOnDisconnectLocked(std::move(status), {}); } t->stream_map.emplace(s->id, s); @@ -3485,7 +3507,8 @@ grpc_core::Transport* grpc_create_chttp2_transport( void grpc_chttp2_transport_start_reading( grpc_core::Transport* transport, grpc_slice_buffer* read_buffer, - grpc_closure* notify_on_receive_settings, + absl::AnyInvocable)> + notify_on_receive_settings, grpc_pollset_set* interested_parties_until_recv_settings, grpc_closure* notify_on_close) { auto t = reinterpret_cast(transport)->Ref(); @@ -3494,30 +3517,157 @@ void grpc_chttp2_transport_start_reading( } auto* tp = t.get(); tp->combiner->Run( - grpc_core::NewClosure([t = std::move(t), notify_on_receive_settings, + grpc_core::NewClosure([t = std::move(t), + notify_on_receive_settings = + std::move(notify_on_receive_settings), interested_parties_until_recv_settings, notify_on_close](grpc_error_handle) mutable { + t->interested_parties_until_recv_settings = + interested_parties_until_recv_settings; + t->notify_on_receive_settings = std::move(notify_on_receive_settings); if (!t->closed_with_error.ok()) { - if (notify_on_receive_settings != nullptr) { - if (t->ep != nullptr && - interested_parties_until_recv_settings != nullptr) { - grpc_endpoint_delete_from_pollset_set( - t->ep.get(), interested_parties_until_recv_settings); - } - grpc_core::ExecCtx::Run(DEBUG_LOCATION, notify_on_receive_settings, - t->closed_with_error); - } + t->MaybeNotifyOnReceiveSettingsLocked(t->closed_with_error); if (notify_on_close != nullptr) { grpc_core::ExecCtx::Run(DEBUG_LOCATION, notify_on_close, t->closed_with_error); } return; } - t->interested_parties_until_recv_settings = - interested_parties_until_recv_settings; - t->notify_on_receive_settings = notify_on_receive_settings; t->notify_on_close = notify_on_close; read_action_locked(std::move(t), absl::OkStatus()); }), absl::OkStatus()); } + +void grpc_chttp2_transport::StartWatch( + grpc_core::RefCountedPtr watcher) { + combiner->Run( + grpc_core::NewClosure([t = RefAsSubclass(), + watcher = std::move(watcher)]( + grpc_error_handle) mutable { + GRPC_CHECK(t->watcher == nullptr); + if (t->ep != nullptr) { + auto* interested_parties = watcher->interested_parties(); + if (interested_parties != nullptr) { + grpc_endpoint_add_to_pollset_set(t->ep.get(), interested_parties); + } + } + t->watcher = std::move(watcher); + if (!t->closed_with_error.ok()) { + // TODO(roth, ctiller): Provide better disconnect info here. + t->NotifyStateWatcherOnDisconnectLocked(t->closed_with_error, {}); + } else { + t->NotifyStateWatcherOnPeerMaxConcurrentStreamsUpdateLocked(); + } + }), + absl::OkStatus()); +} + +void grpc_chttp2_transport::StopWatch( + grpc_core::RefCountedPtr watcher) { + combiner->Run( + grpc_core::NewClosure([t = RefAsSubclass(), + watcher = std::move(watcher)](grpc_error_handle) { + if (t->watcher != watcher) return; + if (t->ep != nullptr) { + auto* interested_parties = watcher->interested_parties(); + if (interested_parties != nullptr) { + grpc_endpoint_delete_from_pollset_set(t->ep.get(), + interested_parties); + } + } + t->watcher.reset(); + }), + absl::OkStatus()); +} + +void grpc_chttp2_transport::NotifyStateWatcherOnDisconnectLocked( + absl::Status status, StateWatcher::DisconnectInfo disconnect_info) { + if (watcher == nullptr) return; + if (ep != nullptr) { + auto* interested_parties = watcher->interested_parties(); + if (interested_parties != nullptr) { + grpc_endpoint_delete_from_pollset_set(ep.get(), interested_parties); + } + } + event_engine->Run([watcher = std::move(watcher), status = std::move(status), + disconnect_info]() mutable { + grpc_core::ExecCtx exec_ctx; + watcher->OnDisconnect(std::move(status), disconnect_info); + watcher.reset(); // Before ExecCtx goes out of scope. + }); +} + +void grpc_chttp2_transport::OnPeerMaxConcurrentStreamsUpdateComplete() { + combiner->Run( + grpc_core::NewClosure( + [t = RefAsSubclass()](grpc_error_handle) { + t->max_concurrent_streams_notification_in_flight = false; + t->MaybeNotifyStateWatcherOfPeerMaxConcurrentStreamsLocked(); + }), + absl::OkStatus()); +} + +void grpc_chttp2_transport:: + MaybeNotifyStateWatcherOfPeerMaxConcurrentStreamsLocked() { + if (watcher == nullptr) return; + if (last_reported_max_concurrent_streams == + settings.peer().max_concurrent_streams()) { + return; + } + if (max_concurrent_streams_notification_in_flight) return; + NotifyStateWatcherOnPeerMaxConcurrentStreamsUpdateLocked(); +} + +namespace { + +class MaxConcurrentStreamsUpdateOnDone final + : public grpc_core::Transport::StateWatcher:: + MaxConcurrentStreamsUpdateDoneHandle { + public: + explicit MaxConcurrentStreamsUpdateOnDone( + grpc_core::RefCountedPtr transport) + : transport_(std::move(transport)) {} + + ~MaxConcurrentStreamsUpdateOnDone() override { + transport_->OnPeerMaxConcurrentStreamsUpdateComplete(); + } + + private: + grpc_core::RefCountedPtr transport_; +}; + +} // namespace + +void grpc_chttp2_transport:: + NotifyStateWatcherOnPeerMaxConcurrentStreamsUpdateLocked() { + last_reported_max_concurrent_streams = + settings.peer().max_concurrent_streams(); + max_concurrent_streams_notification_in_flight = true; + event_engine->Run([t = RefAsSubclass(), + watcher = watcher, + max_concurrent_streams = + settings.peer().max_concurrent_streams()]() mutable { + grpc_core::ExecCtx exec_ctx; + watcher->OnPeerMaxConcurrentStreamsUpdate( + max_concurrent_streams, + std::make_unique(std::move(t))); + watcher.reset(); // Before ExecCtx goes out of scope. + }); +} + +void grpc_chttp2_transport::MaybeNotifyOnReceiveSettingsLocked( + absl::StatusOr max_concurrent_streams) { + if (notify_on_receive_settings == nullptr) return; + if (ep != nullptr && interested_parties_until_recv_settings != nullptr) { + grpc_endpoint_delete_from_pollset_set( + ep.get(), interested_parties_until_recv_settings); + interested_parties_until_recv_settings = nullptr; + } + event_engine->Run( + [notify_on_receive_settings = std::move(notify_on_receive_settings), + max_concurrent_streams]() mutable { + grpc_core::ExecCtx exec_ctx; + std::move(notify_on_receive_settings)(max_concurrent_streams); + }); +} diff --git a/deps/grpc/src/core/ext/transport/chttp2/transport/chttp2_transport.h b/deps/grpc/src/core/ext/transport/chttp2/transport/chttp2_transport.h index d583b82b377..6e8f57cc4b9 100644 --- a/deps/grpc/src/core/ext/transport/chttp2/transport/chttp2_transport.h +++ b/deps/grpc/src/core/ext/transport/chttp2/transport/chttp2_transport.h @@ -48,14 +48,22 @@ grpc_core::Transport* grpc_create_chttp2_transport( /// Takes ownership of \a read_buffer, which (if non-NULL) contains /// leftover bytes previously read from the endpoint (e.g., by handshakers). +/// /// If non-null, \a notify_on_receive_settings will be scheduled when -/// HTTP/2 settings are received from the peer. +/// HTTP/2 settings are received from the peer. The argument will be +/// the peer's MAX_CONCURRENT_STREAMS setting. +/// /// If non-null, the endpoint will be removed from /// interested_parties_until_recv_settings before /// notify_on_receive_settings is invoked. +// +// TODO(roth): Consider using the new StateWatcher API in the connector +// code instead of supporting notify_on_receive_settings and +// notify_on_close here. This might be easier after pollset_set goes away. void grpc_chttp2_transport_start_reading( grpc_core::Transport* transport, grpc_slice_buffer* read_buffer, - grpc_closure* notify_on_receive_settings, + absl::AnyInvocable)> + notify_on_receive_settings, grpc_pollset_set* interested_parties_until_recv_settings, grpc_closure* notify_on_close); diff --git a/deps/grpc/src/core/ext/transport/chttp2/transport/flow_control.cc b/deps/grpc/src/core/ext/transport/chttp2/transport/flow_control.cc index 8f2c214e9fd..a15a69482f2 100644 --- a/deps/grpc/src/core/ext/transport/chttp2/transport/flow_control.cc +++ b/deps/grpc/src/core/ext/transport/chttp2/transport/flow_control.cc @@ -23,21 +23,24 @@ #include #include +#include #include #include #include #include -#include "absl/log/log.h" -#include "absl/strings/str_cat.h" -#include "absl/strings/str_format.h" -#include "absl/strings/str_join.h" #include "src/core/ext/transport/chttp2/transport/http2_settings.h" #include "src/core/ext/transport/chttp2/transport/http2_settings_manager.h" #include "src/core/lib/experiments/experiments.h" #include "src/core/lib/resource_quota/memory_quota.h" #include "src/core/util/grpc_check.h" #include "src/core/util/useful.h" +#include "absl/log/log.h" +#include "absl/status/status.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/str_format.h" +#include "absl/strings/str_join.h" +#include "absl/strings/string_view.h" namespace grpc_core { namespace chttp2 { @@ -96,6 +99,26 @@ std::ostream& operator<<(std::ostream& out, const FlowControlAction& action) { return out << action.DebugString(); } +std::string FlowControlAction::ImmediateUpdateReasons() const { + std::string result; + if (send_stream_update_ == Urgency::UPDATE_IMMEDIATELY) { + absl::StrAppend(&result, "send_stream_update,"); + } + if (send_transport_update_ == Urgency::UPDATE_IMMEDIATELY) { + absl::StrAppend(&result, "send_transport_update,"); + } + if (send_initial_window_update_ == Urgency::UPDATE_IMMEDIATELY) { + absl::StrAppend(&result, "send_initial_window_update,"); + } + if (send_max_frame_size_update_ == Urgency::UPDATE_IMMEDIATELY) { + absl::StrAppend(&result, "send_max_frame_size_update,"); + } + if (preferred_rx_crypto_frame_size_update_ == Urgency::UPDATE_IMMEDIATELY) { + absl::StrAppend(&result, "preferred_rx_crypto_frame_size_update,"); + } + return result; +} + TransportFlowControl::TransportFlowControl(absl::string_view name, bool enable_bdp_probe, MemoryOwner* memory_owner) @@ -381,6 +404,18 @@ FlowControlAction StreamFlowControl::UpdateAction(FlowControlAction action) { return action; } +void StreamFlowControl::IncomingUpdateContext::HackIncrementPendingSize( + int64_t pending_size) { + GRPC_CHECK_GE(pending_size, 0); + if (sfc_->pending_size_.has_value()) { + int64_t final_size = Clamp(sfc_->pending_size_.value() + pending_size, + int64_t{0}, kMaxWindowUpdateSize); + *sfc_->pending_size_ = final_size; + } else { + sfc_->pending_size_ = pending_size; + } +} + void StreamFlowControl::IncomingUpdateContext::SetPendingSize( int64_t pending_size) { GRPC_CHECK_GE(pending_size, 0); diff --git a/deps/grpc/src/core/ext/transport/chttp2/transport/flow_control.h b/deps/grpc/src/core/ext/transport/chttp2/transport/flow_control.h index 8566531bd03..385b3c731d8 100644 --- a/deps/grpc/src/core/ext/transport/chttp2/transport/flow_control.h +++ b/deps/grpc/src/core/ext/transport/chttp2/transport/flow_control.h @@ -23,14 +23,12 @@ #include #include +#include #include #include #include #include -#include "absl/functional/function_ref.h" -#include "absl/status/status.h" -#include "absl/strings/string_view.h" #include "src/core/channelz/property_list.h" #include "src/core/ext/transport/chttp2/transport/http2_settings.h" #include "src/core/ext/transport/chttp2/transport/http2_settings_manager.h" @@ -39,12 +37,11 @@ #include "src/core/lib/transport/bdp_estimator.h" #include "src/core/util/grpc_check.h" #include "src/core/util/time.h" - -namespace grpc { -namespace testing { -class TrickledCHTTP2; // to make this a friend -} // namespace testing -} // namespace grpc +#include "absl/functional/function_ref.h" +#include "absl/log/log.h" +#include "absl/status/status.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/string_view.h" namespace grpc_core { namespace chttp2 { @@ -59,11 +56,18 @@ static constexpr const uint32_t kMaxInitialWindowSize = (1u << 30); static constexpr const int64_t kMaxWindowDelta = (1u << 20); static constexpr const int kDefaultPreferredRxCryptoFrameSize = INT_MAX; +// TODO(tjagtap) [PH2][P2][BDP] Remove this static sleep when the BDP code is +// done. This needs to be dynamic. +constexpr Duration kFlowControlPeriodicUpdateTimer = Duration::Seconds(8); + class TransportFlowControl; class StreamFlowControl; enum class StallEdge { kNoChange, kStalled, kUnstalled }; +#define GRPC_HTTP2_FLOW_CONTROL_DLOG \ + DLOG_IF(INFO, GRPC_TRACE_FLAG_ENABLED(http2_ph2_transport)) + // Encapsulates a collections of actions the transport needs to take with // regard to flow control. Each action comes with urgencies that tell the // transport how quickly the action must take place. @@ -72,10 +76,10 @@ class GRPC_MUST_USE_RESULT FlowControlAction { enum class Urgency : uint8_t { // Nothing to be done. NO_ACTION_NEEDED = 0, - // Initiate a write to update the initial window immediately. + // Initiate a write to send updates immediately. UPDATE_IMMEDIATELY, - // Push the flow control update into a send buffer, to be sent - // out the next time a write is initiated. + // Queue the flow control update, to be sent out the next time a write is + // initiated. QUEUE_UPDATE, }; @@ -90,6 +94,8 @@ class GRPC_MUST_USE_RESULT FlowControlAction { Urgency preferred_rx_crypto_frame_size_update() const { return preferred_rx_crypto_frame_size_update_; } + + // Returns true if any action has UPDATE_IMMEDIATELY urgency. bool AnyUpdateImmediately() const { return send_stream_update_ == Urgency::UPDATE_IMMEDIATELY || send_transport_update_ == Urgency::UPDATE_IMMEDIATELY || @@ -99,12 +105,56 @@ class GRPC_MUST_USE_RESULT FlowControlAction { Urgency::UPDATE_IMMEDIATELY; } + std::string ImmediateUpdateReasons() const; + + // Returns the value of SETTINGS_INITIAL_WINDOW_SIZE that we will send to the + // peer. uint32_t initial_window_size() const { return initial_window_size_; } + // Returns the value of SETTINGS_MAX_FRAME_SIZE that we will send to the peer. uint32_t max_frame_size() const { return max_frame_size_; } + // Returns the value of GRPC_PREFERRED_RECEIVE_CRYPTO_FRAME_SIZE that we will + // send to the peer. uint32_t preferred_rx_crypto_frame_size() const { return preferred_rx_crypto_frame_size_; } + FlowControlAction& test_only_set_send_initial_window_update(Urgency u, + uint32_t update) { + return set_send_initial_window_update(u, update); + } + FlowControlAction& test_only_set_send_max_frame_size_update(Urgency u, + uint32_t update) { + return set_send_max_frame_size_update(u, update); + } + FlowControlAction& test_only_set_preferred_rx_crypto_frame_size_update( + Urgency u, uint32_t update) { + return set_preferred_rx_crypto_frame_size_update(u, update); + } + + static const char* UrgencyString(Urgency u); + std::string DebugString() const; + + void AssertEmpty() { GRPC_CHECK(*this == FlowControlAction()); } + + bool operator==(const FlowControlAction& other) const { + return send_stream_update_ == other.send_stream_update_ && + send_transport_update_ == other.send_transport_update_ && + send_initial_window_update_ == other.send_initial_window_update_ && + send_max_frame_size_update_ == other.send_max_frame_size_update_ && + (send_initial_window_update_ == Urgency::NO_ACTION_NEEDED || + initial_window_size_ == other.initial_window_size_) && + (send_max_frame_size_update_ == Urgency::NO_ACTION_NEEDED || + max_frame_size_ == other.max_frame_size_) && + (preferred_rx_crypto_frame_size_update_ == + Urgency::NO_ACTION_NEEDED || + preferred_rx_crypto_frame_size_ == + other.preferred_rx_crypto_frame_size_); + } + + private: + friend class StreamFlowControl; + friend class TransportFlowControl; + FlowControlAction& set_send_stream_update(Urgency u) { send_stream_update_ = u; return *this; @@ -132,27 +182,6 @@ class GRPC_MUST_USE_RESULT FlowControlAction { return *this; } - static const char* UrgencyString(Urgency u); - std::string DebugString() const; - - void AssertEmpty() { GRPC_CHECK(*this == FlowControlAction()); } - - bool operator==(const FlowControlAction& other) const { - return send_stream_update_ == other.send_stream_update_ && - send_transport_update_ == other.send_transport_update_ && - send_initial_window_update_ == other.send_initial_window_update_ && - send_max_frame_size_update_ == other.send_max_frame_size_update_ && - (send_initial_window_update_ == Urgency::NO_ACTION_NEEDED || - initial_window_size_ == other.initial_window_size_) && - (send_max_frame_size_update_ == Urgency::NO_ACTION_NEEDED || - max_frame_size_ == other.max_frame_size_) && - (preferred_rx_crypto_frame_size_update_ == - Urgency::NO_ACTION_NEEDED || - preferred_rx_crypto_frame_size_ == - other.preferred_rx_crypto_frame_size_); - } - - private: Urgency send_stream_update_ = Urgency::NO_ACTION_NEEDED; Urgency send_transport_update_ = Urgency::NO_ACTION_NEEDED; Urgency send_initial_window_update_ = Urgency::NO_ACTION_NEEDED; @@ -168,6 +197,7 @@ std::ostream& operator<<(std::ostream& out, const FlowControlAction& action); // Implementation of flow control that abides to HTTP/2 spec and attempts // to be as performant as possible. +// This class manages the flow control at a connection level. class TransportFlowControl final { public: explicit TransportFlowControl(absl::string_view name, bool enable_bdp_probe, @@ -176,16 +206,19 @@ class TransportFlowControl final { bool bdp_probe() const { return enable_bdp_probe_; } - // returns an announce if we should send a transport update to our peer, - // else returns zero; writing_anyway indicates if a write would happen + // Returns a non-zero announce if we should send a transport update to our + // peer, else returns zero; writing_anyway indicates if a write would happen // regardless of the send - if it is false and this function returns non-zero, - // this announce will cause a write to occur + // the caller can send a flow control update. uint32_t DesiredAnnounceSize(bool writing_anyway) const; - // notify that we've actually sent a stream window update - // (should be DesiredAnnounceSize()) + + // Call to update transport flow control state after sending a transport + // WINDOW_UPDATE with `announce` size. `announce` should be value returned + // by `DesiredAnnounceSize`. void SentUpdate(uint32_t announce); - // Older API: combines getting the DesiredAnnounceSize() with SentUpdate() + // Convenience method that combines `DesiredAnnounceSize` and `SentUpdate`. + // Call to get window increment and update state in one go. uint32_t MaybeSendUpdate(bool writing_anyway) { uint32_t n = DesiredAnnounceSize(writing_anyway); SentUpdate(n); @@ -193,8 +226,8 @@ class TransportFlowControl final { } // Track an update to the incoming flow control counters - that is how many - // tokens we report to our peer that we're willing to accept. - // Instantiators *must* call MakeAction before destruction of this value. + // tokens we report to our peer for the data that we are willing to accept. + // Instantiators *must* call MakeAction before destruction of this object. class IncomingUpdateContext { public: explicit IncomingUpdateContext(TransportFlowControl* tfc) : tfc_(tfc) {} @@ -202,19 +235,32 @@ class TransportFlowControl final { IncomingUpdateContext(const IncomingUpdateContext&) = delete; IncomingUpdateContext& operator=(const IncomingUpdateContext&) = delete; + IncomingUpdateContext(IncomingUpdateContext&&) = delete; + IncomingUpdateContext& operator=(IncomingUpdateContext&&) = delete; // Reads the flow control data and returns an actionable struct that will - // tell chttp2 exactly what it needs to do + // tell the transport exactly what it needs to do. FlowControlAction MakeAction() { return std::exchange(tfc_, nullptr)->UpdateAction(FlowControlAction()); } - // Notify of data receipt. Returns OkStatus if the data was accepted, - // else an error status if the connection should be closed. + // We have received data from the wire. + // We check if this data is within our flow control limits or not. + // If it exceeds the limit, we send an error. + // RFC9113 : A receiver MAY respond with a stream error or connection + // error of type FLOW_CONTROL_ERROR if it is unable to accept a frame. + // + // This function updates transport window for received data. + // Call this ONLY IF stream is not available (e.g. already closed) AND + // transport window must be updated to remain in sync with peer. + // If stream IS available, call RecvData() on + // StreamFlowControl::IncomingUpdateContext instead. absl::Status RecvData( int64_t incoming_frame_size, absl::FunctionRef stream = []() { return absl::OkStatus(); }); + private: + friend class StreamFlowControl; // Update a stream announce window delta, keeping track of how much total // positive delta is present on the transport. void UpdateAnnouncedWindowDelta(int64_t* delta, int64_t change) { @@ -228,7 +274,6 @@ class TransportFlowControl final { } } - private: TransportFlowControl* tfc_; }; @@ -237,9 +282,14 @@ class TransportFlowControl final { class OutgoingUpdateContext { public: explicit OutgoingUpdateContext(TransportFlowControl* tfc) : tfc_(tfc) {} - void StreamSentData(int64_t size) { tfc_->remote_window_ -= size; } - // we have received a WINDOW_UPDATE frame for a transport + OutgoingUpdateContext(const OutgoingUpdateContext&) = delete; + OutgoingUpdateContext& operator=(const OutgoingUpdateContext&) = delete; + OutgoingUpdateContext(OutgoingUpdateContext&&) = delete; + OutgoingUpdateContext& operator=(OutgoingUpdateContext&&) = delete; + + // Call this function when a transport-level WINDOW_UPDATE frame is received + // from peer to increase remote window. void RecvUpdate(uint32_t size) { tfc_->remote_window_ += size; } // Finish the update and check whether we became stalled or unstalled. @@ -253,29 +303,37 @@ class TransportFlowControl final { } private: + friend class StreamFlowControl; + void StreamSentData(int64_t size) { tfc_->remote_window_ -= size; } + TransportFlowControl* tfc_; const bool was_stalled_ = tfc_->remote_window_ <= 0; }; // Call periodically (at a low-ish rate, 100ms - 10s makes sense) // to perform more complex flow control calculations and return an action - // to let chttp2 change its parameters + // to let the transport change its parameters. + // TODO(tjagtap) [PH2][P2] Plumb with PH2 flow control. FlowControlAction PeriodicUpdate(); - int64_t target_window() const; - int64_t target_frame_size() const { return target_frame_size_; } - int64_t target_preferred_rx_crypto_frame_size() const { - return target_preferred_rx_crypto_frame_size_; + int64_t test_only_target_window() const { return target_window(); } + int64_t test_only_target_frame_size() const { return target_frame_size(); } + int64_t test_only_target_preferred_rx_crypto_frame_size() const { + return target_preferred_rx_crypto_frame_size(); } BdpEstimator* bdp_estimator() { return &bdp_estimator_; } - uint32_t acked_init_window() const { return acked_init_window_; } - uint32_t queued_init_window() const { return target_initial_window_size_; } - uint32_t sent_init_window() const { return sent_init_window_; } + uint32_t test_only_acked_init_window() const { return acked_init_window(); } + uint32_t test_only_sent_init_window() const { return sent_init_window(); } + // Call after you prepare and queue a settings frame to send to the peer. void FlushedSettings() { sent_init_window_ = queued_init_window(); } + // Updates the initial window size that we have acknowledged from the peer. + // This affects stream-level flow control for data received from the peer. + // If the new value differs from target_initial_window_size_, we return an + // action to send an update to the peer with our target. FlowControlAction SetAckedInitialWindow(uint32_t value); void set_target_initial_window_size(uint32_t value) { @@ -285,16 +343,10 @@ class TransportFlowControl final { // Getters int64_t remote_window() const { return remote_window_; } - int64_t announced_window() const { return announced_window_; } - - int64_t announced_stream_total_over_incoming_window() const { - return announced_stream_total_over_incoming_window_; - } + int64_t test_only_announced_window() const { return announced_window(); } - void RemoveAnnouncedWindowDelta(int64_t delta) { - if (delta > 0) { - announced_stream_total_over_incoming_window_ -= delta; - } + int64_t test_only_announced_stream_total_over_incoming_window() const { + return announced_stream_total_over_incoming_window(); } // A snapshot of the flow control stats to export. @@ -353,7 +405,28 @@ class TransportFlowControl final { } private: + friend class StreamFlowControl; + + void RemoveAnnouncedWindowDelta(int64_t delta) { + if (delta > 0) { + announced_stream_total_over_incoming_window_ -= delta; + } + } + double TargetInitialWindowSizeBasedOnMemoryPressureAndBdp() const; + int64_t target_window() const; + int64_t target_frame_size() const { return target_frame_size_; } + int64_t target_preferred_rx_crypto_frame_size() const { + return target_preferred_rx_crypto_frame_size_; + } + uint32_t acked_init_window() const { return acked_init_window_; } + uint32_t queued_init_window() const { return target_initial_window_size_; } + uint32_t sent_init_window() const { return sent_init_window_; } + int64_t announced_window() const { return announced_window_; } + int64_t announced_stream_total_over_incoming_window() const { + return announced_stream_total_over_incoming_window_; + } + static void UpdateSetting(absl::string_view name, int64_t* desired_value, uint32_t new_desired_value, FlowControlAction* action, @@ -407,20 +480,50 @@ class StreamFlowControl final { explicit IncomingUpdateContext(StreamFlowControl* sfc) : tfc_upd_(sfc->tfc_), sfc_(sfc) {} + IncomingUpdateContext(const IncomingUpdateContext&) = delete; + IncomingUpdateContext& operator=(const IncomingUpdateContext&) = delete; + IncomingUpdateContext(IncomingUpdateContext&&) = delete; + IncomingUpdateContext& operator=(IncomingUpdateContext&&) = delete; + FlowControlAction MakeAction() { return sfc_->UpdateAction(tfc_upd_.MakeAction()); } - // we have received data from the wire + // We have received data from the wire. + // We check if this data is within our flow control limits or not. + // If it exceeds the limit, we send an error. + // RFC9113 : A receiver MAY respond with a stream error or connection + // error of type FLOW_CONTROL_ERROR if it is unable to accept a frame. + // + // Updates stream and transport window for received data on an active + // stream. Calling this updates BOTH windows; do not call + // TransportFlowControl::IncomingUpdateContext::RecvData() separately. absl::Status RecvData(int64_t incoming_frame_size); - // the application is asking for a certain amount of bytes + // Informs flow control that the application needs at least + // `min_progress_size` bytes to make progress on reading the current stream. + // An example usage of this would be, say we receive the first 1000 bytes of + // a 2000 byte gRPC message, we can call SetMinProgressSize(1000) + // TODO(tjagtap) [PH2][P2] Plumb with PH2 flow control. void SetMinProgressSize(int64_t min_progress_size) { sfc_->min_progress_size_ = min_progress_size; } + // Informs flow control that `pending_size` bytes are buffered and waiting + // for application to read. Call this when a complete message is assembled + // but not yet pulled by the application. This helps flow control decide + // whether to send a WINDOW_UPDATE to the peer. + // TODO(tjagtap) [PH2][P1] Plumb with PH2 flow control. void SetPendingSize(int64_t pending_size); + // This is a hack in place till SetPendingSize is fully plumbed. This hack + // function just pretends that the application needs more bytes. Since we + // dont actually know how many bytes the application needs, we just want to + // refill the used up tokens. The only way to refill used up tokens is to + // call this function for each DATA frame. + // TODO(tjagtap) [PH2][P1] Remove hack after SetPendingSize is plumbed. + void HackIncrementPendingSize(int64_t pending_size); + private: TransportFlowControl::IncomingUpdateContext tfc_upd_; StreamFlowControl* const sfc_; @@ -432,10 +535,18 @@ class StreamFlowControl final { public: explicit OutgoingUpdateContext(StreamFlowControl* sfc) : tfc_upd_(sfc->tfc_), sfc_(sfc) {} - // we have received a WINDOW_UPDATE frame for a stream + + OutgoingUpdateContext(const OutgoingUpdateContext&) = delete; + OutgoingUpdateContext& operator=(const OutgoingUpdateContext&) = delete; + OutgoingUpdateContext(OutgoingUpdateContext&&) = delete; + OutgoingUpdateContext& operator=(OutgoingUpdateContext&&) = delete; + + // Call this when a WINDOW_UPDATE frame is received from peer for this + // stream, to increase send window. void RecvUpdate(uint32_t size) { sfc_->remote_window_delta_ += size; } - // we have sent data on the wire, we must track this in our bookkeeping for - // the remote peer's flow control. + + // Call this after sending a DATA frame for this stream, to decrease send + // window based on `outgoing_frame_size`. void SentData(int64_t outgoing_frame_size) { tfc_upd_.StreamSentData(outgoing_frame_size); sfc_->remote_window_delta_ -= outgoing_frame_size; @@ -446,14 +557,17 @@ class StreamFlowControl final { StreamFlowControl* const sfc_; }; - // returns an announce if we should send a stream update to our peer, else - // returns zero + // Returns a non-zero announce if we should send a stream update to our + // peer, else returns zero; uint32_t DesiredAnnounceSize() const; - // notify that we've actually sent a stream window update - // (should be DesiredAnnounceSize()) + + // Call after sending stream-level WINDOW_UPDATE to peer to update internal + // state. Argument should be value previously returned by + // `DesiredAnnounceSize`. void SentUpdate(uint32_t announce); - // Older API: combines getting the DesiredAnnounceSize() with SentUpdate() + // Convenience method that combines `DesiredAnnounceSize` and `SentUpdate`. + // Call to get window increment and update state in one go. uint32_t MaybeSendUpdate() { uint32_t n = DesiredAnnounceSize(); SentUpdate(n); @@ -461,8 +575,10 @@ class StreamFlowControl final { } int64_t remote_window_delta() const { return remote_window_delta_; } - int64_t announced_window_delta() const { return announced_window_delta_; } - int64_t min_progress_size() const { return min_progress_size_; } + int64_t test_only_announced_window_delta() const { + return announced_window_delta_; + } + int64_t test_only_min_progress_size() const { return min_progress_size_; } // A snapshot of the flow control stats to export. struct Stats { @@ -476,13 +592,32 @@ class StreamFlowControl final { Stats stats() const { Stats stats; - stats.min_progress_size = min_progress_size(); + stats.min_progress_size = min_progress_size_; stats.remote_window_delta = remote_window_delta(); - stats.announced_window_delta = announced_window_delta(); + stats.announced_window_delta = announced_window_delta_; stats.pending_size = pending_size_; return stats; } + void ReportIfStalled(bool is_client, uint32_t stream_id, + const Http2Settings& peer_settings) const { + if (remote_window_delta() + peer_settings.initial_window_size() <= 0 || + tfc_->remote_window_ == 0) { + GRPC_HTTP2_FLOW_CONTROL_DLOG + << "PH2 " << (is_client ? "CLIENT" : "SERVER") + << " Flow Control Stalled :" + << " Settings { peer initial window size=" + << peer_settings.initial_window_size() + << "}, Transport {remote_window=" << tfc_->remote_window() + << ", transport announced_window=" << tfc_->announced_window() + << "}, Stream {stream_id=" << stream_id + << ", remote_window_delta=" << remote_window_delta() + << ", remote_window_delta() + peer_settings.initial_window_size() =" + << (remote_window_delta() + peer_settings.initial_window_size()) + << " }"; + } + } + private: TransportFlowControl* const tfc_; int64_t min_progress_size_ = 0; diff --git a/deps/grpc/src/core/ext/transport/chttp2/transport/flow_control_manager.h b/deps/grpc/src/core/ext/transport/chttp2/transport/flow_control_manager.h index 1e0f10e89e1..d484e25f29d 100644 --- a/deps/grpc/src/core/ext/transport/chttp2/transport/flow_control_manager.h +++ b/deps/grpc/src/core/ext/transport/chttp2/transport/flow_control_manager.h @@ -19,13 +19,15 @@ #ifndef GRPC_SRC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FLOW_CONTROL_MANAGER_H #define GRPC_SRC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FLOW_CONTROL_MANAGER_H +#include #include #include -#include "absl/container/flat_hash_map.h" #include "src/core/ext/transport/chttp2/transport/flow_control.h" #include "src/core/ext/transport/chttp2/transport/frame.h" #include "src/core/ext/transport/chttp2/transport/http2_settings.h" +#include "src/core/util/grpc_check.h" +#include "absl/container/flat_hash_map.h" namespace grpc_core { namespace http2 { @@ -34,6 +36,10 @@ constexpr chttp2::FlowControlAction::Urgency kNoActionNeeded = chttp2::FlowControlAction::Urgency::NO_ACTION_NEEDED; constexpr chttp2::FlowControlAction::Urgency kUpdateImmediately = chttp2::FlowControlAction::Urgency::UPDATE_IMMEDIATELY; +constexpr int64_t kZero = 0; + +#define GRPC_HTTP2_FLOW_CONTROL_HELPERS \ + DLOG_IF(INFO, GRPC_TRACE_FLAG_ENABLED(http2_ph2_transport)) // Function to update local settings based on FlowControlAction. // This function does the settings related tasks equivalent to @@ -54,6 +60,45 @@ inline void ActOnFlowControlActionSettings( } } +// RFC9113 : A sender MUST NOT allow a flow-control window to exceed ((2^31)-1) +// octets. If a sender receives a WINDOW_UPDATE that causes a flow-control +// window to exceed this maximum, it MUST terminate either the stream or the +// connection, as appropriate. +// While the return value is int64_t for compatibility with CHTTP2 flow control, +// we dont expect this value to exceed ((2^31)-1) i.e kMaxSize31Bit +inline int64_t GetStreamFlowControlTokens( + chttp2::StreamFlowControl& stream_flow_control, + const Http2Settings& peer_settings) { + GRPC_DCHECK(stream_flow_control.remote_window_delta() + + peer_settings.initial_window_size() <= + RFC9113::kMaxSize31Bit); + return std::max(kZero, stream_flow_control.remote_window_delta() + + peer_settings.initial_window_size()); +} + +inline uint32_t GetMaxPermittedDequeue( + chttp2::TransportFlowControl& transport_flow_control, + chttp2::StreamFlowControl& stream_flow_control, const size_t upper_limit, + const Http2Settings& peer_settings) { + const int64_t flow_control_tokens = + std::min(transport_flow_control.remote_window(), + GetStreamFlowControlTokens(stream_flow_control, peer_settings)); + uint32_t max_dequeue = 0; + if (flow_control_tokens > 0) { + max_dequeue = static_cast( + std::min({static_cast(flow_control_tokens), upper_limit, + static_cast(RFC9113::kMaxSize31Bit - 1)})); + } + GRPC_HTTP2_FLOW_CONTROL_HELPERS + << "GetFlowControlTokens flow_control_tokens = " << flow_control_tokens + << " upper_limit = " << upper_limit << " max_dequeue = " << max_dequeue; + return max_dequeue; +} + +// TODO(tjagtap) [PH2][P4] : Ensure that the total transport flow control window +// or stream flow control window does not exceed the max permitted limit of +// 2^31-1 + } // namespace http2 } // namespace grpc_core diff --git a/deps/grpc/src/core/ext/transport/chttp2/transport/frame.cc b/deps/grpc/src/core/ext/transport/chttp2/transport/frame.cc index 4efb2380624..8e578b0eae7 100644 --- a/deps/grpc/src/core/ext/transport/chttp2/transport/frame.cc +++ b/deps/grpc/src/core/ext/transport/chttp2/transport/frame.cc @@ -20,15 +20,18 @@ #include #include #include +#include -#include "absl/status/status.h" -#include "absl/strings/str_cat.h" +#include "src/core/call/message.h" #include "src/core/ext/transport/chttp2/transport/http2_settings.h" +#include "src/core/lib/debug/trace_impl.h" #include "src/core/lib/slice/slice.h" #include "src/core/lib/slice/slice_buffer.h" #include "src/core/util/crash.h" #include "src/core/util/grpc_check.h" #include "src/core/util/memory_usage.h" +#include "absl/log/log.h" +#include "absl/strings/str_cat.h" // TODO(tjagtap) TODO(akshitpatel): [PH2][P3] : Write micro benchmarks for // framing code @@ -39,6 +42,9 @@ using grpc_core::http2::ValueOrHttp2Status; namespace grpc_core { +#define GRPC_HTTP2_FRAME_DLOG \ + DLOG_IF(INFO, GRPC_TRACE_FLAG_ENABLED(http2_ph2_transport)) + /////////////////////////////////////////////////////////////////////////////// // Settings Frame Validations @@ -214,6 +220,11 @@ class SerializeHeaderAndPayload { serialize_return_(serialize_return) {} void operator()(Http2DataFrame& frame) { + GRPC_HTTP2_FRAME_DLOG + << "SerializeHeaderAndPayload Http2DataFrame Type:0 { stream_id:" + << frame.stream_id << ", end_stream:" << frame.end_stream + << ", payload_length:" << frame.payload.Length() + << ", payload:" << MaybeTruncatePayload(frame.payload) << "}"; auto hdr = extra_bytes_.TakeFirst(kFrameHeaderSize); Http2FrameHeader{static_cast(frame.payload.Length()), static_cast(FrameType::kData), @@ -226,6 +237,12 @@ class SerializeHeaderAndPayload { } void operator()(Http2HeaderFrame& frame) { + GRPC_HTTP2_FRAME_DLOG + << "SerializeHeaderAndPayload Http2HeaderFrame Type:1 { stream_id:" + << frame.stream_id << ", end_headers:" << frame.end_headers + << ", end_stream:" << frame.end_stream + << ", payload_length:" << frame.payload.Length() + << ", payload:" << MaybeTruncatePayload(frame.payload) << "}"; auto hdr = extra_bytes_.TakeFirst(kFrameHeaderSize); Http2FrameHeader{ static_cast(frame.payload.Length()), @@ -240,6 +257,13 @@ class SerializeHeaderAndPayload { } void operator()(Http2ContinuationFrame& frame) { + GRPC_HTTP2_FRAME_DLOG << "SerializeHeaderAndPayload Http2ContinuationFrame " + "Type:9 { stream_id:" + << frame.stream_id + << ", end_headers:" << frame.end_headers + << ", payload_length:" << frame.payload.Length() + << ", payload:" << MaybeTruncatePayload(frame.payload) + << "}"; auto hdr = extra_bytes_.TakeFirst(kFrameHeaderSize); Http2FrameHeader{ static_cast(frame.payload.Length()), @@ -253,6 +277,9 @@ class SerializeHeaderAndPayload { } void operator()(Http2RstStreamFrame& frame) { + GRPC_HTTP2_FRAME_DLOG + << "SerializeHeaderAndPayload Http2RstStreamFrame Type:3 { stream_id:" + << frame.stream_id << ", error_code:" << frame.error_code << "}"; auto hdr_and_payload = extra_bytes_.TakeFirst(kFrameHeaderSize + 4); Http2FrameHeader{4, static_cast(FrameType::kRstStream), 0, frame.stream_id} @@ -262,6 +289,10 @@ class SerializeHeaderAndPayload { } void operator()(Http2SettingsFrame& frame) { + GRPC_HTTP2_FRAME_DLOG + << "SerializeHeaderAndPayload Http2SettingsFrame Type:4 { ack:" + << frame.ack << ", length:" << frame.settings.size() << ", settings:[" + << DebugStringSettings(frame.settings) << "] }"; // Six bytes per setting (u16 id, u32 value) const size_t payload_size = 6 * frame.settings.size(); auto hdr_and_payload = @@ -280,6 +311,9 @@ class SerializeHeaderAndPayload { } void operator()(Http2PingFrame& frame) { + GRPC_HTTP2_FRAME_DLOG + << "SerializeHeaderAndPayload Http2PingFrame Type:6 { ack:" << frame.ack + << ", opaque:" << frame.opaque << "}"; auto hdr_and_payload = extra_bytes_.TakeFirst(kFrameHeaderSize + 8); Http2FrameHeader{8, static_cast(FrameType::kPing), MaybeFlag(frame.ack, kFlagAck), 0} @@ -289,6 +323,10 @@ class SerializeHeaderAndPayload { } void operator()(Http2GoawayFrame& frame) { + GRPC_HTTP2_FRAME_DLOG + << "SerializeHeaderAndPayload Http2GoawayFrame Type:7 { last_stream_id:" + << frame.last_stream_id << ", error_code:" << frame.error_code + << ", debug_data:" << frame.debug_data.as_string_view() << "}"; auto hdr_and_fixed_payload = extra_bytes_.TakeFirst(kFrameHeaderSize + 8); Http2FrameHeader{static_cast(8 + frame.debug_data.length()), static_cast(FrameType::kGoaway), 0, 0} @@ -306,6 +344,10 @@ class SerializeHeaderAndPayload { } void operator()(Http2WindowUpdateFrame& frame) { + GRPC_HTTP2_FRAME_DLOG << "SerializeHeaderAndPayload Http2WindowUpdateFrame " + "Type:8 { stream_id:" + << frame.stream_id + << ", increment:" << frame.increment << "}"; auto hdr_and_payload = extra_bytes_.TakeFirst(kFrameHeaderSize + 4); Http2FrameHeader{4, static_cast(FrameType::kWindowUpdate), 0, frame.stream_id} @@ -321,6 +363,9 @@ class SerializeHeaderAndPayload { } void operator()(Http2SecurityFrame& frame) { + GRPC_HTTP2_FRAME_DLOG << "SerializeHeaderAndPayload Http2SecurityFrame " + "Type:200 { payload_length:" + << frame.payload.Length() << ", payload: redacted}"; auto hdr = extra_bytes_.TakeFirst(kFrameHeaderSize); Http2FrameHeader{static_cast(frame.payload.Length()), static_cast(FrameType::kCustomSecurity), 0, 0} @@ -331,9 +376,21 @@ class SerializeHeaderAndPayload { void operator()(Http2UnknownFrame&) { Crash("unreachable"); } - void operator()(Http2EmptyFrame&) {} + void operator()(Http2EmptyFrame&) { + GRPC_HTTP2_FRAME_DLOG << "SerializeHeaderAndPayload Http2EmptyFrame {}"; + } private: + std::string DebugStringSettings( + const std::vector& settings) { + std::string settings_str; + for (const auto& setting : settings) { + absl::StrAppend(&settings_str, " {id:", setting.id, + ", value:", setting.value, "}"); + } + return settings_str; + } + SliceBuffer& out_; MutableSlice extra_bytes_; SerializeReturn& serialize_return_; @@ -390,6 +447,8 @@ ValueOrHttp2Status ParseDataFrame(const Http2FrameHeader& hdr, std::move(payload)}); } +// This function MUST NOT return a Http2StreamError. Doing this will cause the +// HPACK state to be corrupted. ValueOrHttp2Status ParseHeaderFrame(const Http2FrameHeader& hdr, SliceBuffer& payload) { if (GPR_UNLIKELY((hdr.stream_id % 2) == 0)) { @@ -426,6 +485,8 @@ ValueOrHttp2Status ParseHeaderFrame(const Http2FrameHeader& hdr, ExtractFlag(hdr.flags, kFlagEndStream), std::move(payload)}); } +// This function MUST NOT return a Http2StreamError. Doing this will cause the +// HPACK state to be corrupted. ValueOrHttp2Status ParseContinuationFrame( const Http2FrameHeader& hdr, SliceBuffer& payload) { if (GPR_UNLIKELY((hdr.stream_id % 2) == 0)) { @@ -577,15 +638,14 @@ ValueOrHttp2Status ParseWindowUpdateFrame( payload.CopyToBuffer(buffer); const uint32_t window_size_increment = Read31bits(buffer); if (GPR_UNLIKELY(window_size_increment == 0)) { - if (hdr.stream_id == 0) { - return Http2Status::Http2ConnectionError( - Http2ErrorCode::kProtocolError, - absl::StrCat(RFC9113::kWindowSizeIncrement, hdr.ToString())); - } else { - return Http2Status::Http2StreamError( - Http2ErrorCode::kProtocolError, - absl::StrCat(RFC9113::kWindowSizeIncrement, hdr.ToString())); - } + // According to RFC9113, if window_size_increment == 0, and (stream id != 0) + // the receiver MUST treat this as a stream error of type PROTOCOL_ERROR. + // However we will be treating this too as a connection error + // 1. To be consistent with CHTTP2 transport + // 2. To be less lenient as compared to the RFC9113 for security reasons. + return Http2Status::Http2ConnectionError( + Http2ErrorCode::kProtocolError, + absl::StrCat(RFC9113::kWindowSizeIncrement, hdr.ToString())); } return ValueOrHttp2Status( Http2WindowUpdateFrame{hdr.stream_id, window_size_increment}); @@ -699,10 +759,10 @@ http2::ValueOrHttp2Status ParseFramePayload( } } -http2::Http2ErrorCode RstFrameErrorCodeToHttp2ErrorCode( +http2::Http2ErrorCode FrameErrorCodeToHttp2ErrorCode( const uint32_t error_code) { if (GPR_UNLIKELY(error_code > http2::GetMaxHttp2ErrorCode())) { - LOG(ERROR) << "RstFrameErrorCodeToHttp2ErrorCode: Invalid error code " + LOG(ERROR) << "FrameErrorCodeToHttp2ErrorCode: Invalid error code " "received from RST_STREAM frame: " << error_code; return http2::Http2ErrorCode::kInternalError; @@ -710,9 +770,10 @@ http2::Http2ErrorCode RstFrameErrorCodeToHttp2ErrorCode( return static_cast(error_code); } -uint32_t Http2ErrorCodeToRstFrameErrorCode( +uint32_t Http2ErrorCodeToFrameErrorCode( const http2::Http2ErrorCode error_code) { - DCHECK_LE(static_cast(error_code), http2::GetMaxHttp2ErrorCode()); + GRPC_DCHECK_LE(static_cast(error_code), + http2::GetMaxHttp2ErrorCode()); return static_cast(error_code); } @@ -722,28 +783,73 @@ size_t GetFrameMemoryUsage(const Http2Frame& frame) { /////////////////////////////////////////////////////////////////////////////// // GRPC Header +namespace { +ValueOrHttp2Status ParseGrpcMessageFlags(const uint8_t flags) { + switch (flags) { + case kGrpcMessageHeaderNoFlags: + return 0u; + case kGrpcMessageHeaderWriteInternalCompress: + return GRPC_WRITE_INTERNAL_COMPRESS; + default: + LOG(ERROR) << "Invalid gRPC header flags: " + << static_cast(flags); + return Http2Status::Http2StreamError( + Http2ErrorCode::kInternalError, + absl::StrCat("Invalid gRPC header flags: ", flags)); + } +} -GrpcMessageHeader ExtractGrpcHeader(SliceBuffer& payload) { +uint8_t SerializeGrpcMessageFlags(const uint32_t flags) { + return (flags & GRPC_WRITE_INTERNAL_COMPRESS) + ? kGrpcMessageHeaderWriteInternalCompress + : kGrpcMessageHeaderNoFlags; +} +} // namespace + +ValueOrHttp2Status ExtractGrpcHeader(SliceBuffer& payload) { GRPC_CHECK_GE(payload.Length(), kGrpcHeaderSizeInBytes); uint8_t buffer[kGrpcHeaderSizeInBytes]; payload.CopyFirstNBytesIntoBuffer(kGrpcHeaderSizeInBytes, buffer); GrpcMessageHeader header; - header.flags = buffer[0]; + ValueOrHttp2Status message_flags = ParseGrpcMessageFlags(buffer[0]); + if (!message_flags.IsOk()) { + return message_flags.TakeStatus(std::move(message_flags)); + } + + header.flags = message_flags.value(); header.length = Read4b(buffer + 1); return header; } -void AppendGrpcHeaderToSliceBuffer(SliceBuffer& payload, const uint8_t flags, +void AppendGrpcHeaderToSliceBuffer(SliceBuffer& payload, const uint32_t flags, const uint32_t length) { uint8_t* frame_hdr = payload.AddTiny(kGrpcHeaderSizeInBytes); - frame_hdr[0] = flags; + frame_hdr[0] = SerializeGrpcMessageFlags(flags); Write4b(length, frame_hdr + 1); } Http2Status ValidateFrameHeader(const uint32_t max_frame_size_setting, const bool incoming_header_in_progress, const uint32_t incoming_header_stream_id, - Http2FrameHeader& current_frame_header) { + Http2FrameHeader& current_frame_header, + const uint32_t last_stream_id, + const bool is_client, + const bool is_first_settings_processed) { + if (GPR_UNLIKELY(!is_first_settings_processed)) { + // This check works only because we pause the read loop after reading the + // first SETTINGS frame. + const bool is_settings_frame = + (current_frame_header.type == + static_cast(FrameType::kSettings) && + !ExtractFlag(current_frame_header.flags, kFlagAck)); + if (GPR_UNLIKELY(!is_settings_frame)) { + return Http2Status::Http2ConnectionError( + Http2ErrorCode::kProtocolError, + std::string(is_client ? RFC9113::kFirstSettingsFrameClient + : RFC9113::kFirstSettingsFrameServer)); + } + } + if (GPR_UNLIKELY(current_frame_header.length > max_frame_size_setting)) { return Http2Status::Http2ConnectionError( Http2ErrorCode::kFrameSizeError, @@ -760,8 +866,28 @@ Http2Status ValidateFrameHeader(const uint32_t max_frame_size_setting, Http2ErrorCode::kProtocolError, std::string(RFC9113::kAssemblerContiguousSequenceError)); } + // If a frame is received with a stream id larger than the last stream id sent + // by the transport, it is a protocol error. This condition holds for clients + // as in gRPC only clients can initiate a stream. last_stream_id is the stream + // id of the last stream created by the transport. If no streams were created + // by the transport, last_stream_id is 0. + // TODO(akshitpatel) : [PH2][P3] : Revisit this for server. + if (is_client && current_frame_header.stream_id > last_stream_id) { + return Http2Status::Http2ConnectionError( + Http2ErrorCode::kProtocolError, std::string(RFC9113::kUnknownStreamId)); + } // TODO(tjagtap) : [PH2][P2]:Consider validating MAX_CONCURRENT_STREAMS here + // for server. return Http2Status::Ok(); } +std::string MaybeTruncatePayload(SliceBuffer& payload, const uint32_t length) { + if (payload.Length() <= length) { + return payload.JoinIntoString(); + } + std::string result(length, '\0'); + payload.CopyFirstNBytesIntoBuffer(length, result.data()); + return absl::StrCat(result, ""); +} + } // namespace grpc_core diff --git a/deps/grpc/src/core/ext/transport/chttp2/transport/frame.h b/deps/grpc/src/core/ext/transport/chttp2/transport/frame.h index acfa0ff319f..335109e0534 100644 --- a/deps/grpc/src/core/ext/transport/chttp2/transport/frame.h +++ b/deps/grpc/src/core/ext/transport/chttp2/transport/frame.h @@ -22,16 +22,20 @@ #include #include -#include "absl/status/statusor.h" -#include "absl/strings/string_view.h" -#include "absl/types/span.h" #include "src/core/ext/transport/chttp2/transport/http2_settings.h" #include "src/core/ext/transport/chttp2/transport/http2_status.h" #include "src/core/lib/slice/slice.h" #include "src/core/lib/slice/slice_buffer.h" +#include "absl/status/statusor.h" +#include "absl/strings/string_view.h" +#include "absl/types/span.h" namespace grpc_core { +// Prints the first `length` bytes of the payload. If the payload is longer than +// `length`, it appends "" to the output. +std::string MaybeTruncatePayload(SliceBuffer& payload, uint32_t length = 15); + /////////////////////////////////////////////////////////////////////////////// // Frame types // @@ -242,8 +246,8 @@ http2::ValueOrHttp2Status ParseFramePayload( // move things out of frames) SerializeReturn Serialize(absl::Span frames, SliceBuffer& out); -http2::Http2ErrorCode RstFrameErrorCodeToHttp2ErrorCode(uint32_t error_code); -uint32_t Http2ErrorCodeToRstFrameErrorCode(http2::Http2ErrorCode error_code); +http2::Http2ErrorCode FrameErrorCodeToHttp2ErrorCode(uint32_t error_code); +uint32_t Http2ErrorCodeToFrameErrorCode(http2::Http2ErrorCode error_code); // Returns approximate memory usage of the frame. size_t GetFrameMemoryUsage(const Http2Frame& frame); @@ -252,19 +256,22 @@ size_t GetFrameMemoryUsage(const Http2Frame& frame); // GRPC Header constexpr uint8_t kGrpcHeaderSizeInBytes = 5; +constexpr uint8_t kGrpcMessageHeaderNoFlags = 0; +constexpr uint8_t kGrpcMessageHeaderWriteInternalCompress = 1; struct GrpcMessageHeader { - uint8_t flags = 0; + uint32_t flags = 0; uint32_t length = 0; }; // If the payload SliceBuffer is too small to hold a gRPC header, this function // will crash. The calling function MUST ensure that the payload SliceBuffer // has length greater than or equal to the gRPC header. -GrpcMessageHeader ExtractGrpcHeader(SliceBuffer& payload); +http2::ValueOrHttp2Status ExtractGrpcHeader( + SliceBuffer& payload); -void AppendGrpcHeaderToSliceBuffer(SliceBuffer& payload, const uint8_t flags, - const uint32_t length); +void AppendGrpcHeaderToSliceBuffer(SliceBuffer& payload, uint32_t flags, + uint32_t length); /////////////////////////////////////////////////////////////////////////////// // Validations @@ -275,7 +282,9 @@ http2::Http2Status ValidateSettingsValues( http2::Http2Status ValidateFrameHeader(uint32_t max_frame_size_setting, bool incoming_header_in_progress, uint32_t incoming_header_stream_id, - Http2FrameHeader& current_frame_header); + Http2FrameHeader& current_frame_header, + uint32_t last_stream_id, bool is_client, + bool is_first_settings_processed); /////////////////////////////////////////////////////////////////////////////// // RFC9113 Related Strings and Consts @@ -309,6 +318,9 @@ inline constexpr absl::string_view kSettingsStreamIdMustBeZero = "RFC9113: If an endpoint receives a SETTINGS frame whose Stream " "Identifier field is anything other than 0x00, the endpoint MUST respond " "with a connection error"; +inline constexpr absl::string_view kUnknownStreamId = + "RFC9113: An endpoint that receives an unexpected stream identifier MUST " + "respond with a connection error"; // Frame length related errors inline constexpr absl::string_view kRstStreamLength4 = @@ -368,6 +380,18 @@ inline constexpr absl::string_view kIncorrectFrameSizeSetting = inline constexpr absl::string_view kSettingsTimeout = "Settings timeout. The HTTP2 settings frame was not ACKed within the " "timeout. Connection will be closed"; +inline constexpr absl::string_view kLastStreamClosed = + "Closing last stream and cannot create any more streams."; +inline constexpr absl::string_view kFirstSettingsFrameClient = + "RFC9113: The server connection preface consists of a potentially empty " + "SETTINGS frame that MUST be the first frame the server sends in the " + "HTTP/2 connection. Clients and servers MUST treat an invalid connection " + "preface as a connection error of type PROTOCOL_ERROR."; +inline constexpr absl::string_view kFirstSettingsFrameServer = + "RFC9113: The client connection preface starts with a sequence of 24 " + "octets. This sequence is followed by a SETTINGS frame, which MAY be " + "empty. Clients and servers MUST treat an invalid connection preface as a " + "connection error of type PROTOCOL_ERROR."; inline constexpr uint32_t kMaxStreamId31Bit = 0x7fffffffu; inline constexpr uint32_t kMaxSize31Bit = 0x7fffffffu; @@ -378,6 +402,16 @@ inline constexpr uint32_t kMaximumFrameSize = 16777215; inline constexpr uint32_t kHttp2InitialWindowSize = 65535u; } // namespace RFC9113 + +namespace GrpcErrors { +inline constexpr absl::string_view kTooManyMetadata = + "gRPC Error : A gRPC server can send upto 1 initial metadata followed by " + "upto 1 trailing metadata."; +inline constexpr absl::string_view kOutOfOrderDataFrame = + "gRPC Error : DATA frames must follow initial metadata and precede " + "trailing metadata."; +} // namespace GrpcErrors + } // namespace grpc_core #endif // GRPC_SRC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_H diff --git a/deps/grpc/src/core/ext/transport/chttp2/transport/frame_data.cc b/deps/grpc/src/core/ext/transport/chttp2/transport/frame_data.cc index 0a06b526ea7..16323556897 100644 --- a/deps/grpc/src/core/ext/transport/chttp2/transport/frame_data.cc +++ b/deps/grpc/src/core/ext/transport/chttp2/transport/frame_data.cc @@ -22,8 +22,6 @@ #include #include -#include "absl/status/status.h" -#include "absl/strings/str_format.h" #include "src/core/ext/transport/chttp2/transport/call_tracer_wrapper.h" #include "src/core/ext/transport/chttp2/transport/internal.h" #include "src/core/lib/experiments/experiments.h" @@ -33,6 +31,8 @@ #include "src/core/telemetry/stats.h" #include "src/core/util/grpc_check.h" #include "src/core/util/status_helper.h" +#include "absl/status/status.h" +#include "absl/strings/str_format.h" absl::Status grpc_chttp2_data_parser_begin_frame(uint8_t flags, uint32_t stream_id, diff --git a/deps/grpc/src/core/ext/transport/chttp2/transport/frame_data.h b/deps/grpc/src/core/ext/transport/chttp2/transport/frame_data.h index 4aa2a69a210..7481c559d34 100644 --- a/deps/grpc/src/core/ext/transport/chttp2/transport/frame_data.h +++ b/deps/grpc/src/core/ext/transport/chttp2/transport/frame_data.h @@ -25,7 +25,6 @@ #include #include -#include "absl/status/status.h" #include "src/core/ext/transport/chttp2/transport/http2_ztrace_collector.h" #include "src/core/ext/transport/chttp2/transport/legacy_frame.h" #include "src/core/lib/iomgr/error.h" @@ -33,6 +32,7 @@ #include "src/core/lib/slice/slice_buffer.h" #include "src/core/lib/transport/transport.h" #include "src/core/telemetry/call_tracer.h" +#include "absl/status/status.h" // start processing a new data frame absl::Status grpc_chttp2_data_parser_begin_frame(uint8_t flags, diff --git a/deps/grpc/src/core/ext/transport/chttp2/transport/frame_goaway.cc b/deps/grpc/src/core/ext/transport/chttp2/transport/frame_goaway.cc index 7587d84330c..37eb006cb62 100644 --- a/deps/grpc/src/core/ext/transport/chttp2/transport/frame_goaway.cc +++ b/deps/grpc/src/core/ext/transport/chttp2/transport/frame_goaway.cc @@ -23,12 +23,12 @@ #include #include +#include "src/core/ext/transport/chttp2/transport/internal.h" +#include "src/core/util/grpc_check.h" #include "absl/base/attributes.h" #include "absl/status/status.h" #include "absl/strings/str_format.h" #include "absl/strings/string_view.h" -#include "src/core/ext/transport/chttp2/transport/internal.h" -#include "src/core/util/grpc_check.h" void grpc_chttp2_goaway_parser_init(grpc_chttp2_goaway_parser* p) { p->debug_data = nullptr; diff --git a/deps/grpc/src/core/ext/transport/chttp2/transport/frame_ping.cc b/deps/grpc/src/core/ext/transport/chttp2/transport/frame_ping.cc index ab1b8087456..447ca7149ba 100644 --- a/deps/grpc/src/core/ext/transport/chttp2/transport/frame_ping.cc +++ b/deps/grpc/src/core/ext/transport/chttp2/transport/frame_ping.cc @@ -25,15 +25,15 @@ #include -#include "absl/container/flat_hash_map.h" -#include "absl/log/log.h" -#include "absl/status/status.h" -#include "absl/strings/str_format.h" #include "src/core/ext/transport/chttp2/transport/internal.h" #include "src/core/ext/transport/chttp2/transport/ping_abuse_policy.h" #include "src/core/ext/transport/chttp2/transport/ping_callbacks.h" #include "src/core/lib/debug/trace.h" #include "src/core/util/grpc_check.h" +#include "absl/container/flat_hash_map.h" +#include "absl/log/log.h" +#include "absl/status/status.h" +#include "absl/strings/str_format.h" grpc_slice grpc_chttp2_ping_create(uint8_t ack, uint64_t opaque_8bytes) { grpc_slice slice = GRPC_SLICE_MALLOC(9 + 8); diff --git a/deps/grpc/src/core/ext/transport/chttp2/transport/frame_rst_stream.cc b/deps/grpc/src/core/ext/transport/chttp2/transport/frame_rst_stream.cc index 633173a6788..604466f772c 100644 --- a/deps/grpc/src/core/ext/transport/chttp2/transport/frame_rst_stream.cc +++ b/deps/grpc/src/core/ext/transport/chttp2/transport/frame_rst_stream.cc @@ -22,11 +22,6 @@ #include #include -#include "absl/log/log.h" -#include "absl/random/distributions.h" -#include "absl/status/status.h" -#include "absl/strings/str_cat.h" -#include "absl/strings/str_format.h" #include "src/core/call/metadata_batch.h" #include "src/core/ext/transport/chttp2/transport/call_tracer_wrapper.h" #include "src/core/ext/transport/chttp2/transport/http2_status.h" @@ -38,6 +33,11 @@ #include "src/core/util/grpc_check.h" #include "src/core/util/shared_bit_gen.h" #include "src/core/util/status_helper.h" +#include "absl/log/log.h" +#include "absl/random/distributions.h" +#include "absl/status/status.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/str_format.h" using grpc_core::http2::Http2ErrorCode; diff --git a/deps/grpc/src/core/ext/transport/chttp2/transport/frame_security.cc b/deps/grpc/src/core/ext/transport/chttp2/transport/frame_security.cc index 8fe0524bfea..3228ebb5280 100644 --- a/deps/grpc/src/core/ext/transport/chttp2/transport/frame_security.cc +++ b/deps/grpc/src/core/ext/transport/chttp2/transport/frame_security.cc @@ -19,13 +19,13 @@ #include #include -#include "absl/status/status.h" #include "src/core/ext/transport/chttp2/transport/internal.h" #include "src/core/ext/transport/chttp2/transport/legacy_frame.h" #include "src/core/lib/iomgr/event_engine_shims/endpoint.h" #include "src/core/lib/slice/slice.h" #include "src/core/lib/slice/slice_buffer.h" #include "src/core/lib/transport/transport_framing_endpoint_extension.h" +#include "absl/status/status.h" absl::Status grpc_chttp2_security_frame_parser_parse(void* parser, grpc_chttp2_transport* t, diff --git a/deps/grpc/src/core/ext/transport/chttp2/transport/frame_settings.cc b/deps/grpc/src/core/ext/transport/chttp2/transport/frame_settings.cc index e0e3e9eaa4a..8eaafce45a9 100644 --- a/deps/grpc/src/core/ext/transport/chttp2/transport/frame_settings.cc +++ b/deps/grpc/src/core/ext/transport/chttp2/transport/frame_settings.cc @@ -24,10 +24,6 @@ #include -#include "absl/base/attributes.h" -#include "absl/log/log.h" -#include "absl/status/status.h" -#include "absl/strings/str_format.h" #include "src/core/ext/transport/chttp2/transport/flow_control.h" #include "src/core/ext/transport/chttp2/transport/frame_goaway.h" #include "src/core/ext/transport/chttp2/transport/http2_settings.h" @@ -40,6 +36,10 @@ #include "src/core/telemetry/stats.h" #include "src/core/util/debug_location.h" #include "src/core/util/useful.h" +#include "absl/base/attributes.h" +#include "absl/log/log.h" +#include "absl/status/status.h" +#include "absl/strings/str_format.h" using grpc_core::http2::Http2ErrorCode; @@ -135,21 +135,13 @@ grpc_error_handle grpc_chttp2_settings_parser_parse(void* p, t->http2_ztrace_collector.Append( []() { return grpc_core::H2SettingsTrace{true, {}}; }); *parser->target_settings = *parser->incoming_settings; + t->MaybeNotifyStateWatcherOfPeerMaxConcurrentStreamsLocked(); t->num_pending_induced_frames++; grpc_slice_buffer_add(&t->qbuf, grpc_chttp2_settings_ack_create()); grpc_chttp2_initiate_write(t, GRPC_CHTTP2_INITIATE_WRITE_SETTINGS_ACK); - if (t->notify_on_receive_settings != nullptr) { - if (t->interested_parties_until_recv_settings != nullptr) { - grpc_endpoint_delete_from_pollset_set( - t->ep.get(), t->interested_parties_until_recv_settings); - t->interested_parties_until_recv_settings = nullptr; - } - grpc_core::ExecCtx::Run(DEBUG_LOCATION, - t->notify_on_receive_settings, - absl::OkStatus()); - t->notify_on_receive_settings = nullptr; - } + t->MaybeNotifyOnReceiveSettingsLocked( + parser->target_settings->max_concurrent_streams()); } return absl::OkStatus(); } diff --git a/deps/grpc/src/core/ext/transport/chttp2/transport/frame_window_update.cc b/deps/grpc/src/core/ext/transport/chttp2/transport/frame_window_update.cc index 504bf14559e..6021036cd09 100644 --- a/deps/grpc/src/core/ext/transport/chttp2/transport/frame_window_update.cc +++ b/deps/grpc/src/core/ext/transport/chttp2/transport/frame_window_update.cc @@ -21,9 +21,6 @@ #include #include -#include "absl/status/status.h" -#include "absl/strings/str_cat.h" -#include "absl/strings/str_format.h" #include "src/core/ext/transport/chttp2/transport/call_tracer_wrapper.h" #include "src/core/ext/transport/chttp2/transport/flow_control.h" #include "src/core/ext/transport/chttp2/transport/http2_ztrace_collector.h" @@ -32,6 +29,9 @@ #include "src/core/telemetry/stats.h" #include "src/core/util/grpc_check.h" #include "src/core/util/time.h" +#include "absl/status/status.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/str_format.h" grpc_slice grpc_chttp2_window_update_create( uint32_t id, uint32_t window_delta, diff --git a/deps/grpc/src/core/ext/transport/chttp2/transport/goaway.cc b/deps/grpc/src/core/ext/transport/chttp2/transport/goaway.cc index 475433cdb6c..543d6154382 100644 --- a/deps/grpc/src/core/ext/transport/chttp2/transport/goaway.cc +++ b/deps/grpc/src/core/ext/transport/chttp2/transport/goaway.cc @@ -18,6 +18,112 @@ #include "src/core/ext/transport/chttp2/transport/goaway.h" +#include "src/core/util/grpc_check.h" + namespace grpc_core { -namespace http2 {} // namespace http2 +namespace http2 { + +GoawayManager::GoawayManager(std::unique_ptr goaway_interface) + : context_(MakeRefCounted(std::move(goaway_interface))) {} + +std::optional GoawayManager::MaybeGetGoawayFrame() { + switch (context_->goaway_state) { + case GoawayState::kIdle: + case GoawayState::kDone: + break; + case GoawayState::kInitialGracefulGoawayScheduled: { + GRPC_DCHECK(!goaway_sent_); + Http2Frame goaway_frame = context_->GetInitialGracefulGoawayFrame(); + GRPC_HTTP2_GOAWAY_LOG << "Graceful GOAWAY frame created."; + goaway_sent_ = true; + return std::move(goaway_frame); + } + case GoawayState::kFinalGracefulGoawayScheduled: { + GRPC_DCHECK(!goaway_sent_); + Http2Frame goaway_frame = context_->GetFinalGracefulGoawayFrame(); + GRPC_HTTP2_GOAWAY_LOG << "Final graceful GOAWAY frame created."; + goaway_sent_ = true; + return std::move(goaway_frame); + } + case GoawayState::kImmediateGoawayRequested: { + GRPC_DCHECK(!goaway_sent_); + Http2Frame goaway_frame = context_->GetImmediateGoawayFrame(); + GRPC_HTTP2_GOAWAY_LOG << "Immediate GOAWAY frame created."; + goaway_sent_ = true; + return std::move(goaway_frame); + } + } + + return std::nullopt; +} + +void GoawayManager::MaybeGetSerializedGoawayFrame(SliceBuffer& output_buf) { + GRPC_HTTP2_GOAWAY_LOG << "MaybeGetSerializedGoawayFrames: current state: " + << context_->GoawayStateToString( + context_->goaway_state); + + std::optional goaway_frame = MaybeGetGoawayFrame(); + if (goaway_frame.has_value()) { + Serialize(absl::Span(&goaway_frame.value(), 1), output_buf); + GRPC_HTTP2_GOAWAY_LOG << "GOAWAY frame serialized."; + } +} + +void GoawayManager::NotifyGoawaySent() { + if (goaway_sent_) { + GRPC_HTTP2_GOAWAY_LOG << "GOAWAY frame sent in current write cycle."; + context_->SentGoawayTransition(); + goaway_sent_ = false; + } +} + +void GoawayManager::Context::SentGoawayTransition() { + GRPC_HTTP2_GOAWAY_LOG << "SentGoawayTransition: current state: " + << GoawayStateToString(goaway_state); + switch (goaway_state) { + case GoawayState::kIdle: + case GoawayState::kInitialGracefulGoawayScheduled: + case GoawayState::kDone: + break; + case GoawayState::kFinalGracefulGoawayScheduled: + case GoawayState::kImmediateGoawayRequested: { + GRPC_HTTP2_GOAWAY_LOG << "Transitioning to kDone from " + << GoawayStateToString(goaway_state); + goaway_state = GoawayState::kDone; + WaitSet::WakeupSet wakers_to_wakeup = wakers.TakeWakeupSet(); + wakers_to_wakeup.Wakeup(); + break; + } + default: + break; + } +} + +std::string GoawayManager::Context::GoawayStateToString( + GoawayState goaway_state) { + switch (goaway_state) { + case GoawayState::kIdle: + return "kIdle"; + case GoawayState::kInitialGracefulGoawayScheduled: + return "kInitialGracefulGoawayScheduled"; + case GoawayState::kFinalGracefulGoawayScheduled: + return "kFinalGracefulGoawayScheduled"; + case GoawayState::kImmediateGoawayRequested: + return "kImmediateGoawayRequested"; + case GoawayState::kDone: + return "kDone"; + default: + return "unknown"; + } +} + +std::optional GoawayManager::TestOnlyMaybeGetGoawayFrame() { + GRPC_HTTP2_GOAWAY_LOG << "TestOnlyMaybeGetGoawayFrame: current state: " + << context_->GoawayStateToString( + context_->goaway_state); + + return MaybeGetGoawayFrame(); +} + +} // namespace http2 } // namespace grpc_core diff --git a/deps/grpc/src/core/ext/transport/chttp2/transport/goaway.h b/deps/grpc/src/core/ext/transport/chttp2/transport/goaway.h index 7d6191b076a..9ba9ca715c9 100644 --- a/deps/grpc/src/core/ext/transport/chttp2/transport/goaway.h +++ b/deps/grpc/src/core/ext/transport/chttp2/transport/goaway.h @@ -19,7 +19,6 @@ #ifndef GRPC_SRC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_GOAWAY_H #define GRPC_SRC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_GOAWAY_H -#include "absl/status/status.h" #include "src/core/ext/transport/chttp2/transport/frame.h" #include "src/core/ext/transport/chttp2/transport/http2_status.h" #include "src/core/lib/promise/activity.h" @@ -30,9 +29,322 @@ #include "src/core/lib/promise/wait_set.h" #include "src/core/lib/slice/slice_buffer.h" #include "src/core/util/ref_counted_ptr.h" +#include "absl/status/status.h" + +// This file contains the promise based implementation details of HTTP2 GOAWAY +// mechanism. +// RFC9113 https://www.rfc-editor.org/rfc/rfc9113.html#name-goaway namespace grpc_core { -namespace http2 {} // namespace http2 +namespace http2 { +#define GRPC_HTTP2_GOAWAY_LOG VLOG(2) + +class GoawayInterface { + public: + virtual ~GoawayInterface() = default; + // Returns a promise that will be resolved when a ping frame is sent and the + // corresponding ack is received. + virtual Promise SendPingAndWaitForAck() = 0; + + // Triggers a transport write cycle. + virtual void TriggerWriteCycle() = 0; + + // Only used for graceful GOAWAY (and by extension relevant only for server). + // Returns the last accepted stream id by the transport. + virtual uint32_t GetLastAcceptedStreamId() = 0; +}; + +enum class GoawayState : uint8_t { + // No GOAWAY is in progress. + kIdle, + // Initial graceful GOAWAY is scheduled to be sent in the next transport write + // cycle. + kInitialGracefulGoawayScheduled, + // Final graceful GOAWAY is scheduled to be sent in the next transport write + // cycle. Sending this GOAWAY frame completes the graceful GOAWAY process and + // transitions the state to kDone. + kFinalGracefulGoawayScheduled, + // Immediate GOAWAY is requested to be sent in the next transport write + // cycle. Sending this GOAWAY frame completes the immediate GOAWAY process and + // transitions the state to kDone. + kImmediateGoawayRequested, + // GOAWAY is complete. This is the terminal state for all RequestGoaway calls. + // Any subsequent RequestGoaway calls will be immediately resolved with OK + // status. + kDone, +}; + +// Information needed to construct a GOAWAY frame. +struct GoawayArgs { + uint32_t error_code = 0; + uint32_t last_good_stream_id = 0; + Slice debug_data; +}; + +class GoawayManager { + private: + std::optional MaybeGetGoawayFrame(); + + // Context for the GOAWAY process. This is passed around as a ref to all the + // promises to ensure that the all the promises have valid access to the + // context. + struct Context : public RefCounted { + explicit Context(std::unique_ptr goaway_interface) + : goaway_interface(std::move(goaway_interface)) {} + + Http2Frame GetImmediateGoawayFrame() { + GRPC_HTTP2_GOAWAY_LOG + << "GetImmediateGoawayFrame: " + << " error code: " << goaway_args.error_code + << " last good stream id: " << goaway_args.last_good_stream_id + << " debug data: " << goaway_args.debug_data.as_string_view(); + + return Http2GoawayFrame{ + /*last_stream_id=*/goaway_args.last_good_stream_id, + /*error_code=*/goaway_args.error_code, + /*debug_data=*/std::move(goaway_args.debug_data)}; + } + + Http2Frame GetInitialGracefulGoawayFrame() { + GRPC_HTTP2_GOAWAY_LOG + << "GetInitialGracefulGoawayFrame: " + << " error code: " << static_cast(Http2ErrorCode::kNoError) + << " last good stream id: " << RFC9113::kMaxStreamId31Bit + << " debug data: " << goaway_args.debug_data.as_string_view(); + return Http2GoawayFrame{ + /*last_stream_id=*/RFC9113::kMaxStreamId31Bit, + /*error_code=*/static_cast(Http2ErrorCode::kNoError), + /*debug_data=*/ + Slice::FromCopiedBuffer(goaway_args.debug_data.as_string_view())}; + } + + Http2Frame GetFinalGracefulGoawayFrame() { + // Update the last good stream id before sending the final graceful GOAWAY + // frame. This is needed as the server MAY accept new streams after the + // first graceful GOAWAY frame is sent. + goaway_args.last_good_stream_id = + goaway_interface->GetLastAcceptedStreamId(); + GRPC_HTTP2_GOAWAY_LOG + << "GetFinalGracefulGoawayFrame: " + << " error code: " << static_cast(Http2ErrorCode::kNoError) + << " last good stream id: " << goaway_args.last_good_stream_id + << " debug data: " << goaway_args.debug_data.as_string_view(); + return Http2GoawayFrame{ + /*last_stream_id=*/goaway_args.last_good_stream_id, + /*error_code=*/static_cast(Http2ErrorCode::kNoError), + /*debug_data=*/std::move(goaway_args.debug_data)}; + } + + void AddWaker(Waker&& waker) { + wakers.AddPending(std::move(waker)); + GRPC_HTTP2_GOAWAY_LOG << "AddWaker: " << wakers.ToString(); + } + + void SetGoawayArgs(const uint32_t error_code, Slice&& debug_data, + const uint32_t last_good_stream_id) { + GRPC_HTTP2_GOAWAY_LOG << "SetGoawayArgs: " + << " error code: " << error_code + << " last good stream id: " << last_good_stream_id + << " debug data: " << debug_data.as_string_view(); + goaway_args = GoawayArgs{/*error_code=*/error_code, + /*last_good_stream_id=*/last_good_stream_id, + /*debug_data=*/std::move(debug_data)}; + } + + std::string GoawayStateToString(GoawayState goaway_state); + + void SentGoawayTransition(); + + GoawayState goaway_state = GoawayState::kIdle; + std::unique_ptr goaway_interface; + // TODO(akshitpatel) : [PH2][P4] : There is scope to make this + // IntractivityWaker. + WaitSet wakers; + GoawayArgs goaway_args{}; + }; + + // Runs the given promise until the GOAWAY state is kDone. + template + auto UntilDone(PromiseType&& promise) { + return Race( + [ctx = context_->Ref()]() -> Poll { + if (ctx->goaway_state == GoawayState::kDone) { + GRPC_HTTP2_GOAWAY_LOG << "GOAWAY state is kDone. Resolving the " + "promise with OK status."; + return absl::OkStatus(); + } + ctx->wakers.AddPending(GetContext()->MakeNonOwningWaker()); + return Pending{}; + }, + std::forward(promise)); + } + + // Handles an immediate GOAWAY request. The flow is as follows: + // 1. If there is no pending GOAWAY(state is kIdle), then + // a. Set the GOAWAY state to kImmediateGoawayRequested. + // b. Set the GOAWAY args. + // c. Trigger a write cycle. + // d. Once the transport invokes MaybeGetSerializedGoawayFrames, + // a GOAWAY frame is sent and the state is changed to kDone effectively + // completing the GOAWAY process (and resolving the promise). + // 2. If there is already an Immediate GOAWAY request in progress, then + // the function allows the previous error/debug data to take precedence + // and returns a pending promise. In this case, the promise resolves when + // the previous GOAWAY request completes. + // 3. If there is a graceful GOAWAY request in progress(state is either + // kInitialGracefulGoawayScheduled or kFinalGracefulGoawayScheduled), then + // the immediate GOAWAY request takes precedence (because it has a error + // code that may be needed by the peer) and the current error/debug data + // will be sent in the next transport write cycle. The graceful GOAWAY + // request will be effectively cancelled. The promise resolves when the + // immediate GOAWAY request completes. + // In the above comments, `the promise` refers to the promise returned by + // RequestGoaway. + static auto HandleImmediateGoaway(RefCountedPtr ctx, + const Http2ErrorCode error_code, + Slice&& debug_data, + const uint32_t last_good_stream_id) { + return [ctx = std::move(ctx), error_code, debug_data = debug_data.Ref(), + last_good_stream_id]() mutable -> Poll { + if (ctx->goaway_state == GoawayState::kImmediateGoawayRequested) { + GRPC_HTTP2_GOAWAY_LOG + << "[Immediate GOAWAY] request already in progress."; + // Previous GOAWAY request error/debug data takes precedence. + return Pending{}; + } + GRPC_HTTP2_GOAWAY_LOG << "[Immediate GOAWAY] state change " + << ctx->GoawayStateToString(ctx->goaway_state) + << " -> " + "kImmediateGoawayRequested."; + + ctx->goaway_state = GoawayState::kImmediateGoawayRequested; + ctx->SetGoawayArgs( + /*error_code=*/static_cast(error_code), + /*debug_data=*/debug_data.TakeOwned(), + /*last_good_stream_id=*/last_good_stream_id); + ctx->goaway_interface->TriggerWriteCycle(); + return Pending{}; + }; + } + + // Handles a graceful GOAWAY request. The flow is as follows: + // 1. If there is no pending GOAWAY(state is kIdle), then + // a. Set the GOAWAY state to kInitialGracefulGoawayScheduled. + // b. Set the GOAWAY args. + // c. Trigger a write cycle and request a ping request. + // d. Once the ping ack is received and the state is + // kInitialGracefulGoawayScheduled, the state is changed to + // kFinalGracefulGoawayScheduled and a write cycle is triggered. The + // state is checked again as an immediate GOAWAY request could have been + // made in between in which case the current graceful GOAWAY request is + // effectively cancelled. In either case, the promise resolves when the + // GOAWAY request completes. + // e. Once the state is kFinalGracefulGoawayScheduled, the transport write + // cycle + // will send a GOAWAY frame and the state is changed to kDone + // effectively completing the GOAWAY process (and resolving the + // promise). + // 2. If the state is anything other than kIdle, then we don't need to + // start a new graceful GOAWAY request. The promise resolves when the + // previous GOAWAY request completes. + // In the above comments, `the promise` refers to the promise returned by + // RequestGoaway. + static auto HandleGracefulGoaway(RefCountedPtr ctx, + const Http2ErrorCode error_code, + Slice&& debug_data, + const uint32_t last_good_stream_id) { + GoawayState previous_state = ctx->goaway_state; + return If( + previous_state == GoawayState::kIdle, + [ctx = std::move(ctx), error_code, debug_data = debug_data.Ref(), + last_good_stream_id]() mutable { + // TODO(akshitpatel) : [PH2][P4] : Investigate if we need to modify + // transport ping timeout for the graceful GOAWAY process. + // Only begin the graceful GOAWAY process (at most once) + // if there is no pending GOAWAY. + GRPC_HTTP2_GOAWAY_LOG << "[Graceful GOAWAY] state change " + << ctx->GoawayStateToString(ctx->goaway_state) + << " -> " + "kInitialGracefulGoawayScheduled."; + GRPC_DCHECK(error_code == Http2ErrorCode::kNoError); + ctx->goaway_state = GoawayState::kInitialGracefulGoawayScheduled; + ctx->SetGoawayArgs( + /*error_code=*/static_cast(Http2ErrorCode::kNoError), + /*debug_data=*/debug_data.TakeOwned(), + /*last_good_stream_id=*/last_good_stream_id); + ctx->goaway_interface->TriggerWriteCycle(); + return TrySeq(ctx->goaway_interface->SendPingAndWaitForAck(), + [ctx]() -> Poll { + GRPC_HTTP2_GOAWAY_LOG + << "Ping resolved. Current state: " + << ctx->GoawayStateToString(ctx->goaway_state); + if (ctx->goaway_state == + GoawayState::kInitialGracefulGoawayScheduled) { + GRPC_HTTP2_GOAWAY_LOG + << " [Graceful GOAWAY] state change " + << ctx->GoawayStateToString(ctx->goaway_state) + << " -> " + "kFinalGracefulGoawayScheduled."; + ctx->goaway_state = + GoawayState::kFinalGracefulGoawayScheduled; + ctx->goaway_interface->TriggerWriteCycle(); + } + return Pending{}; + }); + }, + []() -> Poll { + GRPC_HTTP2_GOAWAY_LOG << "GOAWAY request already in progress."; + return Pending{}; + }); + } + + RefCountedPtr context_; + bool goaway_sent_ = false; + + public: + explicit GoawayManager(std::unique_ptr goaway_interface); + + // Returns a promise that will be resolved when the GOAWAY process is + // complete. For immediate GOAWAY, the promise will be resolved once the + // GOAWAY frame is sent. For graceful GOAWAY, the promise will be resolved + // once the final GOAWAY frame is sent. + auto RequestGoaway(const Http2ErrorCode error_code, Slice&& debug_data, + const uint32_t last_good_stream_id, const bool immediate) { + return AssertResultType(UntilDone(If( + immediate, + [ctx = context_->Ref(), error_code, debug_data = debug_data.Ref(), + last_good_stream_id]() mutable { + return AssertResultType(HandleImmediateGoaway( + std::move(ctx), error_code, std::move(debug_data), + last_good_stream_id)); + }, + [ctx = context_->Ref(), error_code, debug_data = debug_data.Ref(), + last_good_stream_id]() mutable { + return AssertResultType( + HandleGracefulGoaway(std::move(ctx), error_code, + std::move(debug_data), last_good_stream_id)); + }))); + } + + // Called from the transport write cycle to serialize the GOAWAY frame if + // needed. + void MaybeGetSerializedGoawayFrame(SliceBuffer& output_buf); + + bool IsImmediateGoAway() const { + return context_->goaway_state == GoawayState::kImmediateGoawayRequested; + } + + // Called from the transport write cycle to notify the GOAWAY manager that a + // GOAWAY frame may have been sent. If a GOAWAY frame is sent in current + // write cycle, this function handles the needed state transition. + void NotifyGoawaySent(); + + // Returns the current GOAWAY state. + GoawayState TestOnlyGetGoawayState() const { return context_->goaway_state; } + std::optional TestOnlyMaybeGetGoawayFrame(); +}; + +} // namespace http2 } // namespace grpc_core #endif // GRPC_SRC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_GOAWAY_H diff --git a/deps/grpc/src/core/ext/transport/chttp2/transport/header_assembler.h b/deps/grpc/src/core/ext/transport/chttp2/transport/header_assembler.h index c49c5f3d2b9..20d576d9190 100644 --- a/deps/grpc/src/core/ext/transport/chttp2/transport/header_assembler.h +++ b/deps/grpc/src/core/ext/transport/chttp2/transport/header_assembler.h @@ -23,17 +23,23 @@ #include #include +#include +#include -#include "absl/log/log.h" #include "src/core/call/metadata_batch.h" #include "src/core/ext/transport/chttp2/transport/frame.h" #include "src/core/ext/transport/chttp2/transport/hpack_encoder.h" #include "src/core/ext/transport/chttp2/transport/hpack_parser.h" #include "src/core/ext/transport/chttp2/transport/http2_status.h" +#include "src/core/lib/iomgr/error.h" #include "src/core/lib/slice/slice.h" #include "src/core/lib/slice/slice_buffer.h" #include "src/core/util/grpc_check.h" #include "src/core/util/shared_bit_gen.h" +#include "src/core/util/status_helper.h" +#include "absl/log/log.h" +#include "absl/status/status.h" +#include "absl/strings/str_cat.h" // TODO(tjagtap) TODO(akshitpatel): [PH2][P3] : Write micro benchmarks for // assembler and disassembler code @@ -42,7 +48,7 @@ namespace grpc_core { namespace http2 { // If the Client Transport code is using HeaderAssembler in the wrong way, -// we fail with a DCHECK. +// we fail with a GRPC_DCHECK. // If the peer sent some bad data, we fail with the appropriate Http2Status. #define ASSEMBLER_LOG DVLOG(3) @@ -85,17 +91,20 @@ constexpr uint8_t kMaxHeaderFrames = 2; class HeaderAssembler { public: // Call this for each incoming HTTP2 Header frame. - // The payload of the Http2HeaderFrame will be cleared in this function. - Http2Status AppendHeaderFrame(Http2HeaderFrame&& frame) { + // If AppendHeaderFrame returns an OK status, the payload will be consumed. + // Else, the payload will be left in the frame. + Http2Status AppendHeaderFrame(Http2HeaderFrame& frame) { // Validate input frame GRPC_DCHECK_GT(frame.stream_id, 0u) << "RFC9113 : HEADERS frames MUST be associated with a stream."; + // Validate assembler state + GRPC_DCHECK(!header_in_progress_); + // Manage size constraints const size_t current_len = frame.payload.Length(); if constexpr (sizeof(size_t) == 4) { if (GPR_UNLIKELY(buffer_.Length() >= UINT32_MAX - current_len)) { - Cleanup(); LOG(ERROR) << "Stream Error: SliceBuffer overflow for 32 bit platforms."; return Http2Status::Http2StreamError( @@ -109,11 +118,12 @@ class HeaderAssembler { // Manage payload frame.payload.MoveFirstNBytesIntoSliceBuffer(current_len, buffer_); - ASSEMBLER_LOG << "AppendHeaderFrame " << current_len << " Bytes."; + ASSEMBLER_LOG << "HeaderAssembler::AppendHeaderFrame " << current_len + << " Bytes."; // Manage if last frame if (frame.end_headers) { - ASSEMBLER_LOG << "AppendHeaderFrame end_headers"; + ASSEMBLER_LOG << "HeaderAssembler::AppendHeaderFrame end_headers"; is_ready_ = true; } @@ -121,16 +131,21 @@ class HeaderAssembler { } // Call this for each incoming HTTP2 Continuation frame. - // The payload of the Http2ContinuationFrame will be cleared in this function. - Http2Status AppendContinuationFrame(Http2ContinuationFrame&& frame) { + // If AppendContinuationFrame returns an OK status, the payload will be + // consumed. Else, the payload will be left in the frame. + Http2Status AppendContinuationFrame(Http2ContinuationFrame& frame) { + // Validate Assembler state + GRPC_DCHECK(header_in_progress_); + // Manage payload const size_t current_len = frame.payload.Length(); frame.payload.MoveFirstNBytesIntoSliceBuffer(current_len, buffer_); - ASSEMBLER_LOG << "AppendContinuationFrame " << current_len << " Bytes."; + ASSEMBLER_LOG << "HeaderAssembler::AppendContinuationFrame " << current_len + << " Bytes."; // Manage if last frame if (frame.end_headers) { - ASSEMBLER_LOG << "AppendHeaderFrame end_headers"; + ASSEMBLER_LOG << "HeaderAssembler::AppendContinuationFrame end_headers"; is_ready_ = true; } @@ -142,10 +157,13 @@ class HeaderAssembler { HPackParser& parser, bool is_initial_metadata, bool is_client, const uint32_t max_header_list_size_soft_limit, const uint32_t max_header_list_size_hard_limit) { - ASSEMBLER_LOG << "ReadMetadata " << buffer_.Length() << " Bytes."; + ASSEMBLER_LOG << "HeaderAssembler::ReadMetadata " << buffer_.Length() + << " Bytes."; // Validate GRPC_DCHECK_EQ(is_ready_, true); + GRPC_DCHECK_GT(stream_id_, 0u) + << "Stream id must be set before reading metadata."; // Generate the gRPC Metadata from buffer_ // RFC9113 : A receiver MUST terminate the connection with a connection @@ -162,48 +180,60 @@ class HeaderAssembler { // experiment of its own. For now we just honour allow_true_binary_metadata_ // while writing frames for the peer on the write path. We do not enforce it // on the read path. - parser.BeginFrame( - /*grpc_metadata_batch*/ metadata.get(), max_header_list_size_soft_limit, - max_header_list_size_hard_limit, - is_initial_metadata ? HPackParser::Boundary::EndOfHeaders - : HPackParser::Boundary::EndOfStream, - HPackParser::Priority::None, - HPackParser::LogInfo{stream_id_, - is_initial_metadata - ? HPackParser::LogInfo::Type::kHeaders - : HPackParser::LogInfo::Type::kTrailers, - is_client}); - for (size_t i = 0; i < buffer_.Count(); i++) { - absl::Status result = parser.Parse( - buffer_.c_slice_at(i), i == buffer_.Count() - 1, SharedBitGen(), - /*call_tracer=*/nullptr); - if (GPR_UNLIKELY(!result.ok())) { - Cleanup(); - LOG(ERROR) << "Connection Error: " << kAssemblerHpackError; - return Http2Status::Http2ConnectionError( - Http2ErrorCode::kCompressionError, - std::string(kAssemblerHpackError)); - } - } - parser.FinishFrame(); - + Http2Status status = ParseHeader( + parser, std::move(buffer_), metadata.get(), + ParseHeaderArgs{ + /*is_initial_metadata=*/is_initial_metadata, + /*is_end_headers=*/is_ready_, + /*is_client=*/is_client, + /*max_header_list_size_soft_limit=*/max_header_list_size_soft_limit, + /*max_header_list_size_hard_limit=*/max_header_list_size_hard_limit, + /*stream_id=*/stream_id_, + }); Cleanup(); - + if (!status.IsOk()) { + return std::move(status); + } return ValueOrHttp2Status>( std::move(metadata)); } + Http2Status ParseAndDiscardHeaders( + HPackParser& parser, const bool is_initial_metadata, const bool is_client, + const uint32_t max_header_list_size_soft_limit, + const uint32_t max_header_list_size_hard_limit) { + ASSEMBLER_LOG << "HeaderAssembler::ParseAndDiscardHeaders " + << buffer_.Length() << " Bytes" + << " is_initial_metadata: " << is_initial_metadata + << " is_client: " << is_client + << " max_header_list_size_soft_limit: " + << max_header_list_size_soft_limit + << "max_header_list_size_hard_limit: " + << max_header_list_size_hard_limit; + Http2Status status = ParseHeader( + parser, std::move(buffer_), /*grpc_metadata_batch=*/nullptr, + ParseHeaderArgs{ + /*is_initial_metadata=*/is_initial_metadata, + /*is_end_headers=*/is_ready_, + /*is_client=*/is_client, + /*max_header_list_size_soft_limit=*/max_header_list_size_soft_limit, + /*max_header_list_size_hard_limit=*/max_header_list_size_hard_limit, + /*stream_id=*/stream_id_, + }); + Cleanup(); + return status; + } + size_t GetBufferedHeadersLength() const { return buffer_.Length(); } // This value MUST be checked before calling ReadMetadata() bool IsReady() const { return is_ready_; } - explicit HeaderAssembler(const uint32_t stream_id, - const bool allow_true_binary_metadata_acked) + explicit HeaderAssembler() : header_in_progress_(false), is_ready_(false), - allow_true_binary_metadata_acked_(allow_true_binary_metadata_acked), - stream_id_(stream_id) {} + allow_true_binary_metadata_acked_(true), + stream_id_(0) {} ~HeaderAssembler() = default; @@ -212,6 +242,92 @@ class HeaderAssembler { HeaderAssembler(const HeaderAssembler&) = delete; HeaderAssembler& operator=(const HeaderAssembler&) = delete; + void InitializeStream(const uint32_t stream_id, + const bool allow_true_binary_metadata_acked) { + GRPC_DCHECK_EQ(stream_id_, 0u); + GRPC_DCHECK_NE(stream_id, 0u); + stream_id_ = stream_id; + allow_true_binary_metadata_acked_ = allow_true_binary_metadata_acked; + } + + // HPACK parser helpers + struct ParseHeaderArgs { + bool is_initial_metadata; + bool is_end_headers; + bool is_client; + uint32_t max_header_list_size_soft_limit; + uint32_t max_header_list_size_hard_limit; + uint32_t stream_id; + + std::string DebugString() const { + return absl::StrCat( + "is_initial_metadata: ", is_initial_metadata, + " is_end_headers: ", is_end_headers, " is_client: ", is_client, + " max_header_list_size_soft_limit: ", max_header_list_size_soft_limit, + " max_header_list_size_hard_limit: ", + max_header_list_size_hard_limit); + } + }; + + static Http2Status ParseHeader(HPackParser& parser, SliceBuffer&& buffer, + grpc_metadata_batch* grpc_metadata_batch, + const ParseHeaderArgs args) { + parser.BeginFrame( + /*grpc_metadata_batch*/ grpc_metadata_batch, + args.max_header_list_size_soft_limit, + args.max_header_list_size_hard_limit, + GetBoundary(args.is_initial_metadata, args.is_end_headers), + HPackParser::Priority::None, + HPackParser::LogInfo{args.stream_id, + args.is_initial_metadata + ? HPackParser::LogInfo::Type::kHeaders + : HPackParser::LogInfo::Type::kTrailers, + args.is_client}); + // TODO(tjagtap) [PH2][P5] Bug fix : Check if the received metadata honours + // allow_true_binary_metadata or not. Will need changes to HPack code. + absl::Status stream_error = absl::OkStatus(); + for (size_t i = 0; i < buffer.Count(); i++) { + absl::Status result = parser.Parse( + buffer.c_slice_at(i), i == buffer.Count() - 1, SharedBitGen(), + /*call_tracer=*/nullptr); + if (GPR_UNLIKELY(!result.ok())) { + parser.StopBufferingFrame(); + intptr_t unused; + if (grpc_error_get_int(result, StatusIntProperty::kStreamId, &unused)) { + // We need to keep parsing the other slices in slice buffer. Because + // HPACK state needs to be maintained for the other streams. Store the + // error and continue. + if (stream_error.ok()) { + stream_error = result; + } + } else { + LOG(ERROR) << "HPack Error: " << result; + return ToHttpOkOrConnError(result); + } + } + } + if (GPR_UNLIKELY(!stream_error.ok())) { + return Http2Status::AbslStreamError(stream_error.code(), + std::string(stream_error.message())); + } + parser.FinishFrame(); + return Http2Status::Ok(); + } + + static HPackParser::Boundary GetBoundary(const bool is_initial_metadata, + const bool is_end_headers) { + HPackParser::Boundary boundary = HPackParser::Boundary::None; + if (is_end_headers) { + if (is_initial_metadata) { + boundary = HPackParser::Boundary::EndOfHeaders; + } else { + boundary = HPackParser::Boundary::EndOfStream; + } + } + + return boundary; + } + private: void Cleanup() { buffer_.Clear(); @@ -221,8 +337,8 @@ class HeaderAssembler { bool header_in_progress_; bool is_ready_; - GRPC_UNUSED const bool allow_true_binary_metadata_acked_; - const uint32_t stream_id_; + bool allow_true_binary_metadata_acked_; + uint32_t stream_id_; SliceBuffer buffer_; }; @@ -244,6 +360,9 @@ class HeaderDisassembler { Http2Frame GetNextFrame(const uint32_t max_frame_length, bool& out_end_headers) { + GRPC_DCHECK_GT(stream_id_, 0u) << "Stream id must be set before getting " + "next Header/Continuation frame."; + if (buffer_.Length() == 0 || is_done_) { GRPC_DCHECK(false) << "Calling code must check size using HasMoreData() " "before GetNextFrame()"; @@ -273,14 +392,12 @@ class HeaderDisassembler { // A separate HeaderDisassembler object MUST be made for Initial Metadata and // Trailing Metadata - explicit HeaderDisassembler(const uint32_t stream_id, - const bool is_trailing_metadata, - const bool allow_true_binary_metadata_peer) - : stream_id_(stream_id), + explicit HeaderDisassembler(const bool is_trailing_metadata) + : stream_id_(0), end_stream_(is_trailing_metadata), did_send_header_frame_(false), is_done_(false), - allow_true_binary_metadata_peer_(allow_true_binary_metadata_peer) {} + allow_true_binary_metadata_peer_(false) {} ~HeaderDisassembler() = default; @@ -290,13 +407,20 @@ class HeaderDisassembler { HeaderDisassembler& operator=(const HeaderDisassembler&) = delete; size_t TestOnlyGetMainBufferLength() const { return buffer_.Length(); } + void Initialize(const uint32_t stream_id, + const bool allow_true_binary_metadata_peer) { + GRPC_DCHECK_EQ(stream_id_, 0u); + GRPC_DCHECK_NE(stream_id, 0u); + stream_id_ = stream_id; + allow_true_binary_metadata_peer_ = allow_true_binary_metadata_peer; + } private: - const uint32_t stream_id_; + uint32_t stream_id_; const bool end_stream_; bool did_send_header_frame_; bool is_done_; // Protect against the same disassembler from being used twice - const bool allow_true_binary_metadata_peer_; + bool allow_true_binary_metadata_peer_; SliceBuffer buffer_; }; diff --git a/deps/grpc/src/core/ext/transport/chttp2/transport/hpack_encoder.cc b/deps/grpc/src/core/ext/transport/chttp2/transport/hpack_encoder.cc index 7cd522d46be..57aec834863 100644 --- a/deps/grpc/src/core/ext/transport/chttp2/transport/hpack_encoder.cc +++ b/deps/grpc/src/core/ext/transport/chttp2/transport/hpack_encoder.cc @@ -25,7 +25,6 @@ #include #include -#include "absl/log/log.h" #include "src/core/ext/transport/chttp2/transport/bin_encoder.h" #include "src/core/ext/transport/chttp2/transport/hpack_constants.h" #include "src/core/ext/transport/chttp2/transport/hpack_encoder_table.h" @@ -36,6 +35,7 @@ #include "src/core/lib/transport/timeout_encoding.h" #include "src/core/util/crash.h" #include "src/core/util/grpc_check.h" +#include "absl/log/log.h" namespace grpc_core { diff --git a/deps/grpc/src/core/ext/transport/chttp2/transport/hpack_encoder.h b/deps/grpc/src/core/ext/transport/chttp2/transport/hpack_encoder.h index d2f4fdda290..a31ead5de7b 100644 --- a/deps/grpc/src/core/ext/transport/chttp2/transport/hpack_encoder.h +++ b/deps/grpc/src/core/ext/transport/chttp2/transport/hpack_encoder.h @@ -27,10 +27,6 @@ #include #include -#include "absl/log/log.h" -#include "absl/strings/match.h" -#include "absl/strings/str_cat.h" -#include "absl/strings/string_view.h" #include "src/core/call/metadata_batch.h" #include "src/core/call/metadata_compression_traits.h" #include "src/core/ext/transport/chttp2/transport/hpack_constants.h" @@ -42,6 +38,10 @@ #include "src/core/lib/transport/transport.h" #include "src/core/telemetry/call_tracer.h" #include "src/core/util/time.h" +#include "absl/log/log.h" +#include "absl/strings/match.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/string_view.h" namespace grpc_core { diff --git a/deps/grpc/src/core/ext/transport/chttp2/transport/hpack_parse_result.cc b/deps/grpc/src/core/ext/transport/chttp2/transport/hpack_parse_result.cc index c6430f1f88b..50a09662ede 100644 --- a/deps/grpc/src/core/ext/transport/chttp2/transport/hpack_parse_result.cc +++ b/deps/grpc/src/core/ext/transport/chttp2/transport/hpack_parse_result.cc @@ -17,12 +17,12 @@ #include #include -#include "absl/strings/str_format.h" #include "src/core/ext/transport/chttp2/transport/hpack_constants.h" #include "src/core/lib/iomgr/error.h" #include "src/core/lib/slice/slice.h" #include "src/core/util/grpc_check.h" #include "src/core/util/status_helper.h" +#include "absl/strings/str_format.h" namespace grpc_core { diff --git a/deps/grpc/src/core/ext/transport/chttp2/transport/hpack_parse_result.h b/deps/grpc/src/core/ext/transport/chttp2/transport/hpack_parse_result.h index 7d3ee783727..71c9c548bd4 100644 --- a/deps/grpc/src/core/ext/transport/chttp2/transport/hpack_parse_result.h +++ b/deps/grpc/src/core/ext/transport/chttp2/transport/hpack_parse_result.h @@ -23,15 +23,15 @@ #include #include -#include "absl/status/status.h" -#include "absl/strings/str_cat.h" -#include "absl/strings/string_view.h" #include "src/core/call/metadata_batch.h" #include "src/core/lib/surface/validate_metadata.h" #include "src/core/util/crash.h" #include "src/core/util/grpc_check.h" #include "src/core/util/ref_counted.h" #include "src/core/util/ref_counted_ptr.h" +#include "absl/status/status.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/string_view.h" namespace grpc_core { diff --git a/deps/grpc/src/core/ext/transport/chttp2/transport/hpack_parser.cc b/deps/grpc/src/core/ext/transport/chttp2/transport/hpack_parser.cc index f0fa00ab8b4..e12ff5c0d4f 100644 --- a/deps/grpc/src/core/ext/transport/chttp2/transport/hpack_parser.cc +++ b/deps/grpc/src/core/ext/transport/chttp2/transport/hpack_parser.cc @@ -30,13 +30,6 @@ #include #include -#include "absl/base/attributes.h" -#include "absl/log/log.h" -#include "absl/status/status.h" -#include "absl/strings/match.h" -#include "absl/strings/str_cat.h" -#include "absl/strings/string_view.h" -#include "absl/types/span.h" #include "src/core/call/metadata_info.h" #include "src/core/call/parsed_metadata.h" #include "src/core/ext/transport/chttp2/transport/decode_huff.h" @@ -52,6 +45,13 @@ #include "src/core/telemetry/stats_data.h" #include "src/core/util/grpc_check.h" #include "src/core/util/match.h" +#include "absl/base/attributes.h" +#include "absl/log/log.h" +#include "absl/status/status.h" +#include "absl/strings/match.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/string_view.h" +#include "absl/types/span.h" // IWYU pragma: no_include diff --git a/deps/grpc/src/core/ext/transport/chttp2/transport/hpack_parser.h b/deps/grpc/src/core/ext/transport/chttp2/transport/hpack_parser.h index b7d9aea30b1..edb5bbfb3fb 100644 --- a/deps/grpc/src/core/ext/transport/chttp2/transport/hpack_parser.h +++ b/deps/grpc/src/core/ext/transport/chttp2/transport/hpack_parser.h @@ -30,10 +30,6 @@ #include #include -#include "absl/random/bit_gen_ref.h" -#include "absl/strings/str_cat.h" -#include "absl/strings/string_view.h" -#include "absl/types/span.h" #include "src/core/call/metadata_batch.h" #include "src/core/ext/transport/chttp2/transport/hpack_parse_result.h" #include "src/core/ext/transport/chttp2/transport/hpack_parser_table.h" @@ -43,6 +39,10 @@ #include "src/core/lib/slice/slice_refcount.h" #include "src/core/telemetry/call_tracer.h" #include "src/core/util/random_early_detection.h" +#include "absl/random/bit_gen_ref.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/string_view.h" +#include "absl/types/span.h" // IWYU pragma: no_include diff --git a/deps/grpc/src/core/ext/transport/chttp2/transport/hpack_parser_table.cc b/deps/grpc/src/core/ext/transport/chttp2/transport/hpack_parser_table.cc index 04ffdfc4d9a..413f16b0cf1 100644 --- a/deps/grpc/src/core/ext/transport/chttp2/transport/hpack_parser_table.cc +++ b/deps/grpc/src/core/ext/transport/chttp2/transport/hpack_parser_table.cc @@ -26,10 +26,6 @@ #include #include -#include "absl/log/log.h" -#include "absl/status/status.h" -#include "absl/strings/str_cat.h" -#include "absl/strings/string_view.h" #include "src/core/ext/transport/chttp2/transport/hpack_constants.h" #include "src/core/ext/transport/chttp2/transport/hpack_parse_result.h" #include "src/core/ext/transport/chttp2/transport/http2_stats_collector.h" @@ -37,6 +33,10 @@ #include "src/core/lib/slice/slice.h" #include "src/core/telemetry/stats.h" #include "src/core/util/grpc_check.h" +#include "absl/log/log.h" +#include "absl/status/status.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/string_view.h" namespace grpc_core { diff --git a/deps/grpc/src/core/ext/transport/chttp2/transport/hpack_parser_table.h b/deps/grpc/src/core/ext/transport/chttp2/transport/hpack_parser_table.h index 96a1514674a..d88b04dd1bd 100644 --- a/deps/grpc/src/core/ext/transport/chttp2/transport/hpack_parser_table.h +++ b/deps/grpc/src/core/ext/transport/chttp2/transport/hpack_parser_table.h @@ -28,7 +28,6 @@ #include #include -#include "absl/functional/function_ref.h" #include "src/core/call/metadata_batch.h" #include "src/core/call/parsed_metadata.h" #include "src/core/ext/transport/chttp2/transport/hpack_constants.h" @@ -36,6 +35,7 @@ #include "src/core/ext/transport/chttp2/transport/http2_stats_collector.h" #include "src/core/util/no_destruct.h" #include "src/core/util/unique_ptr_with_bitset.h" +#include "absl/functional/function_ref.h" namespace grpc_core { diff --git a/deps/grpc/src/core/ext/transport/chttp2/transport/http2_client_transport.cc b/deps/grpc/src/core/ext/transport/chttp2/transport/http2_client_transport.cc index 2fd4f9816ee..e3bf2a55317 100644 --- a/deps/grpc/src/core/ext/transport/chttp2/transport/http2_client_transport.cc +++ b/deps/grpc/src/core/ext/transport/chttp2/transport/http2_client_transport.cc @@ -19,56 +19,95 @@ #include "src/core/ext/transport/chttp2/transport/http2_client_transport.h" #include +#include #include +#include +#include +#include #include +#include #include #include +#include #include +#include -#include "absl/log/log.h" -#include "absl/status/status.h" -#include "absl/strings/string_view.h" #include "src/core/call/call_spine.h" #include "src/core/call/message.h" +#include "src/core/call/metadata.h" #include "src/core/call/metadata_batch.h" +#include "src/core/call/metadata_info.h" +#include "src/core/channelz/channelz.h" #include "src/core/ext/transport/chttp2/transport/flow_control.h" #include "src/core/ext/transport/chttp2/transport/flow_control_manager.h" #include "src/core/ext/transport/chttp2/transport/frame.h" +#include "src/core/ext/transport/chttp2/transport/goaway.h" #include "src/core/ext/transport/chttp2/transport/header_assembler.h" #include "src/core/ext/transport/chttp2/transport/http2_settings.h" -#include "src/core/ext/transport/chttp2/transport/http2_settings_manager.h" +#include "src/core/ext/transport/chttp2/transport/http2_settings_promises.h" #include "src/core/ext/transport/chttp2/transport/http2_status.h" +#include "src/core/ext/transport/chttp2/transport/http2_transport.h" #include "src/core/ext/transport/chttp2/transport/http2_ztrace_collector.h" -#include "src/core/ext/transport/chttp2/transport/internal_channel_arg_names.h" +#include "src/core/ext/transport/chttp2/transport/incoming_metadata_tracker.h" +#include "src/core/ext/transport/chttp2/transport/keepalive.h" #include "src/core/ext/transport/chttp2/transport/message_assembler.h" +#include "src/core/ext/transport/chttp2/transport/ping_promise.h" +#include "src/core/ext/transport/chttp2/transport/stream.h" #include "src/core/ext/transport/chttp2/transport/stream_data_queue.h" #include "src/core/ext/transport/chttp2/transport/transport_common.h" #include "src/core/lib/channel/channel_args.h" -#include "src/core/lib/debug/trace.h" +#include "src/core/lib/iomgr/exec_ctx.h" +#include "src/core/lib/promise/activity.h" +#include "src/core/lib/promise/context.h" #include "src/core/lib/promise/for_each.h" +#include "src/core/lib/promise/if.h" #include "src/core/lib/promise/loop.h" #include "src/core/lib/promise/map.h" #include "src/core/lib/promise/match_promise.h" #include "src/core/lib/promise/party.h" #include "src/core/lib/promise/poll.h" #include "src/core/lib/promise/promise.h" +#include "src/core/lib/promise/race.h" +#include "src/core/lib/promise/sleep.h" #include "src/core/lib/promise/try_seq.h" #include "src/core/lib/resource_quota/arena.h" #include "src/core/lib/resource_quota/resource_quota.h" #include "src/core/lib/slice/slice.h" #include "src/core/lib/slice/slice_buffer.h" +#include "src/core/lib/transport/connectivity_state.h" #include "src/core/lib/transport/promise_endpoint.h" #include "src/core/lib/transport/transport.h" +#include "src/core/util/debug_location.h" #include "src/core/util/grpc_check.h" +#include "src/core/util/latent_see.h" +#include "src/core/util/orphanable.h" #include "src/core/util/ref_counted_ptr.h" #include "src/core/util/sync.h" +#include "src/core/util/time.h" +#include "absl/base/thread_annotations.h" +#include "absl/container/flat_hash_map.h" +#include "absl/log/log.h" +#include "absl/status/status.h" +#include "absl/strings/cord.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/string_view.h" +#include "absl/types/span.h" namespace grpc_core { namespace http2 { +// TODO(akshitpatel)(tjagtap) [PH2][P2] : When settings frame increases incoming +// window size, our transport must make the streams that were blocked on stream +// flow control as writeable. + +// As a gRPC server never initiates a stream, the last incoming stream id on +// the client side will always be 0. +constexpr uint32_t kLastIncomingStreamIdClient = 0; + using grpc_event_engine::experimental::EventEngine; -using EnqueueResult = StreamDataQueue::EnqueueResult; +using StreamWritabilityUpdate = + StreamDataQueue::StreamWritabilityUpdate; // Experimental : This is just the initial skeleton of class // and it is functions. The code will be written iteratively. @@ -77,6 +116,32 @@ using EnqueueResult = StreamDataQueue::EnqueueResult; // TODO(tjagtap) : [PH2][P3] : Delete this comment when http2 // rollout begins +template +void Http2ClientTransport::SpawnInfallible(RefCountedPtr party, + absl::string_view name, + Factory&& factory) { + party->Spawn(name, std::forward(factory), [](Empty) {}); +} + +template +void Http2ClientTransport::SpawnInfallibleTransportParty(absl::string_view name, + Factory&& factory) { + SpawnInfallible(general_party_, name, std::forward(factory)); +} + +template +void Http2ClientTransport::SpawnGuardedTransportParty(absl::string_view name, + Factory&& factory) { + general_party_->Spawn( + name, std::forward(factory), + [self = RefAsSubclass()](absl::Status status) { + if (!status.ok()) { + GRPC_UNUSED absl::Status error = self->HandleError( + /*stream_id=*/std::nullopt, ToHttpOkOrConnError(status)); + } + }); +} + void Http2ClientTransport::PerformOp(grpc_transport_op* op) { // Notes : Refer : src/core/ext/transport/chaotic_good/client_transport.cc // Functions : StartConnectivityWatch, StopConnectivityWatch, PerformOp @@ -118,90 +183,145 @@ void Http2ClientTransport::StopConnectivityWatch( state_tracker_.RemoveWatcher(watcher); } +void Http2ClientTransport::ReportDisconnection( + const absl::Status& status, StateWatcher::DisconnectInfo disconnect_info, + const char* reason) { + MutexLock lock(&transport_mutex_); + ReportDisconnectionLocked(status, disconnect_info, reason); +} + +void Http2ClientTransport::ReportDisconnectionLocked( + const absl::Status& status, StateWatcher::DisconnectInfo disconnect_info, + const char* reason) { + GRPC_HTTP2_CLIENT_DLOG << "Http2ClientTransport ReportDisconnection: status=" + << status.ToString() << "; reason=" << reason; + state_tracker_.SetState(GRPC_CHANNEL_TRANSIENT_FAILURE, status, reason); + NotifyStateWatcherOnDisconnectLocked(status, disconnect_info); +} + +void Http2ClientTransport::StartWatch(RefCountedPtr watcher) { + MutexLock lock(&transport_mutex_); + GRPC_CHECK(watcher_ == nullptr); + watcher_ = std::move(watcher); + if (is_transport_closed_) { + // TODO(tjagtap) : [PH2][P2] : Provide better status message and + // disconnect info here. + NotifyStateWatcherOnDisconnectLocked( + absl::UnknownError("transport closed before watcher started"), {}); + } else { + // TODO(tjagtap) : [PH2][P2] : Notify the state watcher of the current + // value of the peer's MAX_CONCURRENT_STREAMS setting. + } +} + +void Http2ClientTransport::StopWatch(RefCountedPtr watcher) { + MutexLock lock(&transport_mutex_); + if (watcher_ == watcher) watcher_.reset(); +} + +void Http2ClientTransport::NotifyStateWatcherOnDisconnectLocked( + absl::Status status, StateWatcher::DisconnectInfo disconnect_info) { + if (watcher_ == nullptr) return; + event_engine_->Run([watcher = std::move(watcher_), status = std::move(status), + disconnect_info]() mutable { + ExecCtx exec_ctx; + watcher->OnDisconnect(std::move(status), disconnect_info); + watcher.reset(); // Before ExecCtx goes out of scope. + }); +} + void Http2ClientTransport::Orphan() { GRPC_HTTP2_CLIENT_DLOG << "Http2ClientTransport Orphan Begin"; // Accessing general_party here is not advisable. It may so happen that // the party is already freed/may free up any time. The only guarantee here // is that the transport is still valid. - MaybeSpawnCloseTransport(Http2Status::AbslConnectionError( - absl::StatusCode::kUnavailable, "Orphaned")); + SourceDestructing(); + MaybeSpawnCloseTransport( + ToHttpOkOrConnError(absl::UnavailableError("Orphaned"))); Unref(); GRPC_HTTP2_CLIENT_DLOG << "Http2ClientTransport Orphan End"; } -void Http2ClientTransport::AbortWithError() { - GRPC_HTTP2_CLIENT_DLOG << "Http2ClientTransport AbortWithError Begin"; - // TODO(tjagtap) : [PH2][P2] : Implement this function. - GRPC_HTTP2_CLIENT_DLOG << "Http2ClientTransport AbortWithError End"; -} - /////////////////////////////////////////////////////////////////////////////// // Processing each type of frame Http2Status Http2ClientTransport::ProcessHttp2DataFrame(Http2DataFrame frame) { // https://www.rfc-editor.org/rfc/rfc9113.html#name-data - GRPC_HTTP2_CLIENT_DLOG << "Http2Transport ProcessHttp2DataFrame { stream_id=" - << frame.stream_id - << ", end_stream=" << frame.end_stream - << ", payload=" << frame.payload.JoinIntoString() - << "}"; + GRPC_HTTP2_CLIENT_DLOG + << "Http2ClientTransport ProcessHttp2DataFrame { stream_id=" + << frame.stream_id << ", end_stream=" << frame.end_stream + << ", payload=" << MaybeTruncatePayload(frame.payload) + << ", payload length=" << frame.payload.Length() << "}"; // TODO(akshitpatel) : [PH2][P3] : Investigate if we should do this even if // the function returns a non-ok status? - ping_manager_.ReceivedDataFrame(); + ping_manager_->ReceivedDataFrame(); // Lookup stream - GRPC_HTTP2_CLIENT_DLOG << "Http2Transport ProcessHttp2DataFrame LookupStream"; + GRPC_HTTP2_CLIENT_DLOG + << "Http2ClientTransport ProcessHttp2DataFrame LookupStream"; RefCountedPtr stream = LookupStream(frame.stream_id); + + ValueOrHttp2Status flow_control_action = + ProcessIncomingDataFrameFlowControl(current_frame_header_, flow_control_, + stream); + if (!flow_control_action.IsOk()) { + return ValueOrHttp2Status::TakeStatus( + std::move(flow_control_action)); + } + ActOnFlowControlAction(flow_control_action.value(), stream); + if (stream == nullptr) { // TODO(tjagtap) : [PH2][P2] : Implement the correct behaviour later. // RFC9113 : If a DATA frame is received whose stream is not in the "open" // or "half-closed (local)" state, the recipient MUST respond with a stream // error (Section 5.4.2) of type STREAM_CLOSED. GRPC_HTTP2_CLIENT_DLOG - << "Http2Transport ProcessHttp2DataFrame { stream_id=" + << "Http2ClientTransport ProcessHttp2DataFrame { stream_id=" << frame.stream_id << "} Lookup Failed"; return Http2Status::Ok(); } - if (stream->GetStreamState() == HttpStreamState::kHalfClosedRemote) { - return Http2Status::Http2StreamError( - Http2ErrorCode::kStreamClosed, - std::string(RFC9113::kHalfClosedRemoteState)); + // TODO(akshitpatel) : [PH2][P3] : We should add a check to reset stream if + // the stream state is kIdle as well. + + Http2Status stream_status = stream->CanStreamReceiveDataFrames(); + if (!stream_status.IsOk()) { + return stream_status; } // Add frame to assembler GRPC_HTTP2_CLIENT_DLOG - << "Http2Transport ProcessHttp2DataFrame AppendNewDataFrame"; + << "Http2ClientTransport ProcessHttp2DataFrame AppendNewDataFrame"; GrpcMessageAssembler& assembler = stream->assembler; Http2Status status = assembler.AppendNewDataFrame(frame.payload, frame.end_stream); if (!status.IsOk()) { - GRPC_HTTP2_CLIENT_DLOG - << "Http2Transport ProcessHttp2DataFrame AppendNewDataFrame Failed"; + GRPC_HTTP2_CLIENT_DLOG << "Http2ClientTransport ProcessHttp2DataFrame " + "AppendNewDataFrame Failed"; return status; } // Pass the messages up the stack if it is ready. while (true) { GRPC_HTTP2_CLIENT_DLOG - << "Http2Transport ProcessHttp2DataFrame ExtractMessage"; + << "Http2ClientTransport ProcessHttp2DataFrame ExtractMessage"; ValueOrHttp2Status result = assembler.ExtractMessage(); if (!result.IsOk()) { GRPC_HTTP2_CLIENT_DLOG - << "Http2Transport ProcessHttp2DataFrame ExtractMessage Failed"; + << "Http2ClientTransport ProcessHttp2DataFrame ExtractMessage Failed"; return ValueOrHttp2Status::TakeStatus(std::move(result)); } MessageHandle message = TakeValue(std::move(result)); if (message != nullptr) { GRPC_HTTP2_CLIENT_DLOG - << "Http2Transport ProcessHttp2DataFrame SpawnPushMessage " + << "Http2ClientTransport ProcessHttp2DataFrame SpawnPushMessage " << message->DebugString(); stream->call.SpawnPushMessage(std::move(message)); continue; } GRPC_HTTP2_CLIENT_DLOG - << "Http2Transport ProcessHttp2DataFrame While Break"; + << "Http2ClientTransport ProcessHttp2DataFrame While Break"; break; } @@ -221,11 +341,14 @@ Http2Status Http2ClientTransport::ProcessHttp2HeaderFrame( Http2HeaderFrame frame) { // https://www.rfc-editor.org/rfc/rfc9113.html#name-headers GRPC_HTTP2_CLIENT_DLOG - << "Http2Transport ProcessHttp2HeaderFrame Promise { stream_id=" + << "Http2ClientTransport ProcessHttp2HeaderFrame Promise { stream_id=" << frame.stream_id << ", end_headers=" << frame.end_headers << ", end_stream=" << frame.end_stream - << ", payload=" << frame.payload.JoinIntoString() << " }"; - ping_manager_.ReceivedDataFrame(); + << ", payload=" << MaybeTruncatePayload(frame.payload) << " }"; + // State update MUST happen before processing the frame. + incoming_headers_.OnHeaderReceived(frame); + + ping_manager_->ReceivedDataFrame(); RefCountedPtr stream = LookupStream(frame.stream_id); if (stream == nullptr) { @@ -237,71 +360,82 @@ Http2Status Http2ClientTransport::ProcessHttp2HeaderFrame( // receives an unexpected stream identifier MUST respond with a connection // error (Section 5.4.1) of type PROTOCOL_ERROR. GRPC_HTTP2_CLIENT_DLOG - << "Http2Transport ProcessHttp2HeaderFrame Promise { stream_id=" + << "Http2ClientTransport ProcessHttp2HeaderFrame Promise { stream_id=" << frame.stream_id << "} Lookup Failed"; - return Http2Status::Ok(); + return ParseAndDiscardHeaders(std::move(frame.payload), frame.end_headers, + /*stream=*/nullptr, Http2Status::Ok()); } - if (stream->GetStreamState() == HttpStreamState::kHalfClosedRemote) { - return Http2Status::Http2StreamError( - Http2ErrorCode::kStreamClosed, - std::string(RFC9113::kHalfClosedRemoteState)); + + if (stream->IsStreamHalfClosedRemote()) { + return ParseAndDiscardHeaders( + std::move(frame.payload), frame.end_headers, stream, + Http2Status::Http2StreamError( + Http2ErrorCode::kStreamClosed, + std::string(RFC9113::kHalfClosedRemoteState))); } - incoming_header_in_progress_ = !frame.end_headers; - incoming_header_stream_id_ = frame.stream_id; - incoming_header_end_stream_ = frame.end_stream; - if ((incoming_header_end_stream_ && stream->did_push_trailing_metadata) || - (!incoming_header_end_stream_ && stream->did_push_initial_metadata)) { - return Http2Status::Http2StreamError( - Http2ErrorCode::kInternalError, - "gRPC Error : A gRPC server can send upto 1 initial metadata followed " - "by upto 1 trailing metadata"); + if (incoming_headers_.ClientReceivedDuplicateMetadata( + stream->did_receive_initial_metadata, + stream->did_receive_trailing_metadata)) { + return ParseAndDiscardHeaders( + std::move(frame.payload), frame.end_headers, stream, + Http2Status::Http2StreamError( + Http2ErrorCode::kInternalError, + std::string(GrpcErrors::kTooManyMetadata))); } - HeaderAssembler& assembler = stream->header_assembler; - Http2Status append_result = assembler.AppendHeaderFrame(std::move(frame)); - if (append_result.IsOk()) { - return ProcessMetadata(stream); + Http2Status append_result = stream->header_assembler.AppendHeaderFrame(frame); + if (!append_result.IsOk()) { + // Frame payload is not consumed if AppendHeaderFrame returns a non-OK + // status. We need to process it to keep our in consistent state. + return ParseAndDiscardHeaders(std::move(frame.payload), frame.end_headers, + stream, std::move(append_result)); } - return append_result; + + Http2Status status = ProcessMetadata(stream); + if (!status.IsOk()) { + // Frame payload has been moved to the HeaderAssembler. So calling + // ParseAndDiscardHeaders with an empty buffer. + return ParseAndDiscardHeaders(SliceBuffer(), frame.end_headers, stream, + std::move(status)); + } + + // Frame payload has either been processed or moved to the HeaderAssembler. + return Http2Status::Ok(); } Http2Status Http2ClientTransport::ProcessMetadata( RefCountedPtr stream) { - const uint32_t stream_id = stream->GetStreamId(); HeaderAssembler& assembler = stream->header_assembler; CallHandler call = stream->call; - GRPC_HTTP2_CLIENT_DLOG << "Http2Transport ProcessMetadata"; + GRPC_HTTP2_CLIENT_DLOG << "Http2ClientTransport ProcessMetadata"; if (assembler.IsReady()) { ValueOrHttp2Status read_result = - assembler.ReadMetadata(parser_, !incoming_header_end_stream_, + assembler.ReadMetadata(parser_, !incoming_headers_.HeaderHasEndStream(), /*is_client=*/true, /*max_header_list_size_soft_limit=*/ - max_header_list_size_soft_limit_, + incoming_headers_.soft_limit(), /*max_header_list_size_hard_limit=*/ - settings_.acked().max_header_list_size()); + settings_->acked().max_header_list_size()); if (read_result.IsOk()) { ServerMetadataHandle metadata = TakeValue(std::move(read_result)); - if (incoming_header_end_stream_) { + if (incoming_headers_.HeaderHasEndStream()) { // TODO(tjagtap) : [PH2][P1] : Is this the right way to differentiate // between initial and trailing metadata? - GRPC_HTTP2_CLIENT_DLOG - << "Http2Transport ProcessMetadata SpawnPushServerTrailingMetadata"; stream->MarkHalfClosedRemote(); - BeginCloseStream( - stream_id, - Http2ErrorCodeToRstFrameErrorCode(Http2ErrorCode::kNoError), - std::move(metadata)); + stream->did_receive_trailing_metadata = true; + BeginCloseStream(stream, /*reset_stream_error_code=*/std::nullopt, + std::move(metadata)); } else { - GRPC_HTTP2_CLIENT_DLOG - << "Http2Transport ProcessMetadata SpawnPushServerInitialMetadata"; - stream->did_push_initial_metadata = true; + GRPC_HTTP2_CLIENT_DLOG << "Http2ClientTransport ProcessMetadata " + "SpawnPushServerInitialMetadata"; + stream->did_receive_initial_metadata = true; call.SpawnPushServerInitialMetadata(std::move(metadata)); } return Http2Status::Ok(); } - GRPC_HTTP2_CLIENT_DLOG << "Http2Transport ProcessMetadata Failed"; + GRPC_HTTP2_CLIENT_DLOG << "Http2ClientTransport ProcessMetadata Failed"; return ValueOrHttp2Status>::TakeStatus( std::move(read_result)); } @@ -312,14 +446,18 @@ Http2Status Http2ClientTransport::ProcessHttp2RstStreamFrame( Http2RstStreamFrame frame) { // https://www.rfc-editor.org/rfc/rfc9113.html#name-rst_stream GRPC_HTTP2_CLIENT_DLOG - << "Http2Transport ProcessHttp2RstStreamFrame { stream_id=" + << "Http2ClientTransport ProcessHttp2RstStreamFrame { stream_id=" << frame.stream_id << ", error_code=" << frame.error_code << " }"; - Http2ErrorCode error_code = - RstFrameErrorCodeToHttp2ErrorCode(frame.error_code); + + Http2ErrorCode error_code = FrameErrorCodeToHttp2ErrorCode(frame.error_code); absl::Status status = absl::Status(ErrorCodeToAbslStatusCode(error_code), "Reset stream frame received."); - BeginCloseStream(frame.stream_id, /*reset_stream_error_code=*/std::nullopt, - CancelledServerMetadataFromStatus(status)); + RefCountedPtr stream = LookupStream(frame.stream_id); + if (stream != nullptr) { + stream->MarkHalfClosedRemote(); + BeginCloseStream(stream, /*reset_stream_error_code=*/std::nullopt, + CancelledServerMetadataFromStatus(status)); + } // In case of stream error, we do not want the Read Loop to be broken. Hence // returning an ok status. @@ -330,33 +468,28 @@ Http2Status Http2ClientTransport::ProcessHttp2SettingsFrame( Http2SettingsFrame frame) { // https://www.rfc-editor.org/rfc/rfc9113.html#name-settings - GRPC_HTTP2_CLIENT_DLOG << "Http2Transport ProcessHttp2SettingsFrame { ack=" - << frame.ack - << ", settings length=" << frame.settings.size() - << "}"; - - // The connector code needs us to run this - if (on_receive_settings_ != nullptr) { - ExecCtx::Run(DEBUG_LOCATION, on_receive_settings_, absl::OkStatus()); - on_receive_settings_ = nullptr; - } + GRPC_HTTP2_CLIENT_DLOG + << "Http2ClientTransport ProcessHttp2SettingsFrame { ack=" << frame.ack + << ", settings length=" << frame.settings.size() << "}"; - // TODO(tjagtap) : [PH2][P2] Decide later if we want this only for AckLastSend - // or does any other operation also need this lock. - MutexLock lock(&transport_mutex_); if (!frame.ack) { - // Check if the received settings have legal values Http2Status status = ValidateSettingsValues(frame.settings); if (!status.IsOk()) { return status; } - // TODO(tjagtap) : [PH2][P1] - // Apply the new settings - // Quickly send the ACK to the peer once the settings are applied + settings_->BufferPeerSettings(std::move(frame.settings)); + SpawnGuardedTransportParty("SettingsAck", TriggerWriteCycle()); + if (GPR_UNLIKELY(!settings_->IsFirstPeerSettingsApplied())) { + // Apply the first settings before we read any other frames. + reader_state_.SetPauseReadLoop(); + } } else { - // Process the SETTINGS ACK Frame - if (settings_.AckLastSend()) { - transport_settings_.OnSettingsAckReceived(); + if (settings_->OnSettingsAckReceived()) { + parser_.hpack_table()->SetMaxBytes( + settings_->acked().header_table_size()); + ActOnFlowControlAction(flow_control_.SetAckedInitialWindow( + settings_->acked().initial_window_size()), + /*stream=*/nullptr); } else { // TODO(tjagtap) [PH2][P4] : The RFC does not say anything about what // should happen if we receive an unsolicited SETTINGS ACK. Decide if we @@ -370,7 +503,7 @@ Http2Status Http2ClientTransport::ProcessHttp2SettingsFrame( auto Http2ClientTransport::ProcessHttp2PingFrame(Http2PingFrame frame) { // https://www.rfc-editor.org/rfc/rfc9113.html#name-ping - GRPC_HTTP2_CLIENT_DLOG << "Http2Transport ProcessHttp2PingFrame { ack=" + GRPC_HTTP2_CLIENT_DLOG << "Http2ClientTransport ProcessHttp2PingFrame { ack=" << frame.ack << ", opaque=" << frame.opaque << " }"; return AssertResultType(If( frame.ack, @@ -379,37 +512,114 @@ auto Http2ClientTransport::ProcessHttp2PingFrame(Http2PingFrame frame) { return self->AckPing(opaque); }, [self = RefAsSubclass(), opaque = frame.opaque]() { - // TODO(akshitpatel) : [PH2][P2] : Have a counter to track number of - // pending induced frames (Ping/Settings Ack). This is to ensure that - // if write is taking a long time, we can stop reads and prioritize - // writes. - // RFC9113: PING responses SHOULD be given higher priority than any - // other frame. - self->ping_manager_.AddPendingPingAck(opaque); - // TODO(akshitpatel) : [PH2][P2] : This is done assuming that the other - // ProcessFrame promises may return stream or connection failures. If - // this does not turn out to be true, consider returning absl::Status - // here. - return Map(self->TriggerWriteCycle(), [](absl::Status status) { - return (status.ok()) - ? Http2Status::Ok() - : Http2Status::AbslConnectionError( - status.code(), std::string(status.message())); - }); + return If( + self->test_only_ack_pings_, + [self, opaque]() { + // TODO(akshitpatel) : [PH2][P2] : Have a counter to track number + // of pending induced frames (Ping/Settings Ack). This is to + // ensure that if write is taking a long time, we can stop reads + // and prioritize writes. RFC9113: PING responses SHOULD be given + // higher priority than any other frame. + self->ping_manager_->AddPendingPingAck(opaque); + // TODO(akshitpatel) : [PH2][P2] : This is done assuming that the + // other ProcessFrame promises may return stream or connection + // failures. If this does not turn out to be true, consider + // returning absl::Status here. + return Map(self->TriggerWriteCycle(), [](absl::Status status) { + return ToHttpOkOrConnError(status); + }); + }, + []() { + GRPC_HTTP2_CLIENT_DLOG + << "Http2ClientTransport ProcessHttp2PingFrame " + "test_only_ack_pings_ is false. Ignoring the ping " + "request."; + return Immediate(Http2Status::Ok()); + }); })); } Http2Status Http2ClientTransport::ProcessHttp2GoawayFrame( Http2GoawayFrame frame) { // https://www.rfc-editor.org/rfc/rfc9113.html#name-goaway - GRPC_HTTP2_CLIENT_DLOG << "Http2Transport ProcessHttp2GoawayFrame Factory"; - // TODO(tjagtap) : [PH2][P2] : Implement this. - GRPC_HTTP2_CLIENT_DLOG << "Http2Transport ProcessHttp2GoawayFrame Promise { " - "last_stream_id=" - << frame.last_stream_id - << ", error_code=" << frame.error_code - << ", debug_data=" << frame.debug_data.as_string_view() - << "}"; + GRPC_HTTP2_CLIENT_DLOG + << "Http2ClientTransport ProcessHttp2GoawayFrame Promise { " + "last_stream_id=" + << frame.last_stream_id << ", error_code=" << frame.error_code + << ", debug_data=" << frame.debug_data.as_string_view() << "}"; + LOG_IF(ERROR, + frame.error_code != static_cast(Http2ErrorCode::kNoError)) + << "Received GOAWAY frame with error code: " << frame.error_code + << " and debug data: " << frame.debug_data.as_string_view(); + + uint32_t last_stream_id = 0; + absl::Status status(ErrorCodeToAbslStatusCode( + FrameErrorCodeToHttp2ErrorCode(frame.error_code)), + frame.debug_data.as_string_view()); + if (frame.error_code == static_cast(Http2ErrorCode::kNoError) && + frame.last_stream_id == RFC9113::kMaxStreamId31Bit) { + const uint32_t next_stream_id = PeekNextStreamId(); + last_stream_id = (next_stream_id > 1) ? next_stream_id - 2 : 0; + } else { + last_stream_id = frame.last_stream_id; + } + SetMaxAllowedStreamId(last_stream_id); + + bool close_transport = false; + { + MutexLock lock(&transport_mutex_); + if (CanCloseTransportLocked()) { + close_transport = true; + GRPC_HTTP2_CLIENT_DLOG << "Http2ClientTransport ProcessHttp2GoawayFrame " + "stream_list_ is empty"; + } + } + + StateWatcher::DisconnectInfo disconnect_info; + disconnect_info.reason = Transport::StateWatcher::kGoaway; + disconnect_info.http2_error_code = + static_cast(frame.error_code); + + // Throttle keepalive time if the server sends a GOAWAY with error code + // ENHANCE_YOUR_CALM and debug data equal to "too_many_pings". This will + // apply to any new transport created on by any subchannel of this channel. + if (GPR_UNLIKELY(frame.error_code == static_cast( + Http2ErrorCode::kEnhanceYourCalm) && + frame.debug_data == "too_many_pings")) { + LOG(ERROR) << ": Received a GOAWAY with error code ENHANCE_YOUR_CALM and " + "debug data equal to \"too_many_pings\". Current keepalive " + "time (before throttling): " + << keepalive_time_.ToString(); + constexpr int max_keepalive_time_millis = + INT_MAX / KEEPALIVE_TIME_BACKOFF_MULTIPLIER; + uint64_t throttled_keepalive_time = + keepalive_time_.millis() > max_keepalive_time_millis + ? INT_MAX + : keepalive_time_.millis() * KEEPALIVE_TIME_BACKOFF_MULTIPLIER; + if (!IsTransportStateWatcherEnabled()) { + status.SetPayload(kKeepaliveThrottlingKey, + absl::Cord(std::to_string(throttled_keepalive_time))); + } + disconnect_info.keepalive_time = + Duration::Milliseconds(throttled_keepalive_time); + } + + if (close_transport) { + // TODO(akshitpatel) : [PH2][P3] : Ideally the error here should be + // kNoError. However, Http2Status does not support kNoError. We should + // revisit this and update the error code. + MaybeSpawnCloseTransport(Http2Status::Http2ConnectionError( + FrameErrorCodeToHttp2ErrorCode(( + frame.error_code == + Http2ErrorCodeToFrameErrorCode(Http2ErrorCode::kNoError) + ? Http2ErrorCodeToFrameErrorCode(Http2ErrorCode::kInternalError) + : frame.error_code)), + std::string(frame.debug_data.as_string_view()))); + } + + // lie: use transient failure from the transport to indicate goaway has been + // received. + ReportDisconnection(status, disconnect_info, "got_goaway"); return Http2Status::Ok(); } @@ -417,23 +627,30 @@ Http2Status Http2ClientTransport::ProcessHttp2WindowUpdateFrame( Http2WindowUpdateFrame frame) { // https://www.rfc-editor.org/rfc/rfc9113.html#name-window_update GRPC_HTTP2_CLIENT_DLOG - << "Http2Transport ProcessHttp2WindowUpdateFrame Factory"; - // TODO(tjagtap) : [PH2][P2] : Implement this. - GRPC_HTTP2_CLIENT_DLOG - << "Http2Transport ProcessHttp2WindowUpdateFrame Promise { " + << "Http2ClientTransport ProcessHttp2WindowUpdateFrame Promise { " " stream_id=" << frame.stream_id << ", increment=" << frame.increment << "}"; + + RefCountedPtr stream = nullptr; if (frame.stream_id != 0) { - RefCountedPtr stream = LookupStream(frame.stream_id); - if (stream != nullptr) { - chttp2::StreamFlowControl::OutgoingUpdateContext fc_update( - &stream->flow_control); - fc_update.RecvUpdate(frame.increment); + stream = LookupStream(frame.stream_id); + } + if (stream != nullptr) { + StreamWritabilityUpdate update = + stream->ReceivedFlowControlWindowUpdate(frame.increment); + if (update.became_writable) { + absl::Status status = writable_stream_list_.EnqueueWrapper( + stream, update.priority, AreTransportFlowControlTokensAvailable()); + if (!status.ok()) { + return ToHttpOkOrConnError(status); + } } - } else { - chttp2::TransportFlowControl::OutgoingUpdateContext fc_update( - &flow_control_); - fc_update.RecvUpdate(frame.increment); + } + + const bool should_trigger_write = + ProcessIncomingWindowUpdateFrameFlowControl(frame, flow_control_, stream); + if (should_trigger_write) { + SpawnGuardedTransportParty("TransportTokensAvailable", TriggerWriteCycle()); } return Http2Status::Ok(); } @@ -442,11 +659,14 @@ Http2Status Http2ClientTransport::ProcessHttp2ContinuationFrame( Http2ContinuationFrame frame) { // https://www.rfc-editor.org/rfc/rfc9113.html#name-continuation GRPC_HTTP2_CLIENT_DLOG - << "Http2Transport ProcessHttp2ContinuationFrame Promise { " + << "Http2ClientTransport ProcessHttp2ContinuationFrame Promise { " "stream_id=" << frame.stream_id << ", end_headers=" << frame.end_headers - << ", payload=" << frame.payload.JoinIntoString() << " }"; - incoming_header_in_progress_ = !frame.end_headers; + << ", payload=" << MaybeTruncatePayload(frame.payload) << " }"; + + // State update MUST happen before processing the frame. + incoming_headers_.OnContinuationReceived(frame); + RefCountedPtr stream = LookupStream(frame.stream_id); if (stream == nullptr) { // TODO(tjagtap) : [PH2][P3] : Implement this. @@ -456,32 +676,45 @@ Http2Status Http2ClientTransport::ProcessHttp2ContinuationFrame( // frame and streams that are reserved using PUSH_PROMISE. An endpoint that // receives an unexpected stream identifier MUST respond with a connection // error (Section 5.4.1) of type PROTOCOL_ERROR. - return Http2Status::Ok(); + return ParseAndDiscardHeaders(std::move(frame.payload), frame.end_headers, + nullptr, Http2Status::Ok()); + } + + if (stream->IsStreamHalfClosedRemote()) { + return ParseAndDiscardHeaders( + std::move(frame.payload), frame.end_headers, stream, + Http2Status::Http2StreamError( + Http2ErrorCode::kStreamClosed, + std::string(RFC9113::kHalfClosedRemoteState))); } - if (stream->GetStreamState() == HttpStreamState::kHalfClosedRemote) { - return Http2Status::Http2StreamError( - Http2ErrorCode::kStreamClosed, - std::string(RFC9113::kHalfClosedRemoteState)); + + Http2Status append_result = + stream->header_assembler.AppendContinuationFrame(frame); + if (!append_result.IsOk()) { + // Frame payload is not consumed if AppendContinuationFrame returns a + // non-OK status. We need to process it to keep our in consistent state. + return ParseAndDiscardHeaders(std::move(frame.payload), frame.end_headers, + stream, std::move(append_result)); } - HeaderAssembler& assember = stream->header_assembler; - Http2Status result = assember.AppendContinuationFrame(std::move(frame)); - if (result.IsOk()) { - return ProcessMetadata(stream); + Http2Status status = ProcessMetadata(stream); + if (!status.IsOk()) { + // Frame payload is consumed by HeaderAssembler. So passing an empty + // SliceBuffer to ParseAndDiscardHeaders. + return ParseAndDiscardHeaders(SliceBuffer(), frame.end_headers, stream, + std::move(status)); } - return result; + + // Frame payload has either been processed or moved to the HeaderAssembler. + return Http2Status::Ok(); } Http2Status Http2ClientTransport::ProcessHttp2SecurityFrame( Http2SecurityFrame frame) { - GRPC_HTTP2_CLIENT_DLOG << "Http2Transport ProcessHttp2SecurityFrame " - "ProcessHttp2SecurityFrame { payload=" - << frame.payload.JoinIntoString() << " }"; - if ((settings_.acked().allow_security_frame() || - settings_.local().allow_security_frame()) && - settings_.peer().allow_security_frame()) { - // TODO(tjagtap) : [PH2][P4] : Evaluate when to accept the frame and when to - // reject it. Compare it with the requirement and with CHTTP2. + GRPC_HTTP2_CLIENT_DLOG << "Http2ClientTransport ProcessHttp2SecurityFrame " + "{ payload.Length=" + << frame.payload.Length() << " }"; + if (settings_->IsSecurityFrameExpected()) { // TODO(tjagtap) : [PH2][P3] : Add handling of Security frame // Just the frame.payload needs to be passed to the endpoint_ object. // Refer usage of TransportFramingEndpointExtension. @@ -525,7 +758,7 @@ auto Http2ClientTransport::ProcessOneFrame(Http2Frame frame) { return self->ProcessHttp2SecurityFrame(std::move(frame)); }, [](GRPC_UNUSED Http2UnknownFrame frame) { - // As per HTTP2 RFC, implementations MUST ignore and discard frames of + // RFC9113: Implementations MUST ignore and discard frames of // unknown types. return Http2Status::Ok(); }, @@ -536,8 +769,64 @@ auto Http2ClientTransport::ProcessOneFrame(Http2Frame frame) { })); } +Http2Status Http2ClientTransport::ParseAndDiscardHeaders( + SliceBuffer&& buffer, const bool is_end_headers, + const RefCountedPtr stream, Http2Status&& original_status, + DebugLocation whence) { + const bool is_initial_metadata = !incoming_headers_.HeaderHasEndStream(); + const uint32_t incoming_stream_id = incoming_headers_.GetStreamId(); + GRPC_HTTP2_CLIENT_DLOG + << "Http2ClientTransport ParseAndDiscardHeaders buffer " + "size: " + << buffer.Length() << " is_initial_metadata: " << is_initial_metadata + << " is_end_headers: " << is_end_headers + << " incoming_stream_id: " << incoming_stream_id + << " stream_id: " << (stream == nullptr ? 0 : stream->GetStreamId()) + << " original_status: " << original_status.DebugString() + << " whence: " << whence.file() << ":" << whence.line(); + + return http2::ParseAndDiscardHeaders( + parser_, std::move(buffer), + HeaderAssembler::ParseHeaderArgs{ + /*is_initial_metadata=*/is_initial_metadata, + /*is_end_headers=*/is_end_headers, + /*is_client=*/true, + /*max_header_list_size_soft_limit=*/ + incoming_headers_.soft_limit(), + /*max_header_list_size_hard_limit=*/ + settings_->acked().max_header_list_size(), + /*stream_id=*/incoming_stream_id, + }, + stream, std::move(original_status)); +} + /////////////////////////////////////////////////////////////////////////////// // Read Related Promises and Promise Factories +auto Http2ClientTransport::EndpointReadSlice(const size_t num_bytes) { + return Map( + endpoint_.ReadSlice(num_bytes), + [self = RefAsSubclass(), + num_bytes](absl::StatusOr status) { + if (status.ok()) { + self->keepalive_manager_->GotData(); + self->ztrace_collector_->Append(PromiseEndpointReadTrace{num_bytes}); + } + return status; + }); +} + +auto Http2ClientTransport::EndpointRead(const size_t num_bytes) { + return Map( + endpoint_.Read(num_bytes), + [self = RefAsSubclass(), + num_bytes](absl::StatusOr status) { + if (status.ok()) { + self->keepalive_manager_->GotData(); + self->ztrace_collector_->Append(PromiseEndpointReadTrace{num_bytes}); + } + return status; + }); +} auto Http2ClientTransport::ReadAndProcessOneFrame() { GRPC_HTTP2_CLIENT_DLOG @@ -556,10 +845,16 @@ auto Http2ClientTransport::ReadAndProcessOneFrame() { // Validate the incoming frame as per the current state of the transport [self = RefAsSubclass()](Http2FrameHeader header) { Http2Status status = ValidateFrameHeader( - /*max_frame_size_setting*/ self->settings_.acked().max_frame_size(), - /*incoming_header_in_progress*/ self->incoming_header_in_progress_, - /*incoming_header_stream_id*/ self->incoming_header_stream_id_, - /*current_frame_header*/ header); + /*max_frame_size_setting*/ self->settings_->acked() + .max_frame_size(), + /*incoming_header_in_progress*/ + self->incoming_headers_.IsWaitingForContinuationFrame(), + /*incoming_header_stream_id*/ + self->incoming_headers_.GetStreamId(), + /*current_frame_header*/ header, + /*last_stream_id=*/self->GetLastStreamId(), + /*is_client=*/true, /*is_first_settings_processed=*/ + self->settings_->IsFirstPeerSettingsApplied()); if (GPR_UNLIKELY(!status.IsOk())) { GRPC_DCHECK(status.GetType() == @@ -584,7 +879,7 @@ auto Http2ClientTransport::ReadAndProcessOneFrame() { SliceBuffer payload) -> absl::StatusOr { GRPC_HTTP2_CLIENT_DLOG << "Http2ClientTransport ReadAndProcessOneFrame ParseFramePayload " - << payload.JoinIntoString(); + << MaybeTruncatePayload(payload); ValueOrHttp2Status frame = ParseFramePayload(self->current_frame_header_, std::move(payload)); if (!frame.IsOk()) { @@ -607,6 +902,9 @@ auto Http2ClientTransport::ReadAndProcessOneFrame() { } return absl::OkStatus(); })); + }, + [self = RefAsSubclass()]() -> Poll { + return self->reader_state_.MaybePauseReadLoop(); })); } @@ -623,95 +921,155 @@ auto Http2ClientTransport::ReadLoop() { })); } -auto Http2ClientTransport::OnReadLoopEnded() { - GRPC_HTTP2_CLIENT_DLOG << "Http2ClientTransport OnReadLoopEnded Factory"; - return - [self = RefAsSubclass()](absl::Status status) { +/////////////////////////////////////////////////////////////////////////////// +// Flow Control for the Transport + +auto Http2ClientTransport::FlowControlPeriodicUpdateLoop() { + GRPC_HTTP2_CLIENT_DLOG << "Http2ClientTransport PeriodicUpdateLoop Factory"; + return AssertResultType( + Loop([self = RefAsSubclass()]() { GRPC_HTTP2_CLIENT_DLOG - << "Http2ClientTransport OnReadLoopEnded Promise Status=" << status; - GRPC_UNUSED absl::Status error = self->HandleError( - std::nullopt, Http2Status::AbslConnectionError( - status.code(), std::string(status.message()))); - }; + << "Http2ClientTransport FlowControlPeriodicUpdateLoop Loop"; + return TrySeq( + // TODO(tjagtap) [PH2][P2][BDP] Remove this static sleep when the + // BDP code is done. + Sleep(chttp2::kFlowControlPeriodicUpdateTimer), + [self]() -> Poll { + GRPC_HTTP2_CLIENT_DLOG + << "Http2ClientTransport FlowControl PeriodicUpdate()"; + chttp2::FlowControlAction action = + self->flow_control_.PeriodicUpdate(); + bool is_action_empty = action == chttp2::FlowControlAction(); + // This may trigger a write cycle + self->ActOnFlowControlAction(action, nullptr); + if (is_action_empty) { + // TODO(tjagtap) [PH2][P2][BDP] Remove this when the BDP code is + // done. We must continue to do PeriodicUpdate once BDP is in + // place. + MutexLock lock(&self->transport_mutex_); + if (self->GetActiveStreamCountLocked() == 0) { + self->AddPeriodicUpdatePromiseWaker(); + return Pending{}; + } + } + return absl::OkStatus(); + }, + [self]() -> LoopCtl { return Continue{}; }); + })); } // Equivalent to grpc_chttp2_act_on_flowctl_action in chttp2_transport.cc -// TODO(tjagtap) : [PH2][P4] : grpc_chttp2_act_on_flowctl_action has a "reason" -// parameter which looks like it would be really helpful for debugging. Add that void Http2ClientTransport::ActOnFlowControlAction( - const chttp2::FlowControlAction& action, const uint32_t stream_id) { - GRPC_HTTP2_CLIENT_DLOG << "Http2ClientTransport::ActOnFlowControlAction"; + const chttp2::FlowControlAction& action, RefCountedPtr stream) { + GRPC_HTTP2_CLIENT_DLOG << "Http2ClientTransport::ActOnFlowControlAction" + << action.DebugString(); if (action.send_stream_update() != kNoActionNeeded) { - GRPC_DCHECK_GT(stream_id, 0u); - RefCountedPtr stream = LookupStream(stream_id); if (GPR_LIKELY(stream != nullptr)) { - const HttpStreamState state = stream->GetStreamState(); - if (state != HttpStreamState::kHalfClosedRemote && - state != HttpStreamState::kClosed) { - // Stream is not remotely closed, so sending a WINDOW_UPDATE is - // potentially useful. - // TODO(tjagtap) : [PH2][P1] Plumb with flow control + GRPC_DCHECK_GT(stream->GetStreamId(), 0u); + if (stream->CanSendWindowUpdateFrames()) { + window_update_list_.insert(stream->GetStreamId()); + GRPC_HTTP2_CLIENT_DLOG + << "Http2ClientTransport::ActOnFlowControlAction " + "added stream " + << stream->GetStreamId() << " to window_update_list_"; } } else { GRPC_HTTP2_CLIENT_DLOG - << "Http2ClientTransport ActOnFlowControlAction stream is null"; + << "Http2ClientTransport::ActOnFlowControlAction stream is null"; } } - if (action.send_transport_update() != kNoActionNeeded) { - // TODO(tjagtap) : [PH2][P1] Plumb with flow control - } - - // TODO(tjagtap) : [PH2][P1] Plumb - // enable_preferred_rx_crypto_frame_advertisement with settings ActOnFlowControlActionSettings( - action, settings_.mutable_local(), - /*enable_preferred_rx_crypto_frame_advertisement=*/true); + action, settings_->mutable_local(), + enable_preferred_rx_crypto_frame_advertisement_); if (action.AnyUpdateImmediately()) { - TriggerWriteCycle(); + // Prioritize sending flow control updates over reading data. If we + // continue reading while urgent flow control updates are pending, we might + // exhaust the flow control window. This prevents us from sending window + // updates to the peer, causing the peer to block unnecessarily while + // waiting for flow control tokens. + reader_state_.SetPauseReadLoop(); + SpawnGuardedTransportParty("SendControlFrames", TriggerWriteCycle()); + GRPC_HTTP2_CLIENT_DLOG << "Update Immediately : " + << action.ImmediateUpdateReasons(); } } /////////////////////////////////////////////////////////////////////////////// // Write Related Promises and Promise Factories -auto Http2ClientTransport::WriteControlFrames() { - GRPC_HTTP2_CLIENT_DLOG << "Http2ClientTransport WriteControlFrames Factory"; +auto Http2ClientTransport::ProcessAndWriteControlFrames() { SliceBuffer output_buf; if (is_first_write_) { - GRPC_HTTP2_CLIENT_DLOG << "Http2ClientTransport Write " + // RFC9113: That is, the connection preface starts with the string + // "PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n" + // This sequence MUST be followed by a SETTINGS frame, which MAY be empty. + GRPC_HTTP2_CLIENT_DLOG << "Http2ClientTransport WriteControlFrames " "GRPC_CHTTP2_CLIENT_CONNECT_STRING"; - output_buf.Append(Slice( - grpc_slice_from_copied_string(GRPC_CHTTP2_CLIENT_CONNECT_STRING))); + output_buf.Append( + Slice::FromCopiedString(GRPC_CHTTP2_CLIENT_CONNECT_STRING)); + settings_->MaybeGetSettingsAndSettingsAckFrames(flow_control_, output_buf); + // TODO(tjagtap) [PH2][P2][Server] : This will be opposite for server. We + // must read before we write for the server. So the ReadLoop will be Spawned + // just after the constructor, and the write loop should be spawned only + // after the first SETTINGS frame is completely received. + // + // Because the client is expected to write before it reads, we spawn the + // ReadLoop of the client only after the first write is queued. + SpawnGuardedTransportParty("ReadLoop", UntilTransportClosed(ReadLoop())); is_first_write_ = false; } - MaybeGetSettingsFrame(output_buf); - ping_manager_.MaybeGetSerializedPingFrames(output_buf, - NextAllowedPingInterval()); + + // Order of Control Frames is important. + // 1. GOAWAY - This is first because if this is the final GoAway, then we may + // not need to send anything else to the peer. + // 2. SETTINGS and SETTINGS ACK + // 3. PING and PING acks. + // 4. WINDOW_UPDATE + // 5. Custom gRPC security frame + + goaway_manager_.MaybeGetSerializedGoawayFrame(output_buf); + http2::Http2ErrorCode apply_status = + settings_->MaybeReportAndApplyBufferedPeerSettings(event_engine_.get()); + if (!goaway_manager_.IsImmediateGoAway() && + apply_status == http2::Http2ErrorCode::kNoError) { + EnforceLatestIncomingSettings(); + settings_->MaybeGetSettingsAndSettingsAckFrames(flow_control_, output_buf); + ping_manager_->MaybeGetSerializedPingFrames(output_buf, + NextAllowedPingInterval()); + MaybeGetWindowUpdateFrames(output_buf); + } const uint64_t buffer_length = output_buf.Length(); - return If( - buffer_length > 0, - [self = RefAsSubclass(), - output_buf = std::move(output_buf), buffer_length]() mutable { - GRPC_HTTP2_CLIENT_DLOG - << "Http2ClientTransport WriteControlFrames Writing buffer of size " - << buffer_length << " to endpoint"; - return self->endpoint_.Write(std::move(output_buf), - PromiseEndpoint::WriteArgs{}); - }, - [self = RefAsSubclass(), buffer_length] { - self->ztrace_collector_->Append( - PromiseEndpointWriteTrace{buffer_length}); - return absl::OkStatus(); - }); + ztrace_collector_->Append(PromiseEndpointWriteTrace{buffer_length}); + GRPC_HTTP2_CLIENT_DLOG << "Http2ClientTransport WriteControlFrames Size : " + << buffer_length; + return AssertResultType( + If((buffer_length > 0 && apply_status == http2::Http2ErrorCode::kNoError), + [self = RefAsSubclass(), + output_buf = std::move(output_buf)]() mutable { + return self->endpoint_.Write(std::move(output_buf), + GetWriteArgs(self->settings_->peer())); + }, + [self = RefAsSubclass(), apply_status]() { + if (apply_status != http2::Http2ErrorCode::kNoError) { + return self->HandleError( + std::nullopt, + Http2Status::Http2ConnectionError( + apply_status, "Failed to apply incoming settings")); + } + return absl::OkStatus(); + })); } void Http2ClientTransport::NotifyControlFramesWriteDone() { // Notify Control modules that we have sent the frames. // All notifications are expected to be synchronous. GRPC_HTTP2_CLIENT_DLOG << "Http2ClientTransport NotifyControlFramesWriteDone"; - ping_manager_.NotifyPingSent(ping_timeout_); + reader_state_.ResumeReadLoopIfPaused(); + ping_manager_->NotifyPingSent(); + goaway_manager_.NotifyGoawaySent(); + MaybeSpawnWaitForSettingsTimeout(); } auto Http2ClientTransport::SerializeAndWrite(std::vector&& frames) { @@ -728,7 +1086,7 @@ auto Http2ClientTransport::SerializeAndWrite(std::vector&& frames) { [self = RefAsSubclass(), output_buf = std::move(output_buf)]() mutable { return self->endpoint_.Write(std::move(output_buf), - PromiseEndpoint::WriteArgs{}); + GetWriteArgs(self->settings_->peer())); }, []() { return absl::OkStatus(); })); } @@ -740,45 +1098,71 @@ Http2ClientTransport::DequeueStreamFrames(RefCountedPtr stream) { // data frames when write_bytes_remaining_ is very low. As the // available transport tokens can only range from 0 to 2^31 - 1, // we are clamping the write_bytes_remaining_ to that range. - // TODO(akshitpatel) : [PH2][P3] : Plug transport_tokens when - // transport flow control is implemented. + const uint32_t tokens = + GetMaxPermittedDequeue(flow_control_, stream->flow_control, + write_bytes_remaining_, settings_->peer()); + const uint32_t stream_flow_control_tokens = static_cast( + GetStreamFlowControlTokens(stream->flow_control, settings_->peer())); + stream->flow_control.ReportIfStalled( + /*is_client=*/true, stream->GetStreamId(), settings_->peer()); StreamDataQueue::DequeueResult result = - stream->DequeueFrames( - /*transport_tokens*/ std::min( - std::numeric_limits::max(), - static_cast(Clamp(write_bytes_remaining_, 0, - RFC9113::kMaxSize31Bit - 1))), - settings_.peer().max_frame_size(), encoder_); + stream->DequeueFrames(tokens, stream_flow_control_tokens, + settings_->peer().max_frame_size(), encoder_); + ProcessOutgoingDataFrameFlowControl(stream->flow_control, + result.flow_control_tokens_consumed); if (result.is_writable) { // Stream is still writable. Enqueue it back to the writable // stream list. - // TODO(akshitpatel) : [PH2][P3] : Plug transport_tokens when - // transport flow control is implemented. - absl::Status status = - writable_stream_list_.Enqueue(stream, result.priority); + absl::Status status = writable_stream_list_.EnqueueWrapper( + stream, result.priority, AreTransportFlowControlTokensAvailable()); + if (GPR_UNLIKELY(!status.ok())) { GRPC_HTTP2_CLIENT_DLOG - << "Http2ClientTransport MultiplexerLoop Failed to " + << "Http2ClientTransport DequeueStreamFrames Failed to " "enqueue stream " << stream->GetStreamId() << " with status: " << status; // Close transport if we fail to enqueue stream. - return HandleError(std::nullopt, Http2Status::AbslConnectionError( - absl::StatusCode::kUnavailable, - std::string(status.message()))); + return HandleError(std::nullopt, ToHttpOkOrConnError(status)); } } + + // If the stream is aborted before initial metadata is dequeued, we will + // not dequeue any frames from the stream data queue (including RST_STREAM). + // Because of this, we will add the stream to the stream_list only when + // we are guaranteed to send initial metadata on the wire. If the above + // mentioned scenario occurs, the stream ref will be dropped by the + // multiplexer loop as the stream will never be writable again. Additionally, + // the other two stream refs, CallHandler OnDone and OutboundLoop will be + // dropped by Callv3 triggering cleaning up the stream object. if (result.InitialMetadataDequeued()) { + GRPC_HTTP2_CLIENT_DLOG + << "Http2ClientTransport DequeueStreamFrames InitialMetadataDequeued " + "stream_id = " + << stream->GetStreamId(); stream->SentInitialMetadata(); + // After this point, initial metadata is guaranteed to be sent out. + AddToStreamList(stream); } + if (result.HalfCloseDequeued()) { - CloseStream(stream, CloseStreamArgs{/*close_reads=*/false, - /*close_writes=*/true}); + GRPC_HTTP2_CLIENT_DLOG + << "Http2ClientTransport DequeueStreamFrames HalfCloseDequeued " + "stream_id = " + << stream->GetStreamId(); stream->MarkHalfClosedLocal(); + CloseStream( + stream, + CloseStreamArgs{/*close_reads=*/stream->did_receive_trailing_metadata, + /*close_writes=*/true}); } if (result.ResetStreamDequeued()) { + GRPC_HTTP2_CLIENT_DLOG + << "Http2ClientTransport DequeueStreamFrames ResetStreamDequeued " + "stream_id = " + << stream->GetStreamId(); + stream->MarkHalfClosedLocal(); CloseStream(stream, CloseStreamArgs{/*close_reads=*/true, /*close_writes=*/true}); - stream->MarkHalfClosedLocal(); } // Update the write_bytes_remaining_ based on the bytes consumed @@ -787,7 +1171,7 @@ Http2ClientTransport::DequeueStreamFrames(RefCountedPtr stream) { (write_bytes_remaining_ >= result.total_bytes_consumed) ? (write_bytes_remaining_ - result.total_bytes_consumed) : 0; - GRPC_HTTP2_CLIENT_DLOG << "Http2ClientTransport MultiplexerLoop " + GRPC_HTTP2_CLIENT_DLOG << "Http2ClientTransport DequeueStreamFrames " "write_bytes_remaining_ after dequeue = " << write_bytes_remaining_ << " total_bytes_consumed = " << result.total_bytes_consumed @@ -799,6 +1183,8 @@ Http2ClientTransport::DequeueStreamFrames(RefCountedPtr stream) { return std::move(result.frames); } +// This MultiplexerLoop promise is responsible for Multiplexing multiple gRPC +// Requests (HTTP2 Streams) and writing them into one common endpoint. auto Http2ClientTransport::MultiplexerLoop() { GRPC_HTTP2_CLIENT_DLOG << "Http2ClientTransport MultiplexerLoop Factory"; return AssertResultType< @@ -814,17 +1200,19 @@ auto Http2ClientTransport::MultiplexerLoop() { // WriteControlFrames() to indicate if we should do a separate write // for the queued control frames or send the queued frames with the // data frames(if any). - return Map(self->WriteControlFrames(), [self](absl::Status status) { - if (GPR_UNLIKELY(!status.ok())) { - GRPC_HTTP2_CLIENT_DLOG - << "Http2ClientTransport MultiplexerLoop Failed to " - "write control frames with status: " - << status; - return status; - } - self->NotifyControlFramesWriteDone(); - return absl::OkStatus(); - }); + return Map( + self->ProcessAndWriteControlFrames(), + [self](absl::Status status) { + if (GPR_UNLIKELY(!status.ok())) { + GRPC_HTTP2_CLIENT_DLOG + << "Http2ClientTransport MultiplexerLoop Failed to " + "write control frames with status: " + << status; + return status; + } + self->NotifyControlFramesWriteDone(); + return absl::OkStatus(); + }); }, [self]() -> absl::StatusOr> { std::vector frames; @@ -833,8 +1221,6 @@ auto Http2ClientTransport::MultiplexerLoop() { // some cases, we may write more than max_write_size_ bytes(like // writing metadata). while (self->write_bytes_remaining_ > 0) { - // TODO(akshitpatel) : [PH2][P3] : Plug transport_tokens when - // transport flow control is implemented. std::optional> optional_stream = self->writable_stream_list_.ImmediateNext( self->AreTransportFlowControlTokensAvailable()); @@ -852,8 +1238,28 @@ auto Http2ClientTransport::MultiplexerLoop() { << stream->GetStreamId() << " is_closed_for_writes = " << stream->IsClosedForWrites(); + if (stream->GetStreamId() == kInvalidStreamId) { + GRPC_DCHECK(stream->IsStreamIdle()); + // TODO(akshitpatel) : [PH2][P5] : We will waste a stream id in + // the rare scenario where the stream is aborted before it can be + // written to. This is a possible area to optimize in future. + absl::Status status = self->InitializeStream(stream); + if (!status.ok()) { + GRPC_HTTP2_CLIENT_DLOG + << "Http2ClientTransport MultiplexerLoop " + "Failed to assign stream id and add to stream list for " + "stream: " + << stream.get() << " closing this stream."; + self->BeginCloseStream( + stream, /*reset_stream_error_code=*/std::nullopt, + CancelledServerMetadataFromStatus(status)); + continue; + } + } + if (GPR_LIKELY(!stream->IsClosedForWrites())) { - auto stream_frames = self->DequeueStreamFrames(stream); + absl::StatusOr> stream_frames = + self->DequeueStreamFrames(stream); if (GPR_UNLIKELY(!stream_frames.ok())) { GRPC_HTTP2_CLIENT_DLOG << "Http2ClientTransport MultiplexerLoop " @@ -884,7 +1290,7 @@ auto Http2ClientTransport::MultiplexerLoop() { if (self->should_reset_ping_clock_) { GRPC_HTTP2_CLIENT_DLOG << "Http2ClientTransport MultiplexerLoop ResetPingClock"; - self->ping_manager_.ResetPingClock(/*is_client=*/true); + self->ping_manager_->ResetPingClock(/*is_client=*/true); self->should_reset_ping_clock_ = false; } return Continue(); @@ -892,18 +1298,102 @@ auto Http2ClientTransport::MultiplexerLoop() { })); } -auto Http2ClientTransport::OnMultiplexerLoopEnded() { - GRPC_HTTP2_CLIENT_DLOG - << "Http2ClientTransport OnMultiplexerLoopEnded Factory"; - return - [self = RefAsSubclass()](absl::Status status) { - GRPC_HTTP2_CLIENT_DLOG - << "Http2ClientTransport OnMultiplexerLoopEnded Promise Status=" - << status; - GRPC_UNUSED absl::Status error = self->HandleError( - std::nullopt, Http2Status::AbslConnectionError( - status.code(), std::string(status.message()))); - }; +absl::Status Http2ClientTransport::InitializeStream( + RefCountedPtr stream) { + absl::StatusOr next_stream_id = NextStreamId(); + if (!next_stream_id.ok()) { + GRPC_HTTP2_CLIENT_DLOG << "Http2ClientTransport InitializeStream " + "Failed to get next stream id for stream: " + << stream.get(); + return std::move(next_stream_id).status(); + } + GRPC_HTTP2_CLIENT_DLOG << "Http2ClientTransport InitializeStream " + "Assigned stream id: " + << next_stream_id.value() + << " to stream: " << stream.get() + << ", allow_true_binary_metadata:" + << settings_->peer().allow_true_binary_metadata(); + stream->InitializeStream(next_stream_id.value(), + settings_->peer().allow_true_binary_metadata(), + settings_->acked().allow_true_binary_metadata()); + return absl::OkStatus(); +} + +void Http2ClientTransport::AddToStreamList(RefCountedPtr stream) { + bool should_wake_periodic_updates = false; + { + MutexLock lock(&transport_mutex_); + GRPC_DCHECK(stream != nullptr) << "stream is null"; + GRPC_DCHECK_GT(stream->GetStreamId(), 0u) << "stream id is invalid"; + GRPC_HTTP2_CLIENT_DLOG + << "Http2ClientTransport AddToStreamList for stream id: " + << stream->GetStreamId(); + stream_list_.emplace(stream->GetStreamId(), stream); + // TODO(tjagtap) [PH2][P2][BDP] Remove this when the BDP code is done. + if (GetActiveStreamCountLocked() == 1) { + should_wake_periodic_updates = true; + } + } + // TODO(tjagtap) [PH2][P2][BDP] Remove this when the BDP code is done. + if (should_wake_periodic_updates) { + // Release the lock before you wake up another promise on the party. + WakeupPeriodicUpdatePromise(); + } +} + +/////////////////////////////////////////////////////////////////////////////// +// Settings and Window Update Management + +void Http2ClientTransport::EnforceLatestIncomingSettings() { + encoder_.SetMaxTableSize(settings_->peer().header_table_size()); +} + +auto Http2ClientTransport::WaitForSettingsTimeoutOnDone() { + return [self = RefAsSubclass()](absl::Status status) { + if (!status.ok()) { + GRPC_UNUSED absl::Status result = self->HandleError( + std::nullopt, Http2Status::Http2ConnectionError( + Http2ErrorCode::kProtocolError, + std::string(RFC9113::kSettingsTimeout))); + } + }; +} + +void Http2ClientTransport::MaybeSpawnWaitForSettingsTimeout() { + if (settings_->ShouldSpawnWaitForSettingsTimeout()) { + GRPC_HTTP2_CLIENT_DLOG + << "Http2ClientTransport::MaybeSpawnWaitForSettingsTimeout Spawning"; + general_party_->Spawn("WaitForSettingsTimeout", + settings_->WaitForSettingsTimeout(), + WaitForSettingsTimeoutOnDone()); + } +} + +void Http2ClientTransport::MaybeGetWindowUpdateFrames(SliceBuffer& output_buf) { + std::vector frames; + frames.reserve(window_update_list_.size() + 1); + uint32_t window_size = + flow_control_.DesiredAnnounceSize(/*writing_anyway=*/true); + if (window_size > 0) { + GRPC_HTTP2_CLIENT_DLOG + << "Http2ClientTransport::MaybeGetWindowUpdateFrames Transport Window " + "Update : " + << window_size; + frames.emplace_back(Http2WindowUpdateFrame{/*stream_id=*/0, window_size}); + flow_control_.SentUpdate(window_size); + } + for (const uint32_t stream_id : window_update_list_) { + RefCountedPtr stream = LookupStream(stream_id); + MaybeAddStreamWindowUpdateFrame(stream, frames); + } + window_update_list_.clear(); + if (!frames.empty()) { + GRPC_HTTP2_CLIENT_DLOG + << "Http2ClientTransport::MaybeGetWindowUpdateFrames Total Window " + "Update Frames : " + << frames.size(); + Serialize(absl::Span(frames), output_buf); + } } /////////////////////////////////////////////////////////////////////////////// @@ -912,54 +1402,20 @@ auto Http2ClientTransport::OnMultiplexerLoopEnded() { Http2ClientTransport::Http2ClientTransport( PromiseEndpoint endpoint, GRPC_UNUSED const ChannelArgs& channel_args, std::shared_ptr event_engine, - grpc_closure* on_receive_settings) + absl::AnyInvocable)> on_receive_settings) : channelz::DataSource(http2::CreateChannelzSocketNode( endpoint.GetEventEngineEndpoint(), channel_args)), + event_engine_(std::move(event_engine)), endpoint_(std::move(endpoint)), - stream_id_mutex_(/*Initial Stream Id*/ 1), + settings_(MakeRefCounted( + std::move(on_receive_settings))), + next_stream_id_(/*Initial Stream ID*/ 1), should_reset_ping_clock_(false), - incoming_header_in_progress_(false), - incoming_header_end_stream_(false), is_first_write_(true), - incoming_header_stream_id_(0), - on_receive_settings_(on_receive_settings), - max_header_list_size_soft_limit_( - GetSoftLimitFromChannelArgs(channel_args)), max_write_size_(kMaxWriteSize), - keepalive_time_(std::max( - Duration::Seconds(10), - channel_args.GetDurationFromIntMillis(GRPC_ARG_KEEPALIVE_TIME_MS) - .value_or(Duration::Infinity()))), - // Keepalive timeout is only passed to the keepalive manager if it is less - // than the ping timeout. As keepalives use pings for health checks, if - // keepalive timeout is greater than ping timeout, we would always hit the - // ping timeout first. - keepalive_timeout_(std::max( - Duration::Zero(), - channel_args.GetDurationFromIntMillis(GRPC_ARG_KEEPALIVE_TIMEOUT_MS) - .value_or(keepalive_time_ == Duration::Infinity() - ? Duration::Infinity() - : (Duration::Seconds(20))))), - ping_timeout_(std::max( - Duration::Zero(), - channel_args.GetDurationFromIntMillis(GRPC_ARG_PING_TIMEOUT_MS) - .value_or(keepalive_time_ == Duration::Infinity() - ? Duration::Infinity() - : Duration::Minutes(1)))), - ping_manager_(channel_args, PingSystemInterfaceImpl::Make(this), - event_engine), - keepalive_manager_( - KeepAliveInterfaceImpl::Make(this), - ((keepalive_timeout_ < ping_timeout_) ? keepalive_timeout_ - : Duration::Infinity()), - keepalive_time_), - keepalive_permit_without_calls_( - channel_args.GetBool(GRPC_ARG_KEEPALIVE_PERMIT_WITHOUT_CALLS) - .value_or(false)), - enable_preferred_rx_crypto_frame_advertisement_( - channel_args - .GetBool(GRPC_ARG_EXPERIMENTAL_HTTP2_PREFERRED_CRYPTO_FRAME_SIZE) - .value_or(false)), + ping_manager_(std::nullopt), + keepalive_manager_(std::nullopt), + goaway_manager_(GoawayInterfaceImpl::Make(this)), memory_owner_(channel_args.GetObject() ->memory_quota() ->CreateMemoryOwner()), @@ -969,165 +1425,274 @@ Http2ClientTransport::Http2ClientTransport( &memory_owner_), ztrace_collector_(std::make_shared()) { GRPC_HTTP2_CLIENT_DLOG << "Http2ClientTransport Constructor Begin"; - SourceConstructed(); + // Initialize the general party and write party. + RefCountedPtr party_arena = SimpleArenaAllocator(0)->MakeArena(); + party_arena->SetContext(event_engine_.get()); + general_party_ = Party::Make(std::move(party_arena)); - InitLocalSettings(settings_.mutable_local(), /*is_client=*/true); - ReadSettingsFromChannelArgs(channel_args, settings_.mutable_local(), - flow_control_, /*is_client=*/true); + InitLocalSettings(settings_->mutable_local(), /*is_client=*/true); + TransportChannelArgs args; + ReadChannelArgs(channel_args, args); - // Initialize the general party and write party. - auto general_party_arena = SimpleArenaAllocator(0)->MakeArena(); - general_party_arena->SetContext(event_engine.get()); - general_party_ = Party::Make(std::move(general_party_arena)); - - general_party_->Spawn("ReadLoop", UntilTransportClosed(ReadLoop()), - OnReadLoopEnded()); - general_party_->Spawn("MultiplexerLoop", - UntilTransportClosed(MultiplexerLoop()), - OnMultiplexerLoopEnded()); - // The keepalive loop is only spawned if the keepalive time is not infinity. - keepalive_manager_.Spawn(general_party_.get()); - - // TODO(tjagtap) : [PH2][P2] Delete this hack once flow control is done. - // We are increasing the flow control window so that we can avoid sending - // WINDOW_UPDATE frames while flow control is under development. Once it is - // ready we should remove these lines. - // - Http2ErrorCode code = settings_.mutable_local().Apply( - Http2Settings::kInitialWindowSizeWireId, - (Http2Settings::max_initial_window_size() - 1)); - GRPC_DCHECK(code == Http2ErrorCode::kNoError); - // - - const int max_hpack_table_size = - channel_args.GetInt(GRPC_ARG_HTTP2_HPACK_TABLE_SIZE_ENCODER).value_or(-1); - if (max_hpack_table_size >= 0) { - encoder_.SetMaxUsableSize(max_hpack_table_size); - } + ping_manager_.emplace(channel_args, args.ping_timeout, + PingSystemInterfaceImpl::Make(this), event_engine_); - transport_settings_.SetSettingsTimeout(channel_args, keepalive_timeout_); + // The keepalive loop is only spawned if the keepalive time is not infinity. + keepalive_manager_.emplace( + KeepAliveInterfaceImpl::Make(this), + ((args.keepalive_timeout < args.ping_timeout) ? args.keepalive_timeout + : Duration::Infinity()), + args.keepalive_time, general_party_.get()); - if (settings_.local().allow_security_frame()) { + if (settings_->local().allow_security_frame()) { // TODO(tjagtap) : [PH2][P3] : Setup the plumbing to pass the security frame // to the endpoing via TransportFramingEndpointExtension. // Also decide if this plumbing is done here, or when the peer sends // allow_security_frame too. } - // Spawn a promise to flush the gRPC initial connection string and settings - // frames. - general_party_->Spawn("SpawnFlushInitialFrames", TriggerWriteCycle(), - [](GRPC_UNUSED absl::Status status) {}); - + GRPC_DCHECK(ping_manager_.has_value()); + GRPC_DCHECK(keepalive_manager_.has_value()); + SourceConstructed(); GRPC_HTTP2_CLIENT_DLOG << "Http2ClientTransport Constructor End"; } +void Http2ClientTransport::SpawnTransportLoops() { + GRPC_HTTP2_CLIENT_DLOG << "Http2ClientTransport::SpawnTransportLoops Begin"; + SpawnGuardedTransportParty( + "FlowControlPeriodicUpdateLoop", + UntilTransportClosed(FlowControlPeriodicUpdateLoop())); + + SpawnGuardedTransportParty("FlushInitialFrames", TriggerWriteCycle()); + SpawnGuardedTransportParty("MultiplexerLoop", + UntilTransportClosed(MultiplexerLoop())); + GRPC_HTTP2_CLIENT_DLOG << "Http2ClientTransport::SpawnTransportLoops End"; +} + +void Http2ClientTransport::ReadChannelArgs(const ChannelArgs& channel_args, + TransportChannelArgs& args) { + http2::ReadChannelArgs(channel_args, args, settings_->mutable_local(), + flow_control_, + /*is_client=*/true); + + // Assign the channel args to the member variables. + keepalive_time_ = args.keepalive_time; + incoming_headers_.set_soft_limit(args.max_header_list_size_soft_limit); + keepalive_permit_without_calls_ = args.keepalive_permit_without_calls; + enable_preferred_rx_crypto_frame_advertisement_ = + args.enable_preferred_rx_crypto_frame_advertisement; + test_only_ack_pings_ = args.test_only_ack_pings; + + if (args.initial_sequence_number > 0) { + next_stream_id_ = args.initial_sequence_number; + } + + settings_->SetSettingsTimeout(args.settings_timeout); + if (args.max_usable_hpack_table_size >= 0) { + encoder_.SetMaxUsableSize(args.max_usable_hpack_table_size); + } +} + // This function MUST be idempotent. This function MUST be called from the // transport party. void Http2ClientTransport::CloseStream(RefCountedPtr stream, CloseStreamArgs args, DebugLocation whence) { - // TODO(akshitpatel) : [PH2][P3] : Measure the impact of holding mutex - // throughout this function. - MutexLock lock(&transport_mutex_); - GRPC_DCHECK(stream != nullptr) << "stream is null"; - GRPC_HTTP2_CLIENT_DLOG << "Http2ClientTransport::CloseStream for stream id: " - << stream->GetStreamId() - << " location=" << whence.file() << ":" - << whence.line(); + std::optional close_transport_error; - if (args.close_writes) { - stream->SetWriteClosed(); - } - - if (args.close_reads) { + { + // TODO(akshitpatel) : [PH2][P3] : Measure the impact of holding mutex + // throughout this function. + MutexLock lock(&transport_mutex_); + GRPC_DCHECK(stream != nullptr) << "stream is null"; GRPC_HTTP2_CLIENT_DLOG << "Http2ClientTransport::CloseStream for stream id: " - << stream->GetStreamId() << " closing stream for reads."; - stream_list_.erase(stream->GetStreamId()); + << stream->GetStreamId() << " close_reads=" << args.close_reads + << " close_writes=" << args.close_writes + << " incoming_headers_=" << incoming_headers_.DebugString() + << " location=" << whence.file() << ":" << whence.line(); + + if (args.close_writes) { + stream->SetWriteClosed(); + } + + if (args.close_reads) { + GRPC_HTTP2_CLIENT_DLOG + << "Http2ClientTransport::CloseStream for stream id: " + << stream->GetStreamId() << " closing stream for reads."; + // If the stream is closed while reading HEADER/CONTINUATION frames, we + // should still parse the enqueued buffer to maintain HPACK state between + // peers. + if (incoming_headers_.IsWaitingForContinuationFrame()) { + Http2Status result = http2::ParseAndDiscardHeaders( + parser_, SliceBuffer(), + HeaderAssembler::ParseHeaderArgs{ + /*is_initial_metadata=*/!incoming_headers_.HeaderHasEndStream(), + /*is_end_headers=*/false, + /*is_client=*/true, + /*max_header_list_size_soft_limit=*/ + incoming_headers_.soft_limit(), + /*max_header_list_size_hard_limit=*/ + settings_->acked().max_header_list_size(), + /*stream_id=*/incoming_headers_.GetStreamId(), + }, + stream, /*original_status=*/Http2Status::Ok()); + if (result.GetType() == Http2Status::Http2ErrorType::kConnectionError) { + GRPC_HTTP2_CLIENT_DLOG + << "Http2ClientTransport::CloseStream for stream id: " + << stream->GetStreamId() + << " failed to partially process header: " + << result.DebugString(); + close_transport_error.emplace(std::move(result)); + } + } + + stream_list_.erase(stream->GetStreamId()); + if (!close_transport_error.has_value() && CanCloseTransportLocked()) { + // TODO(akshitpatel) : [PH2][P3] : Is kInternalError the right error + // code to use here? IMO it should be kNoError. + close_transport_error.emplace(Http2Status::Http2ConnectionError( + Http2ErrorCode::kInternalError, + std::string(RFC9113::kLastStreamClosed))); + } + } + } + + if (close_transport_error.has_value()) { + GRPC_UNUSED absl::Status status = HandleError( + /*stream_id=*/std::nullopt, std::move(*close_transport_error)); } } -// Here is the flow for stream close: -// 1. BeginCloseStream is invoked if the transport needs to close the stream. -// 2. If reset stream does not need to be sent, the stream is closed for reads -// and writes immediately. Also, the stream is removed from the -// stream_list_. -// 3. If reset stream needs to be sent and the stream is cancelled, the stream -// is closed for reads immediately. This will result in stream being removed -// from the stream_list_. Additionally, the reset stream frame is enqueued -// and the stream is closed for writes once the frame is created. -// 4. Trailing metadata is pushed to the call stack. -// Extended: -// 5. Eventually CallHandler.OnDone() is invoked. -// 6. If the call was cancelled, we try to enqueue a reset stream frame. In most -// of the cases, this would be a no-op. The only case where this would -// enqueue the reset stream frame is an application initiated abort. -// 7. If the call was not cancelled, we try to enqueue a half close frame. If -// the stream was already closed from writes, this would be a no-op. +// This function is idempotent and MUST be called from the transport party. +// All the scenarios that can lead to this function being called are: +// 1. Reading a RST stream frame: In this case, the stream is immediately +// closed for reads and writes and removed from the stream_list_. +// 2. Reading a Trailing Metadata frame: There are two possible scenarios: +// a. The stream is closed for writes: Close the stream for reads and writes +// and remove the stream from the stream_list_. +// b. The stream is NOT closed for writes: Stream is kept open for reads and +// writes. CallHandler OnDone will trigger sending a half close frame. If +// before the multiplexer loop triggers sending a half close a RST stream +// is read, the stream is closed for reads and writes immediately and the +// half close is discarded. If no RST stream is read, the stream is closed +// for reads and writes upon sending the half close frame from the +// multiplexer loop. +// 3. Hitting error condition in the transport: In this case, RST stream is +// enqueued and the stream is closed for reads immediately. This implies we +// reduce the number of active streams inline. When multiplexer loop +// processes the RST stream frame, the stream ref will dropped. The other +// stream ref will be dropped when CallHandler's OnDone is executed causing +// the stream to be destroyed. CallHandlers OnDone also tries to enqueue a +// RST stream frame. This is a no-op at this point. +// 4. Application abort: In this case, CallHandler OnDone will enqueue RST +// stream frame to the stream data queue. The multiplexer loop will send the +// reset stream frame and close the stream from reads and writes. +// 5. Transport close: This takes up the same path as case 3. +// In all the above cases, trailing metadata is pushed to the call spine. +// Note: The stream ref is held in atmost 3 places: +// 1. stream_list_ : This is released when the stream is closed for reads. +// 2. CallHandler OnDone : This is released when Trailing Metadata is pushed to +// the call spine. +// 3. List of writable streams : This is released after the final frame is +// dequeued from the StreamDataQueue. void Http2ClientTransport::BeginCloseStream( - const uint32_t stream_id, std::optional reset_stream_error_code, + RefCountedPtr stream, + std::optional reset_stream_error_code, ServerMetadataHandle&& metadata, DebugLocation whence) { + if (stream == nullptr) { + GRPC_HTTP2_CLIENT_DLOG << "Http2ClientTransport::BeginCloseStream stream " + "is null reset_stream_error_code=" + << (reset_stream_error_code.has_value() + ? absl::StrCat(*reset_stream_error_code) + : "nullopt") + << " metadata=" << metadata->DebugString(); + return; + } + GRPC_HTTP2_CLIENT_DLOG - << "Http2ClientTransport::BeginCloseStream for stream id: " << stream_id - << " error_code=" + << "Http2ClientTransport::BeginCloseStream for stream id: " + << stream->GetStreamId() << " error_code=" << (reset_stream_error_code.has_value() ? absl::StrCat(*reset_stream_error_code) : "nullopt") << " ServerMetadata=" << metadata->DebugString() << " location=" << whence.file() << ":" << whence.line(); - RefCountedPtr stream = LookupStream(stream_id); - if (stream != nullptr) { - if (stream->did_push_trailing_metadata) { - return; - } - - // If reset stream needs to be sent, CloseStream will be called from the - // Multiplexer after the reset stream frame is created. + bool close_reads = false; + bool close_writes = false; + if (metadata->get(GrpcCallWasCancelled())) { if (!reset_stream_error_code) { // Callers taking this path: // 1. Reading a RST stream frame (will not send any frame out). - - CloseStream(stream, - CloseStreamArgs{/*close_reads*/ true, /*close_writes=*/true}, - whence); - stream->MarkHalfClosedRemote(); + // 2. Closing a stream before initial metadata is sent. + close_reads = true; + close_writes = true; + GRPC_HTTP2_CLIENT_DLOG + << "Http2ClientTransport::BeginCloseStream for stream id: " + << stream->GetStreamId() << " close_reads= " << close_reads + << " close_writes= " << close_writes; } else { // Callers taking this path: - // 1. Reading Trailing Metadata (MAY send half close from OnDone). - // 2. Processing Error in transport (will send reset stream from here). - - if (metadata->get(GrpcCallWasCancelled())) { - CloseStream( - stream, - CloseStreamArgs{/*close_reads*/ true, /*close_writes=*/false}, - whence); - absl::StatusOr enqueue_result = - stream->EnqueueResetStream(reset_stream_error_code.value()); - GRPC_HTTP2_CLIENT_DLOG << "Enqueued ResetStream with error code=" - << reset_stream_error_code.value() - << " status=" << enqueue_result.status(); - if (enqueue_result.ok()) { - GRPC_UNUSED absl::Status status = MaybeAddStreamToWritableStreamList( - stream, enqueue_result.value()); - } + // 1. Processing Error in transport (will send reset stream from here). + absl::StatusOr enqueue_result = + stream->EnqueueResetStream(reset_stream_error_code.value()); + GRPC_HTTP2_CLIENT_DLOG << "Enqueued ResetStream with error code=" + << reset_stream_error_code.value() + << " status=" << enqueue_result.status(); + if (enqueue_result.ok()) { + GRPC_UNUSED absl::Status status = + MaybeAddStreamToWritableStreamList(stream, enqueue_result.value()); } + close_reads = true; + GRPC_HTTP2_CLIENT_DLOG + << "Http2ClientTransport::BeginCloseStream for stream id: " + << stream->GetStreamId() << " close_reads= " << close_reads + << " close_writes= " << close_writes; } + } else { + // Callers taking this path: + // 1. Reading Trailing Metadata (MAY send half close from OnDone). + if (stream->IsClosedForWrites()) { + close_reads = true; + close_writes = true; + GRPC_HTTP2_CLIENT_DLOG + << "Http2ClientTransport::BeginCloseStream for stream id: " + << stream->GetStreamId() << " close_reads= " << close_reads + << " close_writes= " << close_writes; + } + } - stream->did_push_trailing_metadata = true; - // This maybe called multiple times while closing a stream. This should be - // fine as the the call spine ignores the subsequent calls. - stream->call.SpawnPushServerTrailingMetadata(std::move(metadata)); + if (close_reads || close_writes) { + CloseStream(stream, CloseStreamArgs{close_reads, close_writes}, whence); } + + // If the call was cancelled, the stream MUST be closed for reads. + GRPC_DCHECK(metadata->get(GrpcCallWasCancelled()) ? close_reads : true); + + // This maybe called multiple times while closing a stream. In CallV3, the + // flow for pushing server trailing metadata is idempotent. However, there is + // a subtle difference. When we push server trailing metadata with a cancelled + // status PushServerTrailingMetadata is spawned inline on the Call party + // whereas for the non-cancelled status, PushServerTrailingMetadata is + // spawned in the server_to_client spawn serializer. Because of this, in + // case when the server pushes trailing metadata (non-cancelled) followed by a + // RST stream with cancelled status, it is possible that the cancelled + // trailing metadata (for RST stream) is processed before. This would result + // in losing the actual status/message pushed by the server. + // To address this, we push the server trailing metadata to the stream only + // if it is not pushed already. + stream->MaybePushServerTrailingMetadata(std::move(metadata)); } void Http2ClientTransport::CloseTransport() { GRPC_HTTP2_CLIENT_DLOG << "Http2ClientTransport::CloseTransport"; transport_closed_latch_.Set(); - // This is the only place where the general_party_ is - // reset. + settings_->HandleTransportShutdown(event_engine_.get()); + + MutexLock lock(&transport_mutex_); + // This is the only place where the general_party_ is reset. general_party_.reset(); } @@ -1153,16 +1718,15 @@ void Http2ClientTransport::MaybeSpawnCloseTransport(Http2Status http2_status, absl::flat_hash_map> stream_list = std::move(stream_list_); stream_list_.clear(); - state_tracker_.SetState(GRPC_CHANNEL_SHUTDOWN, - http2_status.GetAbslConnectionError(), - "transport closed"); + ReportDisconnectionLocked( + http2_status.GetAbslConnectionError(), {}, + absl::StrCat("Transport closed: ", http2_status.DebugString()).c_str()); lock.Release(); - general_party_->Spawn( - "CloseTransport", - [self = RefAsSubclass(), - stream_list = std::move(stream_list), - http2_status = std::move(http2_status)]() mutable { + SpawnInfallibleTransportParty( + "CloseTransport", [self = RefAsSubclass(), + stream_list = std::move(stream_list), + http2_status = std::move(http2_status)]() mutable { GRPC_HTTP2_CLIENT_DLOG << "Http2ClientTransport::CloseTransport Cleaning up call stacks"; // Clean up the call stacks for all active streams. @@ -1172,8 +1736,8 @@ void Http2ClientTransport::MaybeSpawnCloseTransport(Http2Status http2_status, // fail. Also, as this is running on the transport // party, there would not be concurrent access to the stream. auto& stream = pair.second; - self->BeginCloseStream(stream->stream_id, - Http2ErrorCodeToRstFrameErrorCode( + self->BeginCloseStream(stream, + Http2ErrorCodeToFrameErrorCode( http2_status.GetConnectionErrorCode()), CancelledServerMetadataFromStatus( http2_status.GetAbslConnectionError())); @@ -1183,38 +1747,115 @@ void Http2ClientTransport::MaybeSpawnCloseTransport(Http2Status http2_status, // the connection; a receiver of a GOAWAY that has no more use for the // connection SHOULD still send a GOAWAY frame before terminating the // connection. - // TODO(akshitpatel) : [PH2][P2] : There would a timer for sending - // goaway here. Once goaway is sent or timer is expired, close the - // transport. - return Map(Immediate(absl::OkStatus()), - [self](GRPC_UNUSED absl::Status) mutable { - self->CloseTransport(); - return Empty{}; - }); - }, - [](Empty) {}); + return Map( + // TODO(akshitpatel) : [PH2][P4] : This is creating a copy of + // the debug data. Verify if this is causing a performance + // issue. + Race(AssertResultType( + self->goaway_manager_.RequestGoaway( + http2_status.GetConnectionErrorCode(), + /*debug_data=*/ + Slice::FromCopiedString( + http2_status.GetAbslConnectionError().message()), + kLastIncomingStreamIdClient, /*immediate=*/true)), + // Failsafe to close the transport if goaway is not + // sent within kGoawaySendTimeoutSeconds seconds. + Sleep(Duration::Seconds(kGoawaySendTimeoutSeconds))), + [self](auto) mutable { + self->CloseTransport(); + return Empty{}; + }); + ; + }); +} + +bool Http2ClientTransport::CanCloseTransportLocked() const { + // If there are no more streams and next stream id is greater than the + // max allowed stream id, then no more streams can be created and it is + // safe to close the transport. + GRPC_HTTP2_CLIENT_DLOG << "Http2ClientTransport::CanCloseTransportLocked " + "GetActiveStreamCountLocked=" + << GetActiveStreamCountLocked() + << " PeekNextStreamId=" << PeekNextStreamId() + << " GetMaxAllowedStreamId=" + << GetMaxAllowedStreamId(); + return GetActiveStreamCountLocked() == 0 && + PeekNextStreamId() > GetMaxAllowedStreamId(); } Http2ClientTransport::~Http2ClientTransport() { GRPC_HTTP2_CLIENT_DLOG << "Http2ClientTransport Destructor Begin"; GRPC_DCHECK(stream_list_.empty()); + GRPC_DCHECK(general_party_ == nullptr); memory_owner_.Reset(); - SourceDestructing(); GRPC_HTTP2_CLIENT_DLOG << "Http2ClientTransport Destructor End"; } +void Http2ClientTransport::SpawnAddChannelzData(RefCountedPtr party, + channelz::DataSink sink) { + SpawnInfallible( + std::move(party), "AddData", + [self = RefAsSubclass(), + sink = std::move(sink)]() mutable { + GRPC_HTTP2_CLIENT_DLOG << "Http2ClientTransport::AddData Promise"; + sink.AddData( + "Http2ClientTransport", + channelz::PropertyList() + .Set("keepalive_time", self->keepalive_time_) + .Set("keepalive_permit_without_calls", + self->keepalive_permit_without_calls_) + .Set("settings", self->settings_->ChannelzProperties()) + .Set("flow_control", + self->flow_control_.stats().ChannelzProperties())); + self->general_party_->ExportToChannelz("Http2ClientTransport Party", + sink); + GRPC_HTTP2_CLIENT_DLOG << "Http2ClientTransport::AddData End"; + return Empty{}; + }); +} + void Http2ClientTransport::AddData(channelz::DataSink sink) { - sink.AddData( - "Http2ClientTransport", - channelz::PropertyList() - .Set("settings", settings_.ChannelzProperties()) - .Set("keepalive_time", keepalive_time_) - .Set("keepalive_timeout", keepalive_timeout_) - .Set("ping_timeout", ping_timeout_) - .Set("keepalive_permit_without_calls", - keepalive_permit_without_calls_) - .Set("flow_control", flow_control_.stats().ChannelzProperties())); - general_party_->ExportToChannelz("Http2ClientTransport Party", sink); + GRPC_HTTP2_CLIENT_DLOG << "Http2ClientTransport::AddData Begin"; + + event_engine_->Run([self = RefAsSubclass(), + sink = std::move(sink)]() mutable { + bool is_party_null = false; + { + // Apart from CloseTransport, this is the only place where a lock is taken + // to access general_party_. All other access to general_party_ happens + // on the general party itself and hence do not race with CloseTransport. + // TODO(akshitpatel) : [PH2][P4] : Check if a new mutex is needed to + // protect general_party_. Curently transport_mutex_ can is used in + // these places: + // 1. In promises running on the transport party + // 2. In AddData promise + // 3. In Orphan function. + // 4. Stream creation (this will be removed soon). + // Given that #1 is already serialized (guaranteed by party), #2 is on + // demand and #3 happens once for the lifetime of the transport while + // closing the transport, the contention should be minimal. + MutexLock lock(&self->transport_mutex_); + // TODO(akshitpatel) : [PH2][P2] : There is still a potential for a race + // here where the general_party_ is reset between the lock being + // released and the spawn. We cannot just do a spawn inside the mutex as + // that may result in deadlock. + // Potential fix to hold a ref to the party inside the mutex and do a + // spawn outside the mutex. The only side effect is that this introduces + // an additional ref to the party other the transport's copy. + if (GPR_UNLIKELY(self->general_party_ == nullptr)) { + is_party_null = true; + GRPC_HTTP2_CLIENT_DLOG + << "Http2ClientTransport::AddData general_party_ is " + "null. Transport is closed."; + } + } + + ExecCtx exec_ctx; + if (!is_party_null) { + self->SpawnAddChannelzData(self->general_party_, std::move(sink)); + } + self.reset(); // Cleanup with exec_ctx in scope + }); } /////////////////////////////////////////////////////////////////////////////// @@ -1240,7 +1881,7 @@ bool Http2ClientTransport::SetOnDone(CallHandler call_handler, GRPC_HTTP2_CLIENT_DLOG << "PH2: Client call " << self.get() << " id=" << stream_id << " done: cancelled=" << cancelled; - absl::StatusOr enqueue_result; + absl::StatusOr enqueue_result; GRPC_HTTP2_CLIENT_DLOG << "PH2: Client call " << self.get() << " id=" << stream_id << " done: stream=" << stream.get() << " cancelled=" << cancelled; @@ -1262,6 +1903,12 @@ bool Http2ClientTransport::SetOnDone(CallHandler call_handler, } if (enqueue_result.ok()) { + GRPC_HTTP2_CLIENT_DLOG + << "Http2ClientTransport::SetOnDone " + "MaybeAddStreamToWritableStreamList for stream= " + << stream->GetStreamId() << " enqueue_result={became_writable=" + << enqueue_result.value().became_writable << ", priority=" + << static_cast(enqueue_result.value().priority) << "}"; GRPC_UNUSED absl::Status status = self->MaybeAddStreamToWritableStreamList(stream, enqueue_result.value()); @@ -1270,38 +1917,63 @@ bool Http2ClientTransport::SetOnDone(CallHandler call_handler, } std::optional> Http2ClientTransport::MakeStream( - CallHandler call_handler, const uint32_t stream_id) { + CallHandler call_handler) { // https://datatracker.ietf.org/doc/html/rfc9113#name-stream-identifiers - // TODO(tjagtap) : [PH2][P2] Validate implementation. - - // TODO(akshitpatel) : [PH2][P1] : Probably do not need this lock. This - // function is always called under the stream_id_mutex_. The issue is the - // OnDone needs to be synchronous and hence InterActivityMutex might not be - // an option to protect the stream_list_. - MutexLock lock(&transport_mutex_); - RefCountedPtr stream = MakeRefCounted( - call_handler, stream_id, settings_.peer().allow_true_binary_metadata(), - settings_.acked().allow_true_binary_metadata(), flow_control_); + RefCountedPtr stream; + { + // TODO(akshitpatel) : [PH2][P3] : Remove this mutex once settings is in + // place. + MutexLock lock(&transport_mutex_); + stream = MakeRefCounted(call_handler, flow_control_); + } const bool on_done_added = SetOnDone(call_handler, stream); if (!on_done_added) return std::nullopt; - stream_list_.emplace(stream_id, stream); return stream; } +uint32_t Http2ClientTransport::GetMaxAllowedStreamId() const { + GRPC_HTTP2_CLIENT_DLOG << "Http2ClientTransport GetMaxAllowedStreamId " + << max_allowed_stream_id_; + return max_allowed_stream_id_; +} + +void Http2ClientTransport::SetMaxAllowedStreamId( + const uint32_t max_allowed_stream_id) { + const uint32_t old_max_allowed_stream_id = GetMaxAllowedStreamId(); + GRPC_HTTP2_CLIENT_DLOG << "Http2ClientTransport SetMaxAllowedStreamId " + << " max_allowed_stream_id: " << max_allowed_stream_id + << " old_allowed_max_stream_id: " + << old_max_allowed_stream_id; + // RFC9113 : Endpoints MUST NOT increase the value they send in the last + // stream identifier, since the peers might already have retried unprocessed + // requests on another connection. + if (GPR_LIKELY(max_allowed_stream_id <= old_max_allowed_stream_id)) { + max_allowed_stream_id_ = max_allowed_stream_id; + } else { + LOG_IF(ERROR, max_allowed_stream_id > old_max_allowed_stream_id) + << "Endpoints MUST NOT increase the value they send in the last " + "stream " + "identifier"; + GRPC_DCHECK_LE(max_allowed_stream_id, old_max_allowed_stream_id) + << "Endpoints MUST NOT increase the value they send in the last " + "stream " + "identifier"; + } +} + /////////////////////////////////////////////////////////////////////////////// // Call Spine related operations -auto Http2ClientTransport::CallOutboundLoop( - CallHandler call_handler, RefCountedPtr stream, - InterActivityMutex::Lock lock /* Locked stream_id_mutex */, - ClientMetadataHandle metadata) { +auto Http2ClientTransport::CallOutboundLoop(CallHandler call_handler, + RefCountedPtr stream, + ClientMetadataHandle metadata) { GRPC_HTTP2_CLIENT_DLOG << "Http2ClientTransport CallOutboundLoop"; GRPC_DCHECK(stream != nullptr); auto send_message = [self = RefAsSubclass(), stream](MessageHandle&& message) mutable { return TrySeq(stream->EnqueueMessage(std::move(message)), - [self, stream](const EnqueueResult result) mutable { + [self, stream](const StreamWritabilityUpdate result) mutable { GRPC_HTTP2_CLIENT_DLOG << "Http2ClientTransport CallOutboundLoop " "Enqueued Message"; @@ -1317,7 +1989,7 @@ auto Http2ClientTransport::CallOutboundLoop( [stream, metadata = std::move(metadata)]() mutable { return stream->EnqueueInitialMetadata(std::move(metadata)); }, - [self, stream](const EnqueueResult result) mutable { + [self, stream](const StreamWritabilityUpdate result) mutable { GRPC_HTTP2_CLIENT_DLOG << "Http2ClientTransport CallOutboundLoop " "Enqueued Initial Metadata"; return self->MaybeAddStreamToWritableStreamList(std::move(stream), @@ -1328,7 +2000,7 @@ auto Http2ClientTransport::CallOutboundLoop( auto send_half_closed = [self = RefAsSubclass(), stream]() mutable { return TrySeq([stream]() { return stream->EnqueueHalfClosed(); }, - [self, stream](const EnqueueResult result) mutable { + [self, stream](const StreamWritabilityUpdate result) mutable { GRPC_HTTP2_CLIENT_DLOG << "Http2ClientTransport CallOutboundLoop " "Enqueued Half Closed"; @@ -1340,7 +2012,7 @@ auto Http2ClientTransport::CallOutboundLoop( "Ph2CallOutboundLoop", TrySeq( send_initial_metadata(), - [call_handler, send_message, lock = std::move(lock)]() { + [call_handler, send_message]() { // The lock will be released once the promise is constructed from // this factory. ForEach will be polled after the lock is // released. @@ -1365,44 +2037,38 @@ void Http2ClientTransport::StartCall(CallHandler call_handler) { GRPC_HTTP2_CLIENT_DLOG << "Http2ClientTransport StartCall Begin"; call_handler.SpawnGuarded( "OutboundLoop", - TrySeq( - call_handler.PullClientInitialMetadata(), - [self = RefAsSubclass()]( - ClientMetadataHandle metadata) { - // Lock the stream_id_mutex_ - return Staple(self->stream_id_mutex_.Acquire(), - std::move(metadata)); - }, - [self = RefAsSubclass(), - call_handler](auto args /* Locked stream_id_mutex */) mutable { - // For a gRPC Client, we only need to check the - // MAX_CONCURRENT_STREAMS setting compliance at the time of - // sending (that is write path). A gRPC Client will never - // receive a stream initiated by a server, so we dont have to - // check MAX_CONCURRENT_STREAMS compliance on the Read-Path. - // - // TODO(tjagtap) : [PH2][P1] Check for MAX_CONCURRENT_STREAMS - // sent by peer before making a stream. Decide behaviour if we are - // crossing this threshold. - // - // TODO(tjagtap) : [PH2][P1] : For a server we will have to do - // this for incoming streams only. If a server receives more streams - // from a client than is allowed by the clients settings, whether or - // not we should fail is debatable. - const uint32_t stream_id = self->NextStreamId(std::get<0>(args)); - std::optional> stream = - self->MakeStream(call_handler, stream_id); - return If( - stream.has_value(), - [self, call_handler, stream, args = std::move(args)]() mutable { - return Map( - self->CallOutboundLoop(call_handler, stream.value(), - std::move(std::get<0>(args)), - std::move(std::get<1>(args))), - [](absl::Status status) { return status; }); - }, - []() { return absl::InternalError("Failed to make stream"); }); - })); + TrySeq(call_handler.PullClientInitialMetadata(), + [self = RefAsSubclass(), + call_handler](ClientMetadataHandle metadata) mutable { + // For a gRPC Client, we only need to check the + // MAX_CONCURRENT_STREAMS setting compliance at the time of + // sending (that is write path). A gRPC Client will never + // receive a stream initiated by a server, so we dont have to + // check MAX_CONCURRENT_STREAMS compliance on the Read-Path. + // + // TODO(tjagtap) : [PH2][P1] Check for MAX_CONCURRENT_STREAMS + // sent by peer before making a stream. Decide behaviour if we + // are crossing this threshold. + // + // TODO(tjagtap) : [PH2][P1] : For a server we will have to do + // this for incoming streams only. If a server receives more + // streams from a client than is allowed by the clients settings, + // whether or not we should fail is debatable. + std::optional> stream = + self->MakeStream(call_handler); + return If( + stream.has_value(), + [self, call_handler, stream, + initial_metadata = std::move(metadata)]() mutable { + return Map( + self->CallOutboundLoop(call_handler, stream.value(), + std::move(initial_metadata)), + [](absl::Status status) { return status; }); + }, + []() { + return absl::InternalError("Failed to make stream"); + }); + })); GRPC_HTTP2_CLIENT_DLOG << "Http2ClientTransport StartCall End"; } diff --git a/deps/grpc/src/core/ext/transport/chttp2/transport/http2_client_transport.h b/deps/grpc/src/core/ext/transport/chttp2/transport/http2_client_transport.h index 16f48e94569..b65ec1eec80 100644 --- a/deps/grpc/src/core/ext/transport/chttp2/transport/http2_client_transport.h +++ b/deps/grpc/src/core/ext/transport/chttp2/transport/http2_client_transport.h @@ -19,59 +19,75 @@ #ifndef GRPC_SRC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_HTTP2_CLIENT_TRANSPORT_H #define GRPC_SRC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_HTTP2_CLIENT_TRANSPORT_H +#include +#include #include +#include #include +#include +#include +#include #include +#include #include "src/core/call/call_spine.h" +#include "src/core/call/metadata.h" +#include "src/core/channelz/channelz.h" #include "src/core/ext/transport/chttp2/transport/flow_control.h" -#include "src/core/ext/transport/chttp2/transport/flow_control_manager.h" #include "src/core/ext/transport/chttp2/transport/frame.h" -#include "src/core/ext/transport/chttp2/transport/header_assembler.h" +#include "src/core/ext/transport/chttp2/transport/goaway.h" #include "src/core/ext/transport/chttp2/transport/hpack_encoder.h" #include "src/core/ext/transport/chttp2/transport/hpack_parser.h" -#include "src/core/ext/transport/chttp2/transport/http2_settings_manager.h" #include "src/core/ext/transport/chttp2/transport/http2_settings_promises.h" #include "src/core/ext/transport/chttp2/transport/http2_status.h" #include "src/core/ext/transport/chttp2/transport/http2_transport.h" #include "src/core/ext/transport/chttp2/transport/http2_ztrace_collector.h" +#include "src/core/ext/transport/chttp2/transport/incoming_metadata_tracker.h" #include "src/core/ext/transport/chttp2/transport/keepalive.h" -#include "src/core/ext/transport/chttp2/transport/message_assembler.h" #include "src/core/ext/transport/chttp2/transport/ping_promise.h" #include "src/core/ext/transport/chttp2/transport/stream.h" +#include "src/core/ext/transport/chttp2/transport/stream_data_queue.h" #include "src/core/ext/transport/chttp2/transport/writable_streams.h" -#include "src/core/lib/promise/inter_activity_mutex.h" -#include "src/core/lib/promise/loop.h" -#include "src/core/lib/promise/mpsc.h" +#include "src/core/lib/channel/channel_args.h" +#include "src/core/lib/iomgr/closure.h" +#include "src/core/lib/iomgr/iomgr_fwd.h" +#include "src/core/lib/promise/activity.h" +#include "src/core/lib/promise/context.h" +#include "src/core/lib/promise/if.h" +#include "src/core/lib/promise/latch.h" +#include "src/core/lib/promise/map.h" #include "src/core/lib/promise/party.h" +#include "src/core/lib/promise/poll.h" +#include "src/core/lib/promise/promise.h" +#include "src/core/lib/promise/race.h" +#include "src/core/lib/promise/try_seq.h" #include "src/core/lib/resource_quota/memory_quota.h" +#include "src/core/lib/slice/slice.h" +#include "src/core/lib/slice/slice_buffer.h" #include "src/core/lib/transport/connectivity_state.h" #include "src/core/lib/transport/promise_endpoint.h" #include "src/core/lib/transport/transport.h" +#include "src/core/util/check_class_size.h" +#include "src/core/util/debug_location.h" +#include "src/core/util/grpc_check.h" #include "src/core/util/orphanable.h" #include "src/core/util/ref_counted_ptr.h" #include "src/core/util/sync.h" +#include "src/core/util/time.h" +#include "absl/base/thread_annotations.h" +#include "absl/container/flat_hash_map.h" +#include "absl/container/flat_hash_set.h" +#include "absl/functional/any_invocable.h" +#include "absl/log/log.h" +#include "absl/status/status.h" +#include "absl/status/statusor.h" +#include "absl/strings/string_view.h" +#include "absl/types/span.h" namespace grpc_core { namespace http2 { -// All Promise Based HTTP2 Transport TODOs have the tag -// [PH2][Pn] where n = 0 to 5. -// This helps to maintain the uniformity for quick lookup and fixing. -// -// [PH2][P0] MUST be fixed before the current PR is submitted. -// [PH2][P1] MUST be fixed before the current sub-project is considered -// complete. -// [PH2][P2] MUST be fixed before the current Milestone is considered -// complete. -// [PH2][P3] MUST be fixed before Milestone 3 is considered complete. -// [PH2][P4] Can be fixed after roll out begins. Evaluate these during -// Milestone 4. Either do the TODOs or delete them. -// [PH2][P5] This MUST be a separate standalone project. -// [PH2][EXT] This is a TODO related to a project unrelated to PH2 but happening -// in parallel. - // Http2 Client Transport Spawns Overview // | Promise Spawn | Max Duration | Promise Resolution | Max Spawns | @@ -85,23 +101,21 @@ namespace http2 { // Max Party Slots (Always): 3 // Max Promise Slots (Worst Case): 4 -// Experimental : This is just the initial skeleton of class -// and it is functions. The code will be written iteratively. +// Experimental : The code will be written iteratively. // Do not use or edit any of these functions unless you are // familiar with the PH2 project (Moving chttp2 to promises.) // TODO(tjagtap) : [PH2][P3] : Update the experimental status of the code before // http2 rollout begins. class Http2ClientTransport final : public ClientTransport, public channelz::DataSource { - // TODO(tjagtap) : [PH2][P3] Move the definitions to the header for better - // inlining. For now definitions are in the cc file to - // reduce cognitive load in the header. + // TODO(akshitpatel) [PH2][P1] : Functions that need a mutex to be held should + // have "locked" suffix in function name. public: Http2ClientTransport( PromiseEndpoint endpoint, GRPC_UNUSED const ChannelArgs& channel_args, std::shared_ptr event_engine, - grpc_closure* on_receive_settings); + absl::AnyInvocable)> on_receive_settings); Http2ClientTransport(const Http2ClientTransport&) = delete; Http2ClientTransport& operator=(const Http2ClientTransport&) = delete; @@ -128,8 +142,10 @@ class Http2ClientTransport final : public ClientTransport, OrphanablePtr watcher); void StopConnectivityWatch(ConnectivityStateWatcherInterface* watcher); + void StartWatch(RefCountedPtr watcher) override; + void StopWatch(RefCountedPtr watcher) override; + void Orphan() override; - void AbortWithError(); RefCountedPtr GetSocketNode() const override { return const_cast( @@ -143,6 +159,8 @@ class Http2ClientTransport final : public ClientTransport, } void AddData(channelz::DataSink sink) override; + void SpawnAddChannelzData(RefCountedPtr party, + channelz::DataSink sink); auto TestOnlyTriggerWriteCycle() { return Immediate(writable_stream_list_.ForceReadyForWrite()); @@ -150,12 +168,12 @@ class Http2ClientTransport final : public ClientTransport, auto TestOnlySendPing(absl::AnyInvocable on_initiate, bool important = false) { - return ping_manager_.RequestPing(std::move(on_initiate), important); + return ping_manager_->RequestPing(std::move(on_initiate), important); } template - auto TestOnlySpawnPromise(absl::string_view name, Factory factory) { - return general_party_->Spawn(name, std::move(factory), [](auto) {}); + void TestOnlySpawnPromise(absl::string_view name, Factory&& factory) { + general_party_->Spawn(name, std::forward(factory), [](Empty) {}); } int64_t TestOnlyTransportFlowControlWindow() { @@ -173,6 +191,7 @@ class Http2ClientTransport final : public ClientTransport, bool AreTransportFlowControlTokensAvailable() { return flow_control_.remote_window() > 0; } + void SpawnTransportLoops(); private: // Promise factory for processing each type of frame @@ -199,26 +218,16 @@ class Http2ClientTransport final : public ClientTransport, // Returns a promise that will process one HTTP2 frame. auto ProcessOneFrame(Http2Frame frame); - // Returns a promise that will do the cleanup after the ReadLoop ends. - auto OnReadLoopEnded(); - // Writing to the endpoint. // Write time sensitive control frames to the endpoint. Frames sent from here - // will be: - // 1. SETTINGS - This is first because for a new connection, SETTINGS MUST be - // the first frame to be written onto a connection as per - // RFC9113. - // 2. GOAWAY - This is second because if this is the final GoAway, then we may - // not need to send anything else to the peer. - // 3. PING and PING acks. - // 4. WINDOW_UPDATE - // 5. Custom gRPC security frame + // will be GOAWAY, SETTINGS, PING and PING acks, WINDOW_UPDATE and + // Custom gRPC security frame. // These frames are written to the endpoint in a single endpoint write. If any // module needs to take action after the write (for cases like spawning // timeout promises), they MUST plug the call in the // NotifyControlFramesWriteDone. - auto WriteControlFrames(); + auto ProcessAndWriteControlFrames(); // Notify the control frames modules that the endpoint write is done. void NotifyControlFramesWriteDone(); @@ -227,37 +236,71 @@ class Http2ClientTransport final : public ClientTransport, // the writable streams and write to the endpoint. auto MultiplexerLoop(); - // Returns a promise that will do the cleanup after the MultiplexerLoop - // ends. - auto OnMultiplexerLoopEnded(); - // Returns a promise to fetch data from the callhandler and pass it further // down towards the endpoint. auto CallOutboundLoop(CallHandler call_handler, RefCountedPtr stream, - InterActivityMutex::Lock lock, ClientMetadataHandle metadata); + // TODO(akshitpatel) : [PH2][P1] : Make this a synchronous function. // Force triggers a transport write cycle auto TriggerWriteCycle() { return Immediate(writable_stream_list_.ForceReadyForWrite()); } + auto FlowControlPeriodicUpdateLoop(); + // TODO(tjagtap) [PH2][P2][BDP] Remove this when the BDP code is done. + void AddPeriodicUpdatePromiseWaker() { + periodic_updates_waker_ = GetContext()->MakeNonOwningWaker(); + } + // TODO(tjagtap) [PH2][P2][BDP] Remove this when the BDP code is done. + void WakeupPeriodicUpdatePromise() { periodic_updates_waker_.Wakeup(); } + // Processes the flow control action and take necessary steps. void ActOnFlowControlAction(const chttp2::FlowControlAction& action, - uint32_t stream_id); + RefCountedPtr stream); + + void NotifyStateWatcherOnDisconnectLocked( + absl::Status status, StateWatcher::DisconnectInfo disconnect_info) + ABSL_EXCLUSIVE_LOCKS_REQUIRED(&transport_mutex_); RefCountedPtr general_party_; + std::shared_ptr event_engine_; PromiseEndpoint endpoint_; - Http2SettingsManager settings_; - SettingsTimeoutManager transport_settings_; + RefCountedPtr settings_; Http2FrameHeader current_frame_header_; + // Returns the number of active streams. A stream is removed from the `active` + // list once both client and server agree to close the stream. The count of + // stream_list_(even though stream list represents streams open for reads) + // works here because of the following cases where the stream is closed: + // 1. Reading a RST stream frame: In this case, the stream is immediately + // closed for reads and writes and removed from the stream_list_ + // (effectively tracking the number of active streams). + // 2. Reading a Trailing Metadata frame: In this case, the stream MAY be + // closed for reads and writes immediately which follows the above case. In + // other cases, the transport either reads RST stream frame from the server + // (and follows case 1) or sends a half close frame and closes the stream + // for reads and writes (in the multiplexer loop). + // 3. Hitting error condition in the transport: In this case, RST stream is + // is enqueued and the stream is closed for reads immediately. This means + // we effectively reduce the number of active streams inline (because we + // remove the stream from the stream_list_). This is fine because the + // priority logic in list of writable streams ensures that the RST stream + // frame is given priority over any new streams being created by the + // client. + // 4. Application abort: In this case, multiplexer loop will write RST stream + // frame to the endpoint and close the stream from reads and writes. This + // then follows the same reasoning as case 1. + inline uint32_t GetActiveStreamCountLocked() const + ABSL_EXCLUSIVE_LOCKS_REQUIRED(transport_mutex_) { + return stream_list_.size(); + } - uint32_t NextStreamId( - InterActivityMutex::Lock& next_stream_id_lock) { - const uint32_t stream_id = *next_stream_id_lock; - if (stream_id > RFC9113::kMaxStreamId31Bit) { + // Returns the next stream id. If the next stream id is not available, it + // returns std::nullopt. MUST be called from the transport party. + absl::StatusOr NextStreamId() { + if (next_stream_id_ > GetMaxAllowedStreamId()) { // TODO(tjagtap) : [PH2][P3] : Handle case if transport runs out of stream // ids // RFC9113 : Stream identifiers cannot be reused. Long-lived connections @@ -267,22 +310,53 @@ class Http2ClientTransport final : public ClientTransport, // that is unable to establish a new stream identifier can send a GOAWAY // frame so that the client is forced to open a new connection for new // streams. + return absl::ResourceExhaustedError("No more stream ids available"); } + // TODO(akshitpatel) : [PH2][P3] : There is a channel arg to delay + // starting new streams instead of failing them. This needs to be + // implemented. + { + MutexLock lock(&transport_mutex_); + if (GetActiveStreamCountLocked() >= + settings_->peer().max_concurrent_streams()) { + return absl::ResourceExhaustedError("Reached max concurrent streams"); + } + } + // RFC9113 : Streams initiated by a client MUST use odd-numbered stream // identifiers. - (*next_stream_id_lock) += 2; - return stream_id; + uint32_t new_stream_id = + std::exchange(next_stream_id_, next_stream_id_ + 2); + if (GPR_UNLIKELY(next_stream_id_ > GetMaxAllowedStreamId())) { + ReportDisconnection( + absl::ResourceExhaustedError("Transport Stream IDs exhausted"), + {}, // TODO(tjagtap) : [PH2][P2] : Report better disconnect info. + "no_more_stream_ids"); + } + return new_stream_id; } + // Returns the next stream id without incrementing it. MUST be called from the + // transport party. + uint32_t PeekNextStreamId() const { return next_stream_id_; } + + // Returns the last stream id sent by the transport. If no streams were sent, + // returns 0. MUST be called from the transport party. + uint32_t GetLastStreamId() const { + const uint32_t next_stream_id = PeekNextStreamId(); + return (next_stream_id > 1) ? (next_stream_id - 2) : 0; + } + + absl::Status InitializeStream(RefCountedPtr stream); + + void AddToStreamList(RefCountedPtr stream); + Mutex transport_mutex_; - // TODO(tjagtap) : [PH2][P2] : Add to map in StartCall and clean this - // mapping up in the on_done of the CallInitiator or CallHandler + absl::flat_hash_map> stream_list_ ABSL_GUARDED_BY(transport_mutex_); - // Mutex to preserve the order of headers being sent out for new streams. - // This also tracks the stream_id for creating new streams. - InterActivityMutex stream_id_mutex_; + uint32_t next_stream_id_; HPackCompressor encoder_; HPackParser parser_; bool is_transport_closed_ ABSL_GUARDED_BY(transport_mutex_) = false; @@ -298,78 +372,47 @@ class Http2ClientTransport final : public ClientTransport, std::move(promise)); } + // Spawns an infallible promise on the given party. + template + void SpawnInfallible(RefCountedPtr party, absl::string_view name, + Factory&& factory); + + // Spawns an infallible promise on the transport party. + template + void SpawnInfallibleTransportParty(absl::string_view name, Factory&& factory); + + // Spawns a promise on the transport party. If the promise returns a non-ok + // status, it is handled by closing the transport with the corresponding + // status. + template + void SpawnGuardedTransportParty(absl::string_view name, Factory&& factory); + ConnectivityStateTracker state_tracker_ ABSL_GUARDED_BY(transport_mutex_){ "http2_client", GRPC_CHANNEL_READY}; - std::optional> MakeStream(CallHandler call_handler, - uint32_t stream_id); + RefCountedPtr watcher_ ABSL_GUARDED_BY(transport_mutex_); - struct CloseStreamArgs { - bool close_reads; - bool close_writes; - }; + // Runs on the call party. + std::optional> MakeStream(CallHandler call_handler); // This function MUST be idempotent. void CloseStream(RefCountedPtr stream, CloseStreamArgs args, DebugLocation whence = {}); - void BeginCloseStream(uint32_t stream_id, + void BeginCloseStream(RefCountedPtr stream, std::optional reset_stream_error_code, ServerMetadataHandle&& metadata, DebugLocation whence = {}); RefCountedPtr LookupStream(uint32_t stream_id); - auto EndpointReadSlice(const size_t num_bytes) { - return Map(endpoint_.ReadSlice(num_bytes), - [self = RefAsSubclass(), - num_bytes](absl::StatusOr status) { - if (status.ok()) { - self->keepalive_manager_.GotData(); - self->ztrace_collector_->Append( - PromiseEndpointReadTrace{num_bytes}); - } - return status; - }); - } + auto EndpointReadSlice(const size_t num_bytes); + auto EndpointRead(const size_t num_bytes); // HTTP2 Settings - void MarkPeerSettingsResolved() { - settings_.SetPreviousSettingsPromiseResolved(true); - } - auto WaitForSettingsTimeoutDone() { - return [self = RefAsSubclass()](absl::Status status) { - if (!status.ok()) { - GRPC_UNUSED absl::Status result = self->HandleError( - std::nullopt, Http2Status::Http2ConnectionError( - Http2ErrorCode::kProtocolError, - std::string(RFC9113::kSettingsTimeout))); - } else { - self->MarkPeerSettingsResolved(); - } - }; - } - // TODO(tjagtap) : [PH2][P1] : Plumbing. Call this after the SETTINGS frame - // has been written to endpoint_. - void SpawnWaitForSettingsTimeout() { - settings_.SetPreviousSettingsPromiseResolved(false); - general_party_->Spawn("WaitForSettingsTimeout", - transport_settings_.WaitForSettingsTimeout(), - WaitForSettingsTimeoutDone()); - } - - auto EndpointRead(const size_t num_bytes) { - return Map(endpoint_.Read(num_bytes), - [self = RefAsSubclass(), - num_bytes](absl::StatusOr status) { - if (status.ok()) { - self->keepalive_manager_.GotData(); - self->ztrace_collector_->Append( - PromiseEndpointReadTrace{num_bytes}); - } - return status; - }); - } + auto WaitForSettingsTimeoutOnDone(); + void MaybeSpawnWaitForSettingsTimeout(); + void EnforceLatestIncomingSettings(); // This function MUST run on the transport party. void CloseTransport(); @@ -388,18 +431,22 @@ class Http2ClientTransport final : public ClientTransport, absl::Status HandleError(const std::optional stream_id, Http2Status status, DebugLocation whence = {}) { auto error_type = status.GetType(); - DCHECK(error_type != Http2Status::Http2ErrorType::kOk); + GRPC_DCHECK(error_type != Http2Status::Http2ErrorType::kOk); if (error_type == Http2Status::Http2ErrorType::kStreamError) { - LOG(ERROR) << "Stream Error: " << status.DebugString(); - DCHECK(stream_id.has_value()); + GRPC_HTTP2_CLIENT_ERROR_DLOG << "Stream Error: " << status.DebugString(); + GRPC_DCHECK(stream_id.has_value()); + // Passing a cancelled server metadata handle to propagate the error + // to the upper layers. BeginCloseStream( - *stream_id, - Http2ErrorCodeToRstFrameErrorCode(status.GetStreamErrorCode()), - ServerMetadataFromStatus(status.GetAbslStreamError()), whence); + LookupStream(stream_id.value()), + Http2ErrorCodeToFrameErrorCode(status.GetStreamErrorCode()), + CancelledServerMetadataFromStatus(status.GetAbslStreamError()), + whence); return absl::OkStatus(); } else if (error_type == Http2Status::Http2ErrorType::kConnectionError) { - LOG(ERROR) << "Connection Error: " << status.DebugString(); + GRPC_HTTP2_CLIENT_ERROR_DLOG << "Connection Error: " + << status.DebugString(); absl::Status absl_status = status.GetAbslConnectionError(); MaybeSpawnCloseTransport(std::move(status), whence); return absl_status; @@ -408,13 +455,8 @@ class Http2ClientTransport final : public ClientTransport, } bool should_reset_ping_clock_; - bool incoming_header_in_progress_; - bool incoming_header_end_stream_; bool is_first_write_; - uint32_t incoming_header_stream_id_; - grpc_closure* on_receive_settings_; - - uint32_t max_header_list_size_soft_limit_; + IncomingMetadataTracker incoming_headers_; // The target number of bytes to write in a single write cycle. We may not // always honour this max_write_size. We MAY overshoot it at most once per @@ -436,39 +478,49 @@ class Http2ClientTransport final : public ClientTransport, size_t GetMaxWriteSize() const { return max_write_size_; } auto SerializeAndWrite(std::vector&& frames); + // Tracks the max allowed stream id. Currently this is only set on receiving a + // graceful GOAWAY frame. + uint32_t max_allowed_stream_id_ = RFC9113::kMaxStreamId31Bit; + + uint32_t GetMaxAllowedStreamId() const; + + void SetMaxAllowedStreamId(uint32_t max_allowed_stream_id); + + bool CanCloseTransportLocked() const + ABSL_EXCLUSIVE_LOCKS_REQUIRED(transport_mutex_); // Ping related members - // TODO(akshitpatel) : [PH2][P2] : Consider removing the timeout related - // members. - // Duration between two consecutive keepalive pings - const Duration keepalive_time_; - // Duration to wait for a keepalive ping ack before triggering timeout. This - // only takes effect if the assigned value is less than the ping timeout. - const Duration keepalive_timeout_; - // Duration to wait for ping ack before triggering timeout - const Duration ping_timeout_; - PingManager ping_manager_; - KeepaliveManager keepalive_manager_; + + // Duration between two consecutive keepalive pings. + Duration keepalive_time_; + bool test_only_ack_pings_; + std::optional ping_manager_; + std::optional keepalive_manager_; // Flags bool keepalive_permit_without_calls_; auto SendPing(absl::AnyInvocable on_initiate, bool important) { - return ping_manager_.RequestPing(std::move(on_initiate), important); + return ping_manager_->RequestPing(std::move(on_initiate), important); } - auto WaitForPingAck() { return ping_manager_.WaitForPingAck(); } + auto WaitForPingAck() { return ping_manager_->WaitForPingAck(); } - void MaybeGetSettingsFrame(SliceBuffer& output_buf) { - std::optional settings_frame = settings_.MaybeSendUpdate(); - if (settings_frame.has_value()) { - Serialize(absl::Span(&settings_frame.value(), 1), output_buf); - } - } + void MaybeGetWindowUpdateFrames(SliceBuffer& output_buf); + + void ReportDisconnection(const absl::Status& status, + StateWatcher::DisconnectInfo disconnect_info, + const char* reason); + + void ReportDisconnectionLocked(const absl::Status& status, + StateWatcher::DisconnectInfo disconnect_info, + const char* reason) + ABSL_EXCLUSIVE_LOCKS_REQUIRED(&transport_mutex_); // Ping Helper functions Duration NextAllowedPingInterval() { MutexLock lock(&transport_mutex_); - return (!keepalive_permit_without_calls_ && stream_list_.empty()) + return (!keepalive_permit_without_calls_ && + GetActiveStreamCountLocked() == 0) ? Duration::Hours(2) : Duration::Seconds(1); } @@ -476,7 +528,7 @@ class Http2ClientTransport final : public ClientTransport, auto AckPing(uint64_t opaque_data) { bool valid_ping_ack_received = true; - if (!ping_manager_.AckPing(opaque_data)) { + if (!ping_manager_->AckPing(opaque_data)) { GRPC_HTTP2_CLIENT_DLOG << "Unknown ping response received for ping id=" << opaque_data; valid_ping_ack_received = false; @@ -488,13 +540,10 @@ class Http2ClientTransport final : public ClientTransport, // When this happens, it becomes important to ensure that if a ping ack // is received and there is an "important" outstanding ping request, we // should retry to send it out now. - valid_ping_ack_received && ping_manager_.ImportantPingRequested(), + valid_ping_ack_received && ping_manager_->ImportantPingRequested(), [self = RefAsSubclass()] { return Map(self->TriggerWriteCycle(), [](const absl::Status status) { - return (status.ok()) - ? Http2Status::Ok() - : Http2Status::AbslConnectionError( - status.code(), std::string(status.message())); + return ToHttpOkOrConnError(status); }); }, [] { return Immediate(Http2Status::Ok()); }); @@ -513,9 +562,7 @@ class Http2ClientTransport final : public ClientTransport, } Promise PingTimeout() override { - // TODO(akshitpatel) : [PH2][P2] : Trigger goaway here. - // Returns a promise that resolves once goaway is sent. - LOG(INFO) << "Ping timeout at time: " << Timestamp::Now(); + GRPC_HTTP2_CLIENT_DLOG << "Ping timeout at time: " << Timestamp::Now(); // TODO(akshitpatel) : [PH2][P2] : The error code here has been chosen // based on CHTTP2's usage of GRPC_STATUS_UNAVAILABLE (which corresponds @@ -523,8 +570,9 @@ class Http2ClientTransport final : public ClientTransport, // kRefusedStream doesn't seem to fit this case. We should revisit this // and update the error code. return Immediate(transport_->HandleError( - std::nullopt, Http2Status::Http2ConnectionError( - Http2ErrorCode::kRefusedStream, "Ping timeout"))); + std::nullopt, + Http2Status::Http2ConnectionError(Http2ErrorCode::kRefusedStream, + GRPC_CHTTP2_PING_TIMEOUT_STR))); } private: @@ -554,8 +602,7 @@ class Http2ClientTransport final : public ClientTransport, }); } Promise OnKeepAliveTimeout() override { - // TODO(akshitpatel) : [PH2][P2] : Trigger goaway here. - LOG(INFO) << "Keepalive timeout triggered"; + GRPC_HTTP2_CLIENT_DLOG << "Keepalive timeout triggered"; // TODO(akshitpatel) : [PH2][P2] : The error code here has been chosen // based on CHTTP2's usage of GRPC_STATUS_UNAVAILABLE (which corresponds @@ -563,9 +610,9 @@ class Http2ClientTransport final : public ClientTransport, // kRefusedStream doesn't seem to fit this case. We should revisit this // and update the error code. return Immediate(transport_->HandleError( - std::nullopt, - Http2Status::Http2ConnectionError(Http2ErrorCode::kRefusedStream, - "Keepalive timeout"))); + std::nullopt, Http2Status::Http2ConnectionError( + Http2ErrorCode::kRefusedStream, + GRPC_CHTTP2_KEEPALIVE_TIMEOUT_STR))); } bool NeedToSendKeepAlivePing() override { @@ -573,7 +620,7 @@ class Http2ClientTransport final : public ClientTransport, { MutexLock lock(&transport_->transport_mutex_); need_to_send_ping = (transport_->keepalive_permit_without_calls_ || - !transport_->stream_list_.empty()); + transport_->GetActiveStreamCountLocked() > 0); } return need_to_send_ping; } @@ -585,11 +632,44 @@ class Http2ClientTransport final : public ClientTransport, Http2ClientTransport* transport_; }; + class GoawayInterfaceImpl : public GoawayInterface { + public: + static std::unique_ptr Make( + Http2ClientTransport* transport) { + return std::make_unique( + GoawayInterfaceImpl(transport)); + } + + Promise SendPingAndWaitForAck() override { + return transport_->ping_manager_->RequestPing(/*on_initiate=*/[] {}, + /*important=*/true); + } + + void TriggerWriteCycle() override { transport_->TriggerWriteCycle(); } + + uint32_t GetLastAcceptedStreamId() override { + GRPC_DCHECK(false) + << "GetLastAcceptedStreamId is not implemented for client transport."; + LOG(ERROR) << "GetLastAcceptedStreamId is not implemented for client " + "transport."; + return 0; + } + + private: + explicit GoawayInterfaceImpl(Http2ClientTransport* transport) + : transport_(transport) {} + + Http2ClientTransport* transport_; + }; + + GoawayManager goaway_manager_; + WritableStreams> writable_stream_list_; absl::Status MaybeAddStreamToWritableStreamList( const RefCountedPtr stream, - const StreamDataQueue::EnqueueResult result) { + const StreamDataQueue::StreamWritabilityUpdate + result) { if (result.became_writable) { GRPC_HTTP2_CLIENT_DLOG << "Http2ClientTransport MaybeAddStreamToWritableStreamList " @@ -613,12 +693,22 @@ class Http2ClientTransport final : public ClientTransport, /// Based on channel args, preferred_rx_crypto_frame_sizes are advertised to /// the peer - // TODO(tjagtap) : [PH2][P1] : Plumb this with the necessary frame size flow - // control workflow corresponding to grpc_chttp2_act_on_flowctl_action - GRPC_UNUSED bool enable_preferred_rx_crypto_frame_advertisement_; + bool enable_preferred_rx_crypto_frame_advertisement_; MemoryOwner memory_owner_; chttp2::TransportFlowControl flow_control_; std::shared_ptr ztrace_collector_; + absl::flat_hash_set window_update_list_; + + // TODO(tjagtap) [PH2][P2][BDP] Remove this when the BDP code is done. + Waker periodic_updates_waker_; + + Http2ReadContext reader_state_; + Http2Status ParseAndDiscardHeaders(SliceBuffer&& buffer, bool is_end_headers, + RefCountedPtr stream, + Http2Status&& original_status, + DebugLocation whence = {}); + void ReadChannelArgs(const ChannelArgs& channel_args, + TransportChannelArgs& args); }; // Since the corresponding class in CHTTP2 is about 3.9KB, our goal is to diff --git a/deps/grpc/src/core/ext/transport/chttp2/transport/http2_server_transport.cc b/deps/grpc/src/core/ext/transport/chttp2/transport/http2_server_transport.cc index 09f2f7d0e62..6f44fb7abe9 100644 --- a/deps/grpc/src/core/ext/transport/chttp2/transport/http2_server_transport.cc +++ b/deps/grpc/src/core/ext/transport/chttp2/transport/http2_server_transport.cc @@ -24,8 +24,6 @@ #include #include -#include "absl/log/log.h" -#include "absl/status/status.h" #include "src/core/call/call_destination.h" #include "src/core/ext/transport/chttp2/transport/frame.h" #include "src/core/ext/transport/chttp2/transport/hpack_encoder.h" @@ -44,6 +42,8 @@ #include "src/core/lib/transport/transport.h" #include "src/core/util/grpc_check.h" #include "src/core/util/ref_counted.h" +#include "absl/log/log.h" +#include "absl/status/status.h" namespace grpc_core { namespace http2 { diff --git a/deps/grpc/src/core/ext/transport/chttp2/transport/http2_server_transport.h b/deps/grpc/src/core/ext/transport/chttp2/transport/http2_server_transport.h index 97bad949c07..d24fbff60aa 100644 --- a/deps/grpc/src/core/ext/transport/chttp2/transport/http2_server_transport.h +++ b/deps/grpc/src/core/ext/transport/chttp2/transport/http2_server_transport.h @@ -22,7 +22,6 @@ #include #include -#include "absl/container/flat_hash_map.h" #include "src/core/call/call_destination.h" #include "src/core/call/call_spine.h" #include "src/core/ext/transport/chttp2/transport/frame.h" @@ -34,9 +33,11 @@ #include "src/core/lib/promise/party.h" #include "src/core/lib/transport/promise_endpoint.h" #include "src/core/lib/transport/transport.h" +#include "src/core/util/grpc_check.h" #include "src/core/util/ref_counted.h" #include "src/core/util/ref_counted_ptr.h" #include "src/core/util/sync.h" +#include "absl/container/flat_hash_map.h" namespace grpc_core { namespace http2 { @@ -68,6 +69,15 @@ class Http2ServerTransport final : public ServerTransport { void SetPollset(grpc_stream*, grpc_pollset*) override {} void SetPollsetSet(grpc_stream*, grpc_pollset_set*) override {} + void StartWatch(RefCountedPtr) override { + // TODO(roth): Implement as part of migrating server side to new + // watcher API. + } + void StopWatch(RefCountedPtr) override { + // TODO(roth): Implement as part of migrating server side to new + // watcher API. + } + void SetCallDestination( RefCountedPtr call_destination) override; @@ -157,7 +167,7 @@ class Http2ServerTransport final : public ServerTransport { // corresponding (failed) absl status. absl::Status HandleError(Http2Status status, DebugLocation whence = {}) { auto error_type = status.GetType(); - DCHECK(error_type != Http2Status::Http2ErrorType::kOk); + GRPC_DCHECK(error_type != Http2Status::Http2ErrorType::kOk); if (error_type == Http2Status::Http2ErrorType::kStreamError) { CloseStream(current_frame_header_.stream_id, status.GetAbslStreamError(), diff --git a/deps/grpc/src/core/ext/transport/chttp2/transport/http2_settings.cc b/deps/grpc/src/core/ext/transport/chttp2/transport/http2_settings.cc index 8e7eda6ab18..abc8797a324 100644 --- a/deps/grpc/src/core/ext/transport/chttp2/transport/http2_settings.cc +++ b/deps/grpc/src/core/ext/transport/chttp2/transport/http2_settings.cc @@ -22,9 +22,9 @@ #include -#include "absl/strings/str_cat.h" #include "src/core/ext/transport/chttp2/transport/http2_status.h" #include "src/core/util/useful.h" +#include "absl/strings/str_cat.h" using grpc_core::http2::Http2ErrorCode; diff --git a/deps/grpc/src/core/ext/transport/chttp2/transport/http2_settings.h b/deps/grpc/src/core/ext/transport/chttp2/transport/http2_settings.h index c69167dba11..48c3f98dac1 100644 --- a/deps/grpc/src/core/ext/transport/chttp2/transport/http2_settings.h +++ b/deps/grpc/src/core/ext/transport/chttp2/transport/http2_settings.h @@ -23,11 +23,11 @@ #include #include -#include "absl/functional/function_ref.h" -#include "absl/strings/string_view.h" #include "src/core/channelz/property_list.h" #include "src/core/ext/transport/chttp2/transport/http2_status.h" #include "src/core/util/useful.h" +#include "absl/functional/function_ref.h" +#include "absl/strings/string_view.h" namespace grpc_core { @@ -193,10 +193,12 @@ class Http2Settings { bool enable_push_ = true; // gRPC defined setting - // Unlike most other SETTINGS, this setting is negotiated between the client - // and the server. // Currently this is set only once in the lifetime of a transport. // Disconnect if it is received more than once from the peer. + // Non-Binary Metadata (usually UTF-8) is ALWAYS valid irrespective of this + // flag. Both peers can send each other the default non-binary METADATA + // irrespective of this flag. This flag says if we are willing to accept + // Binary-Metadata from the peer or not. bool allow_true_binary_metadata_ = false; // gRPC defined setting diff --git a/deps/grpc/src/core/ext/transport/chttp2/transport/http2_settings_manager.cc b/deps/grpc/src/core/ext/transport/chttp2/transport/http2_settings_manager.cc index 63bb401743e..00a3cba455d 100644 --- a/deps/grpc/src/core/ext/transport/chttp2/transport/http2_settings_manager.cc +++ b/deps/grpc/src/core/ext/transport/chttp2/transport/http2_settings_manager.cc @@ -22,18 +22,16 @@ #include -#include "absl/strings/str_cat.h" +#include +#include +#include + #include "src/core/ext/transport/chttp2/transport/frame.h" #include "src/core/ext/transport/chttp2/transport/http2_settings.h" -#include "src/core/ext/transport/chttp2/transport/http2_status.h" -#include "src/core/util/useful.h" namespace grpc_core { std::optional Http2SettingsManager::MaybeSendUpdate() { - if (!IsPreviousSettingsPromiseResolved()) { - return std::nullopt; - } switch (update_state_) { case UpdateState::kSending: return std::nullopt; diff --git a/deps/grpc/src/core/ext/transport/chttp2/transport/http2_settings_manager.h b/deps/grpc/src/core/ext/transport/chttp2/transport/http2_settings_manager.h index a5fb61c7461..6acebf76d93 100644 --- a/deps/grpc/src/core/ext/transport/chttp2/transport/http2_settings_manager.h +++ b/deps/grpc/src/core/ext/transport/chttp2/transport/http2_settings_manager.h @@ -22,19 +22,18 @@ #include #include -#include +#include -#include "absl/functional/function_ref.h" -#include "absl/strings/string_view.h" #include "src/core/channelz/property_list.h" #include "src/core/ext/transport/chttp2/transport/frame.h" #include "src/core/ext/transport/chttp2/transport/http2_settings.h" #include "src/core/ext/transport/chttp2/transport/http2_status.h" -#include "src/core/lib/channel/channel_args.h" -#include "src/core/util/useful.h" +#include "absl/strings/string_view.h" namespace grpc_core { +// TODO(tjagtap) [PH2][P1][Settings] : Add new DCHECKs to PH2-Only functions in +// this class. class Http2SettingsManager { public: // Only local and peer settings can be edited by the transport. @@ -55,7 +54,7 @@ class Http2SettingsManager { .SetColumn("acked", acked_.ChannelzProperties()); } - // Returns nullopt if we don't need to send a SETTINGS frame to the peer. + // Returns std::nullopt if we don't need to send a SETTINGS frame to the peer. // Returns Http2SettingsFrame if we need to send a SETTINGS frame to the // peer. Transport MUST send a frame returned by this function to the peer. // This function is not idempotent. @@ -63,7 +62,7 @@ class Http2SettingsManager { // To be called from a promise based HTTP2 transport only http2::Http2ErrorCode ApplyIncomingSettings( - std::vector& settings) { + const std::vector& settings) { for (const auto& setting : settings) { http2::Http2ErrorCode error1 = count_updates_.IsUpdatePermitted(setting.id, setting.value, peer_); @@ -82,13 +81,6 @@ class Http2SettingsManager { // This function is not idempotent. GRPC_MUST_USE_RESULT bool AckLastSend(); - GRPC_MUST_USE_RESULT bool IsPreviousSettingsPromiseResolved() const { - return did_previous_settings_promise_resolve_; - } - void SetPreviousSettingsPromiseResolved(const bool value) { - did_previous_settings_promise_resolve_ = value; - } - private: struct CountUpdates { http2::Http2ErrorCode IsUpdatePermitted(const uint16_t setting_id, @@ -144,8 +136,6 @@ class Http2SettingsManager { Http2Settings local_; Http2Settings sent_; Http2Settings acked_; - - bool did_previous_settings_promise_resolve_ = true; }; } // namespace grpc_core diff --git a/deps/grpc/src/core/ext/transport/chttp2/transport/http2_settings_promises.h b/deps/grpc/src/core/ext/transport/chttp2/transport/http2_settings_promises.h index 9e47c579348..31d29b8da15 100644 --- a/deps/grpc/src/core/ext/transport/chttp2/transport/http2_settings_promises.h +++ b/deps/grpc/src/core/ext/transport/chttp2/transport/http2_settings_promises.h @@ -19,159 +19,397 @@ #ifndef GRPC_SRC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_HTTP2_SETTINGS_PROMISES_H #define GRPC_SRC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_HTTP2_SETTINGS_PROMISES_H +#include #include -#include +#include #include #include -#include +#include +#include +#include -#include "absl/functional/function_ref.h" -#include "absl/strings/string_view.h" #include "src/core/channelz/property_list.h" +#include "src/core/ext/transport/chttp2/transport/flow_control.h" #include "src/core/ext/transport/chttp2/transport/frame.h" #include "src/core/ext/transport/chttp2/transport/http2_settings.h" #include "src/core/ext/transport/chttp2/transport/http2_settings_manager.h" #include "src/core/ext/transport/chttp2/transport/http2_status.h" #include "src/core/lib/channel/channel_args.h" +#include "src/core/lib/iomgr/exec_ctx.h" +#include "src/core/lib/promise/activity.h" +#include "src/core/lib/promise/context.h" +#include "src/core/lib/promise/poll.h" +#include "src/core/lib/promise/promise.h" #include "src/core/lib/promise/race.h" #include "src/core/lib/promise/sleep.h" #include "src/core/lib/promise/try_seq.h" +#include "src/core/lib/slice/slice_buffer.h" #include "src/core/util/grpc_check.h" +#include "src/core/util/ref_counted.h" #include "src/core/util/time.h" -#include "src/core/util/useful.h" +#include "absl/functional/any_invocable.h" +#include "absl/log/log.h" +#include "absl/status/status.h" +#include "absl/status/statusor.h" +#include "absl/strings/str_cat.h" +#include "absl/types/span.h" + namespace grpc_core { // Timeout for getting an ack back on settings changes #define GRPC_ARG_SETTINGS_TIMEOUT "grpc.http2.settings_timeout" -#define GRPC_SETTINGS_TIMEOUT_DLOG DLOG(INFO) +#define GRPC_SETTINGS_TIMEOUT_DLOG \ + DLOG_IF(INFO, GRPC_TRACE_FLAG_ENABLED(http2_ph2_transport)) // This class can only be used only from a promise based HTTP2 transports // general_party_ . // This class is designed with the assumption that only 1 SETTINGS frame will be // in flight at a time. And we do not send a second SETTINGS frame till we -// receive and process the SETTINGS ACK. -class SettingsTimeoutManager { +// receive and process the SETTINGS ACK and resolve the ACK promise. +class SettingsPromiseManager final : public RefCounted { public: + explicit SettingsPromiseManager( + absl::AnyInvocable)> on_receive_settings) + : on_receive_first_settings_(std::move(on_receive_settings)), + state_(SettingsState::kWaitingForFirstPeerSettings) {} + + ~SettingsPromiseManager() override { + GRPC_DCHECK(on_receive_first_settings_ == nullptr); + } + + // Not copyable, movable or assignable. + SettingsPromiseManager(const SettingsPromiseManager&) = delete; + SettingsPromiseManager& operator=(const SettingsPromiseManager&) = delete; + SettingsPromiseManager(SettingsPromiseManager&&) = delete; + SettingsPromiseManager& operator=(SettingsPromiseManager&&) = delete; + + void HandleTransportShutdown( + grpc_event_engine::experimental::EventEngine* event_engine) { + // If some scenario causes the transport to close without ever receiving + // settings, we need to still invoke the closure passed to the transport. + // Additionally, as this function will always run on the transport party, it + // cannot race with reading a settings frame. + // TODO(akshitpatel): [PH2][P4] Pass the actual error that caused the + // transport to be closed here. + MaybeReportInitialSettingsAbort(event_engine); + } + + bool IsFirstPeerSettingsApplied() const { + return state_ == SettingsState::kReady; + } + + ////////////////////////////////////////////////////////////////////////////// + // Functions for SETTINGS being sent from our transport to the peer. + // Assumption : This would be set only once in the life of the transport. - inline void SetSettingsTimeout(const ChannelArgs& channel_args, - const Duration keepalive_timeout) { - timeout_ = - channel_args.GetDurationFromIntMillis(GRPC_ARG_SETTINGS_TIMEOUT) - .value_or(std::max(keepalive_timeout * 2, Duration::Minutes(1))); + inline void SetSettingsTimeout(const Duration timeout) { + GRPC_DCHECK(state_ == SettingsState::kWaitingForFirstPeerSettings); + settings_ack_timeout_ = timeout; } - // To be called when a promise based Transport receives an a SETTINGS ACK - // frame. - inline void OnSettingsAckReceived() { RecordReceivedAck(); } + // Called when transport receives a SETTINGS ACK frame from peer. + // This SETTINGS ACK was sent by peer to confirm receipt of SETTINGS frame + // sent by us. Stop the settings timeout promise. + GRPC_MUST_USE_RESULT bool OnSettingsAckReceived() { + bool is_valid = settings_.AckLastSend(); + if (is_valid) { + RecordReceivedAck(); + } + return is_valid; + } - // This returns a promise which must be spawned on transports general party. - // This must be spawned soon after the transport sends a SETTINGS frame on the - // endpoint. - // If we don't get an ACK before timeout, the caller MUST close the transport. + // Called when our transport enqueues a SETTINGS frame to send to the peer. + // However, the enqueued frames have not yet been written to the endpoint. + void WillSendSettings() { + GRPC_DCHECK(!should_wait_for_settings_ack_); + should_wait_for_settings_ack_ = true; + } + + // Returns true if we should spawn WaitForSettingsTimeout promise. + bool ShouldSpawnWaitForSettingsTimeout() const { + return should_wait_for_settings_ack_; + } + + // This returns a promise which must be spawned on transports general + // party. This must be spawned soon after the transport sends a SETTINGS + // frame on the endpoint. If we don't get an ACK before timeout, the + // caller MUST close the transport. auto WaitForSettingsTimeout() { + did_previous_settings_promise_resolve_ = false; + TimeoutWaiterSpawned(); GRPC_SETTINGS_TIMEOUT_DLOG - << "SettingsTimeoutManager::WaitForSettingsTimeout Factory"; + << "SettingsPromiseManager::WaitForSettingsTimeout Factory timeout_" + << settings_ack_timeout_; StartSettingsTimeoutTimer(); - // TODO(tjagtap) : [PH2][P1] : Make this a ref counted class and manage the - // lifetime - return AssertResultType( - Race( - [this]() -> Poll { - GRPC_SETTINGS_TIMEOUT_DLOG - << "SettingsTimeoutManager::WaitForSettingsTimeout Race"; - // This Promise will "win" the race if we receive the SETTINGS - // ACK from the peer within the timeout time. - if (DidReceiveAck()) { - GRPC_DCHECK( - sent_time_ + - (timeout_ * - 1.1 /* 10% grace time for this promise to be scheduled*/) > + return AssertResultType(Race( + [self = this->Ref()]() -> Poll { + GRPC_SETTINGS_TIMEOUT_DLOG + << "SettingsPromiseManager::WaitForSettingsTimeout Race"; + // This Promise will "win" the race if we receive the SETTINGS + // ACK from the peer within the timeout time. + if (self->HasReceivedAck()) { + GRPC_DCHECK( + self->sent_time_ + + (self->settings_ack_timeout_ * + 1.2 /* Grace time for this promise to be scheduled*/) > Timestamp::Now()) << "Should have timed out"; - RemoveReceivedAck(); - return absl::OkStatus(); - } - AddWaitingForAck(); - return Pending{}; - }, - // This promise will "Win" the Race if timeout is crossed and we did - // not receive the ACK. The transport must close when this happens. - TrySeq(Sleep(timeout_), [sent_time = sent_time_, - timeout = timeout_]() { - GRPC_SETTINGS_TIMEOUT_DLOG - << "SettingsTimeoutManager::WaitForSettingsTimeout Timeout" - " triggered. Transport will close. Sent Time : " - << sent_time << " Timeout Time : " << (sent_time + timeout) - << " Current Time " << Timestamp::Now(); - return absl::CancelledError( - std::string(RFC9113::kSettingsTimeout)); - }))); + self->MarkReceivedAckAsProcessed(); + self->did_previous_settings_promise_resolve_ = true; + return absl::OkStatus(); + } + self->AddWaitingForAck(); + return Pending{}; + }, + // This promise will "Win" the Race if timeout is crossed and we did + // not receive the ACK. The transport must close when this happens. + TrySeq(Sleep(settings_ack_timeout_), + [sent_time = sent_time_, timeout = settings_ack_timeout_]() { + const std::string message = absl::StrCat( + RFC9113::kSettingsTimeout, + " Sent Time : ", sent_time.ToString(), + " Timeout Time : ", (sent_time + timeout).ToString(), + " Current Time : ", Timestamp::Now().ToString()); + GRPC_SETTINGS_TIMEOUT_DLOG + << "SettingsPromiseManager::WaitForSettingsTimeout" + << message; + // Ideally we must set did_previous_settings_promise_resolve_ + // to false, but in this case the transport will be closed so + // it does not matter. I am trying to avoid taking another ref + // on self in this TrySeq. + return absl::CancelledError(message); + }))); + } + + void TestOnlyRecordReceivedAck() { RecordReceivedAck(); } + void TestOnlyTimeoutWaiterSpawned() { TimeoutWaiterSpawned(); } + + ////////////////////////////////////////////////////////////////////////////// + // Functions for SETTINGS being received from the peer. + + // Buffers SETTINGS frames received from peer. + // Buffered to apply settings at start of next write cycle, only after + // SETTINGS ACK is written to the endpoint. + void BufferPeerSettings(std::vector&& settings) { + if (state_ == SettingsState::kWaitingForFirstPeerSettings) { + state_ = SettingsState::kFirstPeerSettingsReceived; + } + ++num_acks_to_send_; + pending_peer_settings_.reserve(pending_peer_settings_.size() + + settings.size()); + pending_peer_settings_.insert(pending_peer_settings_.end(), + settings.begin(), settings.end()); + } + + // Applies settings buffered by BufferPeerSettings(). + // Should be called at start of write cycle, after the SETTINGS ACK has been + // written to apply the settings. If the first settings frame is received from + // the peer that that needs some special handling too. + http2::Http2ErrorCode MaybeReportAndApplyBufferedPeerSettings( + grpc_event_engine::experimental::EventEngine* event_engine) { + http2::Http2ErrorCode status = settings_.ApplyIncomingSettings( + std::exchange(pending_peer_settings_, {})); + if (state_ == SettingsState::kFirstPeerSettingsReceived) { + MaybeReportInitialSettings(event_engine); + state_ = SettingsState::kReady; + } + return status; + } + + ////////////////////////////////////////////////////////////////////////////// + // Wrappers around Http2SettingsManager + + // Appends SETTINGS and SETTINGS ACK frames to output_buf if needed. + // A SETTINGS frame is appended if local settings changed. + // SETTINGS ACK frames are appended for any incoming settings that need + // acknowledgment. This MUST be called only after the + // MaybeReportAndApplyBufferedPeerSettings function. + void MaybeGetSettingsAndSettingsAckFrames( + chttp2::TransportFlowControl& flow_control, SliceBuffer& output_buf) { + GRPC_SETTINGS_TIMEOUT_DLOG << "MaybeGetSettingsAndSettingsAckFrames"; + if (did_previous_settings_promise_resolve_) { + std::optional settings_frame = settings_.MaybeSendUpdate(); + if (settings_frame.has_value()) { + GRPC_SETTINGS_TIMEOUT_DLOG + << "MaybeGetSettingsAndSettingsAckFrames Frame Settings "; + Serialize(absl::Span(&settings_frame.value(), 1), + output_buf); + flow_control.FlushedSettings(); + WillSendSettings(); + } + } + if (num_acks_to_send_ > 0) { + GRPC_SETTINGS_TIMEOUT_DLOG << "Sending " << num_acks_to_send_ + << " settings ACK frames"; + std::vector ack_frames(num_acks_to_send_); + for (uint32_t i = 0; i < num_acks_to_send_; ++i) { + ack_frames[i] = Http2SettingsFrame{true, {}}; + } + Serialize(absl::MakeSpan(ack_frames), output_buf); + num_acks_to_send_ = 0; + } } + Http2Settings& mutable_local() { return settings_.mutable_local(); } + Http2Settings& mutable_peer() { return settings_.mutable_peer(); } + + const Http2Settings& local() const { return settings_.local(); } + const Http2Settings& acked() const { return settings_.acked(); } + const Http2Settings& peer() const { return settings_.peer(); } + + channelz::PropertyGrid ChannelzProperties() const { + return settings_.ChannelzProperties(); + } + + bool IsSecurityFrameExpected() const { + GRPC_DCHECK(IsFirstPeerSettingsApplied()) + << "Security frame must not be received before SETTINGS frame"; + // TODO(tjagtap) : [PH2][P3] : Evaluate when to accept the frame and when to + // reject it. Compare it with the requirement and with CHTTP2. + return (settings_.acked().allow_security_frame() || + settings_.local().allow_security_frame()) && + settings_.peer().allow_security_frame(); + }; + private: + Http2SettingsManager settings_; + + ////////////////////////////////////////////////////////////////////////////// + // Plumbing Settings with Chttp2Connector class + + void MaybeReportInitialSettings( + grpc_event_engine::experimental::EventEngine* event_engine) { + // TODO(tjagtap) [PH2][P2] Relook at this while writing server. I think this + // will be different for client and server. + if (on_receive_first_settings_ != nullptr) { + GRPC_DCHECK(state_ == SettingsState::kFirstPeerSettingsReceived); + GRPC_DCHECK(event_engine != nullptr); + event_engine->Run( + [on_receive_settings = std::move(on_receive_first_settings_), + peer_max_concurrent_streams = + settings_.peer().max_concurrent_streams()]() mutable { + ExecCtx exec_ctx; + std::move(on_receive_settings)(peer_max_concurrent_streams); + }); + GRPC_DCHECK(on_receive_first_settings_ == nullptr); + } + } + + void MaybeReportInitialSettingsAbort( + grpc_event_engine::experimental::EventEngine* event_engine) { + // TODO(tjagtap) [PH2][P2] Relook at this while writing server. I think this + // will be different for client and server. + if (on_receive_first_settings_ != nullptr) { + GRPC_DCHECK(event_engine != nullptr); + GRPC_DCHECK(state_ != SettingsState::kReady); + event_engine->Run([on_receive_settings = + std::move(on_receive_first_settings_)]() mutable { + ExecCtx exec_ctx; + std::move(on_receive_settings)( + absl::UnavailableError("transport closed")); + }); + GRPC_DCHECK(on_receive_first_settings_ == nullptr); + } + } + + ////////////////////////////////////////////////////////////////////////////// + // Functions for SETTINGS being sent from our transport to the peer. + + void TimeoutWaiterSpawned() { should_wait_for_settings_ack_ = false; } + inline void StartSettingsTimeoutTimer() { GRPC_SETTINGS_TIMEOUT_DLOG - << "SettingsTimeoutManager::StartSettingsTimeoutTimer " + << "SettingsPromiseManager::StartSettingsTimeoutTimer " "did_register_waker_ " - << did_register_waker_ + << did_register_ack_timeout_waker_ << " number_of_acks_unprocessed_ : " << number_of_acks_unprocessed_; GRPC_DCHECK_EQ(number_of_acks_unprocessed_, 0); - GRPC_DCHECK(!did_register_waker_); + GRPC_DCHECK(!did_register_ack_timeout_waker_); sent_time_ = Timestamp::Now(); } - inline bool DidReceiveAck() { + + inline bool HasReceivedAck() { GRPC_SETTINGS_TIMEOUT_DLOG - << "SettingsTimeoutManager::DidReceiveAck did_register_waker_ " - << did_register_waker_ + << "SettingsPromiseManager::DidReceiveAck did_register_waker_ " + << did_register_ack_timeout_waker_ << " number_of_acks_unprocessed_ : " << number_of_acks_unprocessed_; return number_of_acks_unprocessed_ > 0; } inline void AddWaitingForAck() { GRPC_SETTINGS_TIMEOUT_DLOG - << "SettingsTimeoutManager::AddWaitingForAck did_register_waker_ " - << did_register_waker_ + << "SettingsPromiseManager::AddWaitingForAck did_register_waker_ " + << did_register_ack_timeout_waker_ << " number_of_acks_unprocessed_ : " << number_of_acks_unprocessed_; - if (!did_register_waker_) { + if (!did_register_ack_timeout_waker_) { GRPC_DCHECK_EQ(number_of_acks_unprocessed_, 0); - waker_ = GetContext()->MakeNonOwningWaker(); - did_register_waker_ = true; + ack_timeout_waker_ = GetContext()->MakeNonOwningWaker(); + did_register_ack_timeout_waker_ = true; } - GRPC_DCHECK(did_register_waker_); + GRPC_DCHECK(did_register_ack_timeout_waker_); } inline void RecordReceivedAck() { GRPC_SETTINGS_TIMEOUT_DLOG - << "SettingsTimeoutManager::RecordReceivedAck did_register_waker_ " - << did_register_waker_ + << "SettingsPromiseManager::RecordReceivedAck did_register_waker_ " + << did_register_ack_timeout_waker_ << " number_of_acks_unprocessed_ : " << number_of_acks_unprocessed_; GRPC_DCHECK_EQ(number_of_acks_unprocessed_, 0); ++number_of_acks_unprocessed_; - if (did_register_waker_) { - // It is possible that we receive the ACK before WaitForSettingsTimeout is - // scheduled. That is why we do this inside an if. - waker_.Wakeup(); - did_register_waker_ = false; + if (did_register_ack_timeout_waker_) { + ack_timeout_waker_.Wakeup(); + did_register_ack_timeout_waker_ = false; + } else { + GRPC_SETTINGS_TIMEOUT_DLOG + << "We receive the ACK before WaitForSettingsTimeout promise was " + "scheduled."; } - GRPC_DCHECK(!did_register_waker_); + GRPC_DCHECK(!did_register_ack_timeout_waker_); } - inline void RemoveReceivedAck() { + inline void MarkReceivedAckAsProcessed() { GRPC_SETTINGS_TIMEOUT_DLOG - << "SettingsTimeoutManager::RemoveReceivedAck did_register_waker_ " - << did_register_waker_ + << "SettingsPromiseManager::RemoveReceivedAck did_register_waker_ " + << did_register_ack_timeout_waker_ << " number_of_acks_unprocessed_ : " << number_of_acks_unprocessed_; --number_of_acks_unprocessed_; GRPC_DCHECK_EQ(number_of_acks_unprocessed_, 0); - GRPC_DCHECK(!did_register_waker_); + GRPC_DCHECK(!did_register_ack_timeout_waker_); } - Duration timeout_; - // We don't actually use this for the timeout. We are just keeping this as - // book keeping for better debuggability. + ////////////////////////////////////////////////////////////////////////////// + // Data Members for SETTINGS being sent from our transport to the peer. + + Duration settings_ack_timeout_; + // TODO(tjagtap) [PH2][P5][Settings] Delete sent_time_. We don't actually use + // sent_time_ for the timeout. We are just keeping this as book keeping for + // better debuggability. Timestamp sent_time_ = Timestamp::InfFuture(); - Waker waker_; - bool did_register_waker_ = false; + Waker ack_timeout_waker_; + bool did_register_ack_timeout_waker_ = false; int number_of_acks_unprocessed_ = 0; + bool should_wait_for_settings_ack_ = false; + + // For CHTTP2, MaybeSendUpdate() checks `update_state_` to ensure only one + // SETTINGS frame is in flight at a time. PH2 requires an additional + // constraint: a new SETTINGS frame cannot be sent until the SETTINGS-ACK + // timeout promise for the previous frame has resolved. This flag tracks this + // condition for PH2. + bool did_previous_settings_promise_resolve_ = true; + + ////////////////////////////////////////////////////////////////////////////// + // Data Members for SETTINGS being received from the peer. + + absl::AnyInvocable)> on_receive_first_settings_; + std::vector pending_peer_settings_; + // Number of incoming SETTINGS frames that we have received but not ACKed yet. + uint32_t num_acks_to_send_ = 0; + + enum class SettingsState : uint8_t { + kWaitingForFirstPeerSettings, + kFirstPeerSettingsReceived, + kReady, + }; + SettingsState state_; }; } // namespace grpc_core diff --git a/deps/grpc/src/core/ext/transport/chttp2/transport/http2_status.h b/deps/grpc/src/core/ext/transport/chttp2/transport/http2_status.h index 5d185819d95..1532b71713a 100644 --- a/deps/grpc/src/core/ext/transport/chttp2/transport/http2_status.h +++ b/deps/grpc/src/core/ext/transport/chttp2/transport/http2_status.h @@ -25,10 +25,10 @@ #include #include +#include "src/core/util/time.h" #include "absl/log/check.h" #include "absl/status/status.h" #include "absl/strings/str_cat.h" -#include "src/core/util/time.h" namespace grpc_core { namespace http2 { @@ -408,6 +408,12 @@ GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION inline T TakeValue( return std::move(value.value()); } +inline Http2Status ToHttpOkOrConnError(const absl::Status& status) { + return status.ok() ? Http2Status::Ok() + : Http2Status::AbslConnectionError( + status.code(), std::string(status.message())); +} + } // namespace http2 } // namespace grpc_core diff --git a/deps/grpc/src/core/ext/transport/chttp2/transport/http2_transport.cc b/deps/grpc/src/core/ext/transport/chttp2/transport/http2_transport.cc index e2e7e9832aa..aeb8389ee2c 100644 --- a/deps/grpc/src/core/ext/transport/chttp2/transport/http2_transport.cc +++ b/deps/grpc/src/core/ext/transport/chttp2/transport/http2_transport.cc @@ -18,41 +18,146 @@ #include "src/core/ext/transport/chttp2/transport/http2_transport.h" +#include +#include + +#include +#include #include +#include +#include +#include #include +#include -#include "src/core/call/call_spine.h" #include "src/core/call/metadata_info.h" #include "src/core/channelz/channelz.h" #include "src/core/ext/transport/chttp2/transport/flow_control.h" #include "src/core/ext/transport/chttp2/transport/frame.h" -#include "src/core/lib/promise/mpsc.h" -#include "src/core/lib/promise/party.h" -#include "src/core/lib/transport/promise_endpoint.h" -#include "src/core/lib/transport/transport.h" +#include "src/core/ext/transport/chttp2/transport/header_assembler.h" +#include "src/core/ext/transport/chttp2/transport/hpack_parser.h" +#include "src/core/ext/transport/chttp2/transport/http2_settings.h" +#include "src/core/ext/transport/chttp2/transport/http2_settings_manager.h" +#include "src/core/ext/transport/chttp2/transport/http2_settings_promises.h" +#include "src/core/ext/transport/chttp2/transport/http2_status.h" +#include "src/core/ext/transport/chttp2/transport/internal_channel_arg_names.h" +#include "src/core/ext/transport/chttp2/transport/stream.h" +#include "src/core/lib/channel/channel_args.h" +#include "src/core/lib/event_engine/tcp_socket_utils.h" +#include "src/core/lib/slice/slice_buffer.h" +#include "src/core/util/grpc_check.h" #include "src/core/util/ref_counted_ptr.h" -#include "src/core/util/sync.h" +#include "src/core/util/time.h" +#include "absl/log/log.h" +#include "absl/types/span.h" namespace grpc_core { namespace http2 { +// All Promise Based HTTP2 Transport TODOs have the tag +// [PH2][Pn] where n = 0 to 5. +// This helps to maintain the uniformity for quick lookup and fixing. +// +// [PH2][P0] MUST be fixed before the current PR is submitted. +// [PH2][P1] MUST be fixed before the current sub-project is considered +// complete. +// [PH2][P2] MUST be fixed before the current Milestone is considered +// complete. +// [PH2][P3] MUST be fixed before Milestone 3 is considered complete. +// [PH2][P4] Can be fixed after roll out begins. Evaluate these during +// Milestone 4. Either do the TODOs or delete them. +// [PH2][P5] Can be fixed after roll out begins. Evaluate these during +// Milestone 4. Either do the TODOs or delete them. +// [PH2][EXT] This is a TODO related to a project unrelated to PH2 but happening +// in parallel. + +constexpr Duration kDefaultPingTimeout = Duration::Minutes(1); +constexpr Duration kDefaultKeepaliveTimeout = Duration::Seconds(20); +constexpr bool kDefaultKeepalivePermitWithoutCalls = false; +constexpr bool kDefaultEnablePreferredRxCryptoFrameAdvertisement = false; +constexpr bool kDefaultAckPings = true; + +constexpr Duration kClientKeepaliveTime = Duration::Infinity(); + +constexpr Duration kServerKeepaliveTime = Duration::Hours(2); + // Experimental : This is just the initial skeleton of class // and it is functions. The code will be written iteratively. // Do not use or edit any of these functions unless you are // familiar with the PH2 project (Moving chttp2 to promises.) +/////////////////////////////////////////////////////////////////////////////// +// Settings helpers + void InitLocalSettings(Http2Settings& settings, const bool is_client) { if (is_client) { // gRPC has never supported PUSH_PROMISE and we have no plan to do so in the // future. settings.SetEnablePush(false); - // This is to make it double-sure that server cannot initite a stream. + // This is to make it double-sure that server cannot initiate a stream. settings.SetMaxConcurrentStreams(0); } settings.SetMaxHeaderListSize(DEFAULT_MAX_HEADER_LIST_SIZE); settings.SetAllowTrueBinaryMetadata(true); } +//////////////////////////////////////////////////////////////////////////////// +// Channel Args helpers +void ReadChannelArgs(const ChannelArgs& channel_args, + TransportChannelArgs& args, Http2Settings& local_settings, + chttp2::TransportFlowControl& flow_control, + bool is_client) { + ReadSettingsFromChannelArgs(channel_args, local_settings, flow_control, + is_client); + + args.max_header_list_size_soft_limit = + GetSoftLimitFromChannelArgs(channel_args); + args.keepalive_time = std::max( + Duration::Milliseconds(1), + channel_args.GetDurationFromIntMillis(GRPC_ARG_KEEPALIVE_TIME_MS) + .value_or(is_client ? kClientKeepaliveTime : kServerKeepaliveTime)); + args.keepalive_timeout = std::max( + Duration::Zero(), + channel_args.GetDurationFromIntMillis(GRPC_ARG_KEEPALIVE_TIMEOUT_MS) + .value_or(args.keepalive_time == Duration::Infinity() + ? Duration::Infinity() + : kDefaultKeepaliveTimeout)); + args.ping_timeout = + std::max(Duration::Zero(), + channel_args.GetDurationFromIntMillis(GRPC_ARG_PING_TIMEOUT_MS) + .value_or(args.keepalive_time == Duration::Infinity() + ? Duration::Infinity() + : kDefaultPingTimeout)); + args.settings_timeout = + channel_args.GetDurationFromIntMillis(GRPC_ARG_SETTINGS_TIMEOUT) + .value_or(std::max(args.keepalive_timeout * 2, Duration::Minutes(1))); + + args.keepalive_permit_without_calls = + channel_args.GetBool(GRPC_ARG_KEEPALIVE_PERMIT_WITHOUT_CALLS) + .value_or(kDefaultKeepalivePermitWithoutCalls); + + args.enable_preferred_rx_crypto_frame_advertisement = + channel_args + .GetBool(GRPC_ARG_EXPERIMENTAL_HTTP2_PREFERRED_CRYPTO_FRAME_SIZE) + .value_or(kDefaultEnablePreferredRxCryptoFrameAdvertisement); + + args.max_usable_hpack_table_size = + channel_args.GetInt(GRPC_ARG_HTTP2_HPACK_TABLE_SIZE_ENCODER).value_or(-1); + + args.initial_sequence_number = + channel_args.GetInt(GRPC_ARG_HTTP2_INITIAL_SEQUENCE_NUMBER).value_or(-1); + if (args.initial_sequence_number >= 0 && + (args.initial_sequence_number & 1) == 0) { + LOG(ERROR) << "Initial sequence number MUST be odd. Ignoring the value."; + args.initial_sequence_number = -1; + } + + args.test_only_ack_pings = + channel_args.GetBool("grpc.http2.ack_pings").value_or(kDefaultAckPings); + + GRPC_HTTP2_COMMON_DLOG << "ChannelArgs: " << args.DebugString(); +} + void ReadSettingsFromChannelArgs(const ChannelArgs& channel_args, Http2Settings& local_settings, chttp2::TransportFlowControl& flow_control, @@ -108,6 +213,11 @@ void ReadSettingsFromChannelArgs(const ChannelArgs& channel_args, local_settings.SetAllowSecurityFrame( channel_args.GetBool(GRPC_ARG_SECURITY_FRAME_ALLOWED).value_or(false)); + // TODO(tjagtap) : [PH2][P4] : If max_header_list_size is set only once + // in the life of a transport, consider making this a data member of + // class IncomingMetadataTracker instead of accessing via acked settings again + // and again. Else delete this comment. + GRPC_HTTP2_COMMON_DLOG << "Http2Settings: {" << "header_table_size: " << local_settings.header_table_size() @@ -124,6 +234,9 @@ void ReadSettingsFromChannelArgs(const ChannelArgs& channel_args, << "}"; } +/////////////////////////////////////////////////////////////////////////////// +// ChannelZ helpers + RefCountedPtr CreateChannelzSocketNode( std::shared_ptr event_engine_endpoint, @@ -145,5 +258,171 @@ RefCountedPtr CreateChannelzSocketNode( return nullptr; } +/////////////////////////////////////////////////////////////////////////////// +// Flow control helpers + +void ProcessOutgoingDataFrameFlowControl( + chttp2::StreamFlowControl& stream_flow_control, + const uint32_t flow_control_tokens_consumed) { + if (flow_control_tokens_consumed > 0) { + chttp2::StreamFlowControl::OutgoingUpdateContext fc_update( + &stream_flow_control); + // This updates flow control tokens for both stream and transport flow + // control. + fc_update.SentData(flow_control_tokens_consumed); + } +} + +ValueOrHttp2Status +ProcessIncomingDataFrameFlowControl(Http2FrameHeader& frame_header, + chttp2::TransportFlowControl& flow_control, + RefCountedPtr stream) { + GRPC_DCHECK_EQ(frame_header.type, 0u); + if (frame_header.length > 0) { + if (stream == nullptr) { + // This flow control bookkeeping needs to happen even though the stream is + // gone because otherwise we will go out-of-sync with the peer. + // The flow control numbers should be consistent for both peers. + chttp2::TransportFlowControl::IncomingUpdateContext transport_fc( + &flow_control); + absl::Status fc_status = transport_fc.RecvData(frame_header.length); + chttp2::FlowControlAction action = transport_fc.MakeAction(); + GRPC_HTTP2_COMMON_DLOG + << "ProcessIncomingDataFrameFlowControl Transport RecvData status: " + << fc_status << " action: " << action.DebugString(); + if (!fc_status.ok()) { + LOG(ERROR) << "Flow control error: " << fc_status.message(); + // RFC9113 : A receiver MAY respond with a stream error or connection + // error of type FLOW_CONTROL_ERROR if it is unable to accept a frame. + return Http2Status::Http2ConnectionError( + Http2ErrorCode::kFlowControlError, + std::string(fc_status.message())); + } + return action; + } else { + chttp2::StreamFlowControl::IncomingUpdateContext stream_fc( + &stream->flow_control); + absl::Status fc_status = stream_fc.RecvData(frame_header.length); + chttp2::FlowControlAction action = stream_fc.MakeAction(); + GRPC_HTTP2_COMMON_DLOG + << "ProcessIncomingDataFrameFlowControl Stream RecvData status: " + << fc_status << " action: " << action.DebugString(); + if (!fc_status.ok()) { + LOG(ERROR) << "Flow control error: " << fc_status.message(); + // RFC9113 : A receiver MAY respond with a stream error or connection + // error of type FLOW_CONTROL_ERROR if it is unable to accept a frame. + return Http2Status::Http2ConnectionError( + Http2ErrorCode::kFlowControlError, + std::string(fc_status.message())); + } + // TODO(tjagtap) [PH2][P1][FlowControl] This is a HACK. Fix this. + stream_fc.HackIncrementPendingSize(frame_header.length); + return action; + } + } + return chttp2::FlowControlAction(); +} + +bool ProcessIncomingWindowUpdateFrameFlowControl( + const Http2WindowUpdateFrame& frame, + chttp2::TransportFlowControl& flow_control, RefCountedPtr stream) { + if (frame.stream_id != 0) { + if (stream != nullptr) { + GRPC_HTTP2_COMMON_DLOG + << "ProcessIncomingWindowUpdateFrameFlowControl stream " + << frame.stream_id << " increment " << frame.increment; + chttp2::StreamFlowControl::OutgoingUpdateContext fc_update( + &stream->flow_control); + fc_update.RecvUpdate(frame.increment); + } else { + // If stream id is non zero, and stream is nullptr, maybe the stream was + // closed. Ignore this WINDOW_UPDATE frame. + GRPC_HTTP2_COMMON_DLOG + << "ProcessIncomingWindowUpdateFrameFlowControl stream " + << frame.stream_id << " not found. Ignoring."; + } + } else { + GRPC_HTTP2_COMMON_DLOG + << "ProcessIncomingWindowUpdateFrameFlowControl transport increment " + << frame.increment; + chttp2::TransportFlowControl::OutgoingUpdateContext fc_update( + &flow_control); + fc_update.RecvUpdate(frame.increment); + if (fc_update.Finish() == chttp2::StallEdge::kUnstalled) { + // If transport moves from kStalled to kUnstalled, streams blocked by + // transport flow control will become writable. Return true to trigger a + // write cycle and attempt to send data from these streams. + // Although it's possible no streams were blocked, triggering an + // unnecessary write cycle in that super-rare case is acceptable. + GRPC_HTTP2_COMMON_DLOG << "ProcessIncomingWindowUpdateFrameFlowControl " + "Transport Unstalled"; + return true; + } + } + return false; +} + +void MaybeAddStreamWindowUpdateFrame(RefCountedPtr stream, + std::vector& frames) { + GRPC_HTTP2_COMMON_DLOG << "MaybeAddStreamWindowUpdateFrame stream=" + << ((stream == nullptr) + ? "null" + : absl::StrCat( + stream->GetStreamId(), + " CanSendWindowUpdateFrames=", + stream->CanSendWindowUpdateFrames())); + if (stream != nullptr && stream->CanSendWindowUpdateFrames()) { + const uint32_t increment = stream->flow_control.MaybeSendUpdate(); + GRPC_HTTP2_COMMON_DLOG + << "MaybeAddStreamWindowUpdateFrame MaybeSendUpdate { " + << stream->GetStreamId() << ", " << increment << " }" + << (increment == 0 ? ". The frame will NOT be sent for increment 0" + : ""); + if (increment > 0) { + frames.emplace_back( + Http2WindowUpdateFrame{stream->GetStreamId(), increment}); + } + } +} + +// ///////////////////////////////////////////////////////////////////////////// +// Header and Continuation frame processing helpers + +Http2Status ParseAndDiscardHeaders(HPackParser& parser, SliceBuffer&& buffer, + HeaderAssembler::ParseHeaderArgs args, + const RefCountedPtr stream, + Http2Status&& original_status) { + GRPC_HTTP2_COMMON_DLOG << "ParseAndDiscardHeaders buffer " + "size: " + << buffer.Length() << " args: " << args.DebugString() + << " stream_id: " + << (stream == nullptr ? 0 : stream->GetStreamId()) + << " original_status: " + << original_status.DebugString(); + + if (stream != nullptr) { + // Parse all the data in the header assembler + Http2Status result = stream->header_assembler.ParseAndDiscardHeaders( + parser, args.is_initial_metadata, args.is_client, + args.max_header_list_size_soft_limit, + args.max_header_list_size_hard_limit); + if (!result.IsOk()) { + GRPC_DCHECK(result.GetType() == + Http2Status::Http2ErrorType::kConnectionError); + LOG(ERROR) << "Connection Error: " << result; + return result; + } + } + + if (buffer.Length() == 0) { + return std::move(original_status); + } + + Http2Status status = HeaderAssembler::ParseHeader( + parser, std::move(buffer), /*grpc_metadata_batch=*/nullptr, args); + + return (status.IsOk()) ? std::move(original_status) : std::move(status); +} + } // namespace http2 } // namespace grpc_core diff --git a/deps/grpc/src/core/ext/transport/chttp2/transport/http2_transport.h b/deps/grpc/src/core/ext/transport/chttp2/transport/http2_transport.h index b0058144294..3d5ba328826 100644 --- a/deps/grpc/src/core/ext/transport/chttp2/transport/http2_transport.h +++ b/deps/grpc/src/core/ext/transport/chttp2/transport/http2_transport.h @@ -20,21 +20,24 @@ #define GRPC_SRC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_HTTP2_TRANSPORT_H #include -#include +#include -#include "src/core/call/call_spine.h" -#include "src/core/call/metadata_info.h" #include "src/core/channelz/channelz.h" #include "src/core/ext/transport/chttp2/transport/flow_control.h" #include "src/core/ext/transport/chttp2/transport/frame.h" +#include "src/core/ext/transport/chttp2/transport/hpack_parser.h" #include "src/core/ext/transport/chttp2/transport/http2_settings.h" -#include "src/core/lib/event_engine/tcp_socket_utils.h" -#include "src/core/lib/promise/mpsc.h" -#include "src/core/lib/promise/party.h" +#include "src/core/ext/transport/chttp2/transport/http2_settings_manager.h" +#include "src/core/ext/transport/chttp2/transport/http2_settings_promises.h" +#include "src/core/ext/transport/chttp2/transport/http2_status.h" +#include "src/core/ext/transport/chttp2/transport/stream.h" +#include "src/core/lib/promise/activity.h" +#include "src/core/lib/promise/context.h" +#include "src/core/lib/promise/poll.h" #include "src/core/lib/transport/promise_endpoint.h" -#include "src/core/lib/transport/transport.h" #include "src/core/util/ref_counted_ptr.h" -#include "src/core/util/sync.h" +#include "absl/log/log.h" +#include "absl/status/status.h" namespace grpc_core { namespace http2 { @@ -49,34 +52,199 @@ namespace http2 { #define GRPC_HTTP2_CLIENT_DLOG \ DLOG_IF(INFO, GRPC_TRACE_FLAG_ENABLED(http2_ph2_transport)) +#define GRPC_HTTP2_CLIENT_ERROR_DLOG \ + LOG_IF(ERROR, GRPC_TRACE_FLAG_ENABLED(http2_ph2_transport)) + #define GRPC_HTTP2_COMMON_DLOG \ DLOG_IF(INFO, GRPC_TRACE_FLAG_ENABLED(http2_ph2_transport)) -// TODO(akshitpatel) : [PH2][P4] : Choose appropriate size later. -constexpr uint32_t kStreamQueueSize = /*1 MB*/ 1024u * 1024u; constexpr uint32_t kMaxWriteSize = /*10 MB*/ 10u * 1024u * 1024u; -enum class HttpStreamState : uint8_t { - // https://www.rfc-editor.org/rfc/rfc9113.html#name-stream-states - kIdle, - kOpen, - kHalfClosedLocal, - kHalfClosedRemote, - kClosed, +constexpr uint32_t kGoawaySendTimeoutSeconds = 5u; + +struct CloseStreamArgs { + bool close_reads; + bool close_writes; +}; + +/////////////////////////////////////////////////////////////////////////////// +// Read and Write helpers + +class Http2ReadContext { + public: + // Signals that the read loop should pause. If it's already paused, this is a + // no-op. + void SetPauseReadLoop() { + // TODO(tjagtap) [PH2][P2][Settings] Plumb with when we receive urgent + // settings. Example - initial window size 0 is urgent because it indicates + // extreme memory pressure on the server. + should_pause_read_loop_ = true; + } + + // If SetPauseReadLoop() was called, this returns Pending and + // registers a waker that will be woken by WakeReadLoop(). + // If SetPauseReadLoop() was not called, this returns OkStatus. + // This should be polled by the read loop to yield control when requested. + Poll MaybePauseReadLoop() { + if (should_pause_read_loop_) { + read_loop_waker_ = GetContext()->MakeNonOwningWaker(); + return Pending{}; + } + return absl::OkStatus(); + } + + // If SetPauseReadLoop() was called, resumes it by + // waking up the ReadLoop. If not paused, this is a no-op. + void ResumeReadLoopIfPaused() { + if (should_pause_read_loop_) { + should_pause_read_loop_ = false; + read_loop_waker_.Wakeup(); + } + } + + private: + bool should_pause_read_loop_ = false; + Waker read_loop_waker_; +}; + +inline PromiseEndpoint::WriteArgs GetWriteArgs( + const Http2Settings& peer_settings) { + PromiseEndpoint::WriteArgs args; + int max_frame_size = peer_settings.preferred_receive_crypto_message_size(); + // Note: max frame size is 0 if the remote peer does not support adjusting the + // sending frame size. + if (max_frame_size == 0) { + max_frame_size = INT_MAX; + } + // `WriteArgs.max_frame_size` is a suggestion to the endpoint implementation + // to group data to be written into frames of the specified max_frame_size. It + // is different from HTTP2 SETTINGS_MAX_FRAME_SIZE. That setting limits HTTP2 + // frame payload size. + args.set_max_frame_size(max_frame_size); + + // TODO(akshitpatel) [PH2][P1] : Currently only the WriteArgs related to + // preferred_receive_crypto_message_size have been plumbed. The other write + // args may need to be plumbed for PH2. + // CHTTP2 : Reference : + // File : src/core/ext/transport/chttp2/transport/chttp2_transport.cc + // Function : write_action + + return args; +} + +/////////////////////////////////////////////////////////////////////////////// +// Settings helpers + +void InitLocalSettings(Http2Settings& settings, bool is_client); + +//////////////////////////////////////////////////////////////////////////////// +// Channel Args helpers + +struct TransportChannelArgs { + Duration keepalive_time; + Duration keepalive_timeout; + Duration ping_timeout; + Duration settings_timeout; + bool keepalive_permit_without_calls; + bool enable_preferred_rx_crypto_frame_advertisement; + // This is used to test peer behaviour when we never send a ping ack. + bool test_only_ack_pings; + uint32_t max_header_list_size_soft_limit; + int max_usable_hpack_table_size; + int initial_sequence_number; + + std::string DebugString() const { + return absl::StrCat( + "keepalive_time: ", keepalive_time, + " keepalive_timeout: ", keepalive_timeout, + " ping_timeout: ", ping_timeout, + " settings_timeout: ", settings_timeout, + " keepalive_permit_without_calls: ", keepalive_permit_without_calls, + " enable_preferred_rx_crypto_frame_advertisement: ", + enable_preferred_rx_crypto_frame_advertisement, + " max_header_list_size_soft_limit: ", max_header_list_size_soft_limit, + " max_usable_hpack_table_size: ", max_usable_hpack_table_size, + " initial_sequence_number: ", initial_sequence_number, + " test_only_ack_pings: ", test_only_ack_pings); + } }; -void InitLocalSettings(Http2Settings& settings, const bool is_client); +void ReadChannelArgs(const ChannelArgs& channel_args, + TransportChannelArgs& args, Http2Settings& local_settings, + chttp2::TransportFlowControl& flow_control, + bool is_client); void ReadSettingsFromChannelArgs(const ChannelArgs& channel_args, Http2Settings& local_settings, chttp2::TransportFlowControl& flow_control, - const bool is_client); + bool is_client); + +/////////////////////////////////////////////////////////////////////////////// +// ChannelZ helpers RefCountedPtr CreateChannelzSocketNode( std::shared_ptr event_engine_endpoint, const ChannelArgs& args); +/////////////////////////////////////////////////////////////////////////////// +// Flow control helpers + +void ProcessOutgoingDataFrameFlowControl( + chttp2::StreamFlowControl& stream_flow_control, + uint32_t flow_control_tokens_consumed); + +ValueOrHttp2Status +ProcessIncomingDataFrameFlowControl(Http2FrameHeader& frame, + chttp2::TransportFlowControl& flow_control, + RefCountedPtr stream); + +// Returns true if a write should be triggered +bool ProcessIncomingWindowUpdateFrameFlowControl( + const Http2WindowUpdateFrame& frame, + chttp2::TransportFlowControl& flow_control, RefCountedPtr stream); + +void MaybeAddStreamWindowUpdateFrame(RefCountedPtr stream, + std::vector& frames); + +/////////////////////////////////////////////////////////////////////////////// +// Header and Continuation frame processing helpers + +// This function is used to partially process a HEADER or CONTINUATION frame. +// `PARTIAL PROCESSING` means reading the payload of a HEADER or CONTINUATION +// and processing it with the HPACK decoder, and then discarding the payload. +// This is done to keep the transports HPACK parser in sync with peers HPACK. +// Scenarios where 'partial processing' is used: +// +// Case 1: Received a HEADER/CONTINUATION frame +// 1. If the frame is invalid ('ParseHeaderFrame'/'ParseContinuationFrame' +// returns a non-OK status) then it is a connection error. In this case, we +// do NOT invoke 'partial processing' as the transport is about to be closed +// anyway. +// 2. If ParseFramePayload returns a non-OK status, then it is a connection +// error. In this case, we do NOT invoke 'partial processing' as the +// transport is about to be closed anyway. +// 3. If the frame is valid, but lookup stream fails, then we invoke 'partial +// processing' and pass the current payload through the HPACK decoder. This +// can happen if the stream was already closed. +// 4. If the frame is valid, lookup stream succeeds and we fail while processing +// the frame (be it stream or connection error), we first parse the buffered +// payload (if any) in the stream through the HPACK decoder and then pass the +// current payload through the HPACK decoder. +// Case 2: Stream close +// 1. If the stream is being aborted by the upper layers or the transport hit +// a stream error on a stream while reading HEADER/CONTINUATION frames, we +// invoke 'partial processing' to parse the enqueued buffer (if any) in the +// stream to keep our HPACK state consistent with the peer right before +// closing the stream. This is done as the next time a HEADER/CONTINUATION +// frame is received from the peer, the stream lookup will start failing. +// This function returns a connection error if HPACK parsing fails. Otherwise, +// it returns the original status. +Http2Status ParseAndDiscardHeaders(HPackParser& parser, SliceBuffer&& buffer, + HeaderAssembler::ParseHeaderArgs args, + RefCountedPtr stream, + Http2Status&& original_status); + } // namespace http2 } // namespace grpc_core diff --git a/deps/grpc/src/core/ext/transport/chttp2/transport/http2_ztrace_collector.h b/deps/grpc/src/core/ext/transport/chttp2/transport/http2_ztrace_collector.h index 1759a87c770..6a0377b9886 100644 --- a/deps/grpc/src/core/ext/transport/chttp2/transport/http2_ztrace_collector.h +++ b/deps/grpc/src/core/ext/transport/chttp2/transport/http2_ztrace_collector.h @@ -221,6 +221,62 @@ struct H2EndWriteCycle { } }; +struct H2TcpMetricsTrace { + std::shared_ptr< + grpc_event_engine::experimental::EventEngine::Endpoint::TelemetryInfo> + telemetry_info; + grpc_event_engine::experimental::EventEngine::Endpoint::WriteEvent event; + std::vector< + grpc_event_engine::experimental::EventEngine::Endpoint::WriteMetric> + metrics; + absl::Time timestamp; + + size_t MemoryUsage() const { + return sizeof(H2TcpMetricsTrace) + metrics.capacity() * sizeof(metrics[0]); + } + + channelz::PropertyList ChannelzProperties() const { + absl::string_view event_string = "unknown"; + switch (event) { + case grpc_event_engine::experimental::EventEngine::Endpoint::WriteEvent:: + kSendMsg: + event_string = "send_msg"; + break; + case grpc_event_engine::experimental::EventEngine::Endpoint::WriteEvent:: + kScheduled: + event_string = "scheduled"; + break; + case grpc_event_engine::experimental::EventEngine::Endpoint::WriteEvent:: + kSent: + event_string = "sent"; + break; + case grpc_event_engine::experimental::EventEngine::Endpoint::WriteEvent:: + kAcked: + event_string = "acked"; + break; + case grpc_event_engine::experimental::EventEngine::Endpoint::WriteEvent:: + kClosed: + event_string = "closed"; + break; + default: + break; + } + return channelz::PropertyList() + .Set("event", event_string) + .Set("tcp_event_timestamp", timestamp) + .Merge([this]() { + channelz::PropertyList props; + for (const auto& metric : metrics) { + if (auto key = telemetry_info->GetMetricName(metric.key); + key.has_value()) { + props.Set(*key, metric.value); + } + } + return props; + }()); + } +}; + using Http2ZTraceCollector = channelz::ZTraceCollector< http2_ztrace_collector_detail::Config, H2DataTrace, H2HeaderTrace, H2RstStreamTrace, H2SettingsTrace, @@ -229,7 +285,7 @@ using Http2ZTraceCollector = channelz::ZTraceCollector< H2RstStreamTrace, H2SettingsTrace, H2PingTrace, H2GoAwayTrace, H2WindowUpdateTrace, H2SecurityTrace, H2UnknownFrameTrace, H2FlowControlStall, H2BeginWriteCycle, H2EndWriteCycle, - H2BeginEndpointWrite>; + H2BeginEndpointWrite, H2TcpMetricsTrace>; struct PromiseEndpointReadTrace { uint64_t bytes; diff --git a/deps/grpc/src/core/ext/transport/chttp2/transport/incoming_metadata_tracker.h b/deps/grpc/src/core/ext/transport/chttp2/transport/incoming_metadata_tracker.h new file mode 100644 index 00000000000..02387d38c99 --- /dev/null +++ b/deps/grpc/src/core/ext/transport/chttp2/transport/incoming_metadata_tracker.h @@ -0,0 +1,128 @@ +// +// +// Copyright 2025 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. +// +// + +#ifndef GRPC_SRC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_INCOMING_METADATA_TRACKER_H +#define GRPC_SRC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_INCOMING_METADATA_TRACKER_H + +#include +#include + +#include "src/core/call/metadata_info.h" +#include "src/core/ext/transport/chttp2/transport/frame.h" +#include "src/core/util/grpc_check.h" +#include "absl/strings/str_cat.h" + +namespace grpc_core { +namespace http2 { + +class IncomingMetadataTracker { + // Manages transport-wide state for incoming HEADERS and CONTINUATION frames. + // RFC 9113 (Section 6.10) requires that if a HEADERS frame does not have + // END_HEADERS set, it must be followed by a contiguous sequence of + // CONTINUATION frames for the same stream, ending with END_HEADERS. No other + // frame types or frames for other streams may be interleaved during this + // sequence. This constraint makes tracking header sequence state a + // transport-level concern, as only one stream can be receiving headers at + // a time. This class is distinct from HeaderAssembler, which buffers header + // payloads on a per-stream basis. + public: + IncomingMetadataTracker() = default; + ~IncomingMetadataTracker() = default; + + IncomingMetadataTracker(IncomingMetadataTracker&& rvalue) = delete; + IncomingMetadataTracker& operator=(IncomingMetadataTracker&& rvalue) = delete; + IncomingMetadataTracker(const IncomingMetadataTracker&) = delete; + IncomingMetadataTracker& operator=(const IncomingMetadataTracker&) = delete; + + void set_soft_limit(uint32_t limit) { + max_header_list_size_soft_limit_ = limit; + } + uint32_t soft_limit() const { return max_header_list_size_soft_limit_; } + + ////////////////////////////////////////////////////////////////////////////// + // Writing Header and Continuation State + + // Called when a HEADER frame is received. + void OnHeaderReceived(const Http2HeaderFrame& frame) { + GRPC_CHECK(!incoming_header_in_progress_); + incoming_header_in_progress_ = !frame.end_headers; + incoming_header_stream_id_ = frame.stream_id; + incoming_header_end_stream_ = frame.end_stream; + } + + // Called when a CONTINUATION frame is received. + void OnContinuationReceived(const Http2ContinuationFrame& frame) { + GRPC_CHECK(incoming_header_in_progress_); + GRPC_CHECK_EQ(frame.stream_id, incoming_header_stream_id_); + incoming_header_in_progress_ = !frame.end_headers; + } + + ////////////////////////////////////////////////////////////////////////////// + // Reading Header and Continuation State + + // Returns true if we are in the middle of receiving a header block + // (i.e., HEADERS without END_HEADERS was received, and we are waiting for + // CONTINUATION frames). + bool IsWaitingForContinuationFrame() const { + return incoming_header_in_progress_; + } + + // Returns true if end_stream was set in the received header. + bool HeaderHasEndStream() const { return incoming_header_end_stream_; } + + // Returns stream id of stream for which headers are being received. + uint32_t GetStreamId() const { return incoming_header_stream_id_; } + + bool ClientReceivedDuplicateMetadata( + const bool did_receive_initial_metadata, + const bool did_receive_trailing_metadata) const { + const bool is_duplicate_initial_metadata = + !incoming_header_end_stream_ && did_receive_initial_metadata; + const bool is_duplicate_trailing_metadata = + incoming_header_end_stream_ && did_receive_trailing_metadata; + return is_duplicate_initial_metadata || is_duplicate_trailing_metadata; + } + + bool ServerReceivedDuplicateMetadata( + const bool did_receive_initial_metadata) const { + // TODO(tjagtap) : [PH2][P2] : Verify this when implementing Server. + // Also write a small unit test for it. + return !incoming_header_end_stream_ && did_receive_initial_metadata; + } + + std::string DebugString() const { + return absl::StrCat( + "{ incoming_header_in_progress : ", + incoming_header_in_progress_ ? "true" : "false", + ", incoming_header_end_stream : ", + incoming_header_end_stream_ ? "true" : "false", + ", incoming_header_stream_id : ", incoming_header_stream_id_, "}"); + } + + private: + bool incoming_header_in_progress_ = false; + bool incoming_header_end_stream_ = false; + uint32_t incoming_header_stream_id_ = 0; + uint32_t max_header_list_size_soft_limit_ = + DEFAULT_MAX_HEADER_LIST_SIZE_SOFT_LIMIT; +}; + +} // namespace http2 +} // namespace grpc_core + +#endif // GRPC_SRC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_INCOMING_METADATA_TRACKER_H diff --git a/deps/grpc/src/core/ext/transport/chttp2/transport/internal.h b/deps/grpc/src/core/ext/transport/chttp2/transport/internal.h index 0d32992d3b8..ae8f6427443 100644 --- a/deps/grpc/src/core/ext/transport/chttp2/transport/internal.h +++ b/deps/grpc/src/core/ext/transport/chttp2/transport/internal.h @@ -34,10 +34,6 @@ #include #include -#include "absl/container/flat_hash_map.h" -#include "absl/random/random.h" -#include "absl/status/status.h" -#include "absl/strings/string_view.h" #include "src/core/call/metadata_batch.h" #include "src/core/channelz/channelz.h" #include "src/core/ext/transport/chttp2/transport/call_tracer_wrapper.h" @@ -68,6 +64,7 @@ #include "src/core/lib/iomgr/iomgr_fwd.h" #include "src/core/lib/resource_quota/arena.h" #include "src/core/lib/resource_quota/memory_quota.h" +#include "src/core/lib/resource_quota/stream_quota.h" #include "src/core/lib/slice/slice.h" #include "src/core/lib/slice/slice_buffer.h" #include "src/core/lib/surface/init_internally.h" @@ -83,6 +80,10 @@ #include "src/core/util/ref_counted.h" #include "src/core/util/ref_counted_ptr.h" #include "src/core/util/time.h" +#include "absl/container/flat_hash_map.h" +#include "absl/random/random.h" +#include "absl/status/status.h" +#include "absl/strings/string_view.h" // Flag that this closure barrier may be covering a write in a pollset, and so // we should not complete this closure until we can prove that the write got @@ -288,6 +289,19 @@ struct grpc_chttp2_transport final : public grpc_core::FilterStackTransport, void WriteSecurityFrame(grpc_core::SliceBuffer* data); void WriteSecurityFrameLocked(grpc_core::SliceBuffer* data); + void StartWatch(grpc_core::RefCountedPtr watcher) override; + void StopWatch(grpc_core::RefCountedPtr watcher) override; + + void NotifyStateWatcherOnDisconnectLocked( + absl::Status status, StateWatcher::DisconnectInfo disconnect_info); + + void OnPeerMaxConcurrentStreamsUpdateComplete(); + void MaybeNotifyStateWatcherOfPeerMaxConcurrentStreamsLocked(); + void NotifyStateWatcherOnPeerMaxConcurrentStreamsUpdateLocked(); + + void MaybeNotifyOnReceiveSettingsLocked( + absl::StatusOr max_concurrent_streams); + // We depend on the ep being available for the life of the transport in // at least one place - event callback in WriteEventSink. Hence, this should // only be orphaned in the destructor. @@ -316,7 +330,7 @@ struct grpc_chttp2_transport final : public grpc_core::FilterStackTransport, // starts a connectivity watch. grpc_pollset_set* interested_parties_until_recv_settings = nullptr; - grpc_closure* notify_on_receive_settings = nullptr; + absl::AnyInvocable)> notify_on_receive_settings; grpc_closure* notify_on_close = nullptr; /// has the upper layer closed the transport? @@ -375,7 +389,12 @@ struct grpc_chttp2_transport final : public grpc_core::FilterStackTransport, void* user_data, grpc_core::ServerMetadata* metadata) = nullptr; void* accept_stream_cb_user_data; + // There should be only a single watcher in use at any given time. + grpc_core::RefCountedPtr watcher; + uint32_t last_reported_max_concurrent_streams; + bool max_concurrent_streams_notification_in_flight; /// connectivity tracking + // TODO(roth): Get rid of this in favor of the new state watcher. grpc_core::ConnectivityStateTracker state_tracker; /// data to write now @@ -593,6 +612,7 @@ struct grpc_chttp2_transport final : public grpc_core::FilterStackTransport, std::shared_ptr http2_stats; grpc_core::Http2ZTraceCollector http2_ztrace_collector; + grpc_core::Timestamp last_ztrace_time = grpc_core::Timestamp::InfPast(); GPR_NO_UNIQUE_ADDRESS grpc_core::latent_see::Flow write_flow; }; diff --git a/deps/grpc/src/core/ext/transport/chttp2/transport/keepalive.cc b/deps/grpc/src/core/ext/transport/chttp2/transport/keepalive.cc index c852b9d0092..787fbdcdea7 100644 --- a/deps/grpc/src/core/ext/transport/chttp2/transport/keepalive.cc +++ b/deps/grpc/src/core/ext/transport/chttp2/transport/keepalive.cc @@ -17,21 +17,28 @@ // #include "src/core/ext/transport/chttp2/transport/keepalive.h" +#include + #include "src/core/lib/promise/all_ok.h" #include "src/core/lib/promise/if.h" #include "src/core/lib/promise/loop.h" +#include "src/core/lib/promise/party.h" #include "src/core/lib/promise/race.h" #include "src/core/lib/promise/sleep.h" #include "src/core/lib/promise/try_seq.h" +#include "src/core/util/grpc_check.h" +#include "src/core/util/time.h" namespace grpc_core { namespace http2 { KeepaliveManager::KeepaliveManager( std::unique_ptr keep_alive_interface, - Duration keepalive_timeout, const Duration keepalive_time) + Duration keepalive_timeout, const Duration keepalive_time, Party* party) : keep_alive_interface_(std::move(keep_alive_interface)), keepalive_timeout_(keepalive_timeout), - keepalive_time_(keepalive_time) {} + keepalive_time_(keepalive_time) { + MaybeSpawnKeepaliveLoop(party); +} auto KeepaliveManager::WaitForKeepAliveTimeout() { return AssertResultType( @@ -59,8 +66,8 @@ auto KeepaliveManager::WaitForKeepAliveTimeout() { })); } auto KeepaliveManager::TimeoutAndSendPing() { - DCHECK(!data_received_in_last_cycle_); - DCHECK(keepalive_timeout_ != Duration::Infinity()); + GRPC_DCHECK(!data_received_in_last_cycle_); + GRPC_DCHECK(keepalive_timeout_ != Duration::Infinity()); return AllOk(Race(WaitForData(), WaitForKeepAliveTimeout()), SendPingAndWaitForAck()); @@ -83,7 +90,7 @@ auto KeepaliveManager::MaybeSendKeepAlivePing() { })); } -void KeepaliveManager::Spawn(Party* party) { +void KeepaliveManager::MaybeSpawnKeepaliveLoop(Party* party) { if (!IsKeepAliveNeeded()) { GRPC_HTTP2_KEEPALIVE_LOG << "Not spawning keepalive loop."; return; diff --git a/deps/grpc/src/core/ext/transport/chttp2/transport/keepalive.h b/deps/grpc/src/core/ext/transport/chttp2/transport/keepalive.h index c56638dfbad..6cf0140ff2c 100644 --- a/deps/grpc/src/core/ext/transport/chttp2/transport/keepalive.h +++ b/deps/grpc/src/core/ext/transport/chttp2/transport/keepalive.h @@ -18,9 +18,10 @@ #ifndef GRPC_SRC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_KEEPALIVE_H #define GRPC_SRC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_KEEPALIVE_H -#include "absl/status/status.h" #include "src/core/lib/promise/party.h" #include "src/core/lib/promise/promise.h" +#include "src/core/util/grpc_check.h" +#include "absl/status/status.h" namespace grpc_core { namespace http2 { @@ -44,11 +45,8 @@ class KeepAliveInterface { class KeepaliveManager { public: KeepaliveManager(std::unique_ptr keep_alive_interface, - Duration keepalive_timeout, Duration keepalive_time); - - // Spawns the keepalive loop on the given party. This MUST be called at most - // once during the lifetime of the keepalive manager. - void Spawn(Party* party); + Duration keepalive_timeout, Duration keepalive_time, + Party* party); // Needs to be called when any data is read from the endpoint. void GotData() { @@ -69,6 +67,10 @@ class KeepaliveManager { } private: + // Spawns the keepalive loop on the given party. This MUST be called at most + // once during the lifetime of the keepalive manager. + void MaybeSpawnKeepaliveLoop(Party* party); + // Returns a promise that sleeps for the keepalive_timeout_ and triggers the // keepalive timeout unless data is read within the keepalive timeout. auto WaitForKeepAliveTimeout(); @@ -104,7 +106,7 @@ class KeepaliveManager { }; } auto SendPingAndWaitForAck() { - DCHECK_EQ(data_received_in_last_cycle_, false); + GRPC_DCHECK_EQ(data_received_in_last_cycle_, false); return keep_alive_interface_->SendPingAndWaitForAck(); } @@ -121,10 +123,12 @@ class KeepaliveManager { } std::unique_ptr keep_alive_interface_; - // If the keepalive_timeout_ is set to infinity, then the timeout is dictated - // by the ping timeout. Otherwise, this field can be used to set a specific - // timeout for keepalive pings. + // Duration to wait before triggering a keepalive timeout. If the + // keepalive_timeout_ is set to infinity, then the timeout is dictated by the + // ping timeout. Otherwise, this field can be used to set a specific timeout + // for keepalive pings. Duration keepalive_timeout_; + // Duration between two consecutive keepalive pings. const Duration keepalive_time_; bool data_received_in_last_cycle_ = false; bool keep_alive_timeout_triggered_ = false; diff --git a/deps/grpc/src/core/ext/transport/chttp2/transport/message_assembler.h b/deps/grpc/src/core/ext/transport/chttp2/transport/message_assembler.h index 35cb4e9f987..3b903847841 100644 --- a/deps/grpc/src/core/ext/transport/chttp2/transport/message_assembler.h +++ b/deps/grpc/src/core/ext/transport/chttp2/transport/message_assembler.h @@ -19,6 +19,8 @@ #ifndef GRPC_SRC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_MESSAGE_ASSEMBLER_H #define GRPC_SRC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_MESSAGE_ASSEMBLER_H +#include + #include #include @@ -30,10 +32,13 @@ #include "src/core/lib/slice/slice_buffer.h" #include "src/core/util/grpc_check.h" #include "src/core/util/ref_counted_ptr.h" +#include "absl/log/log.h" namespace grpc_core { namespace http2 { +#define GRPC_MESSAGE_ASSEMBLER_DEBUG VLOG(2) + // TODO(tjagtap) TODO(akshitpatel): [PH2][P3] : Write micro benchmarks for // assembler and disassembler code @@ -79,15 +84,21 @@ class GrpcMessageAssembler { // TODO(tjagtap) : [PH2][P3] : Write a test for this. return ReturnNullOrError(); } - GrpcMessageHeader header = ExtractGrpcHeader(message_buffer_); + ValueOrHttp2Status header = + ExtractGrpcHeader(message_buffer_); + if (!header.IsOk()) { + return header.TakeStatus(std::move(header)); + } + const uint32_t header_length = header.value().length; + if constexpr (sizeof(size_t) == 4) { - if (GPR_UNLIKELY(header.length > kOneGb)) { + if (GPR_UNLIKELY(header_length > kOneGb)) { return Http2Status::Http2StreamError( Http2ErrorCode::kInternalError, "Stream Error: SliceBuffer overflow for 32 bit platforms."); } } - if (GPR_LIKELY(current_len - kGrpcHeaderSizeInBytes >= header.length)) { + if (GPR_LIKELY(current_len - kGrpcHeaderSizeInBytes >= header_length)) { SliceBuffer discard; message_buffer_.MoveFirstNBytesIntoSliceBuffer(kGrpcHeaderSizeInBytes, discard); @@ -98,9 +109,8 @@ class GrpcMessageAssembler { // bounds. MessageHandle grpc_message = Arena::MakePooled(); message_buffer_.MoveFirstNBytesIntoSliceBuffer( - header.length, *(grpc_message->payload())); - uint32_t& flag = grpc_message->mutable_flags(); - flag = header.flags; + header_length, *(grpc_message->payload())); + grpc_message->mutable_flags() = header.value().flags; return std::move(grpc_message); } return ReturnNullOrError(); @@ -112,21 +122,18 @@ class GrpcMessageAssembler { return Http2Status::Http2StreamError(Http2ErrorCode::kInternalError, "Incomplete gRPC frame received"); } - VLOG(2) << "Incomplete gRPC message received. Return nullptr"; + GRPC_MESSAGE_ASSEMBLER_DEBUG + << "Incomplete gRPC message received. Return nullptr"; return ValueOrHttp2Status(nullptr); } + bool is_end_stream_ = false; SliceBuffer message_buffer_; }; -constexpr uint32_t kMaxMessageBatchSize = (16 * 1024u); - // This class is meant to convert gRPC Messages into Http2DataFrame ensuring // that the payload size of the data frame is configurable. -// This class is not responsible for queueing or backpressure. That will be done -// by other classes. -// TODO(tjagtap) : [PH2][P2] Edit comment once this -// class is integrated and exercised. +// This class is not responsible for queueing or backpressure. class GrpcMessageDisassembler { public: // One GrpcMessageDisassembler instance MUST be associated with one stream @@ -141,9 +148,11 @@ class GrpcMessageDisassembler { // GrpcMessageDisassembler object will take ownership of the message. void PrepareBatchedMessageForSending(MessageHandle message) { + // The size of the message is controlled by the application (and by using + // GRPC_ARG_MAX_SEND_MESSAGE_LENGTH). PH2 ensures that if the the message + // size is larger than the default stream queue size kStreamQueueSize, at + // max one message will be buffered in the disassembler. PrepareMessageForSending(std::move(message)); - GRPC_DCHECK_LE(GetBufferedLength(), kMaxMessageBatchSize) - << "Avoid batches larger than " << kMaxMessageBatchSize << "bytes"; } size_t GetBufferedLength() const { return message_.Length(); } diff --git a/deps/grpc/src/core/ext/transport/chttp2/transport/parsing.cc b/deps/grpc/src/core/ext/transport/chttp2/transport/parsing.cc index 47be8b252f2..279be89a1b6 100644 --- a/deps/grpc/src/core/ext/transport/chttp2/transport/parsing.cc +++ b/deps/grpc/src/core/ext/transport/chttp2/transport/parsing.cc @@ -31,14 +31,6 @@ #include #include -#include "absl/base/attributes.h" -#include "absl/container/flat_hash_map.h" -#include "absl/log/log.h" -#include "absl/random/bit_gen_ref.h" -#include "absl/status/status.h" -#include "absl/strings/str_cat.h" -#include "absl/strings/str_format.h" -#include "absl/strings/string_view.h" #include "src/core/call/metadata_batch.h" #include "src/core/channelz/channelz.h" #include "src/core/ext/transport/chttp2/transport/call_tracer_wrapper.h" @@ -77,6 +69,14 @@ #include "src/core/util/ref_counted_ptr.h" #include "src/core/util/shared_bit_gen.h" #include "src/core/util/status_helper.h" +#include "absl/base/attributes.h" +#include "absl/container/flat_hash_map.h" +#include "absl/log/log.h" +#include "absl/random/bit_gen_ref.h" +#include "absl/status/status.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/str_format.h" +#include "absl/strings/string_view.h" using grpc_core::HPackParser; using grpc_core::http2::Http2ErrorCode; diff --git a/deps/grpc/src/core/ext/transport/chttp2/transport/ping_callbacks.cc b/deps/grpc/src/core/ext/transport/chttp2/transport/ping_callbacks.cc index 3b665db773e..1f8f528a0b9 100644 --- a/deps/grpc/src/core/ext/transport/chttp2/transport/ping_callbacks.cc +++ b/deps/grpc/src/core/ext/transport/chttp2/transport/ping_callbacks.cc @@ -18,9 +18,9 @@ #include +#include "src/core/util/grpc_check.h" #include "absl/meta/type_traits.h" #include "absl/random/distributions.h" -#include "src/core/util/grpc_check.h" namespace grpc_core { diff --git a/deps/grpc/src/core/ext/transport/chttp2/transport/ping_callbacks.h b/deps/grpc/src/core/ext/transport/chttp2/transport/ping_callbacks.h index e04bb6de09e..641a014a693 100644 --- a/deps/grpc/src/core/ext/transport/chttp2/transport/ping_callbacks.h +++ b/deps/grpc/src/core/ext/transport/chttp2/transport/ping_callbacks.h @@ -24,13 +24,13 @@ #include #include +#include "src/core/channelz/property_list.h" +#include "src/core/lib/debug/trace.h" +#include "src/core/util/time.h" #include "absl/container/flat_hash_map.h" #include "absl/functional/any_invocable.h" #include "absl/hash/hash.h" #include "absl/random/bit_gen_ref.h" -#include "src/core/channelz/property_list.h" -#include "src/core/lib/debug/trace.h" -#include "src/core/util/time.h" namespace grpc_core { diff --git a/deps/grpc/src/core/ext/transport/chttp2/transport/ping_promise.cc b/deps/grpc/src/core/ext/transport/chttp2/transport/ping_promise.cc index 326a593b783..1244a23f67c 100644 --- a/deps/grpc/src/core/ext/transport/chttp2/transport/ping_promise.cc +++ b/deps/grpc/src/core/ext/transport/chttp2/transport/ping_promise.cc @@ -17,12 +17,17 @@ // #include "src/core/ext/transport/chttp2/transport/ping_promise.h" +#include +#include + +#include "src/core/lib/channel/channel_args.h" #include "src/core/lib/promise/latch.h" #include "src/core/lib/promise/map.h" #include "src/core/lib/promise/party.h" #include "src/core/lib/promise/race.h" #include "src/core/lib/promise/sleep.h" #include "src/core/lib/promise/try_seq.h" +#include "src/core/util/grpc_check.h" #include "src/core/util/match.h" #include "src/core/util/time.h" @@ -54,13 +59,14 @@ Promise PingManager::PingPromiseCallbacks::WaitForPingAck() { } // Ping System implementation -PingManager::PingManager(const ChannelArgs& channel_args, +PingManager::PingManager(const ChannelArgs& channel_args, Duration ping_timeout, std::unique_ptr ping_interface, std::shared_ptr event_engine) : ping_callbacks_(event_engine), ping_abuse_policy_(channel_args), ping_rate_policy_(channel_args, /*is_client=*/true), - ping_interface_(std::move(ping_interface)) {} + ping_interface_(std::move(ping_interface)), + ping_timeout_(ping_timeout) {} void PingManager::TriggerDelayedPing(const Duration wait) { // Spawn at most once. @@ -146,7 +152,7 @@ void PingManager::MaybeGetSerializedPingFrames( << pending_ping_acks_.size() << " next_allowed_ping_interval: " << next_allowed_ping_interval; - DCHECK(!opaque_data_.has_value()); + GRPC_DCHECK(!opaque_data_.has_value()); std::vector frames; frames.reserve(pending_ping_acks_.size() + 1); // +1 for the ping frame. @@ -170,9 +176,9 @@ void PingManager::MaybeGetSerializedPingFrames( } } -void PingManager::NotifyPingSent(const Duration ping_timeout) { +void PingManager::NotifyPingSent() { if (opaque_data_.has_value()) { - SpawnTimeout(ping_timeout, opaque_data_.value()); + SpawnTimeout(ping_timeout_, opaque_data_.value()); SentPing(); opaque_data_.reset(); } diff --git a/deps/grpc/src/core/ext/transport/chttp2/transport/ping_promise.h b/deps/grpc/src/core/ext/transport/chttp2/transport/ping_promise.h index 395a875fb47..e294de653fd 100644 --- a/deps/grpc/src/core/ext/transport/chttp2/transport/ping_promise.h +++ b/deps/grpc/src/core/ext/transport/chttp2/transport/ping_promise.h @@ -29,6 +29,7 @@ #include "src/core/lib/promise/map.h" #include "src/core/lib/promise/promise.h" #include "src/core/lib/slice/slice_buffer.h" +#include "src/core/util/grpc_check.h" #include "src/core/util/shared_bit_gen.h" #include "src/core/util/time.h" @@ -71,7 +72,7 @@ class PingInterface { // returned by this class on the same transport party. class PingManager { public: - PingManager(const ChannelArgs& channel_args, + PingManager(const ChannelArgs& channel_args, Duration ping_timeout, std::unique_ptr ping_interface, std::shared_ptr event_engine); @@ -83,7 +84,7 @@ class PingManager { // Notify the ping system that a ping has been sent. This will spawn a ping // timeout promise. - void NotifyPingSent(Duration ping_timeout); + void NotifyPingSent(); // Ping Rate policy wrapper void ReceivedDataFrame() { ping_rate_policy_.ReceivedDataFrame(); } @@ -132,7 +133,7 @@ class PingManager { std::optional TestOnlyMaybeGetSerializedPingFrames( SliceBuffer& output_buffer, Duration next_allowed_ping_interval) { - DCHECK(!opaque_data_.has_value()); + GRPC_DCHECK(!opaque_data_.has_value()); if (NeedToPing(next_allowed_ping_interval)) { uint64_t opaque_data = ping_callbacks_.StartPing(); Http2Frame frame = GetHttp2PingFrame(/*ack*/ false, opaque_data); @@ -153,6 +154,7 @@ class PingManager { std::shared_ptr event_engine) : event_engine_(event_engine) {} + ~PingPromiseCallbacks() { CancelCallbacks(); } Promise RequestPing(absl::AnyInvocable on_initiate, bool important); Promise WaitForPingAck(); @@ -220,6 +222,8 @@ class PingManager { std::optional opaque_data_; std::unique_ptr ping_interface_; std::vector pending_ping_acks_; + // Duration to wait before triggering a ping timeout. + Duration ping_timeout_; void TriggerDelayedPing(Duration wait); bool NeedToPing(Duration next_allowed_ping_interval); diff --git a/deps/grpc/src/core/ext/transport/chttp2/transport/ping_rate_policy.cc b/deps/grpc/src/core/ext/transport/chttp2/transport/ping_rate_policy.cc index 25e72e1f638..a873f49bbe6 100644 --- a/deps/grpc/src/core/ext/transport/chttp2/transport/ping_rate_policy.cc +++ b/deps/grpc/src/core/ext/transport/chttp2/transport/ping_rate_policy.cc @@ -21,9 +21,9 @@ #include #include -#include "absl/strings/str_cat.h" #include "src/core/lib/experiments/experiments.h" #include "src/core/util/match.h" +#include "absl/strings/str_cat.h" namespace grpc_core { diff --git a/deps/grpc/src/core/ext/transport/chttp2/transport/security_frame.cc b/deps/grpc/src/core/ext/transport/chttp2/transport/security_frame.cc new file mode 100644 index 00000000000..24783f311da --- /dev/null +++ b/deps/grpc/src/core/ext/transport/chttp2/transport/security_frame.cc @@ -0,0 +1,31 @@ +// +// Copyright 2025 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 "src/core/ext/transport/chttp2/transport/security_frame.h" + +#include +#include + +#include "src/core/lib/slice/slice.h" +#include "src/core/lib/slice/slice_buffer.h" +#include "src/core/lib/transport/transport_framing_endpoint_extension.h" +#include "absl/status/status.h" + +namespace grpc_core { + +// TODO(tjagtap) [PH2][P1] Implement + +} // namespace grpc_core diff --git a/deps/grpc/src/core/ext/transport/chttp2/transport/security_frame.h b/deps/grpc/src/core/ext/transport/chttp2/transport/security_frame.h new file mode 100644 index 00000000000..0229426d555 --- /dev/null +++ b/deps/grpc/src/core/ext/transport/chttp2/transport/security_frame.h @@ -0,0 +1,32 @@ +// +// Copyright 2025 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. +// + +#ifndef GRPC_SRC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_SECURITY_FRAME_H +#define GRPC_SRC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_SECURITY_FRAME_H + +#include +#include + +#include "src/core/lib/slice/slice_buffer.h" +#include "src/core/lib/transport/transport_framing_endpoint_extension.h" + +namespace grpc_core { + +// TODO(tjagtap) [PH2][P1] Implement + +} // namespace grpc_core + +#endif // GRPC_SRC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_SECURITY_FRAME_H diff --git a/deps/grpc/src/core/ext/transport/chttp2/transport/stream.h b/deps/grpc/src/core/ext/transport/chttp2/transport/stream.h index e25396f7cba..c642e083802 100644 --- a/deps/grpc/src/core/ext/transport/chttp2/transport/stream.h +++ b/deps/grpc/src/core/ext/transport/chttp2/transport/stream.h @@ -19,85 +19,132 @@ #ifndef GRPC_SRC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_STREAM_H #define GRPC_SRC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_STREAM_H +#include + +#include +#include +#include +#include + #include "src/core/call/call_spine.h" +#include "src/core/call/message.h" +#include "src/core/call/metadata.h" #include "src/core/ext/transport/chttp2/transport/flow_control.h" -#include "src/core/ext/transport/chttp2/transport/http2_transport.h" +#include "src/core/ext/transport/chttp2/transport/frame.h" +#include "src/core/ext/transport/chttp2/transport/header_assembler.h" +#include "src/core/ext/transport/chttp2/transport/hpack_encoder.h" +#include "src/core/ext/transport/chttp2/transport/http2_status.h" +#include "src/core/ext/transport/chttp2/transport/message_assembler.h" #include "src/core/ext/transport/chttp2/transport/stream_data_queue.h" +#include "src/core/util/grpc_check.h" +#include "src/core/util/ref_counted.h" #include "src/core/util/ref_counted_ptr.h" +#include "absl/log/log.h" namespace grpc_core { namespace http2 { +#define GRPC_HTTP2_STREAM_LOG VLOG(2) + +// TODO(akshitpatel) : [PH2][P4] : Choose appropriate size later. +constexpr uint32_t kStreamQueueSize = /*1 MB*/ 1024u * 1024u; +constexpr uint32_t kInvalidStreamId = 0u; + +enum class HttpStreamState : uint8_t { + // https://www.rfc-editor.org/rfc/rfc9113.html#name-stream-states + kIdle, + kOpen, + kHalfClosedLocal, + kHalfClosedRemote, + kClosed, +}; + // Managing the streams struct Stream : public RefCounted { - explicit Stream(CallHandler call, const uint32_t stream_id1, - bool allow_true_binary_metadata_peer, - bool allow_true_binary_metadata_acked, + explicit Stream(CallHandler call, chttp2::TransportFlowControl& transport_flow_control) : call(std::move(call)), is_write_closed(false), stream_state(HttpStreamState::kIdle), - stream_id(stream_id1), - header_assembler(stream_id1, allow_true_binary_metadata_acked), - did_push_initial_metadata(false), - did_push_trailing_metadata(false), + stream_id(kInvalidStreamId), + did_receive_initial_metadata(false), + did_receive_trailing_metadata(false), + did_push_server_trailing_metadata(false), data_queue(MakeRefCounted>( - /*is_client*/ true, /*stream_id*/ stream_id1, - /*queue_size*/ kStreamQueueSize, allow_true_binary_metadata_peer)), + /*is_client*/ true, + /*queue_size*/ kStreamQueueSize)), flow_control(&transport_flow_control) {} + // TODO(akshitpatel) : [PH2][P4] : SetStreamId can be avoided if we pass the + // stream id as a parameter to the dequeue function. The only downside here + // is that we will be creating two new disassemblers for every dequeue call. + // The upside is that we save 8 bytes per call. Decide based on benchmark + // results. + void InitializeStream(const uint32_t stream_id, + const bool allow_true_binary_metadata_peer, + const bool allow_true_binary_metadata_acked) { + GRPC_DCHECK_NE(stream_id, 0u); + GRPC_DCHECK_EQ(this->stream_id, 0u); + GRPC_HTTP2_STREAM_LOG << "Stream::InitializeStream stream_id=" << stream_id; + if (GPR_LIKELY(this->stream_id == 0)) { + this->stream_id = stream_id; + header_assembler.InitializeStream(stream_id, + allow_true_binary_metadata_acked); + data_queue->SetStreamId(stream_id, allow_true_binary_metadata_peer); + } + } + //////////////////////////////////////////////////////////////////////////// // Data Queue Helpers // All enqueue methods are called from the call party. auto EnqueueInitialMetadata(ClientMetadataHandle&& metadata) { - GRPC_HTTP2_CLIENT_DLOG - << "Http2ClientTransport::Stream::EnqueueInitialMetadata stream_id=" - << stream_id; + GRPC_HTTP2_STREAM_LOG << "Stream::EnqueueInitialMetadata"; return data_queue->EnqueueInitialMetadata(std::move(metadata)); } auto EnqueueTrailingMetadata(ClientMetadataHandle&& metadata) { - GRPC_HTTP2_CLIENT_DLOG - << "Http2ClientTransport::Stream::EnqueueTrailingMetadata stream_id=" - << stream_id; + GRPC_HTTP2_STREAM_LOG << "Stream::EnqueueTrailingMetadata"; return data_queue->EnqueueTrailingMetadata(std::move(metadata)); } auto EnqueueMessage(MessageHandle&& message) { - GRPC_HTTP2_CLIENT_DLOG - << "Http2ClientTransport::Stream::EnqueueMessage stream_id=" - << stream_id << " with payload size = " << message->payload()->Length(); + GRPC_HTTP2_STREAM_LOG << "Stream::EnqueueMessage" + << " with payload size = " + << message->payload()->Length() + << " and flags = " << message->flags(); return data_queue->EnqueueMessage(std::move(message)); } auto EnqueueHalfClosed() { - GRPC_HTTP2_CLIENT_DLOG - << "Http2ClientTransport::Stream::EnqueueHalfClosed stream_id=" - << stream_id; + GRPC_HTTP2_STREAM_LOG << "Stream::EnqueueHalfClosed"; return data_queue->EnqueueHalfClosed(); } auto EnqueueResetStream(const uint32_t error_code) { - GRPC_HTTP2_CLIENT_DLOG - << "Http2ClientTransport::Stream::EnqueueResetStream stream_id=" - << stream_id << " with error_code = " << error_code; + GRPC_HTTP2_STREAM_LOG << "Stream::EnqueueResetStream" + << " with error_code = " << error_code; return data_queue->EnqueueResetStream(error_code); } // Called from the transport party - auto DequeueFrames(const uint32_t transport_tokens, + auto DequeueFrames(const uint32_t tokens, + const uint32_t stream_flow_control_tokens, const uint32_t max_frame_length, HPackCompressor& encoder) { - HttpStreamState state = GetStreamState(); + HttpStreamState state = stream_state; // Reset stream MUST not be sent if the stream is idle or closed. - return data_queue->DequeueFrames(transport_tokens, max_frame_length, - encoder, + return data_queue->DequeueFrames(tokens, max_frame_length, + stream_flow_control_tokens, encoder, /*can_send_reset_stream=*/ !(state == HttpStreamState::kIdle || state == HttpStreamState::kClosed)); } + auto ReceivedFlowControlWindowUpdate(const uint32_t stream_fc_tokens) { + return data_queue->ReceivedFlowControlWindowUpdate(stream_fc_tokens); + } + //////////////////////////////////////////////////////////////////////////// // Stream State Management // All state management helpers MUST be called from the transport party. @@ -119,23 +166,23 @@ struct Stream : public RefCounted { GRPC_DCHECK(false) << "MarkHalfClosedLocal called for an idle stream"; break; case HttpStreamState::kOpen: - GRPC_HTTP2_CLIENT_DLOG - << "Http2ClientTransport::Stream::MarkHalfClosedLocal stream_id=" - << stream_id << " transitioning to kHalfClosedLocal"; + GRPC_HTTP2_STREAM_LOG + << "Stream::MarkHalfClosedLocal stream_id=" << stream_id + << " transitioning to kHalfClosedLocal"; stream_state = HttpStreamState::kHalfClosedLocal; break; case HttpStreamState::kHalfClosedRemote: - GRPC_HTTP2_CLIENT_DLOG - << "Http2ClientTransport::Stream::MarkHalfClosedLocal stream_id=" - << stream_id << " transitioning to kClosed"; + GRPC_HTTP2_STREAM_LOG + << "Stream::MarkHalfClosedLocal stream_id=" << stream_id + << " transitioning to kClosed"; stream_state = HttpStreamState::kClosed; break; case HttpStreamState::kHalfClosedLocal: break; case HttpStreamState::kClosed: - GRPC_HTTP2_CLIENT_DLOG - << "Http2ClientTransport::Stream::MarkHalfClosedLocal stream_id=" - << stream_id << " already closed"; + GRPC_HTTP2_STREAM_LOG + << "Stream::MarkHalfClosedLocal stream_id=" << stream_id + << " already closed"; break; } } @@ -146,33 +193,71 @@ struct Stream : public RefCounted { GRPC_DCHECK(false) << "MarkHalfClosedRemote called for an idle stream"; break; case HttpStreamState::kOpen: - GRPC_HTTP2_CLIENT_DLOG - << "Http2ClientTransport::Stream::MarkHalfClosedRemote stream_id=" - << stream_id << " transitioning to kHalfClosedRemote"; + GRPC_HTTP2_STREAM_LOG + << "Stream::MarkHalfClosedRemote stream_id=" << stream_id + << " transitioning to kHalfClosedRemote"; stream_state = HttpStreamState::kHalfClosedRemote; break; case HttpStreamState::kHalfClosedLocal: - GRPC_HTTP2_CLIENT_DLOG - << "Http2ClientTransport::Stream::MarkHalfClosedRemote stream_id=" - << stream_id << " transitioning to kClosed"; + GRPC_HTTP2_STREAM_LOG + << "Stream::MarkHalfClosedRemote stream_id=" << stream_id + << " transitioning to kClosed"; stream_state = HttpStreamState::kClosed; break; case HttpStreamState::kHalfClosedRemote: break; case HttpStreamState::kClosed: - GRPC_HTTP2_CLIENT_DLOG - << "Http2ClientTransport::Stream::MarkHalfClosedRemote stream_id=" - << stream_id << " already closed"; + GRPC_HTTP2_STREAM_LOG + << "Stream::MarkHalfClosedRemote stream_id=" << stream_id + << " already closed"; break; } } - inline HttpStreamState GetStreamState() const { return stream_state; } + inline bool IsStreamIdle() const { + return stream_state == HttpStreamState::kIdle; + } + inline bool IsStreamHalfClosedRemote() const { + return stream_state == HttpStreamState::kHalfClosedRemote; + } inline uint32_t GetStreamId() const { return stream_id; } inline bool IsClosedForWrites() const { return is_write_closed; } inline void SetWriteClosed() { is_write_closed = true; } + inline bool CanSendWindowUpdateFrames() const { + return stream_state == HttpStreamState::kOpen || + stream_state == HttpStreamState::kHalfClosedLocal; + } + + inline Http2Status CanStreamReceiveDataFrames() const { + if (IsStreamHalfClosedRemote()) { + return Http2Status::Http2StreamError( + Http2ErrorCode::kStreamClosed, + std::string(RFC9113::kHalfClosedRemoteState)); + } + if (!did_receive_initial_metadata || did_receive_trailing_metadata) { + return Http2Status::Http2StreamError( + Http2ErrorCode::kStreamClosed, + std::string(GrpcErrors::kOutOfOrderDataFrame)); + } + return Http2Status::Ok(); + } + + void MaybePushServerTrailingMetadata(ServerMetadataHandle&& metadata) { + GRPC_HTTP2_STREAM_LOG << "Stream::MaybePushServerTrailingMetadata " + "stream_id=" + << stream_id + << " metadata=" << metadata->DebugString() + << " did_push_server_trailing_metadata=" + << did_push_server_trailing_metadata; + + if (!did_push_server_trailing_metadata) { + did_push_server_trailing_metadata = true; + call.SpawnPushServerTrailingMetadata(std::move(metadata)); + } + } + CallHandler call; // This flag is kept separate from the stream_state as the stream_state // is inline with the HTTP2 spec, whereas this flag is an implementation @@ -184,19 +269,14 @@ struct Stream : public RefCounted { bool is_write_closed; // This MUST be accessed from the transport party. HttpStreamState stream_state; - const uint32_t stream_id; + uint32_t stream_id; GrpcMessageAssembler assembler; HeaderAssembler header_assembler; - // TODO(akshitpatel) : [PH2][P2] : StreamQ should maintain a flag that - // tracks if the half close has been sent for this stream. This flag is used - // to notify the mixer that this stream is closed for - // writes(HalfClosedLocal). When the mixer dequeues the last message for - // the streamQ, it will mark the stream as closed for writes and send a - // frame with end_stream or set the end_stream flag in the last data - // frame being sent out. This is done as the stream state should not - // transition to HalfClosedLocal till the end_stream frame is sent. - bool did_push_initial_metadata; - bool did_push_trailing_metadata; + bool did_receive_initial_metadata; + bool did_receive_trailing_metadata; + bool did_push_server_trailing_metadata; + // TODO(akshitpatel) : [PH2][P3][Server] : This would need to change to + // accomodate ServerMetadataHandle for the server side. RefCountedPtr> data_queue; chttp2::StreamFlowControl flow_control; }; diff --git a/deps/grpc/src/core/ext/transport/chttp2/transport/stream_data_queue.h b/deps/grpc/src/core/ext/transport/chttp2/transport/stream_data_queue.h index 1c28328e464..2d117316807 100644 --- a/deps/grpc/src/core/ext/transport/chttp2/transport/stream_data_queue.h +++ b/deps/grpc/src/core/ext/transport/chttp2/transport/stream_data_queue.h @@ -19,13 +19,35 @@ #ifndef GRPC_SRC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_STREAM_DATA_QUEUE_H #define GRPC_SRC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_STREAM_DATA_QUEUE_H +#include + +#include +#include +#include +#include +#include #include +#include +#include +#include +#include -#include "absl/log/log.h" +#include "src/core/call/message.h" +#include "src/core/ext/transport/chttp2/transport/frame.h" #include "src/core/ext/transport/chttp2/transport/header_assembler.h" +#include "src/core/ext/transport/chttp2/transport/hpack_encoder.h" +#include "src/core/ext/transport/chttp2/transport/http2_status.h" #include "src/core/ext/transport/chttp2/transport/message_assembler.h" #include "src/core/ext/transport/chttp2/transport/transport_common.h" +#include "src/core/lib/promise/activity.h" +#include "src/core/lib/promise/context.h" +#include "src/core/lib/promise/poll.h" +#include "src/core/lib/slice/slice_buffer.h" #include "src/core/util/grpc_check.h" +#include "src/core/util/ref_counted.h" +#include "src/core/util/sync.h" +#include "absl/log/log.h" +#include "absl/status/status.h" namespace grpc_core { namespace http2 { @@ -50,7 +72,7 @@ class SimpleQueue { // with tokens = 0. Enqueues with tokens = 0 are primarily for sending // metadata as flow control does not apply to them. This function is NOT // thread safe. - Poll> Enqueue(T& data, const uint32_t tokens) { + Poll Enqueue(T& data, const uint32_t tokens) { return PollEnqueue(data, tokens); } @@ -81,8 +103,13 @@ class SimpleQueue { // Clears the queue. This function is NOT thread safe. void Clear() { std::queue().swap(queue_); } + inline std::optional GetNextEntryTokens() const { + return queue_.empty() ? std::nullopt + : std::make_optional(queue_.front().tokens); + } + private: - Poll> PollEnqueue(T& data, const uint32_t tokens) { + Poll PollEnqueue(T& data, const uint32_t tokens) { GRPC_STREAM_DATA_QUEUE_DEBUG << "Enqueueing data. Data tokens: " << tokens; const uint32_t max_tokens_consumed_threshold = max_tokens_ >= tokens ? max_tokens_ - tokens : 0; @@ -93,7 +120,7 @@ class SimpleQueue { GRPC_STREAM_DATA_QUEUE_DEBUG << "Enqueue successful. Data tokens: " << tokens << " Current tokens consumed: " << tokens_consumed_; - return /*became_non_empty*/ (queue_.size() == 1); + return /*became_non_empty=*/(queue_.size() == 1); } GRPC_STREAM_DATA_QUEUE_DEBUG @@ -106,6 +133,11 @@ class SimpleQueue { inline absl::StatusOr ImmediateEnqueueInternal(T data, const uint32_t tokens) { + GRPC_DCHECK_LE(tokens_consumed_, + std::numeric_limits::max() - tokens); + if (tokens_consumed_ > std::numeric_limits::max() - tokens) { + return absl::InternalError("Tokens consumed overflowed."); + } tokens_consumed_ += tokens; queue_.emplace(Entry{std::move(data), tokens}); GRPC_STREAM_DATA_QUEUE_DEBUG @@ -170,18 +202,12 @@ class SimpleQueue { template class StreamDataQueue : public RefCounted> { public: - explicit StreamDataQueue(const bool is_client, const uint32_t stream_id, - const uint32_t queue_size, - bool allow_true_binary_metadata) - : stream_id_(stream_id), + explicit StreamDataQueue(const bool is_client, const uint32_t queue_size) + : stream_id_(0), is_client_(is_client), queue_(queue_size), - initial_metadata_disassembler_(stream_id, - /*is_trailing_metadata=*/false, - allow_true_binary_metadata), - trailing_metadata_disassembler_(stream_id, - /*is_trailing_metadata=*/true, - allow_true_binary_metadata) {}; + initial_metadata_disassembler_(/*is_trailing_metadata=*/false), + trailing_metadata_disassembler_(/*is_trailing_metadata=*/true) {}; ~StreamDataQueue() = default; StreamDataQueue(StreamDataQueue&& rhs) = delete; @@ -189,6 +215,17 @@ class StreamDataQueue : public RefCounted> { StreamDataQueue(const StreamDataQueue&) = delete; StreamDataQueue& operator=(const StreamDataQueue&) = delete; + void SetStreamId(const uint32_t stream_id, + const bool allow_true_binary_metadata_peer) { + GRPC_DCHECK_EQ(stream_id_, 0u); + GRPC_DCHECK_NE(stream_id, 0u); + stream_id_ = stream_id; + initial_metadata_disassembler_.Initialize(stream_id, + allow_true_binary_metadata_peer); + trailing_metadata_disassembler_.Initialize(stream_id, + allow_true_binary_metadata_peer); + } + ////////////////////////////////////////////////////////////////////////////// // Enqueue Helpers // These enqueue helpers are based on following assumptions: @@ -206,7 +243,7 @@ class StreamDataQueue : public RefCounted> { // end_stream set. If the stream needs to be half closed, the client should // enqueue a half close message. - struct EnqueueResult { + struct StreamWritabilityUpdate { bool became_writable; WritableStreamPriority priority; }; @@ -216,7 +253,7 @@ class StreamDataQueue : public RefCounted> { // 2. This MUST be called before any messages are enqueued. // 3. MUST not be called after trailing metadata is enqueued. // 4. This function is thread safe. - absl::StatusOr EnqueueInitialMetadata( + absl::StatusOr EnqueueInitialMetadata( MetadataHandle&& metadata) { MutexLock lock(&mu_); GRPC_DCHECK(!is_initial_metadata_queued_); @@ -229,11 +266,11 @@ class StreamDataQueue : public RefCounted> { QueueEntry{InitialMetadataType{std::move(metadata)}}, /*tokens=*/0); if (GPR_UNLIKELY(!result.ok())) { GRPC_STREAM_DATA_QUEUE_DEBUG - << "Immediate enqueueing initial metadata for stream " << stream_id_ - << " failed with status: " << result.status(); + << "Immediate enqueueing initial metadata failed with status: " + << result.status(); return result.status(); } - return UpdateWritableStateLocked( + return UpdateWritableStateAndPriorityEnqueueLocked( /*became_non_empty*/ result.value(), WritableStreamPriority::kDefault); } @@ -241,7 +278,7 @@ class StreamDataQueue : public RefCounted> { // 1. MUST be called at most once. // 2. MUST be called only for a server. // 3. This function is thread safe. - absl::StatusOr EnqueueTrailingMetadata( + absl::StatusOr EnqueueTrailingMetadata( MetadataHandle&& metadata) { MutexLock lock(&mu_); GRPC_DCHECK(metadata != nullptr); @@ -249,10 +286,9 @@ class StreamDataQueue : public RefCounted> { GRPC_DCHECK(!is_trailing_metadata_or_half_close_queued_); if (GPR_UNLIKELY(IsEnqueueClosed())) { - GRPC_STREAM_DATA_QUEUE_DEBUG << "Enqueue closed for stream " - << stream_id_; - return EnqueueResult{/*became_writable=*/false, - WritableStreamPriority::kStreamClosed}; + GRPC_STREAM_DATA_QUEUE_DEBUG << "Enqueue closed."; + return StreamWritabilityUpdate{/*became_writable=*/false, + WritableStreamPriority::kStreamClosed}; } is_trailing_metadata_or_half_close_queued_ = true; @@ -260,11 +296,11 @@ class StreamDataQueue : public RefCounted> { QueueEntry{TrailingMetadataType{std::move(metadata)}}, /*tokens=*/0); if (GPR_UNLIKELY(!result.ok())) { GRPC_STREAM_DATA_QUEUE_DEBUG - << "Immediate enqueueing trailing metadata for stream " << stream_id_ - << " failed with status: " << result.status(); + << "Immediate enqueueing trailing metadata failed with status: " + << result.status(); return result.status(); } - return UpdateWritableStateLocked( + return UpdateWritableStateAndPriorityEnqueueLocked( /*became_non_empty*/ result.value(), WritableStreamPriority::kStreamClosed); } @@ -285,26 +321,22 @@ class StreamDataQueue : public RefCounted> { const uint32_t tokens = message->payload()->Length() + kGrpcHeaderSizeInBytes; return [self = this->Ref(), entry = QueueEntry{std::move(message)}, - tokens]() mutable -> Poll> { + tokens]() mutable -> Poll> { MutexLock lock(&self->mu_); if (GPR_UNLIKELY(self->IsEnqueueClosed())) { - GRPC_STREAM_DATA_QUEUE_DEBUG << "Enqueue closed for stream " - << self->stream_id_; - return EnqueueResult{/*became_writable=*/false, - WritableStreamPriority::kStreamClosed}; + GRPC_STREAM_DATA_QUEUE_DEBUG << "Enqueue closed"; + return StreamWritabilityUpdate{/*became_writable=*/false, + WritableStreamPriority::kStreamClosed}; } - Poll> result = self->queue_.Enqueue(entry, tokens); + Poll result = self->queue_.Enqueue(entry, tokens); if (result.ready()) { GRPC_STREAM_DATA_QUEUE_DEBUG - << "Enqueued message for stream " << self->stream_id_ - << " with status: " << result.value().status(); - // TODO(akshitpatel) : [PH2][P2] : Add check for flow control tokens. - if (GPR_LIKELY(result.value().ok())) { - return self->UpdateWritableStateLocked( - /*became_non_empty*/ result.value().value(), - WritableStreamPriority::kDefault); - } - return result.value().status(); + << "Enqueued message with tokens: " << tokens + << "became_non_empty: " << result.value(); + + return self->UpdateWritableStateAndPriorityEnqueueLocked( + /*became_non_empty=*/result.value(), + WritableStreamPriority::kDefault); } return Pending{}; }; @@ -314,7 +346,7 @@ class StreamDataQueue : public RefCounted> { // 1. MUST be called at most once. // 2. MUST be called only for a client. // 3. This function is thread safe. - absl::StatusOr EnqueueHalfClosed() { + absl::StatusOr EnqueueHalfClosed() { MutexLock lock(&mu_); GRPC_DCHECK(is_initial_metadata_queued_); GRPC_DCHECK(is_client_); @@ -322,11 +354,11 @@ class StreamDataQueue : public RefCounted> { if (GPR_UNLIKELY(IsEnqueueClosed() || is_trailing_metadata_or_half_close_queued_)) { GRPC_STREAM_DATA_QUEUE_DEBUG - << "Enqueue closed or trailing metadata/half close queued for stream " - << stream_id_ << " is_trailing_metadata_or_half_close_queued_ = " + << "Enqueue closed or trailing metadata/half close queued " + << " is_trailing_metadata_or_half_close_queued_ = " << is_trailing_metadata_or_half_close_queued_; - return EnqueueResult{/*became_writable=*/false, - WritableStreamPriority::kStreamClosed}; + return StreamWritabilityUpdate{/*became_writable=*/false, + WritableStreamPriority::kStreamClosed}; } is_trailing_metadata_or_half_close_queued_ = true; @@ -334,11 +366,11 @@ class StreamDataQueue : public RefCounted> { queue_.ImmediateEnqueue(QueueEntry{HalfClosed{}}, /*tokens=*/0); if (GPR_UNLIKELY(!result.ok())) { GRPC_STREAM_DATA_QUEUE_DEBUG - << "Immediate enqueueing half closed for stream " << stream_id_ - << " failed with status: " << result.status(); + << "Immediate enqueueing half closed failed with status: " + << result.status(); return result.status(); } - return UpdateWritableStateLocked( + return UpdateWritableStateAndPriorityEnqueueLocked( /*became_non_empty*/ result.value(), WritableStreamPriority::kStreamClosed); } @@ -346,22 +378,21 @@ class StreamDataQueue : public RefCounted> { // Enqueue Reset Stream. // 1. MUST be called at most once. // 3. This function is thread safe. - absl::StatusOr EnqueueResetStream(const uint32_t error_code) { + absl::StatusOr EnqueueResetStream( + const uint32_t error_code) { MutexLock lock(&mu_); GRPC_DCHECK(is_initial_metadata_queued_); // This can happen when the transport tries to close the stream and the // stream is cancelled from the call stack. if (GPR_UNLIKELY(IsEnqueueClosed())) { - GRPC_STREAM_DATA_QUEUE_DEBUG << "Enqueue closed for stream " - << stream_id_; - return EnqueueResult{/*became_writable=*/false, - WritableStreamPriority::kStreamClosed}; + GRPC_STREAM_DATA_QUEUE_DEBUG << "Enqueue closed"; + return StreamWritabilityUpdate{/*became_writable=*/false, + WritableStreamPriority::kStreamClosed}; } GRPC_STREAM_DATA_QUEUE_DEBUG - << "Immediate enqueueing reset stream for stream " << stream_id_ - << " with error code: " << error_code; + << "Immediate enqueueing reset stream with error code: " << error_code; reset_stream_state_ = RstStreamState::kQueued; reset_stream_error_code_ = error_code; @@ -369,7 +400,7 @@ class StreamDataQueue : public RefCounted> { // enqueueing reset stream to the queue. In this case, if the queue is // empty, enqueuing reset stream to StreamDataQueue will make the stream // writable. - return UpdateWritableStateLocked( + return UpdateWritableStateAndPriorityEnqueueLocked( /*became_non_empty*/ queue_.IsEmpty(), WritableStreamPriority::kStreamClosed); } @@ -388,6 +419,7 @@ class StreamDataQueue : public RefCounted> { // Maybe not be extremely accurate but should be good enough for our // purposes. size_t total_bytes_consumed = 0u; + size_t flow_control_tokens_consumed = 0u; // Bitmask of the dequeue flags. uint8_t flags = 0u; @@ -428,17 +460,19 @@ class StreamDataQueue : public RefCounted> { // This function is thread safe. DequeueResult DequeueFrames(const uint32_t max_fc_tokens, const uint32_t max_frame_length, + const uint32_t stream_fc_tokens, HPackCompressor& encoder, const bool can_send_reset_stream) { MutexLock lock(&mu_); GRPC_STREAM_DATA_QUEUE_DEBUG - << "Dequeueing frames for stream " << stream_id_ - << " Max fc tokens: " << max_fc_tokens + << "Dequeueing frames. Max fc tokens: " << max_fc_tokens << " Max frame length: " << max_frame_length << " Message disassembler buffered length: " << message_disassembler_.GetBufferedLength() << " Can send reset stream: " << can_send_reset_stream << " Reset stream state: " << static_cast(reset_stream_state_); + GRPC_DCHECK_GT(stream_id_, 0u) + << "Stream id must be set before dequeueing frames."; // If a reset stream is queued, we do not want to send any more frames. Any // metadata enqueued has not reached HPACK encoder, so it is safe to drop @@ -465,14 +499,35 @@ class StreamDataQueue : public RefCounted> { std::visit(handle_dequeue, std::move(*queue_entry)); } - // TODO(akshitpatel) : [PH2][P2] : Add a check for flow control tokens. - is_writable_ = false; - GRPC_STREAM_DATA_QUEUE_DEBUG << "Stream id: " << stream_id_ - << " writable state changed to " - << is_writable_; - return DequeueResult{handle_dequeue.GetFrames(), is_writable_, priority_, - handle_dequeue.GetTotalBytesConsumed(), - handle_dequeue.GetDequeueFlags()}; + GRPC_DCHECK_GE(stream_fc_tokens, + handle_dequeue.GetFlowControlTokensConsumed()); + + return DequeueResult{ + handle_dequeue.GetFrames(), + UpdateWritableStateDequeueLocked( + stream_fc_tokens - handle_dequeue.GetFlowControlTokensConsumed()), + priority_, + handle_dequeue.GetTotalBytesConsumed(), + handle_dequeue.GetFlowControlTokensConsumed(), + handle_dequeue.GetDequeueFlags()}; + } + + // TODO(tjagtap) : [PH2][P1][FlowControl] : Call this while processing + // window update frame. + // Needs to be invoked when the peer sends stream flow control window update. + // stream_fc_tokens represents the stream flow control (delta) window + + // intial_window_size. + StreamWritabilityUpdate ReceivedFlowControlWindowUpdate( + const uint32_t stream_fc_tokens) { + MutexLock lock(&mu_); + GRPC_STREAM_DATA_QUEUE_DEBUG + << "Received flow control window update. stream_fc_tokens: " + << stream_fc_tokens; + const bool old_writable_state = is_writable_; + const bool new_writable_state = + UpdateWritableStateDequeueLocked(stream_fc_tokens); + return {/*became_writable=*/(!old_writable_state && new_writable_state), + priority_}; } // Returns true if the queue is empty. This function is thread safe. @@ -498,7 +553,8 @@ class StreamDataQueue : public RefCounted> { HPackCompressor& encoder, StreamDataQueue& queue) : queue_(queue), max_frame_length_(max_frame_length), - fc_tokens_available_(max_tokens), + max_tokens_available_(max_tokens), + flow_control_tokens_consumed_(0), encoder_(encoder) {} void operator()(InitialMetadataType initial_metadata) { @@ -542,6 +598,9 @@ class StreamDataQueue : public RefCounted> { } size_t GetTotalBytesConsumed() const { return total_bytes_consumed_; } + size_t GetFlowControlTokensConsumed() const { + return flow_control_tokens_consumed_; + } uint8_t GetDequeueFlags() const { return dequeue_flags_; } private: @@ -586,16 +645,18 @@ class StreamDataQueue : public RefCounted> { inline void MaybeAppendMessageFrames() { while (queue_.message_disassembler_.GetBufferedLength() > 0 && - fc_tokens_available_ > 0) { + (max_tokens_available_ - flow_control_tokens_consumed_) > 0) { GRPC_DCHECK_EQ( queue_.initial_metadata_disassembler_.GetBufferedLength(), 0u); Http2DataFrame frame = queue_.message_disassembler_.GenerateNextFrame( queue_.stream_id_, - std::min(fc_tokens_available_, max_frame_length_)); - fc_tokens_available_ -= frame.payload.Length(); + std::min(max_tokens_available_ - flow_control_tokens_consumed_, + max_frame_length_)); + flow_control_tokens_consumed_ += frame.payload.Length(); GRPC_STREAM_DATA_QUEUE_DEBUG << "Appending message frame with length " << frame.payload.Length() - << "Available tokens: " << fc_tokens_available_; + << " Consumed tokens: " << flow_control_tokens_consumed_ + << " Max tokens: " << max_tokens_available_; AppendFrame(std::move(frame)); } } @@ -620,7 +681,8 @@ class StreamDataQueue : public RefCounted> { StreamDataQueue& queue_; const uint32_t max_frame_length_; - uint32_t fc_tokens_available_; + const uint32_t max_tokens_available_; + uint32_t flow_control_tokens_consumed_; uint32_t error_code_ = static_cast(Http2ErrorCode::kNoError); std::vector frames_; HPackCompressor& encoder_; @@ -628,28 +690,83 @@ class StreamDataQueue : public RefCounted> { uint8_t dequeue_flags_ = 0u; }; - // Updates the stream priority. Also sets the writable state to true if the - // stream has become writable. Returns if the stream became writable and - // updated priority. It is expected that the caller will hold the lock on the - // queue when calling this function. - EnqueueResult UpdateWritableStateLocked(const bool became_non_empty, - const WritableStreamPriority priority) + // Updates the writable state and priority of the stream. MUST only be called + // from the enqueue functions. + // became_non_empty: True if the queue was empty and became non-empty as a + // result of this enqueue operation. + // priority: The new priority of the stream after this enqueue operation. + // Returns the result of the enqueue operation + // + // High level flow: + // Priority is simply updated to the new priority. + // Writable state is updated as follows: + // 1. If the stream was not writable before and became non-empty as a result + // of this enqueue operation, then the stream is marked as writable. + // 2. If the stream was already writable before, it remains writable. + // 3. The case where the stream was not writable before and the queue already + // contained data implies that the stream is blocked on stream flow control + // tokens. When the transport receives stream flow control window update, + // the stream is marked as writable. + // For enqueue operations there is no easy way to query + // stream_flow_control_tokens. So it is assumed that flow control tokens are + // always available for an enqueue operation. This can cause a stream to be + // marked as writable when it is not but this will correct itself in the next + // dequeue operation (which returns an accurate is_writable). + StreamWritabilityUpdate UpdateWritableStateAndPriorityEnqueueLocked( + const bool became_non_empty, const WritableStreamPriority priority) ABSL_EXCLUSIVE_LOCKS_REQUIRED(mu_) { + // Update priority. priority_ = priority; + + // Update writable state. if (!is_writable_ && became_non_empty) { is_writable_ = true; GRPC_STREAM_DATA_QUEUE_DEBUG - << "UpdateWritableStateLocked for stream id: " << stream_id_ - << " became writable with priority: " + << "UpdateWritableStateLocked became writable with priority: " << GetWritableStreamPriorityString(priority_); - return EnqueueResult{/*became_writable=*/true, priority_}; + return StreamWritabilityUpdate{/*became_writable=*/true, priority_}; } GRPC_STREAM_DATA_QUEUE_DEBUG - << "UpdateWritableStateLocked for stream id: " << stream_id_ - << " with priority: " << GetWritableStreamPriorityString(priority_) + << "UpdateWritableStateAndPriorityEnqueueLocked with priority: " + << GetWritableStreamPriorityString(priority_) << " is_writable: " << is_writable_; - return EnqueueResult{/*became_writable=*/false, priority_}; + return StreamWritabilityUpdate{/*became_writable=*/false, priority_}; + } + + // Updates the writable state of the stream. Returns true if the + // stream became writable. + // Writable state is updated as follows: + // 1. If the next message to dequeue is a grpc message, then the stream is + // writable if and only if we have available stream flow control tokens. + // 2. If the next message to dequeue is not a grpc message, then the stream is + // writable if and only if the queue is not empty. + // Unlike UpdateWritableStateAndPriorityEnqueueLocked, this function the + // become_writable returned by this function is `accurate` as it considers + // the whether the stream has bytes to write and the flow control tokens + // available. + bool UpdateWritableStateDequeueLocked( + const uint32_t available_stream_fc_tokens) + ABSL_EXCLUSIVE_LOCKS_REQUIRED(mu_) { + // The stream is writable if the queue is not empty. If the next bytes to + // write are part of a gRPC message, then check if we have stream flow + // control tokens. + is_writable_ = (!queue_.IsEmpty()); + + // Next bytes to write are part of a gRPC message. + if (message_disassembler_.GetBufferedLength() > 0 || + IsNextQueueEntryMessage()) { + is_writable_ = (available_stream_fc_tokens > 0); + } + + GRPC_STREAM_DATA_QUEUE_DEBUG << "UpdateWritableStateLocked with priority: " + << GetWritableStreamPriorityString(priority_) + << " is_writable: " << is_writable_; + return is_writable_; + } + + inline bool IsNextQueueEntryMessage() const { + return (!queue_.IsEmpty() && queue_.GetNextEntryTokens().value() > 0); } // Handles the case where a reset stream is queued. @@ -661,17 +778,17 @@ class StreamDataQueue : public RefCounted> { switch (reset_stream_state_) { case RstStreamState::kDequeued: GRPC_STREAM_DATA_QUEUE_DEBUG - << "Reset stream is already dequeued for stream " << stream_id_ - << ". Returning empty frames."; + << "Reset stream is already dequeued. Returning empty frames."; GRPC_DCHECK(queue_.IsEmpty()); is_writable_ = false; - return DequeueResult{std::vector(), is_writable_, priority_, - /*total_bytes_consumed=*/0u, /*flags=*/0u}; + return DequeueResult{ + std::vector(), is_writable_, priority_, + /*total_bytes_consumed=*/0u, + /*flow_control_tokens_consumed=*/0u, /*flags=*/0u}; case RstStreamState::kQueued: { GRPC_STREAM_DATA_QUEUE_DEBUG << "Reset stream is queued. Skipping all frames (if any) for " - "dequeuing " - << stream_id_; + "dequeuing."; is_writable_ = false; std::vector frames; uint8_t flags = 0u; @@ -682,14 +799,19 @@ class StreamDataQueue : public RefCounted> { } queue_.Clear(); reset_stream_state_ = RstStreamState::kDequeued; - return DequeueResult{std::move(frames), is_writable_, priority_, - /*total_bytes_consumed=*/0u, flags}; + return DequeueResult{std::move(frames), + is_writable_, + priority_, + /*total_bytes_consumed=*/0u, + /*flow_control_tokens_consumed=*/0u, + flags}; } case RstStreamState::kNotQueued: return std::nullopt; default: GRPC_CHECK(false) << "Invalid reset stream state: " << static_cast(reset_stream_state_); + return std::nullopt; } } @@ -701,18 +823,19 @@ class StreamDataQueue : public RefCounted> { case RstStreamState::kDequeued: // This can happen when the transport tries to close the stream and the // stream is cancelled from the call stack. - GRPC_STREAM_DATA_QUEUE_DEBUG - << "Reset stream already queued for stream " << stream_id_; + GRPC_STREAM_DATA_QUEUE_DEBUG << "Reset stream already queued."; return true; default: GRPC_CHECK(false) << "Invalid reset stream state: " << static_cast(reset_stream_state_); } - GPR_UNREACHABLE_CODE("Invalid reset stream state"); + GPR_UNREACHABLE_CODE(return false); } - const uint32_t stream_id_; + uint32_t stream_id_; + + // This is only used for DCHECKs. Not actually used for any business logic. const bool is_client_; enum class RstStreamState : uint8_t { @@ -727,6 +850,10 @@ class StreamDataQueue : public RefCounted> { // Access both during enqueue and dequeue. Mutex mu_; + // This variable tracks whether the stream is writable. 'Writable' represents + // that the stream has bytes to send and the stream has flow control tokens + // (if needed) to send them. This variable also has 1-1 correspondence with + // whether the stream is in the list of writable streams in the transport. bool is_writable_ ABSL_GUARDED_BY(mu_) = false; RstStreamState reset_stream_state_ ABSL_GUARDED_BY(mu_) = RstStreamState::kNotQueued; diff --git a/deps/grpc/src/core/ext/transport/chttp2/transport/stream_lists.cc b/deps/grpc/src/core/ext/transport/chttp2/transport/stream_lists.cc index fabc78d2b66..cfdeeb85c0b 100644 --- a/deps/grpc/src/core/ext/transport/chttp2/transport/stream_lists.cc +++ b/deps/grpc/src/core/ext/transport/chttp2/transport/stream_lists.cc @@ -20,13 +20,13 @@ #include -#include "absl/log/log.h" #include "src/core/ext/transport/chttp2/transport/internal.h" #include "src/core/ext/transport/chttp2/transport/legacy_frame.h" #include "src/core/lib/debug/trace.h" #include "src/core/lib/experiments/experiments.h" #include "src/core/util/bitset.h" #include "src/core/util/grpc_check.h" +#include "absl/log/log.h" static const char* stream_list_id_string(grpc_chttp2_stream_list_id id) { switch (id) { diff --git a/deps/grpc/src/core/ext/transport/chttp2/transport/transport_common.cc b/deps/grpc/src/core/ext/transport/chttp2/transport/transport_common.cc index 75125df13b1..825f5b12b2e 100644 --- a/deps/grpc/src/core/ext/transport/chttp2/transport/transport_common.cc +++ b/deps/grpc/src/core/ext/transport/chttp2/transport/transport_common.cc @@ -20,9 +20,9 @@ #include -#include "absl/random/random.h" #include "src/core/util/shared_bit_gen.h" #include "src/core/util/time.h" +#include "absl/random/random.h" namespace grpc_core { diff --git a/deps/grpc/src/core/ext/transport/chttp2/transport/transport_common.h b/deps/grpc/src/core/ext/transport/chttp2/transport/transport_common.h index 8f5741eac76..685a1bfb73c 100644 --- a/deps/grpc/src/core/ext/transport/chttp2/transport/transport_common.h +++ b/deps/grpc/src/core/ext/transport/chttp2/transport/transport_common.h @@ -44,6 +44,11 @@ #define GRPC_ARG_MAX_CONCURRENT_STREAMS_REJECT_ON_CLIENT \ "grpc.http.max_concurrent_streams_reject_on_client" +#define KEEPALIVE_TIME_BACKOFF_MULTIPLIER 2 + +#define GRPC_CHTTP2_PING_TIMEOUT_STR "ping timeout" +#define GRPC_CHTTP2_KEEPALIVE_TIMEOUT_STR "keepalive timeout" + namespace grpc_core { Duration TarpitDuration(int min_tarpit_duration_ms, int max_tarpit_duration_ms); diff --git a/deps/grpc/src/core/ext/transport/chttp2/transport/writable_streams.h b/deps/grpc/src/core/ext/transport/chttp2/transport/writable_streams.h index dc68cfcdab0..9cdc25a2a2b 100644 --- a/deps/grpc/src/core/ext/transport/chttp2/transport/writable_streams.h +++ b/deps/grpc/src/core/ext/transport/chttp2/transport/writable_streams.h @@ -19,15 +19,22 @@ #ifndef GRPC_SRC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_WRITABLE_STREAMS_H #define GRPC_SRC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_WRITABLE_STREAMS_H +#include +#include +#include #include +#include -#include "absl/log/log.h" #include "src/core/ext/transport/chttp2/transport/transport_common.h" #include "src/core/lib/promise/if.h" #include "src/core/lib/promise/mpsc.h" #include "src/core/lib/promise/race.h" +#include "src/core/lib/promise/status_flag.h" #include "src/core/lib/promise/try_seq.h" #include "src/core/util/grpc_check.h" +#include "absl/log/log.h" +#include "absl/status/status.h" +#include "absl/strings/str_cat.h" namespace grpc_core { namespace http2 { @@ -67,6 +74,16 @@ class WritableStreams { WritableStreams(WritableStreams&&) = delete; WritableStreams& operator=(WritableStreams&&) = delete; + absl::Status EnqueueWrapper(const StreamPtr stream, + const WritableStreamPriority priority, + bool transport_tokens_available) { + if (transport_tokens_available) { + return Enqueue(stream, priority); + } else { + return BlockedOnTransportFlowControl(stream); + } + } + // Enqueues a stream id with the given priority. // If this returns error, transport MUST be closed. absl::Status Enqueue(const StreamPtr stream, @@ -81,14 +98,13 @@ class WritableStreams { StatusFlag status = sender_.UnbufferedImmediateSend( StreamIDAndPriority{stream, priority}, /*tokens*/ 1); GRPC_WRITABLE_STREAMS_DEBUG - << "UnbufferedImmediateEnqueue stream id: " << stream->GetStreamId() - << " with priority " << GetWritableStreamPriorityString(priority) - << " status " << status; + << "UnbufferedImmediateEnqueue stream with priority " + << GetWritableStreamPriorityString(priority) << " status " << status; return (status.ok()) ? absl::OkStatus() : absl::InternalError(absl::StrCat( - "Failed to enqueue stream id: ", stream->GetStreamId())); + "Failed to enqueue stream to list of writable streams ")); } // A synchronous function to add a stream id to the transport flow control @@ -96,8 +112,8 @@ class WritableStreams { absl::Status BlockedOnTransportFlowControl(const StreamPtr stream) { prioritized_queue_.Push( stream, WritableStreamPriority::kWaitForTransportFlowControl); - GRPC_WRITABLE_STREAMS_DEBUG << "BlockedOnTransportFlowControl stream id: " - << stream->GetStreamId(); + GRPC_WRITABLE_STREAMS_DEBUG << "Enqueuing a stream with priority " + "kWaitForTransportFlowControl "; return absl::OkStatus(); } @@ -161,10 +177,10 @@ class WritableStreams { AddToPrioritizedQueue(batch.value()); std::optional stream = prioritized_queue_.Pop(transport_tokens_available); - // TODO(akshitpatel) : [PH2][P4] - This DCHECK should - // ideally be fine. But in case if queue_.NextBatch - // spuriously returns an empty batch, move to a Loop - // to avoid this. + // TODO(akshitpatel) : [PH2][P4] - This GRPC_DCHECK + // should ideally be fine. But in case if + // queue_.NextBatch spuriously returns an empty batch, + // move to a Loop to avoid this. GRPC_DCHECK(stream.has_value()); GRPC_WRITABLE_STREAMS_DEBUG << "Next stream id: " diff --git a/deps/grpc/src/core/ext/transport/chttp2/transport/writing.cc b/deps/grpc/src/core/ext/transport/chttp2/transport/writing.cc index 5ffca57ca61..647058d3be1 100644 --- a/deps/grpc/src/core/ext/transport/chttp2/transport/writing.cc +++ b/deps/grpc/src/core/ext/transport/chttp2/transport/writing.cc @@ -30,9 +30,6 @@ #include #include -#include "absl/container/flat_hash_map.h" -#include "absl/log/log.h" -#include "absl/status/status.h" #include "src/core/call/metadata_batch.h" #include "src/core/channelz/channelz.h" #include "src/core/ext/transport/chttp2/transport/call_tracer_wrapper.h" @@ -75,6 +72,9 @@ #include "src/core/util/shared_bit_gen.h" #include "src/core/util/time.h" #include "src/core/util/useful.h" +#include "absl/container/flat_hash_map.h" +#include "absl/log/log.h" +#include "absl/status/status.h" // IWYU pragma: no_include "src/core/util/orphanable.h" diff --git a/deps/grpc/src/core/ext/transport/inproc/inproc_transport.cc b/deps/grpc/src/core/ext/transport/inproc/inproc_transport.cc index 053b1c9c489..34211ee9349 100644 --- a/deps/grpc/src/core/ext/transport/inproc/inproc_transport.cc +++ b/deps/grpc/src/core/ext/transport/inproc/inproc_transport.cc @@ -20,8 +20,6 @@ #include #include -#include "absl/log/log.h" -#include "absl/status/status.h" #include "src/core/call/metadata.h" #include "src/core/config/core_configuration.h" #include "src/core/ext/transport/inproc/legacy_inproc_transport.h" @@ -36,6 +34,8 @@ #include "src/core/util/crash.h" #include "src/core/util/debug_location.h" #include "src/core/util/grpc_check.h" +#include "absl/log/log.h" +#include "absl/status/status.h" namespace grpc_core { @@ -94,6 +94,9 @@ class InprocServerTransport final : public ServerTransport { ExecCtx::Run(DEBUG_LOCATION, op->on_consumed, absl::OkStatus()); } + void StartWatch(RefCountedPtr) override {} + void StopWatch(RefCountedPtr) override {} + void Disconnect(absl::Status error) { RefCountedPtr connected_state; { @@ -222,6 +225,9 @@ class InprocClientTransport final : public ClientTransport { void SetPollsetSet(grpc_stream*, grpc_pollset_set*) override {} void PerformOp(grpc_transport_op*) override { Crash("unimplemented"); } + void StartWatch(RefCountedPtr) override {} + void StopWatch(RefCountedPtr) override {} + private: ~InprocClientTransport() override { server_transport_->Disconnect( diff --git a/deps/grpc/src/core/ext/transport/inproc/legacy_inproc_transport.cc b/deps/grpc/src/core/ext/transport/inproc/legacy_inproc_transport.cc index 5b72c10c78f..55033f8a5cc 100644 --- a/deps/grpc/src/core/ext/transport/inproc/legacy_inproc_transport.cc +++ b/deps/grpc/src/core/ext/transport/inproc/legacy_inproc_transport.cc @@ -35,11 +35,6 @@ #include #include -#include "absl/log/log.h" -#include "absl/status/status.h" -#include "absl/status/statusor.h" -#include "absl/strings/str_cat.h" -#include "absl/strings/string_view.h" #include "src/core/call/metadata_batch.h" #include "src/core/channelz/channelz.h" #include "src/core/config/core_configuration.h" @@ -64,6 +59,11 @@ #include "src/core/util/ref_counted_ptr.h" #include "src/core/util/status_helper.h" #include "src/core/util/time.h" +#include "absl/log/log.h" +#include "absl/status/status.h" +#include "absl/status/statusor.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/string_view.h" namespace { struct inproc_stream; @@ -139,6 +139,9 @@ struct inproc_transport final : public grpc_core::FilterStackTransport { void DestroyStream(grpc_stream* gs, grpc_closure* then_schedule_closure) override; + void StartWatch(grpc_core::RefCountedPtr) override {} + void StopWatch(grpc_core::RefCountedPtr) override {} + void Orphan() override; void ref() { diff --git a/deps/grpc/src/core/filter/auth/auth_filters.h b/deps/grpc/src/core/filter/auth/auth_filters.h index d97bbd4c69d..06c33538a92 100644 --- a/deps/grpc/src/core/filter/auth/auth_filters.h +++ b/deps/grpc/src/core/filter/auth/auth_filters.h @@ -24,7 +24,6 @@ #include #include -#include "absl/status/statusor.h" #include "src/core/call/status_util.h" #include "src/core/credentials/call/call_credentials.h" #include "src/core/credentials/transport/security_connector.h" @@ -36,6 +35,7 @@ #include "src/core/lib/promise/arena_promise.h" #include "src/core/lib/transport/transport.h" #include "src/core/util/ref_counted_ptr.h" +#include "absl/status/statusor.h" namespace grpc_core { @@ -117,6 +117,9 @@ class ClientAuthFilter final : public ImplementChannelFilter { static const inline NoInterceptor OnServerToClientMessage; static const inline NoInterceptor OnServerTrailingMetadata; static const inline NoInterceptor OnFinalize; + channelz::PropertyList ChannelzProperties() { + return channelz::PropertyList(); + } }; private: @@ -186,6 +189,9 @@ class ServerAuthFilter final : public ImplementChannelFilter { static inline const NoInterceptor OnServerToClientMessage; static inline const NoInterceptor OnServerTrailingMetadata; static inline const NoInterceptor OnFinalize; + channelz::PropertyList ChannelzProperties() { + return channelz::PropertyList(); + } }; private: diff --git a/deps/grpc/src/core/filter/auth/client_auth_filter.cc b/deps/grpc/src/core/filter/auth/client_auth_filter.cc index 516a58e614b..b4beb263730 100644 --- a/deps/grpc/src/core/filter/auth/client_auth_filter.cc +++ b/deps/grpc/src/core/filter/auth/client_auth_filter.cc @@ -29,8 +29,6 @@ #include // IWYU pragma: keep #include -#include "absl/status/status.h" -#include "absl/status/statusor.h" #include "src/core/call/metadata_batch.h" #include "src/core/call/security_context.h" #include "src/core/call/status_util.h" @@ -51,6 +49,8 @@ #include "src/core/transport/auth_context.h" #include "src/core/util/debug_location.h" #include "src/core/util/ref_counted_ptr.h" +#include "absl/status/status.h" +#include "absl/status/statusor.h" #define MAX_CREDENTIALS_METADATA_COUNT 4 diff --git a/deps/grpc/src/core/filter/auth/server_auth_filter.cc b/deps/grpc/src/core/filter/auth/server_auth_filter.cc index 91d8733e1a9..b4d33d0570e 100644 --- a/deps/grpc/src/core/filter/auth/server_auth_filter.cc +++ b/deps/grpc/src/core/filter/auth/server_auth_filter.cc @@ -30,9 +30,6 @@ #include #include -#include "absl/log/log.h" -#include "absl/status/status.h" -#include "absl/status/statusor.h" #include "src/core/call/metadata_batch.h" #include "src/core/call/security_context.h" #include "src/core/credentials/transport/transport_credentials.h" @@ -58,6 +55,9 @@ #include "src/core/util/grpc_check.h" #include "src/core/util/ref_counted_ptr.h" #include "src/core/util/status_helper.h" +#include "absl/log/log.h" +#include "absl/status/status.h" +#include "absl/status/statusor.h" namespace grpc_core { diff --git a/deps/grpc/src/core/filter/blackboard.h b/deps/grpc/src/core/filter/blackboard.h index 19f08be382b..6a467ef7195 100644 --- a/deps/grpc/src/core/filter/blackboard.h +++ b/deps/grpc/src/core/filter/blackboard.h @@ -20,14 +20,14 @@ #include #include -#include "absl/container/flat_hash_map.h" -#include "absl/strings/string_view.h" #include "src/core/resolver/endpoint_addresses.h" #include "src/core/util/debug_location.h" #include "src/core/util/ref_counted.h" #include "src/core/util/ref_counted_ptr.h" #include "src/core/util/unique_type_name.h" #include "src/core/util/useful.h" +#include "absl/container/flat_hash_map.h" +#include "absl/strings/string_view.h" namespace grpc_core { diff --git a/deps/grpc/src/core/filter/filter_args.h b/deps/grpc/src/core/filter/filter_args.h index e4d4a9a5804..bc9fbbfdf91 100644 --- a/deps/grpc/src/core/filter/filter_args.h +++ b/deps/grpc/src/core/filter/filter_args.h @@ -15,12 +15,39 @@ #ifndef GRPC_SRC_CORE_FILTER_FILTER_ARGS_H #define GRPC_SRC_CORE_FILTER_FILTER_ARGS_H +#include + #include "src/core/filter/blackboard.h" #include "src/core/lib/channel/channel_fwd.h" #include "src/core/util/match.h" +#include "src/core/util/ref_counted.h" +#include "src/core/util/ref_counted_ptr.h" +#include "src/core/util/unique_type_name.h" namespace grpc_core { +// A base class for filter configs. +class FilterConfig : public RefCounted { + public: + virtual UniqueTypeName type() const = 0; + + bool operator==(const FilterConfig& other) const { + if (type() != other.type()) return false; + return Equals(other); + } + + bool operator!=(const FilterConfig& other) const { return !(*this == other); } + + virtual bool Equals(const FilterConfig& other) const = 0; + + virtual std::string ToString() const = 0; +}; + +struct FilterAndConfig { + const grpc_channel_filter* filter; + RefCountedPtr config; +}; + // Filter arguments that are independent of channel args. // Here-in should be things that depend on the filters location in the stack, or // things that are ephemeral and disjoint from overall channel args. @@ -31,9 +58,11 @@ class FilterArgs { grpc_channel_element* channel_element, size_t (*channel_stack_filter_instance_number)( grpc_channel_stack*, grpc_channel_element*), + RefCountedPtr config = nullptr, const Blackboard* blackboard = nullptr) : impl_(ChannelStackBased{channel_stack, channel_element, channel_stack_filter_instance_number}), + config_(std::move(config)), blackboard_(blackboard) {} // While we're moving to call-v3 we need to have access to // grpc_channel_stack & friends here. That means that we can't rely on this @@ -41,8 +70,12 @@ class FilterArgs { // of constructing this object without naming it ===> implicit construction. // TODO(ctiller): remove this once we're fully on call-v3 // NOLINTNEXTLINE(google-explicit-constructor) - FilterArgs(size_t instance_id, const Blackboard* blackboard = nullptr) - : impl_(V3Based{instance_id}), blackboard_(blackboard) {} + FilterArgs(size_t instance_id, + RefCountedPtr config = nullptr, + const Blackboard* blackboard = nullptr) + : impl_(V3Based{instance_id}), + config_(std::move(config)), + blackboard_(blackboard) {} ABSL_DEPRECATED("Direct access to channel stack is deprecated") grpc_channel_stack* channel_stack() const { @@ -56,6 +89,8 @@ class FilterArgs { // 0 0 0 1 1 0 2. // This is useful for filters that need to store per-instance data in a // parallel data structure. + // TODO(roth): Remove this once server side is migrated to the new + // approach for handling xDS filter configs. size_t instance_id() const { return Match( impl_, @@ -66,6 +101,8 @@ class FilterArgs { [](const V3Based& v3) { return v3.instance_id; }); } + RefCountedPtr config() const { return config_; } + // Gets the filter state associated with a particular type and key. template RefCountedPtr GetState(const std::string& key) const { @@ -90,6 +127,7 @@ class FilterArgs { using Impl = std::variant; Impl impl_; + const RefCountedPtr config_; const Blackboard* blackboard_ = nullptr; }; diff --git a/deps/grpc/src/core/handshaker/endpoint_info/endpoint_info_handshaker.cc b/deps/grpc/src/core/handshaker/endpoint_info/endpoint_info_handshaker.cc index b6037bfe7cb..c74d67c4826 100644 --- a/deps/grpc/src/core/handshaker/endpoint_info/endpoint_info_handshaker.cc +++ b/deps/grpc/src/core/handshaker/endpoint_info/endpoint_info_handshaker.cc @@ -21,8 +21,6 @@ #include #include -#include "absl/functional/any_invocable.h" -#include "absl/status/status.h" #include "src/core/handshaker/handshaker.h" #include "src/core/handshaker/handshaker_factory.h" #include "src/core/handshaker/handshaker_registry.h" @@ -32,6 +30,8 @@ #include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/util/debug_location.h" #include "src/core/util/ref_counted_ptr.h" +#include "absl/functional/any_invocable.h" +#include "absl/status/status.h" namespace grpc_core { diff --git a/deps/grpc/src/core/handshaker/handshaker.cc b/deps/grpc/src/core/handshaker/handshaker.cc index b633a6bedc5..eb1260c4551 100644 --- a/deps/grpc/src/core/handshaker/handshaker.cc +++ b/deps/grpc/src/core/handshaker/handshaker.cc @@ -28,11 +28,6 @@ #include #include -#include "absl/functional/any_invocable.h" -#include "absl/log/log.h" -#include "absl/status/status.h" -#include "absl/status/statusor.h" -#include "absl/strings/str_format.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/debug/trace.h" #include "src/core/lib/iomgr/endpoint.h" @@ -42,6 +37,11 @@ #include "src/core/util/grpc_check.h" #include "src/core/util/status_helper.h" #include "src/core/util/time.h" +#include "absl/functional/any_invocable.h" +#include "absl/log/log.h" +#include "absl/status/status.h" +#include "absl/status/statusor.h" +#include "absl/strings/str_format.h" using ::grpc_event_engine::experimental::EventEngine; diff --git a/deps/grpc/src/core/handshaker/handshaker.h b/deps/grpc/src/core/handshaker/handshaker.h index 028b297fe59..ecca898d071 100644 --- a/deps/grpc/src/core/handshaker/handshaker.h +++ b/deps/grpc/src/core/handshaker/handshaker.h @@ -26,8 +26,6 @@ #include -#include "absl/base/thread_annotations.h" -#include "absl/container/inlined_vector.h" #include "src/core/channelz/channelz.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/iomgr/closure.h" @@ -40,6 +38,8 @@ #include "src/core/util/ref_counted_ptr.h" #include "src/core/util/sync.h" #include "src/core/util/time.h" +#include "absl/base/thread_annotations.h" +#include "absl/container/inlined_vector.h" namespace grpc_core { diff --git a/deps/grpc/src/core/handshaker/http_connect/http_connect_handshaker.cc b/deps/grpc/src/core/handshaker/http_connect/http_connect_handshaker.cc index b902041de30..983010d65f8 100644 --- a/deps/grpc/src/core/handshaker/http_connect/http_connect_handshaker.cc +++ b/deps/grpc/src/core/handshaker/http_connect/http_connect_handshaker.cc @@ -30,11 +30,6 @@ #include #include -#include "absl/base/thread_annotations.h" -#include "absl/log/log.h" -#include "absl/status/status.h" -#include "absl/strings/str_cat.h" -#include "absl/strings/string_view.h" #include "src/core/config/core_configuration.h" #include "src/core/handshaker/handshaker.h" #include "src/core/handshaker/handshaker_factory.h" @@ -53,6 +48,11 @@ #include "src/core/util/ref_counted_ptr.h" #include "src/core/util/string.h" #include "src/core/util/sync.h" +#include "absl/base/thread_annotations.h" +#include "absl/log/log.h" +#include "absl/status/status.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/string_view.h" namespace grpc_core { diff --git a/deps/grpc/src/core/handshaker/http_connect/http_proxy_mapper.cc b/deps/grpc/src/core/handshaker/http_connect/http_proxy_mapper.cc index 05691c2b3a1..99e7334c806 100644 --- a/deps/grpc/src/core/handshaker/http_connect/http_proxy_mapper.cc +++ b/deps/grpc/src/core/handshaker/http_connect/http_proxy_mapper.cc @@ -29,17 +29,6 @@ #include #include -#include "absl/log/log.h" -#include "absl/status/status.h" -#include "absl/status/statusor.h" -#include "absl/strings/ascii.h" -#include "absl/strings/escaping.h" -#include "absl/strings/match.h" -#include "absl/strings/numbers.h" -#include "absl/strings/str_cat.h" -#include "absl/strings/str_split.h" -#include "absl/strings/string_view.h" -#include "absl/strings/strip.h" #include "src/core/handshaker/http_connect/http_connect_handshaker.h" #include "src/core/lib/address_utils/parse_address.h" #include "src/core/lib/address_utils/sockaddr_utils.h" @@ -51,6 +40,17 @@ #include "src/core/util/memory.h" #include "src/core/util/string.h" #include "src/core/util/uri.h" +#include "absl/log/log.h" +#include "absl/status/status.h" +#include "absl/status/statusor.h" +#include "absl/strings/ascii.h" +#include "absl/strings/escaping.h" +#include "absl/strings/match.h" +#include "absl/strings/numbers.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/str_split.h" +#include "absl/strings/string_view.h" +#include "absl/strings/strip.h" namespace grpc_core { namespace { diff --git a/deps/grpc/src/core/handshaker/http_connect/http_proxy_mapper.h b/deps/grpc/src/core/handshaker/http_connect/http_proxy_mapper.h index 61bbc4bc642..1e59c02333a 100644 --- a/deps/grpc/src/core/handshaker/http_connect/http_proxy_mapper.h +++ b/deps/grpc/src/core/handshaker/http_connect/http_proxy_mapper.h @@ -24,11 +24,11 @@ #include #include -#include "absl/strings/string_view.h" #include "src/core/config/core_configuration.h" #include "src/core/handshaker/proxy_mapper.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/iomgr/resolved_address.h" +#include "absl/strings/string_view.h" namespace grpc_core { diff --git a/deps/grpc/src/core/handshaker/http_connect/xds_http_proxy_mapper.cc b/deps/grpc/src/core/handshaker/http_connect/xds_http_proxy_mapper.cc index 4e5287e5894..26fa8ea25e3 100644 --- a/deps/grpc/src/core/handshaker/http_connect/xds_http_proxy_mapper.cc +++ b/deps/grpc/src/core/handshaker/http_connect/xds_http_proxy_mapper.cc @@ -20,12 +20,12 @@ #include #include -#include "absl/log/log.h" #include "src/core/handshaker/http_connect/http_connect_handshaker.h" #include "src/core/lib/address_utils/parse_address.h" #include "src/core/lib/address_utils/sockaddr_utils.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/xds/grpc/xds_endpoint.h" +#include "absl/log/log.h" namespace grpc_core { diff --git a/deps/grpc/src/core/handshaker/http_connect/xds_http_proxy_mapper.h b/deps/grpc/src/core/handshaker/http_connect/xds_http_proxy_mapper.h index fb448c9755d..ac5615d4098 100644 --- a/deps/grpc/src/core/handshaker/http_connect/xds_http_proxy_mapper.h +++ b/deps/grpc/src/core/handshaker/http_connect/xds_http_proxy_mapper.h @@ -20,11 +20,11 @@ #include #include -#include "absl/strings/string_view.h" #include "src/core/config/core_configuration.h" #include "src/core/handshaker/proxy_mapper.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/iomgr/resolved_address.h" +#include "absl/strings/string_view.h" namespace grpc_core { diff --git a/deps/grpc/src/core/handshaker/proxy_mapper.h b/deps/grpc/src/core/handshaker/proxy_mapper.h index 0747aff03cb..2c5ffb25386 100644 --- a/deps/grpc/src/core/handshaker/proxy_mapper.h +++ b/deps/grpc/src/core/handshaker/proxy_mapper.h @@ -24,9 +24,9 @@ #include #include -#include "absl/strings/string_view.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/iomgr/resolved_address.h" +#include "absl/strings/string_view.h" namespace grpc_core { diff --git a/deps/grpc/src/core/handshaker/proxy_mapper_registry.h b/deps/grpc/src/core/handshaker/proxy_mapper_registry.h index 495edf6b576..14d57ecc65d 100644 --- a/deps/grpc/src/core/handshaker/proxy_mapper_registry.h +++ b/deps/grpc/src/core/handshaker/proxy_mapper_registry.h @@ -27,10 +27,10 @@ #include #include -#include "absl/strings/string_view.h" #include "src/core/handshaker/proxy_mapper.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/iomgr/resolved_address.h" +#include "absl/strings/string_view.h" namespace grpc_core { diff --git a/deps/grpc/src/core/handshaker/security/legacy_secure_endpoint.cc b/deps/grpc/src/core/handshaker/security/legacy_secure_endpoint.cc index 4d489628e62..506226a2d26 100644 --- a/deps/grpc/src/core/handshaker/security/legacy_secure_endpoint.cc +++ b/deps/grpc/src/core/handshaker/security/legacy_secure_endpoint.cc @@ -32,10 +32,6 @@ #include #include -#include "absl/base/thread_annotations.h" -#include "absl/log/log.h" -#include "absl/status/status.h" -#include "absl/strings/string_view.h" #include "src/core/handshaker/security/secure_endpoint.h" #include "src/core/lib/debug/trace.h" #include "src/core/lib/experiments/experiments.h" @@ -57,6 +53,10 @@ #include "src/core/util/ref_counted_ptr.h" #include "src/core/util/string.h" #include "src/core/util/sync.h" +#include "absl/base/thread_annotations.h" +#include "absl/log/log.h" +#include "absl/status/status.h" +#include "absl/strings/string_view.h" #define STAGING_BUFFER_SIZE 8192 diff --git a/deps/grpc/src/core/handshaker/security/pipelined_secure_endpoint.cc b/deps/grpc/src/core/handshaker/security/pipelined_secure_endpoint.cc index 66af4ae60f2..4af7cc6d3c8 100644 --- a/deps/grpc/src/core/handshaker/security/pipelined_secure_endpoint.cc +++ b/deps/grpc/src/core/handshaker/security/pipelined_secure_endpoint.cc @@ -34,13 +34,6 @@ #include #include -#include "absl/base/thread_annotations.h" -#include "absl/functional/any_invocable.h" -#include "absl/log/log.h" -#include "absl/status/status.h" -#include "absl/strings/str_cat.h" -#include "absl/strings/string_view.h" -#include "absl/types/span.h" #include "src/core/handshaker/security/secure_endpoint.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/debug/trace.h" @@ -62,6 +55,13 @@ #include "src/core/util/ref_counted_ptr.h" #include "src/core/util/string.h" #include "src/core/util/sync.h" +#include "absl/base/thread_annotations.h" +#include "absl/functional/any_invocable.h" +#include "absl/log/log.h" +#include "absl/status/status.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/string_view.h" +#include "absl/types/span.h" #define STAGING_BUFFER_SIZE 8192 diff --git a/deps/grpc/src/core/handshaker/security/secure_endpoint.cc b/deps/grpc/src/core/handshaker/security/secure_endpoint.cc index 94a69b7fb5f..2cd8eca0802 100644 --- a/deps/grpc/src/core/handshaker/security/secure_endpoint.cc +++ b/deps/grpc/src/core/handshaker/security/secure_endpoint.cc @@ -37,11 +37,6 @@ #include #include -#include "absl/base/thread_annotations.h" -#include "absl/log/log.h" -#include "absl/status/status.h" -#include "absl/strings/string_view.h" -#include "absl/types/span.h" #include "src/core/lib/debug/trace.h" #include "src/core/lib/experiments/experiments.h" #include "src/core/lib/iomgr/closure.h" @@ -63,6 +58,11 @@ #include "src/core/util/ref_counted_ptr.h" #include "src/core/util/string.h" #include "src/core/util/sync.h" +#include "absl/base/thread_annotations.h" +#include "absl/log/log.h" +#include "absl/status/status.h" +#include "absl/strings/string_view.h" +#include "absl/types/span.h" #define STAGING_BUFFER_SIZE 8192 @@ -71,6 +71,12 @@ static void on_write(void* user_data, grpc_error_handle error); namespace grpc_core { namespace { + +grpc_slice AllocSlice(size_t size, void* user_data) { + auto* owner = static_cast(user_data); + return owner->MakeSlice(MemoryRequest(size)); +} + class FrameProtector : public RefCounted { public: FrameProtector(tsi_frame_protector* protector, @@ -94,6 +100,10 @@ class FrameProtector : public RefCounted { } } if (zero_copy_protector_ != nullptr) { + if (IsTrackZeroCopyAllocationsInResourceQuotaEnabled()) { + tsi_zero_copy_grpc_protector_set_allocator(zero_copy_protector_, + &AllocSlice, &memory_owner_); + } read_staging_buffer_ = grpc_empty_slice(); write_staging_buffer_ = grpc_empty_slice(); } else { diff --git a/deps/grpc/src/core/handshaker/security/security_handshaker.cc b/deps/grpc/src/core/handshaker/security/security_handshaker.cc index 9496e517c76..5bf93e3370b 100644 --- a/deps/grpc/src/core/handshaker/security/security_handshaker.cc +++ b/deps/grpc/src/core/handshaker/security/security_handshaker.cc @@ -35,11 +35,6 @@ #include #include -#include "absl/base/attributes.h" -#include "absl/functional/any_invocable.h" -#include "absl/status/status.h" -#include "absl/strings/str_cat.h" -#include "absl/strings/string_view.h" #include "src/core/channelz/channelz.h" #include "src/core/config/core_configuration.h" #include "src/core/handshaker/handshaker.h" @@ -64,6 +59,11 @@ #include "src/core/util/ref_counted_ptr.h" #include "src/core/util/sync.h" #include "src/core/util/unique_type_name.h" +#include "absl/base/attributes.h" +#include "absl/functional/any_invocable.h" +#include "absl/status/status.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/string_view.h" #define GRPC_INITIAL_HANDSHAKE_BUFFER_SIZE 256 @@ -324,6 +324,9 @@ grpc_error_handle SecurityHandshaker::CheckPeerLocked() { }); connector_->check_peer(peer, args_->endpoint.get(), args_->args, &auth_context_, on_peer_checked_); + if (auth_context_ != nullptr) { + auth_context_->set_protocol(connector_->type().name()); + } grpc_auth_property_iterator it = grpc_auth_context_find_properties_by_name( auth_context_.get(), GRPC_TRANSPORT_SECURITY_LEVEL_PROPERTY_NAME); const grpc_auth_property* prop = grpc_auth_property_iterator_next(&it); diff --git a/deps/grpc/src/core/handshaker/security/security_handshaker.h b/deps/grpc/src/core/handshaker/security/security_handshaker.h index 1c42a8e64f7..193587521d0 100644 --- a/deps/grpc/src/core/handshaker/security/security_handshaker.h +++ b/deps/grpc/src/core/handshaker/security/security_handshaker.h @@ -22,13 +22,13 @@ #include #include -#include "absl/status/statusor.h" #include "src/core/config/core_configuration.h" #include "src/core/credentials/transport/security_connector.h" #include "src/core/handshaker/handshaker.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/tsi/transport_security_interface.h" #include "src/core/util/ref_counted_ptr.h" +#include "absl/status/statusor.h" namespace grpc_core { diff --git a/deps/grpc/src/core/handshaker/tcp_connect/tcp_connect_handshaker.cc b/deps/grpc/src/core/handshaker/tcp_connect/tcp_connect_handshaker.cc index 39351d119b8..b624afb0a5a 100644 --- a/deps/grpc/src/core/handshaker/tcp_connect/tcp_connect_handshaker.cc +++ b/deps/grpc/src/core/handshaker/tcp_connect/tcp_connect_handshaker.cc @@ -27,10 +27,6 @@ #include #include -#include "absl/base/thread_annotations.h" -#include "absl/functional/any_invocable.h" -#include "absl/status/status.h" -#include "absl/status/statusor.h" #include "src/core/config/core_configuration.h" #include "src/core/handshaker/handshaker.h" #include "src/core/handshaker/handshaker_factory.h" @@ -53,6 +49,10 @@ #include "src/core/util/ref_counted_ptr.h" #include "src/core/util/sync.h" #include "src/core/util/uri.h" +#include "absl/base/thread_annotations.h" +#include "absl/functional/any_invocable.h" +#include "absl/status/status.h" +#include "absl/status/statusor.h" namespace grpc_core { diff --git a/deps/grpc/src/core/lib/address_utils/parse_address.cc b/deps/grpc/src/core/lib/address_utils/parse_address.cc index 8a3c270a3d1..d31db250ca7 100644 --- a/deps/grpc/src/core/lib/address_utils/parse_address.cc +++ b/deps/grpc/src/core/lib/address_utils/parse_address.cc @@ -41,17 +41,17 @@ #endif // GRPC_HAVE_UNIX_SOCKET #include -#include "absl/log/check.h" -#include "absl/log/log.h" -#include "absl/status/status.h" -#include "absl/strings/str_cat.h" -#include "absl/strings/strip.h" #include "src/core/lib/iomgr/sockaddr.h" #include "src/core/lib/iomgr/socket_utils.h" #include "src/core/util/grpc_if_nametoindex.h" #include "src/core/util/host_port.h" #include "src/core/util/status_helper.h" #include "src/core/util/string.h" +#include "absl/log/check.h" +#include "absl/log/log.h" +#include "absl/status/status.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/strip.h" // IWYU pragma: no_include diff --git a/deps/grpc/src/core/lib/address_utils/parse_address.h b/deps/grpc/src/core/lib/address_utils/parse_address.h index 840d0c260bc..59d483b344d 100644 --- a/deps/grpc/src/core/lib/address_utils/parse_address.h +++ b/deps/grpc/src/core/lib/address_utils/parse_address.h @@ -22,11 +22,11 @@ #include #include -#include "absl/status/statusor.h" -#include "absl/strings/string_view.h" #include "src/core/lib/iomgr/error.h" #include "src/core/lib/iomgr/resolved_address.h" #include "src/core/util/uri.h" +#include "absl/status/statusor.h" +#include "absl/strings/string_view.h" /// Populate \a resolved_addr from \a uri, whose path is expected to contain a /// unix socket path. Returns true upon success. diff --git a/deps/grpc/src/core/lib/address_utils/sockaddr_utils.cc b/deps/grpc/src/core/lib/address_utils/sockaddr_utils.cc index 20e0d01a96c..0cbceeae5fa 100644 --- a/deps/grpc/src/core/lib/address_utils/sockaddr_utils.cc +++ b/deps/grpc/src/core/lib/address_utils/sockaddr_utils.cc @@ -31,16 +31,16 @@ #include #include -#include "absl/log/log.h" -#include "absl/status/status.h" -#include "absl/strings/str_cat.h" -#include "absl/strings/str_format.h" #include "src/core/lib/iomgr/port.h" #include "src/core/lib/iomgr/sockaddr.h" #include "src/core/lib/iomgr/socket_utils.h" #include "src/core/util/crash.h" #include "src/core/util/host_port.h" #include "src/core/util/uri.h" +#include "absl/log/log.h" +#include "absl/status/status.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/str_format.h" #ifdef GRPC_HAVE_UNIX_SOCKET #ifdef GPR_WINDOWS diff --git a/deps/grpc/src/core/lib/address_utils/sockaddr_utils.h b/deps/grpc/src/core/lib/address_utils/sockaddr_utils.h index c76aa64908a..9c34dc68219 100644 --- a/deps/grpc/src/core/lib/address_utils/sockaddr_utils.h +++ b/deps/grpc/src/core/lib/address_utils/sockaddr_utils.h @@ -24,8 +24,8 @@ #include -#include "absl/status/statusor.h" #include "src/core/lib/iomgr/resolved_address.h" +#include "absl/status/statusor.h" // Returns true if addr is an IPv4-mapped IPv6 address within the // ::ffff:0.0.0.0/96 range, or false otherwise. diff --git a/deps/grpc/src/core/lib/channel/channel_args.cc b/deps/grpc/src/core/lib/channel/channel_args.cc index 88faeadee3f..c4d3509d959 100644 --- a/deps/grpc/src/core/lib/channel/channel_args.cc +++ b/deps/grpc/src/core/lib/channel/channel_args.cc @@ -32,13 +32,13 @@ #include #include +#include "src/core/util/useful.h" #include "absl/log/check.h" #include "absl/log/log.h" #include "absl/strings/match.h" #include "absl/strings/str_cat.h" #include "absl/strings/str_format.h" #include "absl/strings/str_join.h" -#include "src/core/util/useful.h" namespace grpc_core { diff --git a/deps/grpc/src/core/lib/channel/channel_args.h b/deps/grpc/src/core/lib/channel/channel_args.h index 0184ead9fb5..24ee039ded3 100644 --- a/deps/grpc/src/core/lib/channel/channel_args.h +++ b/deps/grpc/src/core/lib/channel/channel_args.h @@ -33,8 +33,6 @@ #include #include -#include "absl/meta/type_traits.h" -#include "absl/strings/string_view.h" #include "src/core/channelz/property_list.h" #include "src/core/lib/surface/channel_stack_type.h" #include "src/core/util/avl.h" @@ -45,6 +43,8 @@ #include "src/core/util/ref_counted_string.h" #include "src/core/util/time.h" #include "src/core/util/useful.h" +#include "absl/meta/type_traits.h" +#include "absl/strings/string_view.h" // TODO(hork): When we're ready to allow setting via a channel arg from the // application, replace this with a macro in diff --git a/deps/grpc/src/core/lib/channel/channel_stack.cc b/deps/grpc/src/core/lib/channel/channel_stack.cc index 8077d7f970a..81f84f233bb 100644 --- a/deps/grpc/src/core/lib/channel/channel_stack.cc +++ b/deps/grpc/src/core/lib/channel/channel_stack.cc @@ -24,7 +24,6 @@ #include #include -#include "absl/log/log.h" #include "src/core/channelz/property_list.h" #include "src/core/config/core_configuration.h" #include "src/core/lib/channel/channel_args.h" @@ -32,6 +31,7 @@ #include "src/core/lib/surface/channel_init.h" #include "src/core/util/alloc.h" #include "src/core/util/grpc_check.h" +#include "absl/log/log.h" using grpc_event_engine::experimental::EventEngine; @@ -58,20 +58,19 @@ static int register_get_name_fn = []() { // per-filter memory, aligned to GPR_MAX_ALIGNMENT // } -size_t grpc_channel_stack_size(const grpc_channel_filter** filters, - size_t filter_count) { +size_t grpc_channel_stack_size( + const std::vector& filters) { // always need the header, and size for the channel elements size_t size = GPR_ROUND_UP_TO_ALIGNMENT_SIZE(sizeof(grpc_channel_stack)) + - GPR_ROUND_UP_TO_ALIGNMENT_SIZE(filter_count * + GPR_ROUND_UP_TO_ALIGNMENT_SIZE(filters.size() * sizeof(grpc_channel_element)); - size_t i; GRPC_CHECK((GPR_MAX_ALIGNMENT & (GPR_MAX_ALIGNMENT - 1)) == 0) << "GPR_MAX_ALIGNMENT must be a power of two"; // add the size for each filter - for (i = 0; i < filter_count; i++) { - size += GPR_ROUND_UP_TO_ALIGNMENT_SIZE(filters[i]->sizeof_channel_data); + for (const auto& [filter, _] : filters) { + size += GPR_ROUND_UP_TO_ALIGNMENT_SIZE(filter->sizeof_channel_data); } return size; @@ -114,13 +113,13 @@ grpc_call_element* grpc_call_stack_element(grpc_call_stack* call_stack, grpc_error_handle grpc_channel_stack_init( int initial_refs, grpc_iomgr_cb_func destroy, void* destroy_arg, - const grpc_channel_filter** filters, size_t filter_count, + std::vector filters, const grpc_core::ChannelArgs& channel_args, const char* name, grpc_channel_stack* stack, const grpc_core::Blackboard* blackboard) { if (GRPC_TRACE_FLAG_ENABLED(channel_stack)) { LOG(INFO) << "CHANNEL_STACK: init " << name; - for (size_t i = 0; i < filter_count; i++) { - LOG(INFO) << "CHANNEL_STACK: filter " << filters[i]->name; + for (const auto& [filter, _] : filters) { + LOG(INFO) << "CHANNEL_STACK: filter " << filter->name; } } @@ -128,31 +127,32 @@ grpc_error_handle grpc_channel_stack_init( stack->event_engine.Init(channel_args.GetObjectRef()); stack->stats_plugin_group.Init(); - size_t call_size = - GPR_ROUND_UP_TO_ALIGNMENT_SIZE(sizeof(grpc_call_stack)) + - GPR_ROUND_UP_TO_ALIGNMENT_SIZE(filter_count * sizeof(grpc_call_element)); + size_t call_size = GPR_ROUND_UP_TO_ALIGNMENT_SIZE(sizeof(grpc_call_stack)) + + GPR_ROUND_UP_TO_ALIGNMENT_SIZE(filters.size() * + sizeof(grpc_call_element)); grpc_channel_element* elems; grpc_channel_element_args args; char* user_data; size_t i; - stack->count = filter_count; + stack->count = filters.size(); GRPC_STREAM_REF_INIT(&stack->refcount, initial_refs, destroy, destroy_arg, name); elems = CHANNEL_ELEMS_FROM_STACK(stack); user_data = (reinterpret_cast(elems)) + - GPR_ROUND_UP_TO_ALIGNMENT_SIZE(filter_count * + GPR_ROUND_UP_TO_ALIGNMENT_SIZE(filters.size() * sizeof(grpc_channel_element)); // init per-filter data args.blackboard = blackboard; grpc_error_handle first_error; - for (i = 0; i < filter_count; i++) { + for (i = 0; i < filters.size(); ++i) { args.channel_stack = stack; args.channel_args = channel_args; args.is_first = i == 0; - args.is_last = i == (filter_count - 1); - elems[i].filter = filters[i]; + args.is_last = i == (filters.size() - 1); + args.config = std::move(filters[i].config); + elems[i].filter = filters[i].filter; elems[i].channel_data = user_data; grpc_error_handle error = elems[i].filter->init_channel_elem(&elems[i], &args); @@ -162,13 +162,14 @@ grpc_error_handle grpc_channel_stack_init( } } user_data += - GPR_ROUND_UP_TO_ALIGNMENT_SIZE(filters[i]->sizeof_channel_data); - call_size += GPR_ROUND_UP_TO_ALIGNMENT_SIZE(filters[i]->sizeof_call_data); + GPR_ROUND_UP_TO_ALIGNMENT_SIZE(filters[i].filter->sizeof_channel_data); + call_size += + GPR_ROUND_UP_TO_ALIGNMENT_SIZE(filters[i].filter->sizeof_call_data); } GRPC_CHECK(user_data > (char*)stack); GRPC_CHECK((uintptr_t)(user_data - (char*)stack) == - grpc_channel_stack_size(filters, filter_count)); + grpc_channel_stack_size(filters)); stack->call_stack_size = call_size; stack->channelz_data_source.Init( diff --git a/deps/grpc/src/core/lib/channel/channel_stack.h b/deps/grpc/src/core/lib/channel/channel_stack.h index 8a8bbb6422b..24d9d81c27e 100644 --- a/deps/grpc/src/core/lib/channel/channel_stack.h +++ b/deps/grpc/src/core/lib/channel/channel_stack.h @@ -48,6 +48,7 @@ #include #include +#include "src/core/filter/filter_args.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/channel_fwd.h" #include "src/core/lib/debug/trace.h" @@ -76,6 +77,7 @@ struct grpc_channel_element_args { grpc_core::ChannelArgs channel_args; int is_first; int is_last; + grpc_core::RefCountedPtr config; const grpc_core::Blackboard* blackboard; }; struct grpc_call_element_args { @@ -267,12 +269,12 @@ size_t grpc_channel_stack_filter_instance_number( grpc_call_element* grpc_call_stack_element(grpc_call_stack* stack, size_t i); // Determine memory required for a channel stack containing a set of filters -size_t grpc_channel_stack_size(const grpc_channel_filter** filters, - size_t filter_count); +size_t grpc_channel_stack_size( + const std::vector& filters); // Initialize a channel stack given some filters grpc_error_handle grpc_channel_stack_init( int initial_refs, grpc_iomgr_cb_func destroy, void* destroy_arg, - const grpc_channel_filter** filters, size_t filter_count, + std::vector filters, const grpc_core::ChannelArgs& args, const char* name, grpc_channel_stack* stack, const grpc_core::Blackboard* blackboard = nullptr); diff --git a/deps/grpc/src/core/lib/channel/channel_stack_builder.cc b/deps/grpc/src/core/lib/channel/channel_stack_builder.cc index 307176e08e1..30d3b35a06e 100644 --- a/deps/grpc/src/core/lib/channel/channel_stack_builder.cc +++ b/deps/grpc/src/core/lib/channel/channel_stack_builder.cc @@ -40,12 +40,16 @@ ChannelStackBuilder& ChannelStackBuilder::SetTarget(const char* target) { return *this; } -void ChannelStackBuilder::PrependFilter(const grpc_channel_filter* filter) { - stack_.insert(stack_.begin(), filter); +void ChannelStackBuilder::PrependFilter( + const grpc_channel_filter* filter, + RefCountedPtr config) { + stack_.insert(stack_.begin(), {filter, std::move(config)}); } -void ChannelStackBuilder::AppendFilter(const grpc_channel_filter* filter) { - stack_.push_back(filter); +void ChannelStackBuilder::AppendFilter( + const grpc_channel_filter* filter, + RefCountedPtr config) { + stack_.push_back({filter, std::move(config)}); } } // namespace grpc_core diff --git a/deps/grpc/src/core/lib/channel/channel_stack_builder.h b/deps/grpc/src/core/lib/channel/channel_stack_builder.h index b1e72116765..7ff406167b1 100644 --- a/deps/grpc/src/core/lib/channel/channel_stack_builder.h +++ b/deps/grpc/src/core/lib/channel/channel_stack_builder.h @@ -20,12 +20,13 @@ #include #include -#include "absl/status/statusor.h" -#include "absl/strings/string_view.h" +#include "src/core/filter/filter_args.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/channel_fwd.h" #include "src/core/lib/surface/channel_stack_type.h" #include "src/core/util/ref_counted_ptr.h" +#include "absl/status/statusor.h" +#include "absl/strings/string_view.h" namespace grpc_core { @@ -53,12 +54,10 @@ class ChannelStackBuilder { const ChannelArgs& channel_args() const { return args_; } // Mutable vector of proposed stack entries. - std::vector* mutable_stack() { return &stack_; } + std::vector* mutable_stack() { return &stack_; } // Immutable vector of proposed stack entries. - const std::vector& stack() const { - return stack_; - } + const std::vector& stack() const { return stack_; } // The type of channel stack being built. grpc_channel_stack_type channel_stack_type() const { return type_; } @@ -68,10 +67,12 @@ class ChannelStackBuilder { // channel init. // Helper to add a filter to the front of the stack. - void PrependFilter(const grpc_channel_filter* filter); + void PrependFilter(const grpc_channel_filter* filter, + RefCountedPtr config = nullptr); // Helper to add a filter to the end of the stack. - void AppendFilter(const grpc_channel_filter* filter); + void AppendFilter(const grpc_channel_filter* filter, + RefCountedPtr config = nullptr); // Build the channel stack. // After success, *result holds the new channel stack, @@ -95,7 +96,7 @@ class ChannelStackBuilder { // Channel args ChannelArgs args_; // The in-progress stack - std::vector stack_; + std::vector stack_; }; } // namespace grpc_core diff --git a/deps/grpc/src/core/lib/channel/channel_stack_builder_impl.cc b/deps/grpc/src/core/lib/channel/channel_stack_builder_impl.cc index bec031a0741..7b909414f6d 100644 --- a/deps/grpc/src/core/lib/channel/channel_stack_builder_impl.cc +++ b/deps/grpc/src/core/lib/channel/channel_stack_builder_impl.cc @@ -29,10 +29,6 @@ #include #include -#include "absl/base/thread_annotations.h" -#include "absl/container/flat_hash_map.h" -#include "absl/status/status.h" -#include "absl/strings/str_cat.h" #include "src/core/call/metadata_batch.h" #include "src/core/lib/channel/channel_fwd.h" #include "src/core/lib/channel/channel_stack.h" @@ -47,20 +43,19 @@ #include "src/core/lib/transport/transport.h" #include "src/core/util/no_destruct.h" #include "src/core/util/sync.h" +#include "absl/base/thread_annotations.h" +#include "absl/container/flat_hash_map.h" +#include "absl/status/status.h" +#include "absl/strings/str_cat.h" namespace grpc_core { absl::StatusOr> ChannelStackBuilderImpl::Build() { - std::vector stack; - - for (const auto* filter : this->stack()) { - stack.push_back(filter); - } + std::vector stack = this->stack(); // calculate the size of the channel stack - size_t channel_stack_size = - grpc_channel_stack_size(stack.data(), stack.size()); + size_t channel_stack_size = grpc_channel_stack_size(stack); // allocate memory auto* channel_stack = @@ -75,8 +70,7 @@ ChannelStackBuilderImpl::Build() { grpc_channel_stack_destroy(stk); gpr_free(stk); }, - channel_stack, stack.data(), stack.size(), channel_args(), name(), - channel_stack, blackboard_); + channel_stack, stack, channel_args(), name(), channel_stack, blackboard_); if (!error.ok()) { grpc_channel_stack_destroy(channel_stack); diff --git a/deps/grpc/src/core/lib/channel/channel_stack_builder_impl.h b/deps/grpc/src/core/lib/channel/channel_stack_builder_impl.h index d68421b629c..045494b4142 100644 --- a/deps/grpc/src/core/lib/channel/channel_stack_builder_impl.h +++ b/deps/grpc/src/core/lib/channel/channel_stack_builder_impl.h @@ -17,10 +17,10 @@ #include -#include "absl/status/statusor.h" #include "src/core/lib/channel/channel_fwd.h" #include "src/core/lib/channel/channel_stack_builder.h" #include "src/core/util/ref_counted_ptr.h" +#include "absl/status/statusor.h" namespace grpc_core { diff --git a/deps/grpc/src/core/lib/channel/connected_channel.cc b/deps/grpc/src/core/lib/channel/connected_channel.cc index e79cb43c770..5da68efa150 100644 --- a/deps/grpc/src/core/lib/channel/connected_channel.cc +++ b/deps/grpc/src/core/lib/channel/connected_channel.cc @@ -31,8 +31,6 @@ #include #include -#include "absl/status/status.h" -#include "absl/status/statusor.h" #include "src/core/call/call_finalization.h" #include "src/core/call/metadata_batch.h" #include "src/core/config/core_configuration.h" @@ -74,6 +72,8 @@ #include "src/core/util/orphanable.h" #include "src/core/util/ref_counted_ptr.h" #include "src/core/util/time.h" +#include "absl/status/status.h" +#include "absl/status/statusor.h" typedef struct connected_channel_channel_data { grpc_core::Transport* transport; diff --git a/deps/grpc/src/core/lib/channel/promise_based_filter.cc b/deps/grpc/src/core/lib/channel/promise_based_filter.cc index c0188e8f1d4..ea3c73eb32f 100644 --- a/deps/grpc/src/core/lib/channel/promise_based_filter.cc +++ b/deps/grpc/src/core/lib/channel/promise_based_filter.cc @@ -23,13 +23,6 @@ #include #include -#include "absl/base/attributes.h" -#include "absl/functional/function_ref.h" -#include "absl/log/log.h" -#include "absl/status/status.h" -#include "absl/strings/str_cat.h" -#include "absl/strings/str_format.h" -#include "absl/strings/str_join.h" #include "src/core/lib/channel/channel_stack.h" #include "src/core/lib/debug/trace.h" #include "src/core/lib/iomgr/error.h" @@ -40,6 +33,13 @@ #include "src/core/util/latent_see.h" #include "src/core/util/manual_constructor.h" #include "src/core/util/status_helper.h" +#include "absl/base/attributes.h" +#include "absl/functional/function_ref.h" +#include "absl/log/log.h" +#include "absl/status/status.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/str_format.h" +#include "absl/strings/str_join.h" namespace grpc_core { namespace promise_filter_detail { @@ -84,7 +84,13 @@ BaseCallData::BaseCallData( grpc_call_element* elem, const grpc_call_element_args* args, uint8_t flags, absl::FunctionRef make_send_interceptor, absl::FunctionRef make_recv_interceptor) - : call_stack_(args->call_stack), + : channelz::DataSource([args]() -> RefCountedPtr { + channelz::CallNode* call_node = + args->arena->GetContext(); + if (call_node == nullptr) return nullptr; + return call_node->Ref(); + }()), + call_stack_(args->call_stack), elem_(elem), arena_(args->arena), call_combiner_(args->call_combiner), @@ -149,6 +155,37 @@ std::string BaseCallData::LogTag() const { absl::Hex(reinterpret_cast(elem_), absl::kZeroPad8), "]"); } +void BaseCallData::AddData(channelz::DataSink sink) { + EnsureRunInExecCtx([this, sink = std::move(sink)]() mutable { + auto add = [sink, this](grpc_error_handle) mutable { + sink.AddData(elem_->filter->name.name(), ChannelzProperties()); + GRPC_CALL_COMBINER_STOP(call_combiner(), "channelz_add_data"); + GRPC_CALL_STACK_UNREF(call_stack_, "channelz_add_data"); + }; + GRPC_CALL_STACK_REF(call_stack_, "channelz_add_data"); + GRPC_CALL_COMBINER_START(call_combiner_, NewClosure(std::move(add)), + absl::OkStatus(), "channelz_add_data"); + }); +} + +channelz::PropertyList BaseCallData::ChannelzProperties() const { + channelz::PropertyList properties; + properties.Set("deadline", deadline_); + if (send_message_ != nullptr) { + properties.Set("promise_based_send_message", + send_message_->ChannelzProperties()); + } + if (receive_message_ != nullptr) { + properties.Set("promise_based_receive_message", + receive_message_->ChannelzProperties()); + } + if (server_initial_metadata_pipe_ != nullptr) { + properties.Set("server_initial_metadata_pipe", + server_initial_metadata_pipe_->sender.ChannelzProperties()); + } + return properties; +} + /////////////////////////////////////////////////////////////////////////////// // BaseCallData::CapturedBatch @@ -1270,9 +1307,11 @@ ClientCallData::ClientCallData(grpc_call_element* elem, if (server_initial_metadata_pipe() != nullptr) { recv_initial_metadata_ = arena()->New(); } + SourceConstructed(); } ClientCallData::~ClientCallData() { + SourceDestructing(); ScopedActivity scoped_activity(this); GRPC_CHECK_EQ(poll_ctx_, nullptr); if (recv_initial_metadata_ != nullptr) { @@ -1803,6 +1842,13 @@ void ClientCallData::OnWakeup() { WakeInsideCombiner(&flusher); } +channelz::PropertyList ClientCallData::ChannelzProperties() const { + return BaseCallData::ChannelzProperties() + .Set("promise", PromiseProperty(&promise_)) + .Set("send_initial_state", StateString(send_initial_state_)) + .Set("recv_trailing_state", StateString(recv_trailing_state_)); +} + /////////////////////////////////////////////////////////////////////////////// // ServerCallData @@ -1952,9 +1998,11 @@ ServerCallData::ServerCallData(grpc_call_element* elem, GRPC_CLOSURE_INIT(&recv_trailing_metadata_ready_, RecvTrailingMetadataReadyCallback, this, grpc_schedule_on_exec_ctx); + SourceConstructed(); } ServerCallData::~ServerCallData() { + SourceDestructing(); GRPC_TRACE_LOG(channel, INFO) << LogTag() << " ~ServerCallData " << DebugString(); if (send_initial_metadata_ != nullptr) { @@ -2503,5 +2551,12 @@ void ServerCallData::OnWakeup() { WakeInsideCombiner(&flusher); } +channelz::PropertyList ServerCallData::ChannelzProperties() const { + return BaseCallData::ChannelzProperties() + .Set("promise", PromiseProperty(&promise_)) + .Set("recv_initial_state", StateString(recv_initial_state_)) + .Set("send_trailing_state", StateString(send_trailing_state_)); +} + } // namespace promise_filter_detail } // namespace grpc_core diff --git a/deps/grpc/src/core/lib/channel/promise_based_filter.h b/deps/grpc/src/core/lib/channel/promise_based_filter.h index 7f227432a2b..fa8c7c34294 100644 --- a/deps/grpc/src/core/lib/channel/promise_based_filter.h +++ b/deps/grpc/src/core/lib/channel/promise_based_filter.h @@ -33,12 +33,6 @@ #include #include -#include "absl/container/inlined_vector.h" -#include "absl/functional/function_ref.h" -#include "absl/log/log.h" -#include "absl/meta/type_traits.h" -#include "absl/status/status.h" -#include "absl/strings/string_view.h" #include "src/core/call/call_filters.h" #include "src/core/call/call_finalization.h" #include "src/core/call/message.h" @@ -75,6 +69,12 @@ #include "src/core/util/grpc_check.h" #include "src/core/util/match.h" #include "src/core/util/time.h" +#include "absl/container/inlined_vector.h" +#include "absl/functional/function_ref.h" +#include "absl/log/log.h" +#include "absl/meta/type_traits.h" +#include "absl/status/status.h" +#include "absl/strings/string_view.h" namespace grpc_core { @@ -1248,7 +1248,9 @@ class InvalidChannelFilter : public ChannelFilter { }; // Call data shared between all implementations of promise-based filters. -class BaseCallData : public Activity, private Wakeable { +class BaseCallData : public Activity, + private Wakeable, + public channelz::DataSource { protected: // Hook to allow interception of messages on the send/receive path by // PipeSender and PipeReceiver, as appropriate according to whether we're @@ -1293,6 +1295,8 @@ class BaseCallData : public Activity, private Wakeable { Call* call() { return arena_->GetContext(); } + void AddData(channelz::DataSink sink) final; + protected: class ScopedContext : public promise_detail::Context, public promise_detail::Context, @@ -1471,6 +1475,10 @@ class BaseCallData : public Activity, private Wakeable { // Return true if we've released the message for forwarding down the stack. bool IsForwarded() const { return state_ == State::kForwardedBatch; } + channelz::PropertyList ChannelzProperties() { + return channelz::PropertyList().Set("state", StateString(state_)); + } + private: enum class State : uint8_t { // Starting state: no batch started, no outgoing pipe configured. @@ -1544,6 +1552,10 @@ class BaseCallData : public Activity, private Wakeable { // Call is completed, we have trailing metadata. Close things out. void Done(const ServerMetadata& metadata, Flusher* flusher); + channelz::PropertyList ChannelzProperties() { + return channelz::PropertyList().Set("state", StateString(state_)); + } + private: enum class State : uint8_t { // Starting state: no batch started, no incoming pipe configured. @@ -1626,6 +1638,7 @@ class BaseCallData : public Activity, private Wakeable { } SendMessage* send_message() const { return send_message_; } ReceiveMessage* receive_message() const { return receive_message_; } + virtual channelz::PropertyList ChannelzProperties() const; bool is_last() const { return grpc_call_stack_element(call_stack_, call_stack_->count - 1) == @@ -1707,6 +1720,7 @@ class ClientCallData : public BaseCallData { static const char* StateString(SendInitialState); static const char* StateString(RecvTrailingState); std::string DebugString() const; + channelz::PropertyList ChannelzProperties() const override; struct RecvInitialMetadata; class PollContext; @@ -1823,6 +1837,7 @@ class ServerCallData : public BaseCallData { static const char* StateString(RecvInitialState state); static const char* StateString(SendTrailingState state); std::string DebugString() const; + channelz::PropertyList ChannelzProperties() const override; class PollContext; struct SendInitialMetadata; @@ -1985,7 +2000,7 @@ struct ChannelFilterWithFlagsMethods { F::Create(args->channel_args, ChannelFilter::Args(args->channel_stack, elem, grpc_channel_stack_filter_instance_number, - args->blackboard)); + args->config, args->blackboard)); if (!status.ok()) { new (elem->channel_data) F*(nullptr); return absl_status_to_grpc_error(status.status()); diff --git a/deps/grpc/src/core/lib/compression/compression_internal.cc b/deps/grpc/src/core/lib/compression/compression_internal.cc index 786aec72850..8398b298e6b 100644 --- a/deps/grpc/src/core/lib/compression/compression_internal.cc +++ b/deps/grpc/src/core/lib/compression/compression_internal.cc @@ -24,16 +24,16 @@ #include -#include "absl/container/inlined_vector.h" -#include "absl/strings/ascii.h" -#include "absl/strings/str_format.h" -#include "absl/strings/str_split.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/debug/trace.h" #include "src/core/util/crash.h" #include "src/core/util/grpc_check.h" #include "src/core/util/ref_counted_ptr.h" #include "src/core/util/ref_counted_string.h" +#include "absl/container/inlined_vector.h" +#include "absl/strings/ascii.h" +#include "absl/strings/str_format.h" +#include "absl/strings/str_split.h" namespace grpc_core { diff --git a/deps/grpc/src/core/lib/compression/compression_internal.h b/deps/grpc/src/core/lib/compression/compression_internal.h index be558da72f0..345c729fc01 100644 --- a/deps/grpc/src/core/lib/compression/compression_internal.h +++ b/deps/grpc/src/core/lib/compression/compression_internal.h @@ -26,10 +26,10 @@ #include #include -#include "absl/strings/string_view.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/slice/slice.h" #include "src/core/util/bitset.h" +#include "absl/strings/string_view.h" namespace grpc_core { diff --git a/deps/grpc/src/core/lib/compression/message_compress.cc b/deps/grpc/src/core/lib/compression/message_compress.cc index f03a670f4f7..8867443d13a 100644 --- a/deps/grpc/src/core/lib/compression/message_compress.cc +++ b/deps/grpc/src/core/lib/compression/message_compress.cc @@ -25,9 +25,9 @@ #include #include -#include "absl/log/log.h" #include "src/core/lib/slice/slice.h" #include "src/core/util/grpc_check.h" +#include "absl/log/log.h" #define OUTPUT_BLOCK_SIZE 1024 diff --git a/deps/grpc/src/core/lib/debug/GEMINI.md b/deps/grpc/src/core/lib/debug/GEMINI.md index f77f9c26c20..21d24c319e8 100644 --- a/deps/grpc/src/core/lib/debug/GEMINI.md +++ b/deps/grpc/src/core/lib/debug/GEMINI.md @@ -9,7 +9,7 @@ The tracing library provides a mechanism for logging trace messages from differe ## How to Add a New Trace Flag 1. Add a new entry to the `trace_flags.yaml` file. The entry should include the name of the trace flag and a brief description of what it does. -2. Run the `tools/codegen/core/gen_trace_flags.py` script to regenerate the `trace_flags.h` and `trace_flags.cc` files. +2. Run the `tools/codegen/core/generate_trace_flags_main.cc` script to regenerate the `trace_flags.h` and `trace_flags.cc` files. 3. Use the `GRPC_TRACE_FLAG_ENABLED` macro to check if the trace flag is enabled, and the `GRPC_TRACE_LOG`, `GRPC_TRACE_DLOG`, or `GRPC_TRACE_VLOG` macros to log trace messages. ## Files diff --git a/deps/grpc/src/core/lib/debug/trace.cc b/deps/grpc/src/core/lib/debug/trace.cc index bd4a81b8ffe..68275482474 100644 --- a/deps/grpc/src/core/lib/debug/trace.cc +++ b/deps/grpc/src/core/lib/debug/trace.cc @@ -18,23 +18,20 @@ #include "src/core/lib/debug/trace.h" -#include #include #include #include #include +#include "src/core/config/config_vars.h" +#include "src/core/util/glob.h" #include "absl/log/log.h" #include "absl/strings/match.h" #include "absl/strings/str_cat.h" #include "absl/strings/str_split.h" #include "absl/strings/string_view.h" #include "absl/strings/strip.h" -#include "src/core/config/config_vars.h" -#include "src/core/util/glob.h" - -int grpc_tracer_set_enabled(const char* name, int enabled); namespace grpc_core { namespace { diff --git a/deps/grpc/src/core/lib/debug/trace.h b/deps/grpc/src/core/lib/debug/trace.h index 6f05aa7abf4..d8aa6ea365b 100644 --- a/deps/grpc/src/core/lib/debug/trace.h +++ b/deps/grpc/src/core/lib/debug/trace.h @@ -18,4 +18,14 @@ #include "src/core/lib/debug/trace_flags.h" // IWYU pragma: export #include "src/core/lib/debug/trace_impl.h" // IWYU pragma: export +#ifdef __cplusplus +extern "C" { +#endif + +int grpc_tracer_set_enabled(const char* name, int enabled); + +#ifdef __cplusplus +} +#endif + #endif // GRPC_SRC_CORE_LIB_DEBUG_TRACE_H diff --git a/deps/grpc/src/core/lib/debug/trace_flags.cc b/deps/grpc/src/core/lib/debug/trace_flags.cc index a66af850b49..6d7eae7cc02 100644 --- a/deps/grpc/src/core/lib/debug/trace_flags.cc +++ b/deps/grpc/src/core/lib/debug/trace_flags.cc @@ -13,12 +13,12 @@ // limitations under the License. // -// Automatically generated by tools/codegen/core/gen_trace_flags.py +// Automatically generated by tools/codegen/core/generate_trace_flags.cc // -#include "absl/container/flat_hash_map.h" #include "src/core/lib/debug/trace.h" #include "src/core/util/no_destruct.h" +#include "absl/container/flat_hash_map.h" namespace grpc_core { diff --git a/deps/grpc/src/core/lib/debug/trace_flags.h b/deps/grpc/src/core/lib/debug/trace_flags.h index 6d4fffe0379..b6a39f3ddeb 100644 --- a/deps/grpc/src/core/lib/debug/trace_flags.h +++ b/deps/grpc/src/core/lib/debug/trace_flags.h @@ -13,7 +13,7 @@ // limitations under the License. // -// Automatically generated by tools/codegen/core/gen_trace_flags.py +// Automatically generated by tools/codegen/core/generate_trace_flags.cc // #ifndef GRPC_SRC_CORE_LIB_DEBUG_TRACE_FLAGS_H diff --git a/deps/grpc/src/core/lib/event_engine/ares_resolver.cc b/deps/grpc/src/core/lib/event_engine/ares_resolver.cc index 77d62cbe00b..2d80ce22a43 100644 --- a/deps/grpc/src/core/lib/event_engine/ares_resolver.cc +++ b/deps/grpc/src/core/lib/event_engine/ares_resolver.cc @@ -53,14 +53,6 @@ #include #include -#include "absl/functional/any_invocable.h" -#include "absl/log/log.h" -#include "absl/strings/match.h" -#include "absl/strings/numbers.h" -#include "absl/strings/str_cat.h" -#include "absl/strings/str_format.h" -#include "absl/strings/string_view.h" -#include "absl/strings/substitute.h" #include "src/core/config/config_vars.h" #include "src/core/lib/address_utils/parse_address.h" #include "src/core/lib/address_utils/sockaddr_utils.h" @@ -73,6 +65,14 @@ #include "src/core/util/host_port.h" #include "src/core/util/orphanable.h" #include "src/core/util/ref_counted_ptr.h" +#include "absl/functional/any_invocable.h" +#include "absl/log/log.h" +#include "absl/strings/match.h" +#include "absl/strings/numbers.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/str_format.h" +#include "absl/strings/string_view.h" +#include "absl/strings/substitute.h" #ifdef GRPC_POSIX_SOCKET_ARES_EV_DRIVER #include "src/core/lib/event_engine/posix_engine/tcp_socket_utils.h" #endif diff --git a/deps/grpc/src/core/lib/event_engine/ares_resolver.h b/deps/grpc/src/core/lib/event_engine/ares_resolver.h index 895bf0b3ffd..ce258dade90 100644 --- a/deps/grpc/src/core/lib/event_engine/ares_resolver.h +++ b/deps/grpc/src/core/lib/event_engine/ares_resolver.h @@ -30,14 +30,14 @@ #include #include -#include "absl/base/thread_annotations.h" -#include "absl/container/flat_hash_map.h" -#include "absl/status/statusor.h" -#include "absl/strings/string_view.h" #include "src/core/lib/event_engine/grpc_polled_fd.h" #include "src/core/lib/event_engine/ref_counted_dns_resolver_interface.h" #include "src/core/util/orphanable.h" #include "src/core/util/sync.h" +#include "absl/base/thread_annotations.h" +#include "absl/container/flat_hash_map.h" +#include "absl/status/statusor.h" +#include "absl/strings/string_view.h" namespace grpc_event_engine::experimental { diff --git a/deps/grpc/src/core/lib/event_engine/cf_engine/cf_engine.cc b/deps/grpc/src/core/lib/event_engine/cf_engine/cf_engine.cc index f2f27c618c0..2f3d3f910ef 100644 --- a/deps/grpc/src/core/lib/event_engine/cf_engine/cf_engine.cc +++ b/deps/grpc/src/core/lib/event_engine/cf_engine/cf_engine.cc @@ -21,7 +21,6 @@ #include #include -#include "absl/log/log.h" #include "src/core/lib/event_engine/cf_engine/cf_engine.h" #include "src/core/lib/event_engine/cf_engine/cfsocket_listener.h" #include "src/core/lib/event_engine/cf_engine/cfstream_endpoint.h" @@ -33,6 +32,7 @@ #include "src/core/util/crash.h" #include "src/core/util/grpc_check.h" #include "src/core/util/useful.h" +#include "absl/log/log.h" #ifndef GRPC_CFSTREAM_MAX_THREADPOOL_SIZE #define GRPC_CFSTREAM_MAX_THREADPOOL_SIZE 16u diff --git a/deps/grpc/src/core/lib/event_engine/cf_engine/cfstream_endpoint.cc b/deps/grpc/src/core/lib/event_engine/cf_engine/cfstream_endpoint.cc index c7694ecd13d..65bf311eafa 100644 --- a/deps/grpc/src/core/lib/event_engine/cf_engine/cfstream_endpoint.cc +++ b/deps/grpc/src/core/lib/event_engine/cf_engine/cfstream_endpoint.cc @@ -18,11 +18,11 @@ #include #ifdef AVAILABLE_MAC_OS_X_VERSION_10_12_AND_LATER +#include "src/core/lib/event_engine/cf_engine/cfstream_endpoint.h" +#include "src/core/util/strerror.h" #include "absl/status/status.h" #include "absl/strings/str_cat.h" #include "absl/strings/str_format.h" -#include "src/core/lib/event_engine/cf_engine/cfstream_endpoint.h" -#include "src/core/util/strerror.h" namespace grpc_event_engine::experimental { diff --git a/deps/grpc/src/core/lib/event_engine/cf_engine/cfstream_endpoint.h b/deps/grpc/src/core/lib/event_engine/cf_engine/cfstream_endpoint.h index b13e48efff3..af745d04a2a 100644 --- a/deps/grpc/src/core/lib/event_engine/cf_engine/cfstream_endpoint.h +++ b/deps/grpc/src/core/lib/event_engine/cf_engine/cfstream_endpoint.h @@ -22,7 +22,6 @@ #include #include -#include "absl/strings/str_format.h" #include "src/core/lib/address_utils/sockaddr_utils.h" #include "src/core/lib/event_engine/cf_engine/cf_engine.h" #include "src/core/lib/event_engine/cf_engine/cftype_unique_ref.h" @@ -31,6 +30,7 @@ #include "src/core/util/host_port.h" #include "src/core/util/ref_counted.h" #include "src/core/util/ref_counted_ptr.h" +#include "absl/strings/str_format.h" namespace grpc_event_engine::experimental { diff --git a/deps/grpc/src/core/lib/event_engine/cf_engine/dns_service_resolver.cc b/deps/grpc/src/core/lib/event_engine/cf_engine/dns_service_resolver.cc index 1d6b304fa45..f7c36996d10 100644 --- a/deps/grpc/src/core/lib/event_engine/cf_engine/dns_service_resolver.cc +++ b/deps/grpc/src/core/lib/event_engine/cf_engine/dns_service_resolver.cc @@ -18,14 +18,14 @@ #include #ifdef AVAILABLE_MAC_OS_X_VERSION_10_12_AND_LATER -#include "absl/strings/str_cat.h" -#include "absl/strings/str_format.h" #include "src/core/lib/address_utils/parse_address.h" #include "src/core/lib/event_engine/cf_engine/dns_service_resolver.h" #include "src/core/lib/event_engine/posix_engine/lockfree_event.h" #include "src/core/lib/event_engine/tcp_socket_utils.h" #include "src/core/util/grpc_check.h" #include "src/core/util/host_port.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/str_format.h" namespace grpc_event_engine::experimental { diff --git a/deps/grpc/src/core/lib/event_engine/cf_engine/dns_service_resolver.h b/deps/grpc/src/core/lib/event_engine/cf_engine/dns_service_resolver.h index 8bf21ba4bf4..94e1316397d 100644 --- a/deps/grpc/src/core/lib/event_engine/cf_engine/dns_service_resolver.h +++ b/deps/grpc/src/core/lib/event_engine/cf_engine/dns_service_resolver.h @@ -23,11 +23,11 @@ #include #include -#include "absl/container/flat_hash_map.h" #include "src/core/lib/event_engine/cf_engine/cf_engine.h" #include "src/core/util/grpc_check.h" #include "src/core/util/ref_counted.h" #include "src/core/util/ref_counted_ptr.h" +#include "absl/container/flat_hash_map.h" namespace grpc_event_engine::experimental { diff --git a/deps/grpc/src/core/lib/event_engine/channel_args_endpoint_config.h b/deps/grpc/src/core/lib/event_engine/channel_args_endpoint_config.h index 8499ee27ee2..e00f881ae3b 100644 --- a/deps/grpc/src/core/lib/event_engine/channel_args_endpoint_config.h +++ b/deps/grpc/src/core/lib/event_engine/channel_args_endpoint_config.h @@ -19,8 +19,8 @@ #include -#include "absl/strings/string_view.h" #include "src/core/lib/channel/channel_args.h" +#include "absl/strings/string_view.h" namespace grpc_event_engine::experimental { diff --git a/deps/grpc/src/core/lib/event_engine/default_event_engine.cc b/deps/grpc/src/core/lib/event_engine/default_event_engine.cc index 10d17647c30..89597b0861a 100644 --- a/deps/grpc/src/core/lib/event_engine/default_event_engine.cc +++ b/deps/grpc/src/core/lib/event_engine/default_event_engine.cc @@ -22,7 +22,6 @@ #include #include -#include "absl/functional/any_invocable.h" #include "src/core/config/core_configuration.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/event_engine/default_event_engine_factory.h" @@ -31,6 +30,7 @@ #include "src/core/util/no_destruct.h" #include "src/core/util/sync.h" #include "src/core/util/wait_for_single_owner.h" +#include "absl/functional/any_invocable.h" #ifdef GRPC_MAXIMIZE_THREADYNESS #include "src/core/lib/event_engine/thready_event_engine/thready_event_engine.h" // IWYU pragma: keep diff --git a/deps/grpc/src/core/lib/event_engine/event_engine.cc b/deps/grpc/src/core/lib/event_engine/event_engine.cc index 30d34b0b598..94c646f832b 100644 --- a/deps/grpc/src/core/lib/event_engine/event_engine.cc +++ b/deps/grpc/src/core/lib/event_engine/event_engine.cc @@ -14,8 +14,8 @@ #include #include -#include "absl/strings/str_cat.h" #include "src/core/telemetry/context_list_entry.h" +#include "absl/strings/str_cat.h" namespace grpc_event_engine::experimental { diff --git a/deps/grpc/src/core/lib/event_engine/extensions/channelz.h b/deps/grpc/src/core/lib/event_engine/extensions/channelz.h index 980752cad29..5f6c03fa083 100644 --- a/deps/grpc/src/core/lib/event_engine/extensions/channelz.h +++ b/deps/grpc/src/core/lib/event_engine/extensions/channelz.h @@ -18,9 +18,9 @@ #include #include -#include "absl/strings/string_view.h" #include "src/core/channelz/channelz.h" #include "src/core/util/ref_counted_ptr.h" +#include "absl/strings/string_view.h" namespace grpc_event_engine::experimental { diff --git a/deps/grpc/src/core/lib/event_engine/extensions/chaotic_good_extension.h b/deps/grpc/src/core/lib/event_engine/extensions/chaotic_good_extension.h index 9414378a238..8522d2f2200 100644 --- a/deps/grpc/src/core/lib/event_engine/extensions/chaotic_good_extension.h +++ b/deps/grpc/src/core/lib/event_engine/extensions/chaotic_good_extension.h @@ -17,8 +17,8 @@ #include -#include "absl/strings/string_view.h" #include "src/core/lib/resource_quota/memory_quota.h" +#include "absl/strings/string_view.h" namespace grpc_event_engine::experimental { diff --git a/deps/grpc/src/core/lib/event_engine/extensions/tcp_trace.h b/deps/grpc/src/core/lib/event_engine/extensions/tcp_trace.h index f31eedffcf5..cfee8fc6102 100644 --- a/deps/grpc/src/core/lib/event_engine/extensions/tcp_trace.h +++ b/deps/grpc/src/core/lib/event_engine/extensions/tcp_trace.h @@ -17,8 +17,10 @@ #include -#include "absl/strings/string_view.h" +#include "src/core/telemetry/instrument.h" #include "src/core/telemetry/tcp_tracer.h" +#include "src/core/util/ref_counted_ptr.h" +#include "absl/strings/string_view.h" namespace grpc_event_engine::experimental { @@ -33,6 +35,11 @@ class TcpTraceExtension { } virtual void SetTcpTracer( std::shared_ptr tracer) = 0; + + // Enable TCP telemetry collection using the Instrumentation API. + virtual void EnableTcpTelemetry( + grpc_core::RefCountedPtr collection_scope, + bool is_control_endpoint) = 0; }; } // namespace grpc_event_engine::experimental diff --git a/deps/grpc/src/core/lib/event_engine/grpc_polled_fd.h b/deps/grpc/src/core/lib/event_engine/grpc_polled_fd.h index 2f02d91bad8..2885697a314 100644 --- a/deps/grpc/src/core/lib/event_engine/grpc_polled_fd.h +++ b/deps/grpc/src/core/lib/event_engine/grpc_polled_fd.h @@ -24,9 +24,9 @@ #include +#include "src/core/util/sync.h" #include "absl/functional/any_invocable.h" #include "absl/status/status.h" -#include "src/core/util/sync.h" namespace grpc_event_engine::experimental { diff --git a/deps/grpc/src/core/lib/event_engine/memory_allocator_factory.h b/deps/grpc/src/core/lib/event_engine/memory_allocator_factory.h index ccc675dbefa..64a4637e4f7 100644 --- a/deps/grpc/src/core/lib/event_engine/memory_allocator_factory.h +++ b/deps/grpc/src/core/lib/event_engine/memory_allocator_factory.h @@ -19,8 +19,8 @@ #include #include -#include "absl/strings/string_view.h" #include "src/core/lib/resource_quota/memory_quota.h" +#include "absl/strings/string_view.h" namespace grpc_event_engine::experimental { diff --git a/deps/grpc/src/core/lib/event_engine/posix_engine/ev_epoll1_linux.cc b/deps/grpc/src/core/lib/event_engine/posix_engine/ev_epoll1_linux.cc index f2cfbd766cb..977fa5d098b 100644 --- a/deps/grpc/src/core/lib/event_engine/posix_engine/ev_epoll1_linux.cc +++ b/deps/grpc/src/core/lib/event_engine/posix_engine/ev_epoll1_linux.cc @@ -22,16 +22,16 @@ #include #include -#include "absl/log/log.h" -#include "absl/status/status.h" -#include "absl/status/statusor.h" -#include "absl/strings/str_format.h" #include "src/core/lib/event_engine/poller.h" #include "src/core/lib/event_engine/posix_engine/posix_interface.h" #include "src/core/lib/event_engine/time_util.h" #include "src/core/lib/iomgr/port.h" #include "src/core/util/crash.h" #include "src/core/util/grpc_check.h" +#include "absl/log/log.h" +#include "absl/status/status.h" +#include "absl/status/statusor.h" +#include "absl/strings/str_format.h" // This polling engine is only relevant on linux kernels supporting epoll // epoll_create() or epoll_create1() diff --git a/deps/grpc/src/core/lib/event_engine/posix_engine/ev_epoll1_linux.h b/deps/grpc/src/core/lib/event_engine/posix_engine/ev_epoll1_linux.h index a432864ae42..d37d97e1d79 100644 --- a/deps/grpc/src/core/lib/event_engine/posix_engine/ev_epoll1_linux.h +++ b/deps/grpc/src/core/lib/event_engine/posix_engine/ev_epoll1_linux.h @@ -21,11 +21,6 @@ #include #include -#include "absl/base/thread_annotations.h" -#include "absl/container/flat_hash_set.h" -#include "absl/container/inlined_vector.h" -#include "absl/functional/function_ref.h" -#include "absl/strings/string_view.h" #include "src/core/lib/event_engine/poller.h" #include "src/core/lib/event_engine/posix_engine/event_poller.h" #include "src/core/lib/event_engine/posix_engine/internal_errqueue.h" @@ -33,6 +28,11 @@ #include "src/core/lib/event_engine/thread_pool/thread_pool.h" #include "src/core/lib/iomgr/port.h" #include "src/core/util/sync.h" +#include "absl/base/thread_annotations.h" +#include "absl/container/flat_hash_set.h" +#include "absl/container/inlined_vector.h" +#include "absl/functional/function_ref.h" +#include "absl/strings/string_view.h" #ifdef GRPC_LINUX_EPOLL #include diff --git a/deps/grpc/src/core/lib/event_engine/posix_engine/ev_poll_posix.cc b/deps/grpc/src/core/lib/event_engine/posix_engine/ev_poll_posix.cc index 773053048a9..9a511da9fa3 100644 --- a/deps/grpc/src/core/lib/event_engine/posix_engine/ev_poll_posix.cc +++ b/deps/grpc/src/core/lib/event_engine/posix_engine/ev_poll_posix.cc @@ -26,11 +26,6 @@ #include #include -#include "absl/container/inlined_vector.h" -#include "absl/functional/any_invocable.h" -#include "absl/status/status.h" -#include "absl/status/statusor.h" -#include "absl/strings/str_format.h" #include "src/core/lib/event_engine/poller.h" #include "src/core/lib/event_engine/posix_engine/event_poller.h" #include "src/core/lib/event_engine/posix_engine/posix_engine_closure.h" @@ -38,6 +33,11 @@ #include "src/core/lib/iomgr/port.h" #include "src/core/util/crash.h" #include "src/core/util/grpc_check.h" +#include "absl/container/inlined_vector.h" +#include "absl/functional/any_invocable.h" +#include "absl/status/status.h" +#include "absl/status/statusor.h" +#include "absl/strings/str_format.h" #ifdef GRPC_POSIX_SOCKET_EV_POLL diff --git a/deps/grpc/src/core/lib/event_engine/posix_engine/ev_poll_posix.h b/deps/grpc/src/core/lib/event_engine/posix_engine/ev_poll_posix.h index b888f389a2c..b550f312085 100644 --- a/deps/grpc/src/core/lib/event_engine/posix_engine/ev_poll_posix.h +++ b/deps/grpc/src/core/lib/event_engine/posix_engine/ev_poll_posix.h @@ -21,14 +21,14 @@ #include #include -#include "absl/base/thread_annotations.h" -#include "absl/functional/function_ref.h" -#include "absl/strings/string_view.h" #include "src/core/lib/event_engine/poller.h" #include "src/core/lib/event_engine/posix_engine/event_poller.h" #include "src/core/lib/event_engine/posix_engine/wakeup_fd_posix.h" #include "src/core/lib/event_engine/thread_pool/thread_pool.h" #include "src/core/util/sync.h" +#include "absl/base/thread_annotations.h" +#include "absl/functional/function_ref.h" +#include "absl/strings/string_view.h" namespace grpc_event_engine::experimental { diff --git a/deps/grpc/src/core/lib/event_engine/posix_engine/event_poller.h b/deps/grpc/src/core/lib/event_engine/posix_engine/event_poller.h index c4a9e517e1a..cde088e01b8 100644 --- a/deps/grpc/src/core/lib/event_engine/posix_engine/event_poller.h +++ b/deps/grpc/src/core/lib/event_engine/posix_engine/event_poller.h @@ -19,11 +19,11 @@ #include -#include "absl/status/status.h" -#include "absl/strings/string_view.h" #include "src/core/lib/event_engine/poller.h" #include "src/core/lib/event_engine/posix_engine/posix_engine_closure.h" #include "src/core/lib/event_engine/posix_engine/posix_interface.h" +#include "absl/status/status.h" +#include "absl/strings/string_view.h" namespace grpc_event_engine::experimental { diff --git a/deps/grpc/src/core/lib/event_engine/posix_engine/event_poller_posix_default.cc b/deps/grpc/src/core/lib/event_engine/posix_engine/event_poller_posix_default.cc index 0dd03e824f3..c0d08be9898 100644 --- a/deps/grpc/src/core/lib/event_engine/posix_engine/event_poller_posix_default.cc +++ b/deps/grpc/src/core/lib/event_engine/posix_engine/event_poller_posix_default.cc @@ -17,13 +17,13 @@ #include #include -#include "absl/strings/str_split.h" -#include "absl/strings/string_view.h" #include "src/core/config/config_vars.h" #include "src/core/lib/event_engine/posix_engine/ev_epoll1_linux.h" #include "src/core/lib/event_engine/posix_engine/ev_poll_posix.h" #include "src/core/lib/event_engine/posix_engine/event_poller.h" #include "src/core/lib/iomgr/port.h" +#include "absl/strings/str_split.h" +#include "absl/strings/string_view.h" namespace grpc_event_engine::experimental { diff --git a/deps/grpc/src/core/lib/event_engine/posix_engine/file_descriptor_collection.cc b/deps/grpc/src/core/lib/event_engine/posix_engine/file_descriptor_collection.cc index a6ffbeeb5ac..3be6528277d 100644 --- a/deps/grpc/src/core/lib/event_engine/posix_engine/file_descriptor_collection.cc +++ b/deps/grpc/src/core/lib/event_engine/posix_engine/file_descriptor_collection.cc @@ -14,10 +14,10 @@ #include "src/core/lib/event_engine/posix_engine/file_descriptor_collection.h" -#include "absl/strings/substitute.h" #include "src/core/lib/experiments/experiments.h" #include "src/core/util/crash.h" // IWYU pragma: keep #include "src/core/util/strerror.h" +#include "absl/strings/substitute.h" namespace grpc_event_engine::experimental { diff --git a/deps/grpc/src/core/lib/event_engine/posix_engine/file_descriptor_collection.h b/deps/grpc/src/core/lib/event_engine/posix_engine/file_descriptor_collection.h index 36de68e5fc1..4dbe6de1f76 100644 --- a/deps/grpc/src/core/lib/event_engine/posix_engine/file_descriptor_collection.h +++ b/deps/grpc/src/core/lib/event_engine/posix_engine/file_descriptor_collection.h @@ -21,10 +21,10 @@ #include #include +#include "src/core/util/sync.h" #include "absl/container/flat_hash_set.h" #include "absl/strings/str_cat.h" #include "absl/strings/str_format.h" -#include "src/core/util/sync.h" namespace grpc_event_engine::experimental { diff --git a/deps/grpc/src/core/lib/event_engine/posix_engine/grpc_polled_fd_posix.h b/deps/grpc/src/core/lib/event_engine/posix_engine/grpc_polled_fd_posix.h index f17b390638c..75a9c3a02d9 100644 --- a/deps/grpc/src/core/lib/event_engine/posix_engine/grpc_polled_fd_posix.h +++ b/deps/grpc/src/core/lib/event_engine/posix_engine/grpc_polled_fd_posix.h @@ -20,11 +20,11 @@ #include -#include "absl/base/thread_annotations.h" #include "src/core/lib/event_engine/posix_engine/file_descriptor_collection.h" #include "src/core/lib/event_engine/posix_engine/posix_interface.h" #include "src/core/lib/iomgr/port.h" #include "src/core/util/sync.h" +#include "absl/base/thread_annotations.h" #if GRPC_ARES == 1 && defined(GRPC_POSIX_SOCKET_ARES_EV_DRIVER) @@ -39,12 +39,12 @@ #include #include -#include "absl/functional/any_invocable.h" -#include "absl/status/status.h" -#include "absl/strings/str_cat.h" #include "src/core/lib/event_engine/grpc_polled_fd.h" #include "src/core/lib/event_engine/posix_engine/event_poller.h" #include "src/core/lib/event_engine/posix_engine/posix_engine_closure.h" +#include "absl/functional/any_invocable.h" +#include "absl/status/status.h" +#include "absl/strings/str_cat.h" namespace grpc_event_engine::experimental { diff --git a/deps/grpc/src/core/lib/event_engine/posix_engine/internal_errqueue.cc b/deps/grpc/src/core/lib/event_engine/posix_engine/internal_errqueue.cc index 18e7909da10..616662653d8 100644 --- a/deps/grpc/src/core/lib/event_engine/posix_engine/internal_errqueue.cc +++ b/deps/grpc/src/core/lib/event_engine/posix_engine/internal_errqueue.cc @@ -16,9 +16,9 @@ #include -#include "absl/log/log.h" #include "src/core/lib/event_engine/posix_engine/posix_interface.h" #include "src/core/lib/iomgr/port.h" +#include "absl/log/log.h" #ifdef GRPC_POSIX_SOCKET_TCP diff --git a/deps/grpc/src/core/lib/event_engine/posix_engine/lockfree_event.cc b/deps/grpc/src/core/lib/event_engine/posix_engine/lockfree_event.cc index 07dae16347f..80b7db31d00 100644 --- a/deps/grpc/src/core/lib/event_engine/posix_engine/lockfree_event.cc +++ b/deps/grpc/src/core/lib/event_engine/posix_engine/lockfree_event.cc @@ -19,12 +19,12 @@ #include #include -#include "absl/status/status.h" #include "src/core/lib/event_engine/posix_engine/event_poller.h" #include "src/core/lib/event_engine/posix_engine/posix_engine_closure.h" #include "src/core/util/crash.h" #include "src/core/util/grpc_check.h" #include "src/core/util/status_helper.h" +#include "absl/status/status.h" // 'state' holds the to call when the fd is readable or writable respectively. // It can contain one of the following values: diff --git a/deps/grpc/src/core/lib/event_engine/posix_engine/lockfree_event.h b/deps/grpc/src/core/lib/event_engine/posix_engine/lockfree_event.h index 609fc22348e..e16d3cea061 100644 --- a/deps/grpc/src/core/lib/event_engine/posix_engine/lockfree_event.h +++ b/deps/grpc/src/core/lib/event_engine/posix_engine/lockfree_event.h @@ -19,9 +19,9 @@ #include #include -#include "absl/status/status.h" #include "src/core/lib/event_engine/posix_engine/posix_engine_closure.h" #include "src/core/lib/event_engine/thread_pool/thread_pool.h" +#include "absl/status/status.h" namespace grpc_event_engine::experimental { diff --git a/deps/grpc/src/core/lib/event_engine/posix_engine/native_posix_dns_resolver.cc b/deps/grpc/src/core/lib/event_engine/posix_engine/native_posix_dns_resolver.cc index 6d5589cdbc4..4dfb616f46e 100644 --- a/deps/grpc/src/core/lib/event_engine/posix_engine/native_posix_dns_resolver.cc +++ b/deps/grpc/src/core/lib/event_engine/posix_engine/native_posix_dns_resolver.cc @@ -27,14 +27,14 @@ #include #include +#include "src/core/lib/event_engine/posix_engine/native_posix_dns_resolver.h" +#include "src/core/util/host_port.h" +#include "src/core/util/useful.h" #include "absl/functional/any_invocable.h" #include "absl/status/status.h" #include "absl/status/statusor.h" #include "absl/strings/str_cat.h" #include "absl/strings/str_format.h" -#include "src/core/lib/event_engine/posix_engine/native_posix_dns_resolver.h" -#include "src/core/util/host_port.h" -#include "src/core/util/useful.h" namespace grpc_event_engine::experimental { diff --git a/deps/grpc/src/core/lib/event_engine/posix_engine/native_posix_dns_resolver.h b/deps/grpc/src/core/lib/event_engine/posix_engine/native_posix_dns_resolver.h index 1bed1e62467..c273152e2fb 100644 --- a/deps/grpc/src/core/lib/event_engine/posix_engine/native_posix_dns_resolver.h +++ b/deps/grpc/src/core/lib/event_engine/posix_engine/native_posix_dns_resolver.h @@ -19,8 +19,8 @@ #include -#include "absl/strings/string_view.h" #include "src/core/lib/iomgr/port.h" +#include "absl/strings/string_view.h" #ifdef GRPC_POSIX_SOCKET_RESOLVE_ADDRESS diff --git a/deps/grpc/src/core/lib/event_engine/posix_engine/posix_endpoint.cc b/deps/grpc/src/core/lib/event_engine/posix_engine/posix_endpoint.cc index f864ef2af65..877b67d4b51 100644 --- a/deps/grpc/src/core/lib/event_engine/posix_engine/posix_endpoint.cc +++ b/deps/grpc/src/core/lib/event_engine/posix_engine/posix_endpoint.cc @@ -30,11 +30,6 @@ #include #include -#include "absl/functional/any_invocable.h" -#include "absl/log/log.h" -#include "absl/status/status.h" -#include "absl/status/statusor.h" -#include "absl/strings/str_cat.h" #include "src/core/lib/debug/trace.h" #include "src/core/lib/event_engine/posix_engine/event_poller.h" #include "src/core/lib/event_engine/posix_engine/internal_errqueue.h" @@ -51,6 +46,11 @@ #include "src/core/util/status_helper.h" #include "src/core/util/strerror.h" #include "src/core/util/sync.h" +#include "absl/functional/any_invocable.h" +#include "absl/log/log.h" +#include "absl/status/status.h" +#include "absl/status/statusor.h" +#include "absl/strings/str_cat.h" #ifdef GRPC_POSIX_SOCKET_TCP #ifdef GRPC_LINUX_ERRQUEUE diff --git a/deps/grpc/src/core/lib/event_engine/posix_engine/posix_endpoint.h b/deps/grpc/src/core/lib/event_engine/posix_engine/posix_endpoint.h index 68449536d54..bb60f060056 100644 --- a/deps/grpc/src/core/lib/event_engine/posix_engine/posix_endpoint.h +++ b/deps/grpc/src/core/lib/event_engine/posix_engine/posix_endpoint.h @@ -29,12 +29,6 @@ #include #include -#include "absl/base/thread_annotations.h" -#include "absl/container/flat_hash_map.h" -#include "absl/functional/any_invocable.h" -#include "absl/log/log.h" -#include "absl/status/status.h" -#include "absl/status/statusor.h" #include "src/core/lib/event_engine/posix.h" #include "src/core/lib/event_engine/posix_engine/event_poller.h" #include "src/core/lib/event_engine/posix_engine/posix_engine_closure.h" @@ -46,6 +40,12 @@ #include "src/core/util/grpc_check.h" #include "src/core/util/ref_counted.h" #include "src/core/util/sync.h" +#include "absl/base/thread_annotations.h" +#include "absl/container/flat_hash_map.h" +#include "absl/functional/any_invocable.h" +#include "absl/log/log.h" +#include "absl/status/status.h" +#include "absl/status/statusor.h" #ifdef GRPC_POSIX_SOCKET_TCP diff --git a/deps/grpc/src/core/lib/event_engine/posix_engine/posix_engine.cc b/deps/grpc/src/core/lib/event_engine/posix_engine/posix_engine.cc index ea24161cf08..85ac566e0be 100644 --- a/deps/grpc/src/core/lib/event_engine/posix_engine/posix_engine.cc +++ b/deps/grpc/src/core/lib/event_engine/posix_engine/posix_engine.cc @@ -29,13 +29,6 @@ #include #include -#include "absl/base/no_destructor.h" -#include "absl/cleanup/cleanup.h" -#include "absl/container/inlined_vector.h" -#include "absl/functional/any_invocable.h" -#include "absl/log/log.h" -#include "absl/status/status.h" -#include "absl/strings/str_cat.h" #include "src/core/lib/debug/trace.h" #include "src/core/lib/event_engine/ares_resolver.h" #include "src/core/lib/event_engine/poller.h" @@ -53,6 +46,13 @@ #include "src/core/util/grpc_check.h" #include "src/core/util/sync.h" #include "src/core/util/useful.h" +#include "absl/base/no_destructor.h" +#include "absl/cleanup/cleanup.h" +#include "absl/container/inlined_vector.h" +#include "absl/functional/any_invocable.h" +#include "absl/log/log.h" +#include "absl/status/status.h" +#include "absl/strings/str_cat.h" #ifdef GRPC_POSIX_SOCKET_TCP #include // IWYU pragma: keep diff --git a/deps/grpc/src/core/lib/event_engine/posix_engine/posix_engine.h b/deps/grpc/src/core/lib/event_engine/posix_engine/posix_engine.h index 130a2bfc745..96d5ceb4353 100644 --- a/deps/grpc/src/core/lib/event_engine/posix_engine/posix_engine.h +++ b/deps/grpc/src/core/lib/event_engine/posix_engine/posix_engine.h @@ -25,13 +25,6 @@ #include #include -#include "absl/base/thread_annotations.h" -#include "absl/container/flat_hash_map.h" -#include "absl/container/inlined_vector.h" -#include "absl/functional/any_invocable.h" -#include "absl/status/status.h" -#include "absl/status/statusor.h" -#include "absl/strings/string_view.h" #include "src/core/lib/event_engine/ares_resolver.h" #include "src/core/lib/event_engine/handle_containers.h" #include "src/core/lib/event_engine/posix.h" @@ -42,6 +35,13 @@ #include "src/core/lib/iomgr/port.h" #include "src/core/util/orphanable.h" #include "src/core/util/sync.h" +#include "absl/base/thread_annotations.h" +#include "absl/container/flat_hash_map.h" +#include "absl/container/inlined_vector.h" +#include "absl/functional/any_invocable.h" +#include "absl/status/status.h" +#include "absl/status/statusor.h" +#include "absl/strings/string_view.h" #ifdef GRPC_POSIX_SOCKET_TCP #include "src/core/lib/event_engine/posix_engine/posix_engine_closure.h" diff --git a/deps/grpc/src/core/lib/event_engine/posix_engine/posix_engine_listener.cc b/deps/grpc/src/core/lib/event_engine/posix_engine/posix_engine_listener.cc index 7e66335ecf2..e50dbf5e796 100644 --- a/deps/grpc/src/core/lib/event_engine/posix_engine/posix_engine_listener.cc +++ b/deps/grpc/src/core/lib/event_engine/posix_engine/posix_engine_listener.cc @@ -32,10 +32,6 @@ #include #include -#include "absl/functional/any_invocable.h" -#include "absl/log/log.h" -#include "absl/status/status.h" -#include "absl/strings/str_cat.h" #include "src/core/lib/debug/trace.h" #include "src/core/lib/event_engine/posix_engine/event_poller.h" #include "src/core/lib/event_engine/posix_engine/posix_endpoint.h" @@ -49,6 +45,10 @@ #include "src/core/util/status_helper.h" #include "src/core/util/strerror.h" #include "src/core/util/time.h" +#include "absl/functional/any_invocable.h" +#include "absl/log/log.h" +#include "absl/status/status.h" +#include "absl/strings/str_cat.h" namespace grpc_event_engine::experimental { @@ -273,6 +273,9 @@ absl::Status PosixEngineListenerImpl::HandleExternalConnection( (void)posix_interface.SetSocketNoSigpipeIfPossible(wrapped); auto peer_name = posix_interface.PeerAddressString(wrapped); if (!peer_name.ok()) { + if (grpc_core::IsGracefulExternalConnectionFailureEnabled()) { + posix_interface.Close(wrapped); + } return absl::UnknownError( absl::StrCat("HandleExternalConnection: peer not connected: ", peer_name.status().ToString())); diff --git a/deps/grpc/src/core/lib/event_engine/posix_engine/posix_engine_listener.h b/deps/grpc/src/core/lib/event_engine/posix_engine/posix_engine_listener.h index 793e3d6f497..9eefe261de9 100644 --- a/deps/grpc/src/core/lib/event_engine/posix_engine/posix_engine_listener.h +++ b/deps/grpc/src/core/lib/event_engine/posix_engine/posix_engine_listener.h @@ -26,14 +26,14 @@ #include #include -#include "absl/base/thread_annotations.h" -#include "absl/functional/any_invocable.h" -#include "absl/status/status.h" -#include "absl/status/statusor.h" #include "src/core/lib/event_engine/posix.h" #include "src/core/lib/event_engine/posix_engine/posix_interface.h" #include "src/core/lib/iomgr/port.h" #include "src/core/util/sync.h" +#include "absl/base/thread_annotations.h" +#include "absl/functional/any_invocable.h" +#include "absl/status/status.h" +#include "absl/status/statusor.h" #ifdef GRPC_POSIX_SOCKET_TCP #include "src/core/lib/event_engine/posix_engine/event_poller.h" diff --git a/deps/grpc/src/core/lib/event_engine/posix_engine/posix_engine_listener_utils.cc b/deps/grpc/src/core/lib/event_engine/posix_engine/posix_engine_listener_utils.cc index d9e8d9def99..e8763713825 100644 --- a/deps/grpc/src/core/lib/event_engine/posix_engine/posix_engine_listener_utils.cc +++ b/deps/grpc/src/core/lib/event_engine/posix_engine/posix_engine_listener_utils.cc @@ -23,10 +23,6 @@ #include #include -#include "absl/cleanup/cleanup.h" -#include "absl/log/log.h" -#include "absl/status/status.h" -#include "absl/strings/str_cat.h" #include "src/core/lib/event_engine/posix_engine/posix_interface.h" #include "src/core/lib/event_engine/posix_engine/tcp_socket_utils.h" #include "src/core/lib/event_engine/tcp_socket_utils.h" @@ -34,6 +30,10 @@ #include "src/core/util/crash.h" // IWYU pragma: keep #include "src/core/util/grpc_check.h" #include "src/core/util/status_helper.h" +#include "absl/cleanup/cleanup.h" +#include "absl/log/log.h" +#include "absl/status/status.h" +#include "absl/strings/str_cat.h" #ifdef GRPC_POSIX_SOCKET_UTILS_COMMON #include // IWYU pragma: keep diff --git a/deps/grpc/src/core/lib/event_engine/posix_engine/posix_engine_listener_utils.h b/deps/grpc/src/core/lib/event_engine/posix_engine/posix_engine_listener_utils.h index 4baf9804260..77099443ed1 100644 --- a/deps/grpc/src/core/lib/event_engine/posix_engine/posix_engine_listener_utils.h +++ b/deps/grpc/src/core/lib/event_engine/posix_engine/posix_engine_listener_utils.h @@ -17,9 +17,9 @@ #include #include -#include "absl/status/statusor.h" #include "src/core/lib/event_engine/posix_engine/posix_interface.h" #include "src/core/lib/event_engine/posix_engine/tcp_socket_utils.h" +#include "absl/status/statusor.h" namespace grpc_event_engine::experimental { diff --git a/deps/grpc/src/core/lib/event_engine/posix_engine/posix_interface.h b/deps/grpc/src/core/lib/event_engine/posix_engine/posix_interface.h index bf6bcf54c98..53c538e1114 100644 --- a/deps/grpc/src/core/lib/event_engine/posix_engine/posix_interface.h +++ b/deps/grpc/src/core/lib/event_engine/posix_engine/posix_interface.h @@ -23,10 +23,10 @@ #include #include -#include "absl/status/status.h" #include "src/core/lib/event_engine/posix_engine/file_descriptor_collection.h" #include "src/core/lib/event_engine/posix_engine/tcp_socket_utils.h" #include "src/core/util/grpc_check.h" +#include "absl/status/status.h" namespace grpc_event_engine::experimental { diff --git a/deps/grpc/src/core/lib/event_engine/posix_engine/posix_interface_posix.cc b/deps/grpc/src/core/lib/event_engine/posix_engine/posix_interface_posix.cc index 958353f9663..3890fece725 100644 --- a/deps/grpc/src/core/lib/event_engine/posix_engine/posix_interface_posix.cc +++ b/deps/grpc/src/core/lib/event_engine/posix_engine/posix_interface_posix.cc @@ -32,17 +32,17 @@ #include #include +#include "src/core/lib/event_engine/posix_engine/file_descriptor_collection.h" +#include "src/core/lib/event_engine/posix_engine/tcp_socket_utils.h" +#include "src/core/lib/event_engine/tcp_socket_utils.h" +#include "src/core/util/crash.h" // IWYU pragma: keep +#include "src/core/util/status_helper.h" #include "absl/cleanup/cleanup.h" #include "absl/log/log.h" #include "absl/status/status.h" #include "absl/strings/str_cat.h" #include "absl/strings/str_replace.h" #include "absl/strings/string_view.h" -#include "src/core/lib/event_engine/posix_engine/file_descriptor_collection.h" -#include "src/core/lib/event_engine/posix_engine/tcp_socket_utils.h" -#include "src/core/lib/event_engine/tcp_socket_utils.h" -#include "src/core/util/crash.h" // IWYU pragma: keep -#include "src/core/util/status_helper.h" #ifdef GRPC_POSIX_SOCKET_UTILS_COMMON #include // IWYU pragma: keep diff --git a/deps/grpc/src/core/lib/event_engine/posix_engine/posix_write_event_sink.h b/deps/grpc/src/core/lib/event_engine/posix_engine/posix_write_event_sink.h index 6fd92be10e4..0019160b541 100644 --- a/deps/grpc/src/core/lib/event_engine/posix_engine/posix_write_event_sink.h +++ b/deps/grpc/src/core/lib/event_engine/posix_engine/posix_write_event_sink.h @@ -17,9 +17,9 @@ #include +#include "src/core/util/bitset.h" #include "absl/base/no_destructor.h" #include "absl/functional/any_invocable.h" -#include "src/core/util/bitset.h" namespace grpc_event_engine::experimental { diff --git a/deps/grpc/src/core/lib/event_engine/posix_engine/tcp_socket_utils.h b/deps/grpc/src/core/lib/event_engine/posix_engine/tcp_socket_utils.h index e04c71c77d9..bf408a4a617 100644 --- a/deps/grpc/src/core/lib/event_engine/posix_engine/tcp_socket_utils.h +++ b/deps/grpc/src/core/lib/event_engine/posix_engine/tcp_socket_utils.h @@ -46,7 +46,7 @@ namespace grpc_event_engine::experimental { struct PosixTcpOptions { static constexpr int kDefaultReadChunkSize = 8192; static constexpr int kDefaultMinReadChunksize = 256; - static constexpr int kDefaultMaxReadChunksize = 4 * 1024 * 1024; + static constexpr int kDefaultMaxReadChunksize = 64 * 1024; static constexpr int kZerocpTxEnabledDefault = 0; static constexpr int kMaxChunkSize = 32 * 1024 * 1024; static constexpr int kDefaultMaxSends = 4; diff --git a/deps/grpc/src/core/lib/event_engine/posix_engine/timer.h b/deps/grpc/src/core/lib/event_engine/posix_engine/timer.h index 87c502c32f3..3ef231a7a67 100644 --- a/deps/grpc/src/core/lib/event_engine/posix_engine/timer.h +++ b/deps/grpc/src/core/lib/event_engine/posix_engine/timer.h @@ -29,11 +29,11 @@ #include #include -#include "absl/base/thread_annotations.h" #include "src/core/lib/event_engine/posix_engine/timer_heap.h" #include "src/core/util/sync.h" #include "src/core/util/time.h" #include "src/core/util/time_averaged_stats.h" +#include "absl/base/thread_annotations.h" namespace grpc_event_engine::experimental { diff --git a/deps/grpc/src/core/lib/event_engine/posix_engine/timer_manager.cc b/deps/grpc/src/core/lib/event_engine/posix_engine/timer_manager.cc index a27b2139ad4..f74f57a8378 100644 --- a/deps/grpc/src/core/lib/event_engine/posix_engine/timer_manager.cc +++ b/deps/grpc/src/core/lib/event_engine/posix_engine/timer_manager.cc @@ -25,10 +25,10 @@ #include #include -#include "absl/log/log.h" -#include "absl/time/time.h" #include "src/core/lib/debug/trace.h" #include "src/core/util/grpc_check.h" +#include "absl/log/log.h" +#include "absl/time/time.h" static thread_local bool g_timer_thread; diff --git a/deps/grpc/src/core/lib/event_engine/posix_engine/timer_manager.h b/deps/grpc/src/core/lib/event_engine/posix_engine/timer_manager.h index e6fad90a663..26bcb15899e 100644 --- a/deps/grpc/src/core/lib/event_engine/posix_engine/timer_manager.h +++ b/deps/grpc/src/core/lib/event_engine/posix_engine/timer_manager.h @@ -27,12 +27,12 @@ #include #include -#include "absl/base/thread_annotations.h" #include "src/core/lib/event_engine/posix_engine/timer.h" #include "src/core/lib/event_engine/thread_pool/thread_pool.h" #include "src/core/util/notification.h" #include "src/core/util/sync.h" #include "src/core/util/time.h" +#include "absl/base/thread_annotations.h" namespace grpc_event_engine::experimental { diff --git a/deps/grpc/src/core/lib/event_engine/posix_engine/traced_buffer_list.cc b/deps/grpc/src/core/lib/event_engine/posix_engine/traced_buffer_list.cc index 4035c7cf43f..2fbba8c0663 100644 --- a/deps/grpc/src/core/lib/event_engine/posix_engine/traced_buffer_list.cc +++ b/deps/grpc/src/core/lib/event_engine/posix_engine/traced_buffer_list.cc @@ -23,12 +23,12 @@ #include -#include "absl/functional/any_invocable.h" -#include "absl/log/log.h" #include "src/core/lib/event_engine/posix_engine/posix_interface.h" #include "src/core/lib/iomgr/port.h" #include "src/core/util/crash.h" #include "src/core/util/sync.h" +#include "absl/functional/any_invocable.h" +#include "absl/log/log.h" #ifdef GRPC_LINUX_ERRQUEUE #include // IWYU pragma: keep diff --git a/deps/grpc/src/core/lib/event_engine/posix_engine/traced_buffer_list.h b/deps/grpc/src/core/lib/event_engine/posix_engine/traced_buffer_list.h index be2a26b43cf..cb3196a63a9 100644 --- a/deps/grpc/src/core/lib/event_engine/posix_engine/traced_buffer_list.h +++ b/deps/grpc/src/core/lib/event_engine/posix_engine/traced_buffer_list.h @@ -22,13 +22,13 @@ #include -#include "absl/functional/any_invocable.h" -#include "absl/status/status.h" #include "src/core/lib/event_engine/posix_engine/internal_errqueue.h" #include "src/core/lib/event_engine/posix_engine/posix_interface.h" #include "src/core/lib/event_engine/posix_engine/posix_write_event_sink.h" #include "src/core/lib/iomgr/port.h" #include "src/core/util/sync.h" +#include "absl/functional/any_invocable.h" +#include "absl/status/status.h" namespace grpc_event_engine::experimental { diff --git a/deps/grpc/src/core/lib/event_engine/posix_engine/wakeup_fd_eventfd.cc b/deps/grpc/src/core/lib/event_engine/posix_engine/wakeup_fd_eventfd.cc index 4de5ce4a351..086a8689141 100644 --- a/deps/grpc/src/core/lib/event_engine/posix_engine/wakeup_fd_eventfd.cc +++ b/deps/grpc/src/core/lib/event_engine/posix_engine/wakeup_fd_eventfd.cc @@ -16,10 +16,10 @@ #include -#include "absl/strings/str_cat.h" #include "src/core/lib/event_engine/posix_engine/posix_interface.h" #include "src/core/lib/iomgr/port.h" #include "src/core/util/crash.h" // IWYU pragma: keep +#include "absl/strings/str_cat.h" #ifdef GRPC_LINUX_EVENTFD diff --git a/deps/grpc/src/core/lib/event_engine/posix_engine/wakeup_fd_eventfd.h b/deps/grpc/src/core/lib/event_engine/posix_engine/wakeup_fd_eventfd.h index dc931a34b7c..feba50e1151 100644 --- a/deps/grpc/src/core/lib/event_engine/posix_engine/wakeup_fd_eventfd.h +++ b/deps/grpc/src/core/lib/event_engine/posix_engine/wakeup_fd_eventfd.h @@ -18,10 +18,10 @@ #include -#include "absl/status/status.h" -#include "absl/status/statusor.h" #include "src/core/lib/event_engine/posix_engine/posix_interface.h" #include "src/core/lib/event_engine/posix_engine/wakeup_fd_posix.h" +#include "absl/status/status.h" +#include "absl/status/statusor.h" namespace grpc_event_engine::experimental { diff --git a/deps/grpc/src/core/lib/event_engine/posix_engine/wakeup_fd_pipe.cc b/deps/grpc/src/core/lib/event_engine/posix_engine/wakeup_fd_pipe.cc index 0ea61aaef88..2f07612474e 100644 --- a/deps/grpc/src/core/lib/event_engine/posix_engine/wakeup_fd_pipe.cc +++ b/deps/grpc/src/core/lib/event_engine/posix_engine/wakeup_fd_pipe.cc @@ -17,10 +17,10 @@ #include #include -#include "absl/strings/str_cat.h" #include "src/core/lib/event_engine/posix_engine/posix_interface.h" #include "src/core/lib/iomgr/port.h" #include "src/core/util/crash.h" // IWYU pragma: keep +#include "absl/strings/str_cat.h" #ifdef GRPC_POSIX_WAKEUP_FD #include diff --git a/deps/grpc/src/core/lib/event_engine/posix_engine/wakeup_fd_pipe.h b/deps/grpc/src/core/lib/event_engine/posix_engine/wakeup_fd_pipe.h index 8212a0cb909..c80384dbc5e 100644 --- a/deps/grpc/src/core/lib/event_engine/posix_engine/wakeup_fd_pipe.h +++ b/deps/grpc/src/core/lib/event_engine/posix_engine/wakeup_fd_pipe.h @@ -18,10 +18,10 @@ #include -#include "absl/status/status.h" -#include "absl/status/statusor.h" #include "src/core/lib/event_engine/posix_engine/posix_interface.h" #include "src/core/lib/event_engine/posix_engine/wakeup_fd_posix.h" +#include "absl/status/status.h" +#include "absl/status/statusor.h" namespace grpc_event_engine::experimental { diff --git a/deps/grpc/src/core/lib/event_engine/posix_engine/wakeup_fd_posix.h b/deps/grpc/src/core/lib/event_engine/posix_engine/wakeup_fd_posix.h index 7daa5d7d4f2..ba287edbadc 100644 --- a/deps/grpc/src/core/lib/event_engine/posix_engine/wakeup_fd_posix.h +++ b/deps/grpc/src/core/lib/event_engine/posix_engine/wakeup_fd_posix.h @@ -44,8 +44,8 @@ #include -#include "absl/status/status.h" #include "src/core/lib/event_engine/posix_engine/posix_interface.h" +#include "absl/status/status.h" namespace grpc_event_engine::experimental { diff --git a/deps/grpc/src/core/lib/event_engine/posix_engine/wakeup_fd_posix_default.cc b/deps/grpc/src/core/lib/event_engine/posix_engine/wakeup_fd_posix_default.cc index fb2db3ba4d0..af3450690f8 100644 --- a/deps/grpc/src/core/lib/event_engine/posix_engine/wakeup_fd_posix_default.cc +++ b/deps/grpc/src/core/lib/event_engine/posix_engine/wakeup_fd_posix_default.cc @@ -15,13 +15,13 @@ #include -#include "absl/status/status.h" -#include "absl/status/statusor.h" #include "src/core/lib/event_engine/posix_engine/posix_interface.h" #include "src/core/lib/event_engine/posix_engine/wakeup_fd_eventfd.h" #include "src/core/lib/event_engine/posix_engine/wakeup_fd_pipe.h" #include "src/core/lib/event_engine/posix_engine/wakeup_fd_posix.h" #include "src/core/lib/iomgr/port.h" +#include "absl/status/status.h" +#include "absl/status/statusor.h" namespace grpc_event_engine::experimental { diff --git a/deps/grpc/src/core/lib/event_engine/posix_engine/wakeup_fd_posix_default.h b/deps/grpc/src/core/lib/event_engine/posix_engine/wakeup_fd_posix_default.h index 3bc5371a355..a37b5328129 100644 --- a/deps/grpc/src/core/lib/event_engine/posix_engine/wakeup_fd_posix_default.h +++ b/deps/grpc/src/core/lib/event_engine/posix_engine/wakeup_fd_posix_default.h @@ -18,8 +18,8 @@ #include -#include "absl/status/statusor.h" #include "src/core/lib/event_engine/posix_engine/posix_interface.h" +#include "absl/status/statusor.h" namespace grpc_event_engine::experimental { diff --git a/deps/grpc/src/core/lib/event_engine/ref_counted_dns_resolver_interface.h b/deps/grpc/src/core/lib/event_engine/ref_counted_dns_resolver_interface.h index 768e34ec4b6..86ff4dc7bfd 100644 --- a/deps/grpc/src/core/lib/event_engine/ref_counted_dns_resolver_interface.h +++ b/deps/grpc/src/core/lib/event_engine/ref_counted_dns_resolver_interface.h @@ -19,8 +19,8 @@ #include #include -#include "absl/strings/string_view.h" #include "src/core/util/orphanable.h" +#include "absl/strings/string_view.h" namespace grpc_event_engine::experimental { diff --git a/deps/grpc/src/core/lib/event_engine/tcp_socket_utils.cc b/deps/grpc/src/core/lib/event_engine/tcp_socket_utils.cc index 9ec8ac942c0..f93cc947d00 100644 --- a/deps/grpc/src/core/lib/event_engine/tcp_socket_utils.cc +++ b/deps/grpc/src/core/lib/event_engine/tcp_socket_utils.cc @@ -53,15 +53,15 @@ #include -#include "absl/log/log.h" -#include "absl/status/status.h" -#include "absl/strings/str_cat.h" -#include "absl/strings/str_format.h" #include "src/core/lib/iomgr/resolved_address.h" #include "src/core/util/grpc_check.h" #include "src/core/util/host_port.h" #include "src/core/util/status_helper.h" #include "src/core/util/uri.h" +#include "absl/log/log.h" +#include "absl/status/status.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/str_format.h" namespace grpc_event_engine::experimental { diff --git a/deps/grpc/src/core/lib/event_engine/tcp_telemetry.h b/deps/grpc/src/core/lib/event_engine/tcp_telemetry.h new file mode 100644 index 00000000000..dc62e87bf83 --- /dev/null +++ b/deps/grpc/src/core/lib/event_engine/tcp_telemetry.h @@ -0,0 +1,126 @@ +// Copyright 2025 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. + +#ifndef GRPC_SRC_CORE_LIB_EVENT_ENGINE_TCP_TELEMETRY_H +#define GRPC_SRC_CORE_LIB_EVENT_ENGINE_TCP_TELEMETRY_H + +#include + +#include "src/core/telemetry/histogram.h" +#include "src/core/telemetry/instrument.h" + +namespace grpc_core { + +class TcpTelemetryDomain final : public InstrumentDomain { + public: + using Backend = HighContentionBackend; + static constexpr absl::string_view kName = "tcp_connection_metrics"; + static constexpr auto kLabels = Labels( + "network.local.address", "network.local.port", "network.remote.address", + "network.remote.port", "is_control_endpoint"); + + static inline const auto kMinRtt = + RegisterHistogram( + "min_rtt", "Minimum round trip time of a connection in microseconds", + "{us}", 1 << 24, 100); // Max bucket is 16 seconds. + static inline const auto kDeliveryRate = + RegisterHistogram( + "delivery_rate", + "TCP's most recent measure of the connection's " + "\"non-app-limited\" throughput.", + "By/s", int64_t{1} << 34, 100); // Max bucket is 16 GiB/s. + static inline const auto kPacketsSent = RegisterCounter( + "packets_sent", + "Total packets sent by TCP including retransmissions and spurious " + "retransmissions.", + "{packet}"); + static inline const auto kPacketsRetransmitted = RegisterCounter( + "packets_retransmitted", + "Total packets sent by TCP except those sent for the first time.", + "{packet}"); + static inline const auto kPacketsSpuriousRetransmitted = RegisterCounter( + "packets_spurious_retransmitted", + "Total packets retransmitted by TCP that were later found to be " + "unnecessary.", + "{packet}"); + static inline const auto kRecurringRetransmits = RegisterCounter( + "recurring_retransmits", + "The number of times the latest TCP packet was retransmitted due to " + "expiration of TCP retransmission timer (RTO), and not acknowledged at " + "the time the connection was closed.", + "{packet}"); + static inline const auto kBytesSent = RegisterCounter( + "bytes_sent", + "Total bytes sent by TCP including retransmissions and spurious " + "retransmissions.", + "By"); + static inline const auto kBytesRetransmitted = RegisterCounter( + "bytes_retransmitted", + "Total bytes sent by TCP except those sent for the first time.", "By"); + static inline const auto kConnectionCount = RegisterUpDownCounter( + "connection_count", "Number of active TCP connections.", "{connection}"); + static inline const auto kSyscallWrites = RegisterCounter( + "syscall_writes", + "The number of times we invoked the sendmsg (or sendmmsg) syscall and " + "wrote data to the TCP socket.", + "{syscall}"); + static inline const auto kWriteSize = + RegisterHistogram( + "write_size", "The number of bytes offered to each syscall_write.", + "By", 8 << 20, 20); + static inline const auto kSyscallReads = RegisterCounter( + "syscall_reads", + "The number of times we invoked the recvmsg (or recvmmsg or zero copy " + "getsockopt) syscall and read data from the TCP socket.", + "{syscall}"); + static inline const auto kReadSize = + RegisterHistogram( + "read_size", "The number of bytes received by each syscall_read.", + "By", 8 << 20, 20); + static inline const auto kSenderLatency = + RegisterHistogram( + "sender_latency", + "Time taken by the TCP socket to write the first byte of a write " + "onto the NIC.", + "us", 1e6, 20); + static inline const auto kTransferLatency1k = + RegisterHistogram( + "transfer_latency_1k", + "Time taken to transmit the first 1024 bytes of a write.", "us", 1e6, + 20); + static inline const auto kTransferLatency8k = + RegisterHistogram( + "transfer_latency_8k", + "Time taken to transmit the first 8196 bytes of a write.", "us", 1e6, + 20); + static inline const auto kTransferLatency64k = + RegisterHistogram( + "transfer_latency_64k", + "Time taken to transmit the first 65536 bytes of a write.", "us", 1e6, + 20); + static inline const auto kTransferLatency256k = + RegisterHistogram( + "transfer_latency_256k", + "Time taken to transmit the first 262144 bytes of a write.", "us", + 1e6, 20); + static inline const auto kTransferLatency2m = + RegisterHistogram( + "transfer_latency_2m", + "Time taken to transmit the first 2097152 bytes of a write.", "us", + 1e6, 20); +}; + +}; // namespace grpc_core + +#endif // GRPC_SRC_CORE_LIB_EVENT_ENGINE_TCP_TELEMETRY_H diff --git a/deps/grpc/src/core/lib/event_engine/thread_pool/thread_count.cc b/deps/grpc/src/core/lib/event_engine/thread_pool/thread_count.cc index 3bf4885eb5b..33cffb999cc 100644 --- a/deps/grpc/src/core/lib/event_engine/thread_pool/thread_count.cc +++ b/deps/grpc/src/core/lib/event_engine/thread_pool/thread_count.cc @@ -18,12 +18,12 @@ #include +#include "src/core/util/time.h" #include "absl/log/log.h" #include "absl/status/status.h" #include "absl/strings/str_format.h" #include "absl/time/clock.h" #include "absl/time/time.h" -#include "src/core/util/time.h" namespace grpc_event_engine::experimental { diff --git a/deps/grpc/src/core/lib/event_engine/thread_pool/thread_count.h b/deps/grpc/src/core/lib/event_engine/thread_pool/thread_count.h index a873e34ee0d..b9b759df07e 100644 --- a/deps/grpc/src/core/lib/event_engine/thread_pool/thread_count.h +++ b/deps/grpc/src/core/lib/event_engine/thread_pool/thread_count.h @@ -24,10 +24,10 @@ #include #include -#include "absl/base/thread_annotations.h" #include "src/core/util/sync.h" #include "src/core/util/time.h" #include "src/core/util/useful.h" +#include "absl/base/thread_annotations.h" namespace grpc_event_engine::experimental { diff --git a/deps/grpc/src/core/lib/event_engine/thread_pool/work_stealing_thread_pool.cc b/deps/grpc/src/core/lib/event_engine/thread_pool/work_stealing_thread_pool.cc index d81fac97e77..17c85bb914e 100644 --- a/deps/grpc/src/core/lib/event_engine/thread_pool/work_stealing_thread_pool.cc +++ b/deps/grpc/src/core/lib/event_engine/thread_pool/work_stealing_thread_pool.cc @@ -28,10 +28,6 @@ #include #include -#include "absl/functional/any_invocable.h" -#include "absl/log/log.h" -#include "absl/time/clock.h" -#include "absl/time/time.h" #include "src/core/lib/debug/trace.h" #include "src/core/lib/event_engine/common_closures.h" #include "src/core/lib/event_engine/thread_local.h" @@ -44,6 +40,10 @@ #include "src/core/util/grpc_check.h" #include "src/core/util/thd.h" #include "src/core/util/time.h" +#include "absl/functional/any_invocable.h" +#include "absl/log/log.h" +#include "absl/time/clock.h" +#include "absl/time/time.h" #ifdef GPR_POSIX_SYNC #include diff --git a/deps/grpc/src/core/lib/event_engine/thread_pool/work_stealing_thread_pool.h b/deps/grpc/src/core/lib/event_engine/thread_pool/work_stealing_thread_pool.h index 556be2203ed..eb81e64f3a1 100644 --- a/deps/grpc/src/core/lib/event_engine/thread_pool/work_stealing_thread_pool.h +++ b/deps/grpc/src/core/lib/event_engine/thread_pool/work_stealing_thread_pool.h @@ -27,9 +27,6 @@ #include #include -#include "absl/base/thread_annotations.h" -#include "absl/container/flat_hash_set.h" -#include "absl/functional/any_invocable.h" #include "src/core/lib/event_engine/thread_pool/thread_count.h" #include "src/core/lib/event_engine/thread_pool/thread_pool.h" #include "src/core/lib/event_engine/work_queue/basic_work_queue.h" @@ -38,6 +35,9 @@ #include "src/core/util/notification.h" #include "src/core/util/sync.h" #include "src/core/util/time.h" +#include "absl/base/thread_annotations.h" +#include "absl/container/flat_hash_set.h" +#include "absl/functional/any_invocable.h" namespace grpc_event_engine::experimental { diff --git a/deps/grpc/src/core/lib/event_engine/utils.cc b/deps/grpc/src/core/lib/event_engine/utils.cc index 73564d63c2d..0296a946d50 100644 --- a/deps/grpc/src/core/lib/event_engine/utils.cc +++ b/deps/grpc/src/core/lib/event_engine/utils.cc @@ -23,13 +23,13 @@ #include #include -#include "absl/log/log.h" -#include "absl/strings/str_cat.h" -#include "absl/strings/string_view.h" #include "src/core/lib/event_engine/extensions/blocking_dns.h" #include "src/core/lib/event_engine/query_extensions.h" #include "src/core/util/notification.h" #include "src/core/util/time.h" +#include "absl/log/log.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/string_view.h" namespace grpc_event_engine::experimental { diff --git a/deps/grpc/src/core/lib/event_engine/utils.h b/deps/grpc/src/core/lib/event_engine/utils.h index e3b1b14352f..837f962a0e5 100644 --- a/deps/grpc/src/core/lib/event_engine/utils.h +++ b/deps/grpc/src/core/lib/event_engine/utils.h @@ -21,9 +21,9 @@ #include #include +#include "src/core/util/time.h" #include "absl/status/statusor.h" #include "absl/strings/string_view.h" -#include "src/core/util/time.h" namespace grpc_event_engine::experimental { diff --git a/deps/grpc/src/core/lib/event_engine/windows/grpc_polled_fd_windows.cc b/deps/grpc/src/core/lib/event_engine/windows/grpc_polled_fd_windows.cc index 0dab2525acf..8ae0e00f33d 100644 --- a/deps/grpc/src/core/lib/event_engine/windows/grpc_polled_fd_windows.cc +++ b/deps/grpc/src/core/lib/event_engine/windows/grpc_polled_fd_windows.cc @@ -21,10 +21,10 @@ #include #include +#include "src/core/lib/address_utils/sockaddr_utils.h" #include "absl/functional/any_invocable.h" #include "absl/status/status.h" #include "absl/strings/str_format.h" -#include "src/core/lib/address_utils/sockaddr_utils.h" // We pull in ares.h transitively here, ares.h is not self-contained // w.r.t. windows headers though, so make sure pull them in above. #include "src/core/lib/event_engine/ares_resolver.h" diff --git a/deps/grpc/src/core/lib/event_engine/windows/grpc_polled_fd_windows.h b/deps/grpc/src/core/lib/event_engine/windows/grpc_polled_fd_windows.h index f96ebd4bc55..82d8fd7ed12 100644 --- a/deps/grpc/src/core/lib/event_engine/windows/grpc_polled_fd_windows.h +++ b/deps/grpc/src/core/lib/event_engine/windows/grpc_polled_fd_windows.h @@ -26,13 +26,13 @@ #include -#include "absl/functional/any_invocable.h" -#include "absl/status/status.h" #include "src/core/lib/event_engine/common_closures.h" #include "src/core/lib/event_engine/grpc_polled_fd.h" #include "src/core/lib/event_engine/windows/iocp.h" #include "src/core/lib/event_engine/windows/win_socket.h" #include "src/core/util/sync.h" +#include "absl/functional/any_invocable.h" +#include "absl/status/status.h" struct iovec; diff --git a/deps/grpc/src/core/lib/event_engine/windows/iocp.cc b/deps/grpc/src/core/lib/event_engine/windows/iocp.cc index d009bb379f5..b222a5cfa29 100644 --- a/deps/grpc/src/core/lib/event_engine/windows/iocp.cc +++ b/deps/grpc/src/core/lib/event_engine/windows/iocp.cc @@ -20,7 +20,6 @@ #include -#include "absl/strings/str_format.h" #include "src/core/lib/event_engine/thread_pool/thread_pool.h" #include "src/core/lib/event_engine/time_util.h" #include "src/core/lib/event_engine/windows/iocp.h" @@ -28,6 +27,7 @@ #include "src/core/lib/iomgr/error.h" #include "src/core/util/crash.h" #include "src/core/util/grpc_check.h" +#include "absl/strings/str_format.h" namespace grpc_event_engine::experimental { diff --git a/deps/grpc/src/core/lib/event_engine/windows/iocp.h b/deps/grpc/src/core/lib/event_engine/windows/iocp.h index 5d5aed03c54..f52fca20d53 100644 --- a/deps/grpc/src/core/lib/event_engine/windows/iocp.h +++ b/deps/grpc/src/core/lib/event_engine/windows/iocp.h @@ -20,10 +20,10 @@ #include -#include "absl/status/status.h" #include "src/core/lib/event_engine/poller.h" #include "src/core/lib/event_engine/thread_pool/thread_pool.h" #include "src/core/lib/event_engine/windows/win_socket.h" +#include "absl/status/status.h" namespace grpc_event_engine::experimental { diff --git a/deps/grpc/src/core/lib/event_engine/windows/native_windows_dns_resolver.cc b/deps/grpc/src/core/lib/event_engine/windows/native_windows_dns_resolver.cc index 225cc630e7a..475a10d281b 100644 --- a/deps/grpc/src/core/lib/event_engine/windows/native_windows_dns_resolver.cc +++ b/deps/grpc/src/core/lib/event_engine/windows/native_windows_dns_resolver.cc @@ -20,13 +20,16 @@ #include #include +#include -#include "absl/strings/str_cat.h" -#include "absl/strings/str_format.h" #include "src/core/lib/event_engine/windows/native_windows_dns_resolver.h" #include "src/core/lib/iomgr/error.h" #include "src/core/util/host_port.h" #include "src/core/util/status_helper.h" +#include "absl/status/status.h" +#include "absl/status/statusor.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/str_format.h" namespace grpc_event_engine::experimental { diff --git a/deps/grpc/src/core/lib/event_engine/windows/win_socket.cc b/deps/grpc/src/core/lib/event_engine/windows/win_socket.cc index 09f543c6d9e..270932be442 100644 --- a/deps/grpc/src/core/lib/event_engine/windows/win_socket.cc +++ b/deps/grpc/src/core/lib/event_engine/windows/win_socket.cc @@ -17,7 +17,6 @@ #include #include -#include "absl/log/log.h" #include "src/core/lib/event_engine/tcp_socket_utils.h" #include "src/core/lib/event_engine/thread_pool/thread_pool.h" #include "src/core/lib/event_engine/windows/win_socket.h" @@ -25,6 +24,7 @@ #include "src/core/util/debug_location.h" #include "src/core/util/grpc_check.h" #include "src/core/util/sync.h" +#include "absl/log/log.h" #if defined(__MSYS__) && defined(GPR_ARCH_64) // Nasty workaround for nasty bug when using the 64 bits msys compiler diff --git a/deps/grpc/src/core/lib/event_engine/windows/win_socket.h b/deps/grpc/src/core/lib/event_engine/windows/win_socket.h index 9e1293a0ae7..34943b05080 100644 --- a/deps/grpc/src/core/lib/event_engine/windows/win_socket.h +++ b/deps/grpc/src/core/lib/event_engine/windows/win_socket.h @@ -20,11 +20,11 @@ #include -#include "absl/base/thread_annotations.h" -#include "absl/functional/any_invocable.h" #include "src/core/lib/event_engine/thread_pool/thread_pool.h" #include "src/core/util/debug_location.h" #include "src/core/util/sync.h" +#include "absl/base/thread_annotations.h" +#include "absl/functional/any_invocable.h" namespace grpc_event_engine::experimental { diff --git a/deps/grpc/src/core/lib/event_engine/windows/windows_endpoint.cc b/deps/grpc/src/core/lib/event_engine/windows/windows_endpoint.cc index f4b1570ca8e..1c081fc5f51 100644 --- a/deps/grpc/src/core/lib/event_engine/windows/windows_endpoint.cc +++ b/deps/grpc/src/core/lib/event_engine/windows/windows_endpoint.cc @@ -18,11 +18,6 @@ #include #include -#include "absl/cleanup/cleanup.h" -#include "absl/functional/any_invocable.h" -#include "absl/log/log.h" -#include "absl/status/status.h" -#include "absl/strings/str_format.h" #include "src/core/lib/event_engine/tcp_socket_utils.h" #include "src/core/lib/event_engine/thread_pool/thread_pool.h" #include "src/core/lib/event_engine/windows/win_socket.h" @@ -31,6 +26,11 @@ #include "src/core/util/debug_location.h" #include "src/core/util/grpc_check.h" #include "src/core/util/status_helper.h" +#include "absl/cleanup/cleanup.h" +#include "absl/functional/any_invocable.h" +#include "absl/log/log.h" +#include "absl/status/status.h" +#include "absl/strings/str_format.h" namespace grpc_event_engine::experimental { diff --git a/deps/grpc/src/core/lib/event_engine/windows/windows_engine.cc b/deps/grpc/src/core/lib/event_engine/windows/windows_engine.cc index a19ce81de06..4e246bf50f5 100644 --- a/deps/grpc/src/core/lib/event_engine/windows/windows_engine.cc +++ b/deps/grpc/src/core/lib/event_engine/windows/windows_engine.cc @@ -24,10 +24,6 @@ #include #include -#include "absl/log/log.h" -#include "absl/status/status.h" -#include "absl/status/statusor.h" -#include "absl/strings/string_view.h" #include "src/core/lib/event_engine/channel_args_endpoint_config.h" #include "src/core/lib/event_engine/common_closures.h" #include "src/core/lib/event_engine/handle_containers.h" @@ -48,6 +44,10 @@ #include "src/core/util/grpc_check.h" #include "src/core/util/sync.h" #include "src/core/util/time.h" +#include "absl/log/log.h" +#include "absl/status/status.h" +#include "absl/status/statusor.h" +#include "absl/strings/string_view.h" namespace grpc_event_engine::experimental { diff --git a/deps/grpc/src/core/lib/event_engine/windows/windows_engine.h b/deps/grpc/src/core/lib/event_engine/windows/windows_engine.h index 707eefb22cd..389b42d9271 100644 --- a/deps/grpc/src/core/lib/event_engine/windows/windows_engine.h +++ b/deps/grpc/src/core/lib/event_engine/windows/windows_engine.h @@ -27,9 +27,6 @@ #include -#include "absl/status/status.h" -#include "absl/status/statusor.h" -#include "absl/strings/string_view.h" #include "src/core/lib/event_engine/ares_resolver.h" #include "src/core/lib/event_engine/extensions/supports_win_sockets.h" #include "src/core/lib/event_engine/handle_containers.h" @@ -40,6 +37,9 @@ #include "src/core/lib/event_engine/windows/windows_endpoint.h" #include "src/core/util/sync.h" #include "src/core/util/time.h" +#include "absl/status/status.h" +#include "absl/status/statusor.h" +#include "absl/strings/string_view.h" namespace grpc_event_engine::experimental { diff --git a/deps/grpc/src/core/lib/event_engine/windows/windows_listener.cc b/deps/grpc/src/core/lib/event_engine/windows/windows_listener.cc index 7734c1647db..fbfe038d287 100644 --- a/deps/grpc/src/core/lib/event_engine/windows/windows_listener.cc +++ b/deps/grpc/src/core/lib/event_engine/windows/windows_listener.cc @@ -15,9 +15,6 @@ #ifdef GPR_WINDOWS -#include "absl/log/log.h" -#include "absl/status/status.h" -#include "absl/strings/str_format.h" #include "src/core/lib/event_engine/extensions/iomgr_compatible.h" #include "src/core/lib/event_engine/tcp_socket_utils.h" #include "src/core/lib/event_engine/windows/iocp.h" @@ -29,6 +26,9 @@ #include "src/core/util/crash.h" #include "src/core/util/grpc_check.h" #include "src/core/util/sync.h" +#include "absl/log/log.h" +#include "absl/status/status.h" +#include "absl/strings/str_format.h" namespace grpc_event_engine::experimental { diff --git a/deps/grpc/src/core/lib/event_engine/windows/windows_listener.h b/deps/grpc/src/core/lib/event_engine/windows/windows_listener.h index 98f399f2af1..536865e26ea 100644 --- a/deps/grpc/src/core/lib/event_engine/windows/windows_listener.h +++ b/deps/grpc/src/core/lib/event_engine/windows/windows_listener.h @@ -23,8 +23,6 @@ #include -#include "absl/base/thread_annotations.h" -#include "absl/status/statusor.h" #include "src/core/lib/event_engine/common_closures.h" #include "src/core/lib/event_engine/extensions/iomgr_compatible.h" #include "src/core/lib/event_engine/query_extensions.h" @@ -32,6 +30,8 @@ #include "src/core/lib/event_engine/windows/iocp.h" #include "src/core/lib/iomgr/port.h" #include "src/core/util/sync.h" +#include "absl/base/thread_annotations.h" +#include "absl/status/statusor.h" #ifdef GRPC_HAVE_UNIX_SOCKET // clang-format off diff --git a/deps/grpc/src/core/lib/event_engine/work_queue/basic_work_queue.h b/deps/grpc/src/core/lib/event_engine/work_queue/basic_work_queue.h index 6a8879fab89..0e164c9ad5d 100644 --- a/deps/grpc/src/core/lib/event_engine/work_queue/basic_work_queue.h +++ b/deps/grpc/src/core/lib/event_engine/work_queue/basic_work_queue.h @@ -19,10 +19,10 @@ #include -#include "absl/base/thread_annotations.h" -#include "absl/functional/any_invocable.h" #include "src/core/lib/event_engine/work_queue/work_queue.h" #include "src/core/util/sync.h" +#include "absl/base/thread_annotations.h" +#include "absl/functional/any_invocable.h" namespace grpc_event_engine::experimental { diff --git a/deps/grpc/src/core/lib/experiments/config.cc b/deps/grpc/src/core/lib/experiments/config.cc index 0488c5a5da1..1fe41fb575d 100644 --- a/deps/grpc/src/core/lib/experiments/config.cc +++ b/deps/grpc/src/core/lib/experiments/config.cc @@ -24,6 +24,10 @@ #include #include +#include "src/core/config/config_vars.h" +#include "src/core/lib/experiments/experiments.h" +#include "src/core/util/crash.h" // IWYU pragma: keep +#include "src/core/util/no_destruct.h" #include "absl/functional/any_invocable.h" #include "absl/log/check.h" #include "absl/log/log.h" @@ -31,10 +35,6 @@ #include "absl/strings/str_split.h" #include "absl/strings/string_view.h" #include "absl/strings/strip.h" -#include "src/core/config/config_vars.h" -#include "src/core/lib/experiments/experiments.h" -#include "src/core/util/crash.h" // IWYU pragma: keep -#include "src/core/util/no_destruct.h" #ifndef GRPC_EXPERIMENTS_ARE_FINAL namespace grpc_core { diff --git a/deps/grpc/src/core/lib/experiments/experiments.cc b/deps/grpc/src/core/lib/experiments/experiments.cc index e9d1114d282..012d5a826bb 100644 --- a/deps/grpc/src/core/lib/experiments/experiments.cc +++ b/deps/grpc/src/core/lib/experiments/experiments.cc @@ -32,6 +32,9 @@ const char* const additional_constraints_channelz_use_v2_for_v1_api = "{}"; const char* const description_channelz_use_v2_for_v1_service = "Use the v2 channelz service for the v1 channelz service."; const char* const additional_constraints_channelz_use_v2_for_v1_service = "{}"; +const char* const description_chaotic_good_connect_deadline = + "Use the deadline from the connect args in chaotic good connector"; +const char* const additional_constraints_chaotic_good_connect_deadline = "{}"; const char* const description_chaotic_good_framing_layer = "Enable the chaotic good framing layer."; const char* const additional_constraints_chaotic_good_framing_layer = "{}"; @@ -82,12 +85,20 @@ const char* const additional_constraints_event_engine_poller_for_python = "{}"; const char* const description_event_engine_secure_endpoint = "Use EventEngine secure endpoint wrapper instead of iomgr when available"; const char* const additional_constraints_event_engine_secure_endpoint = "{}"; +const char* const description_fail_recv_metadata_on_deadline_exceeded = + "Fail recv initial metadata when the deadline is exceeded."; +const char* const + additional_constraints_fail_recv_metadata_on_deadline_exceeded = "{}"; const char* const description_free_large_allocator = "If set, return all free bytes from a \042big\042 allocator"; const char* const additional_constraints_free_large_allocator = "{}"; const char* const description_fuse_filters = "If set, individual filters are merged into fused filters"; const char* const additional_constraints_fuse_filters = "{}"; +const char* const description_graceful_external_connection_failure = + "If set, handles external connection failures gracefully"; +const char* const additional_constraints_graceful_external_connection_failure = + "{}"; const char* const description_keep_alive_ping_timer_batch = "Avoid explicitly cancelling the keepalive timer. Instead adjust the " "callback to re-schedule itself to the next ping interval."; @@ -96,9 +107,6 @@ const char* const description_local_connector_secure = "Local security connector uses TSI_SECURITY_NONE for LOCAL_TCP " "connections."; const char* const additional_constraints_local_connector_secure = "{}"; -const char* const description_max_age_filter_float_to_top = - "If set, the max age filter is placed at the top of the stack."; -const char* const additional_constraints_max_age_filter_float_to_top = "{}"; const char* const description_max_inflight_pings_strict_limit = "If set, the max inflight pings limit is strictly enforced."; const char* const additional_constraints_max_inflight_pings_strict_limit = "{}"; @@ -108,9 +116,16 @@ const char* const additional_constraints_monitoring_experiment = "{}"; const char* const description_multiping = "Allow more than one ping to be in flight at a time by default."; const char* const additional_constraints_multiping = "{}"; +const char* const description_otel_export_telemetry_domains = + "Export telemetry domains in OpenTelemetry metrics."; +const char* const additional_constraints_otel_export_telemetry_domains = "{}"; const char* const description_pick_first_ignore_empty_updates = "Ignore empty resolutions in pick_first"; const char* const additional_constraints_pick_first_ignore_empty_updates = "{}"; +const char* const description_pick_first_ready_to_connecting = + "When the subchannel goes from READY to CONNECTING or TRANSIENT_FAILURE, " + "pick_first goes to CONNECTING and starts a new Happy Eyeballs pass."; +const char* const additional_constraints_pick_first_ready_to_connecting = "{}"; const char* const description_pipelined_read_secure_endpoint = "Enable pipelined reads for EventEngine secure endpoints"; const char* const additional_constraints_pipelined_read_secure_endpoint = "{}"; @@ -171,11 +186,9 @@ const uint8_t required_experiments_secure_endpoint_offload_large_writes[] = { static_cast(grpc_core::kExperimentIdEventEngineClient), static_cast(grpc_core::kExperimentIdEventEngineListener), static_cast(grpc_core::kExperimentIdEventEngineSecureEndpoint)}; -const char* const description_server_global_callbacks_ownership = - "If set, server global callbacks ownership is fixed to not be owned by " - "gRPC."; -const char* const additional_constraints_server_global_callbacks_ownership = - "{}"; +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 = "{}"; @@ -199,6 +212,15 @@ const char* const additional_constraints_tcp_rcv_lowat = "{}"; const char* const description_track_writes_in_resource_quota = "Track the Write memory in Resource Quota."; const char* const additional_constraints_track_writes_in_resource_quota = "{}"; +const char* const description_track_zero_copy_allocations_in_resource_quota = + "Track the memory allocattions under the zero copy path in Resource Quota. " + "This includes the encryption / decryption for privacy-and-integrity " + "payloads."; +const char* const + additional_constraints_track_zero_copy_allocations_in_resource_quota = "{}"; +const char* const description_transport_state_watcher = + "New state watcher API between transport and subchannel."; +const char* const additional_constraints_transport_state_watcher = "{}"; const char* const description_tsi_frame_protector_without_locks = "Do not hold locks while using the tsi_frame_protector."; const char* const additional_constraints_tsi_frame_protector_without_locks = @@ -221,6 +243,9 @@ const ExperimentMetadata g_experiment_metadata[] = { description_channelz_use_v2_for_v1_service, additional_constraints_channelz_use_v2_for_v1_service, nullptr, 0, false, true}, + {"chaotic_good_connect_deadline", description_chaotic_good_connect_deadline, + additional_constraints_chaotic_good_connect_deadline, nullptr, 0, true, + true}, {"chaotic_good_framing_layer", description_chaotic_good_framing_layer, additional_constraints_chaotic_good_framing_layer, nullptr, 0, true, false}, @@ -254,18 +279,23 @@ const ExperimentMetadata g_experiment_metadata[] = { {"event_engine_secure_endpoint", description_event_engine_secure_endpoint, additional_constraints_event_engine_secure_endpoint, nullptr, 0, true, false}, + {"fail_recv_metadata_on_deadline_exceeded", + description_fail_recv_metadata_on_deadline_exceeded, + additional_constraints_fail_recv_metadata_on_deadline_exceeded, nullptr, 0, + false, false}, {"free_large_allocator", description_free_large_allocator, additional_constraints_free_large_allocator, nullptr, 0, false, true}, {"fuse_filters", description_fuse_filters, additional_constraints_fuse_filters, nullptr, 0, false, false}, + {"graceful_external_connection_failure", + description_graceful_external_connection_failure, + additional_constraints_graceful_external_connection_failure, nullptr, 0, + true, false}, {"keep_alive_ping_timer_batch", description_keep_alive_ping_timer_batch, additional_constraints_keep_alive_ping_timer_batch, nullptr, 0, false, true}, {"local_connector_secure", description_local_connector_secure, additional_constraints_local_connector_secure, nullptr, 0, false, true}, - {"max_age_filter_float_to_top", description_max_age_filter_float_to_top, - additional_constraints_max_age_filter_float_to_top, nullptr, 0, true, - true}, {"max_inflight_pings_strict_limit", description_max_inflight_pings_strict_limit, additional_constraints_max_inflight_pings_strict_limit, nullptr, 0, true, @@ -274,10 +304,17 @@ const ExperimentMetadata g_experiment_metadata[] = { additional_constraints_monitoring_experiment, nullptr, 0, true, true}, {"multiping", description_multiping, additional_constraints_multiping, nullptr, 0, false, true}, + {"otel_export_telemetry_domains", description_otel_export_telemetry_domains, + additional_constraints_otel_export_telemetry_domains, nullptr, 0, false, + true}, {"pick_first_ignore_empty_updates", description_pick_first_ignore_empty_updates, additional_constraints_pick_first_ignore_empty_updates, nullptr, 0, false, true}, + {"pick_first_ready_to_connecting", + description_pick_first_ready_to_connecting, + additional_constraints_pick_first_ready_to_connecting, nullptr, 0, false, + true}, {"pipelined_read_secure_endpoint", description_pipelined_read_secure_endpoint, additional_constraints_pipelined_read_secure_endpoint, @@ -318,17 +355,16 @@ 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}, - {"server_global_callbacks_ownership", - description_server_global_callbacks_ownership, - additional_constraints_server_global_callbacks_ownership, nullptr, 0, 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, true}, {"sleep_use_non_owning_waker", description_sleep_use_non_owning_waker, - additional_constraints_sleep_use_non_owning_waker, nullptr, 0, false, - true}, + additional_constraints_sleep_use_non_owning_waker, nullptr, 0, true, true}, {"subchannel_wrapper_cleanup_on_orphan", description_subchannel_wrapper_cleanup_on_orphan, additional_constraints_subchannel_wrapper_cleanup_on_orphan, nullptr, 0, @@ -341,6 +377,12 @@ const ExperimentMetadata g_experiment_metadata[] = { description_track_writes_in_resource_quota, additional_constraints_track_writes_in_resource_quota, nullptr, 0, false, true}, + {"track_zero_copy_allocations_in_resource_quota", + description_track_zero_copy_allocations_in_resource_quota, + additional_constraints_track_zero_copy_allocations_in_resource_quota, + nullptr, 0, false, true}, + {"transport_state_watcher", description_transport_state_watcher, + additional_constraints_transport_state_watcher, nullptr, 0, false, true}, {"tsi_frame_protector_without_locks", description_tsi_frame_protector_without_locks, additional_constraints_tsi_frame_protector_without_locks, nullptr, 0, @@ -364,6 +406,9 @@ const char* const additional_constraints_channelz_use_v2_for_v1_api = "{}"; const char* const description_channelz_use_v2_for_v1_service = "Use the v2 channelz service for the v1 channelz service."; const char* const additional_constraints_channelz_use_v2_for_v1_service = "{}"; +const char* const description_chaotic_good_connect_deadline = + "Use the deadline from the connect args in chaotic good connector"; +const char* const additional_constraints_chaotic_good_connect_deadline = "{}"; const char* const description_chaotic_good_framing_layer = "Enable the chaotic good framing layer."; const char* const additional_constraints_chaotic_good_framing_layer = "{}"; @@ -414,12 +459,20 @@ const char* const additional_constraints_event_engine_poller_for_python = "{}"; const char* const description_event_engine_secure_endpoint = "Use EventEngine secure endpoint wrapper instead of iomgr when available"; const char* const additional_constraints_event_engine_secure_endpoint = "{}"; +const char* const description_fail_recv_metadata_on_deadline_exceeded = + "Fail recv initial metadata when the deadline is exceeded."; +const char* const + additional_constraints_fail_recv_metadata_on_deadline_exceeded = "{}"; const char* const description_free_large_allocator = "If set, return all free bytes from a \042big\042 allocator"; const char* const additional_constraints_free_large_allocator = "{}"; const char* const description_fuse_filters = "If set, individual filters are merged into fused filters"; const char* const additional_constraints_fuse_filters = "{}"; +const char* const description_graceful_external_connection_failure = + "If set, handles external connection failures gracefully"; +const char* const additional_constraints_graceful_external_connection_failure = + "{}"; const char* const description_keep_alive_ping_timer_batch = "Avoid explicitly cancelling the keepalive timer. Instead adjust the " "callback to re-schedule itself to the next ping interval."; @@ -428,9 +481,6 @@ const char* const description_local_connector_secure = "Local security connector uses TSI_SECURITY_NONE for LOCAL_TCP " "connections."; const char* const additional_constraints_local_connector_secure = "{}"; -const char* const description_max_age_filter_float_to_top = - "If set, the max age filter is placed at the top of the stack."; -const char* const additional_constraints_max_age_filter_float_to_top = "{}"; const char* const description_max_inflight_pings_strict_limit = "If set, the max inflight pings limit is strictly enforced."; const char* const additional_constraints_max_inflight_pings_strict_limit = "{}"; @@ -440,9 +490,16 @@ const char* const additional_constraints_monitoring_experiment = "{}"; const char* const description_multiping = "Allow more than one ping to be in flight at a time by default."; const char* const additional_constraints_multiping = "{}"; +const char* const description_otel_export_telemetry_domains = + "Export telemetry domains in OpenTelemetry metrics."; +const char* const additional_constraints_otel_export_telemetry_domains = "{}"; const char* const description_pick_first_ignore_empty_updates = "Ignore empty resolutions in pick_first"; const char* const additional_constraints_pick_first_ignore_empty_updates = "{}"; +const char* const description_pick_first_ready_to_connecting = + "When the subchannel goes from READY to CONNECTING or TRANSIENT_FAILURE, " + "pick_first goes to CONNECTING and starts a new Happy Eyeballs pass."; +const char* const additional_constraints_pick_first_ready_to_connecting = "{}"; const char* const description_pipelined_read_secure_endpoint = "Enable pipelined reads for EventEngine secure endpoints"; const char* const additional_constraints_pipelined_read_secure_endpoint = "{}"; @@ -503,11 +560,9 @@ const uint8_t required_experiments_secure_endpoint_offload_large_writes[] = { static_cast(grpc_core::kExperimentIdEventEngineClient), static_cast(grpc_core::kExperimentIdEventEngineListener), static_cast(grpc_core::kExperimentIdEventEngineSecureEndpoint)}; -const char* const description_server_global_callbacks_ownership = - "If set, server global callbacks ownership is fixed to not be owned by " - "gRPC."; -const char* const additional_constraints_server_global_callbacks_ownership = - "{}"; +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 = "{}"; @@ -531,6 +586,15 @@ const char* const additional_constraints_tcp_rcv_lowat = "{}"; const char* const description_track_writes_in_resource_quota = "Track the Write memory in Resource Quota."; const char* const additional_constraints_track_writes_in_resource_quota = "{}"; +const char* const description_track_zero_copy_allocations_in_resource_quota = + "Track the memory allocattions under the zero copy path in Resource Quota. " + "This includes the encryption / decryption for privacy-and-integrity " + "payloads."; +const char* const + additional_constraints_track_zero_copy_allocations_in_resource_quota = "{}"; +const char* const description_transport_state_watcher = + "New state watcher API between transport and subchannel."; +const char* const additional_constraints_transport_state_watcher = "{}"; const char* const description_tsi_frame_protector_without_locks = "Do not hold locks while using the tsi_frame_protector."; const char* const additional_constraints_tsi_frame_protector_without_locks = @@ -553,6 +617,9 @@ const ExperimentMetadata g_experiment_metadata[] = { description_channelz_use_v2_for_v1_service, additional_constraints_channelz_use_v2_for_v1_service, nullptr, 0, false, true}, + {"chaotic_good_connect_deadline", description_chaotic_good_connect_deadline, + additional_constraints_chaotic_good_connect_deadline, nullptr, 0, true, + true}, {"chaotic_good_framing_layer", description_chaotic_good_framing_layer, additional_constraints_chaotic_good_framing_layer, nullptr, 0, true, false}, @@ -586,18 +653,23 @@ const ExperimentMetadata g_experiment_metadata[] = { {"event_engine_secure_endpoint", description_event_engine_secure_endpoint, additional_constraints_event_engine_secure_endpoint, nullptr, 0, true, false}, + {"fail_recv_metadata_on_deadline_exceeded", + description_fail_recv_metadata_on_deadline_exceeded, + additional_constraints_fail_recv_metadata_on_deadline_exceeded, nullptr, 0, + false, false}, {"free_large_allocator", description_free_large_allocator, additional_constraints_free_large_allocator, nullptr, 0, false, true}, {"fuse_filters", description_fuse_filters, additional_constraints_fuse_filters, nullptr, 0, false, false}, + {"graceful_external_connection_failure", + description_graceful_external_connection_failure, + additional_constraints_graceful_external_connection_failure, nullptr, 0, + true, false}, {"keep_alive_ping_timer_batch", description_keep_alive_ping_timer_batch, additional_constraints_keep_alive_ping_timer_batch, nullptr, 0, false, true}, {"local_connector_secure", description_local_connector_secure, additional_constraints_local_connector_secure, nullptr, 0, false, true}, - {"max_age_filter_float_to_top", description_max_age_filter_float_to_top, - additional_constraints_max_age_filter_float_to_top, nullptr, 0, true, - true}, {"max_inflight_pings_strict_limit", description_max_inflight_pings_strict_limit, additional_constraints_max_inflight_pings_strict_limit, nullptr, 0, true, @@ -606,10 +678,17 @@ const ExperimentMetadata g_experiment_metadata[] = { additional_constraints_monitoring_experiment, nullptr, 0, true, true}, {"multiping", description_multiping, additional_constraints_multiping, nullptr, 0, false, true}, + {"otel_export_telemetry_domains", description_otel_export_telemetry_domains, + additional_constraints_otel_export_telemetry_domains, nullptr, 0, false, + true}, {"pick_first_ignore_empty_updates", description_pick_first_ignore_empty_updates, additional_constraints_pick_first_ignore_empty_updates, nullptr, 0, false, true}, + {"pick_first_ready_to_connecting", + description_pick_first_ready_to_connecting, + additional_constraints_pick_first_ready_to_connecting, nullptr, 0, false, + true}, {"pipelined_read_secure_endpoint", description_pipelined_read_secure_endpoint, additional_constraints_pipelined_read_secure_endpoint, @@ -650,17 +729,16 @@ 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}, - {"server_global_callbacks_ownership", - description_server_global_callbacks_ownership, - additional_constraints_server_global_callbacks_ownership, nullptr, 0, 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, true}, {"sleep_use_non_owning_waker", description_sleep_use_non_owning_waker, - additional_constraints_sleep_use_non_owning_waker, nullptr, 0, false, - true}, + additional_constraints_sleep_use_non_owning_waker, nullptr, 0, true, true}, {"subchannel_wrapper_cleanup_on_orphan", description_subchannel_wrapper_cleanup_on_orphan, additional_constraints_subchannel_wrapper_cleanup_on_orphan, nullptr, 0, @@ -673,6 +751,12 @@ const ExperimentMetadata g_experiment_metadata[] = { description_track_writes_in_resource_quota, additional_constraints_track_writes_in_resource_quota, nullptr, 0, false, true}, + {"track_zero_copy_allocations_in_resource_quota", + description_track_zero_copy_allocations_in_resource_quota, + additional_constraints_track_zero_copy_allocations_in_resource_quota, + nullptr, 0, false, true}, + {"transport_state_watcher", description_transport_state_watcher, + additional_constraints_transport_state_watcher, nullptr, 0, false, true}, {"tsi_frame_protector_without_locks", description_tsi_frame_protector_without_locks, additional_constraints_tsi_frame_protector_without_locks, nullptr, 0, @@ -696,6 +780,9 @@ const char* const additional_constraints_channelz_use_v2_for_v1_api = "{}"; const char* const description_channelz_use_v2_for_v1_service = "Use the v2 channelz service for the v1 channelz service."; const char* const additional_constraints_channelz_use_v2_for_v1_service = "{}"; +const char* const description_chaotic_good_connect_deadline = + "Use the deadline from the connect args in chaotic good connector"; +const char* const additional_constraints_chaotic_good_connect_deadline = "{}"; const char* const description_chaotic_good_framing_layer = "Enable the chaotic good framing layer."; const char* const additional_constraints_chaotic_good_framing_layer = "{}"; @@ -746,12 +833,20 @@ const char* const additional_constraints_event_engine_poller_for_python = "{}"; const char* const description_event_engine_secure_endpoint = "Use EventEngine secure endpoint wrapper instead of iomgr when available"; const char* const additional_constraints_event_engine_secure_endpoint = "{}"; +const char* const description_fail_recv_metadata_on_deadline_exceeded = + "Fail recv initial metadata when the deadline is exceeded."; +const char* const + additional_constraints_fail_recv_metadata_on_deadline_exceeded = "{}"; const char* const description_free_large_allocator = "If set, return all free bytes from a \042big\042 allocator"; const char* const additional_constraints_free_large_allocator = "{}"; const char* const description_fuse_filters = "If set, individual filters are merged into fused filters"; const char* const additional_constraints_fuse_filters = "{}"; +const char* const description_graceful_external_connection_failure = + "If set, handles external connection failures gracefully"; +const char* const additional_constraints_graceful_external_connection_failure = + "{}"; const char* const description_keep_alive_ping_timer_batch = "Avoid explicitly cancelling the keepalive timer. Instead adjust the " "callback to re-schedule itself to the next ping interval."; @@ -760,9 +855,6 @@ const char* const description_local_connector_secure = "Local security connector uses TSI_SECURITY_NONE for LOCAL_TCP " "connections."; const char* const additional_constraints_local_connector_secure = "{}"; -const char* const description_max_age_filter_float_to_top = - "If set, the max age filter is placed at the top of the stack."; -const char* const additional_constraints_max_age_filter_float_to_top = "{}"; const char* const description_max_inflight_pings_strict_limit = "If set, the max inflight pings limit is strictly enforced."; const char* const additional_constraints_max_inflight_pings_strict_limit = "{}"; @@ -772,9 +864,16 @@ const char* const additional_constraints_monitoring_experiment = "{}"; const char* const description_multiping = "Allow more than one ping to be in flight at a time by default."; const char* const additional_constraints_multiping = "{}"; +const char* const description_otel_export_telemetry_domains = + "Export telemetry domains in OpenTelemetry metrics."; +const char* const additional_constraints_otel_export_telemetry_domains = "{}"; const char* const description_pick_first_ignore_empty_updates = "Ignore empty resolutions in pick_first"; const char* const additional_constraints_pick_first_ignore_empty_updates = "{}"; +const char* const description_pick_first_ready_to_connecting = + "When the subchannel goes from READY to CONNECTING or TRANSIENT_FAILURE, " + "pick_first goes to CONNECTING and starts a new Happy Eyeballs pass."; +const char* const additional_constraints_pick_first_ready_to_connecting = "{}"; const char* const description_pipelined_read_secure_endpoint = "Enable pipelined reads for EventEngine secure endpoints"; const char* const additional_constraints_pipelined_read_secure_endpoint = "{}"; @@ -835,11 +934,9 @@ const uint8_t required_experiments_secure_endpoint_offload_large_writes[] = { static_cast(grpc_core::kExperimentIdEventEngineClient), static_cast(grpc_core::kExperimentIdEventEngineListener), static_cast(grpc_core::kExperimentIdEventEngineSecureEndpoint)}; -const char* const description_server_global_callbacks_ownership = - "If set, server global callbacks ownership is fixed to not be owned by " - "gRPC."; -const char* const additional_constraints_server_global_callbacks_ownership = - "{}"; +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 = "{}"; @@ -863,6 +960,15 @@ const char* const additional_constraints_tcp_rcv_lowat = "{}"; const char* const description_track_writes_in_resource_quota = "Track the Write memory in Resource Quota."; const char* const additional_constraints_track_writes_in_resource_quota = "{}"; +const char* const description_track_zero_copy_allocations_in_resource_quota = + "Track the memory allocattions under the zero copy path in Resource Quota. " + "This includes the encryption / decryption for privacy-and-integrity " + "payloads."; +const char* const + additional_constraints_track_zero_copy_allocations_in_resource_quota = "{}"; +const char* const description_transport_state_watcher = + "New state watcher API between transport and subchannel."; +const char* const additional_constraints_transport_state_watcher = "{}"; const char* const description_tsi_frame_protector_without_locks = "Do not hold locks while using the tsi_frame_protector."; const char* const additional_constraints_tsi_frame_protector_without_locks = @@ -885,6 +991,9 @@ const ExperimentMetadata g_experiment_metadata[] = { description_channelz_use_v2_for_v1_service, additional_constraints_channelz_use_v2_for_v1_service, nullptr, 0, false, true}, + {"chaotic_good_connect_deadline", description_chaotic_good_connect_deadline, + additional_constraints_chaotic_good_connect_deadline, nullptr, 0, true, + true}, {"chaotic_good_framing_layer", description_chaotic_good_framing_layer, additional_constraints_chaotic_good_framing_layer, nullptr, 0, true, false}, @@ -918,18 +1027,23 @@ const ExperimentMetadata g_experiment_metadata[] = { {"event_engine_secure_endpoint", description_event_engine_secure_endpoint, additional_constraints_event_engine_secure_endpoint, nullptr, 0, true, false}, + {"fail_recv_metadata_on_deadline_exceeded", + description_fail_recv_metadata_on_deadline_exceeded, + additional_constraints_fail_recv_metadata_on_deadline_exceeded, nullptr, 0, + false, false}, {"free_large_allocator", description_free_large_allocator, additional_constraints_free_large_allocator, nullptr, 0, false, true}, {"fuse_filters", description_fuse_filters, additional_constraints_fuse_filters, nullptr, 0, false, false}, + {"graceful_external_connection_failure", + description_graceful_external_connection_failure, + additional_constraints_graceful_external_connection_failure, nullptr, 0, + true, false}, {"keep_alive_ping_timer_batch", description_keep_alive_ping_timer_batch, additional_constraints_keep_alive_ping_timer_batch, nullptr, 0, false, true}, {"local_connector_secure", description_local_connector_secure, additional_constraints_local_connector_secure, nullptr, 0, false, true}, - {"max_age_filter_float_to_top", description_max_age_filter_float_to_top, - additional_constraints_max_age_filter_float_to_top, nullptr, 0, true, - true}, {"max_inflight_pings_strict_limit", description_max_inflight_pings_strict_limit, additional_constraints_max_inflight_pings_strict_limit, nullptr, 0, true, @@ -938,10 +1052,17 @@ const ExperimentMetadata g_experiment_metadata[] = { additional_constraints_monitoring_experiment, nullptr, 0, true, true}, {"multiping", description_multiping, additional_constraints_multiping, nullptr, 0, false, true}, + {"otel_export_telemetry_domains", description_otel_export_telemetry_domains, + additional_constraints_otel_export_telemetry_domains, nullptr, 0, false, + true}, {"pick_first_ignore_empty_updates", description_pick_first_ignore_empty_updates, additional_constraints_pick_first_ignore_empty_updates, nullptr, 0, false, true}, + {"pick_first_ready_to_connecting", + description_pick_first_ready_to_connecting, + additional_constraints_pick_first_ready_to_connecting, nullptr, 0, false, + true}, {"pipelined_read_secure_endpoint", description_pipelined_read_secure_endpoint, additional_constraints_pipelined_read_secure_endpoint, @@ -982,17 +1103,16 @@ 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}, - {"server_global_callbacks_ownership", - description_server_global_callbacks_ownership, - additional_constraints_server_global_callbacks_ownership, nullptr, 0, 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, true}, {"sleep_use_non_owning_waker", description_sleep_use_non_owning_waker, - additional_constraints_sleep_use_non_owning_waker, nullptr, 0, false, - true}, + additional_constraints_sleep_use_non_owning_waker, nullptr, 0, true, true}, {"subchannel_wrapper_cleanup_on_orphan", description_subchannel_wrapper_cleanup_on_orphan, additional_constraints_subchannel_wrapper_cleanup_on_orphan, nullptr, 0, @@ -1005,6 +1125,12 @@ const ExperimentMetadata g_experiment_metadata[] = { description_track_writes_in_resource_quota, additional_constraints_track_writes_in_resource_quota, nullptr, 0, false, true}, + {"track_zero_copy_allocations_in_resource_quota", + description_track_zero_copy_allocations_in_resource_quota, + additional_constraints_track_zero_copy_allocations_in_resource_quota, + nullptr, 0, false, true}, + {"transport_state_watcher", description_transport_state_watcher, + additional_constraints_transport_state_watcher, nullptr, 0, false, true}, {"tsi_frame_protector_without_locks", description_tsi_frame_protector_without_locks, additional_constraints_tsi_frame_protector_without_locks, nullptr, 0, diff --git a/deps/grpc/src/core/lib/experiments/experiments.h b/deps/grpc/src/core/lib/experiments/experiments.h index 667cf0a4412..c78344f8b0f 100644 --- a/deps/grpc/src/core/lib/experiments/experiments.h +++ b/deps/grpc/src/core/lib/experiments/experiments.h @@ -61,6 +61,8 @@ namespace grpc_core { inline bool IsCallTracerInTransportEnabled() { return true; } inline bool IsChannelzUseV2ForV1ApiEnabled() { return false; } inline bool IsChannelzUseV2ForV1ServiceEnabled() { return false; } +#define GRPC_EXPERIMENT_IS_INCLUDED_CHAOTIC_GOOD_CONNECT_DEADLINE +inline bool IsChaoticGoodConnectDeadlineEnabled() { return true; } #define GRPC_EXPERIMENT_IS_INCLUDED_CHAOTIC_GOOD_FRAMING_LAYER inline bool IsChaoticGoodFramingLayerEnabled() { return true; } inline bool IsChttp2BoundWriteSizeEnabled() { return false; } @@ -81,18 +83,21 @@ inline bool IsEventEngineForAllOtherEndpointsEnabled() { return true; } inline bool IsEventEnginePollerForPythonEnabled() { return false; } #define GRPC_EXPERIMENT_IS_INCLUDED_EVENT_ENGINE_SECURE_ENDPOINT inline bool IsEventEngineSecureEndpointEnabled() { return true; } +inline bool IsFailRecvMetadataOnDeadlineExceededEnabled() { return false; } inline bool IsFreeLargeAllocatorEnabled() { return false; } inline bool IsFuseFiltersEnabled() { return false; } +#define GRPC_EXPERIMENT_IS_INCLUDED_GRACEFUL_EXTERNAL_CONNECTION_FAILURE +inline bool IsGracefulExternalConnectionFailureEnabled() { return true; } inline bool IsKeepAlivePingTimerBatchEnabled() { return false; } inline bool IsLocalConnectorSecureEnabled() { return false; } -#define GRPC_EXPERIMENT_IS_INCLUDED_MAX_AGE_FILTER_FLOAT_TO_TOP -inline bool IsMaxAgeFilterFloatToTopEnabled() { return true; } #define GRPC_EXPERIMENT_IS_INCLUDED_MAX_INFLIGHT_PINGS_STRICT_LIMIT inline bool IsMaxInflightPingsStrictLimitEnabled() { return true; } #define GRPC_EXPERIMENT_IS_INCLUDED_MONITORING_EXPERIMENT inline bool IsMonitoringExperimentEnabled() { return true; } inline bool IsMultipingEnabled() { return false; } +inline bool IsOtelExportTelemetryDomainsEnabled() { return false; } inline bool IsPickFirstIgnoreEmptyUpdatesEnabled() { return false; } +inline bool IsPickFirstReadyToConnectingEnabled() { return false; } inline bool IsPipelinedReadSecureEndpointEnabled() { return false; } inline bool IsPollsetAlternativeEnabled() { return false; } inline bool IsPrioritizeFinishedRequestsEnabled() { return false; } @@ -104,14 +109,16 @@ inline bool IsRrWrrConnectFromRandomIndexEnabled() { return false; } inline bool IsScheduleCancellationOverWriteEnabled() { return false; } inline bool IsSecureEndpointOffloadLargeReadsEnabled() { return false; } inline bool IsSecureEndpointOffloadLargeWritesEnabled() { return false; } -#define GRPC_EXPERIMENT_IS_INCLUDED_SERVER_GLOBAL_CALLBACKS_OWNERSHIP -inline bool IsServerGlobalCallbacksOwnershipEnabled() { return true; } +inline bool IsSkipClearPeerOnCancellationEnabled() { return false; } inline bool IsSleepPromiseExecCtxRemovalEnabled() { return false; } -inline bool IsSleepUseNonOwningWakerEnabled() { return false; } +#define GRPC_EXPERIMENT_IS_INCLUDED_SLEEP_USE_NON_OWNING_WAKER +inline bool IsSleepUseNonOwningWakerEnabled() { return true; } inline bool IsSubchannelWrapperCleanupOnOrphanEnabled() { return false; } inline bool IsTcpFrameSizeTuningEnabled() { return false; } inline bool IsTcpRcvLowatEnabled() { return false; } inline bool IsTrackWritesInResourceQuotaEnabled() { return false; } +inline bool IsTrackZeroCopyAllocationsInResourceQuotaEnabled() { return false; } +inline bool IsTransportStateWatcherEnabled() { return false; } inline bool IsTsiFrameProtectorWithoutLocksEnabled() { return false; } inline bool IsUnconstrainedMaxQuotaBufferSizeEnabled() { return false; } @@ -120,6 +127,8 @@ inline bool IsUnconstrainedMaxQuotaBufferSizeEnabled() { return false; } inline bool IsCallTracerInTransportEnabled() { return true; } inline bool IsChannelzUseV2ForV1ApiEnabled() { return false; } inline bool IsChannelzUseV2ForV1ServiceEnabled() { return false; } +#define GRPC_EXPERIMENT_IS_INCLUDED_CHAOTIC_GOOD_CONNECT_DEADLINE +inline bool IsChaoticGoodConnectDeadlineEnabled() { return true; } #define GRPC_EXPERIMENT_IS_INCLUDED_CHAOTIC_GOOD_FRAMING_LAYER inline bool IsChaoticGoodFramingLayerEnabled() { return true; } inline bool IsChttp2BoundWriteSizeEnabled() { return false; } @@ -140,18 +149,21 @@ inline bool IsEventEngineForAllOtherEndpointsEnabled() { return true; } inline bool IsEventEnginePollerForPythonEnabled() { return false; } #define GRPC_EXPERIMENT_IS_INCLUDED_EVENT_ENGINE_SECURE_ENDPOINT inline bool IsEventEngineSecureEndpointEnabled() { return true; } +inline bool IsFailRecvMetadataOnDeadlineExceededEnabled() { return false; } inline bool IsFreeLargeAllocatorEnabled() { return false; } inline bool IsFuseFiltersEnabled() { return false; } +#define GRPC_EXPERIMENT_IS_INCLUDED_GRACEFUL_EXTERNAL_CONNECTION_FAILURE +inline bool IsGracefulExternalConnectionFailureEnabled() { return true; } inline bool IsKeepAlivePingTimerBatchEnabled() { return false; } inline bool IsLocalConnectorSecureEnabled() { return false; } -#define GRPC_EXPERIMENT_IS_INCLUDED_MAX_AGE_FILTER_FLOAT_TO_TOP -inline bool IsMaxAgeFilterFloatToTopEnabled() { return true; } #define GRPC_EXPERIMENT_IS_INCLUDED_MAX_INFLIGHT_PINGS_STRICT_LIMIT inline bool IsMaxInflightPingsStrictLimitEnabled() { return true; } #define GRPC_EXPERIMENT_IS_INCLUDED_MONITORING_EXPERIMENT inline bool IsMonitoringExperimentEnabled() { return true; } inline bool IsMultipingEnabled() { return false; } +inline bool IsOtelExportTelemetryDomainsEnabled() { return false; } inline bool IsPickFirstIgnoreEmptyUpdatesEnabled() { return false; } +inline bool IsPickFirstReadyToConnectingEnabled() { return false; } inline bool IsPipelinedReadSecureEndpointEnabled() { return false; } inline bool IsPollsetAlternativeEnabled() { return false; } inline bool IsPrioritizeFinishedRequestsEnabled() { return false; } @@ -163,14 +175,16 @@ inline bool IsRrWrrConnectFromRandomIndexEnabled() { return false; } inline bool IsScheduleCancellationOverWriteEnabled() { return false; } inline bool IsSecureEndpointOffloadLargeReadsEnabled() { return false; } inline bool IsSecureEndpointOffloadLargeWritesEnabled() { return false; } -#define GRPC_EXPERIMENT_IS_INCLUDED_SERVER_GLOBAL_CALLBACKS_OWNERSHIP -inline bool IsServerGlobalCallbacksOwnershipEnabled() { return true; } +inline bool IsSkipClearPeerOnCancellationEnabled() { return false; } inline bool IsSleepPromiseExecCtxRemovalEnabled() { return false; } -inline bool IsSleepUseNonOwningWakerEnabled() { return false; } +#define GRPC_EXPERIMENT_IS_INCLUDED_SLEEP_USE_NON_OWNING_WAKER +inline bool IsSleepUseNonOwningWakerEnabled() { return true; } inline bool IsSubchannelWrapperCleanupOnOrphanEnabled() { return false; } inline bool IsTcpFrameSizeTuningEnabled() { return false; } inline bool IsTcpRcvLowatEnabled() { return false; } inline bool IsTrackWritesInResourceQuotaEnabled() { return false; } +inline bool IsTrackZeroCopyAllocationsInResourceQuotaEnabled() { return false; } +inline bool IsTransportStateWatcherEnabled() { return false; } inline bool IsTsiFrameProtectorWithoutLocksEnabled() { return false; } inline bool IsUnconstrainedMaxQuotaBufferSizeEnabled() { return false; } @@ -179,6 +193,8 @@ inline bool IsUnconstrainedMaxQuotaBufferSizeEnabled() { return false; } inline bool IsCallTracerInTransportEnabled() { return true; } inline bool IsChannelzUseV2ForV1ApiEnabled() { return false; } inline bool IsChannelzUseV2ForV1ServiceEnabled() { return false; } +#define GRPC_EXPERIMENT_IS_INCLUDED_CHAOTIC_GOOD_CONNECT_DEADLINE +inline bool IsChaoticGoodConnectDeadlineEnabled() { return true; } #define GRPC_EXPERIMENT_IS_INCLUDED_CHAOTIC_GOOD_FRAMING_LAYER inline bool IsChaoticGoodFramingLayerEnabled() { return true; } inline bool IsChttp2BoundWriteSizeEnabled() { return false; } @@ -199,18 +215,21 @@ inline bool IsEventEngineForAllOtherEndpointsEnabled() { return true; } inline bool IsEventEnginePollerForPythonEnabled() { return false; } #define GRPC_EXPERIMENT_IS_INCLUDED_EVENT_ENGINE_SECURE_ENDPOINT inline bool IsEventEngineSecureEndpointEnabled() { return true; } +inline bool IsFailRecvMetadataOnDeadlineExceededEnabled() { return false; } inline bool IsFreeLargeAllocatorEnabled() { return false; } inline bool IsFuseFiltersEnabled() { return false; } +#define GRPC_EXPERIMENT_IS_INCLUDED_GRACEFUL_EXTERNAL_CONNECTION_FAILURE +inline bool IsGracefulExternalConnectionFailureEnabled() { return true; } inline bool IsKeepAlivePingTimerBatchEnabled() { return false; } inline bool IsLocalConnectorSecureEnabled() { return false; } -#define GRPC_EXPERIMENT_IS_INCLUDED_MAX_AGE_FILTER_FLOAT_TO_TOP -inline bool IsMaxAgeFilterFloatToTopEnabled() { return true; } #define GRPC_EXPERIMENT_IS_INCLUDED_MAX_INFLIGHT_PINGS_STRICT_LIMIT inline bool IsMaxInflightPingsStrictLimitEnabled() { return true; } #define GRPC_EXPERIMENT_IS_INCLUDED_MONITORING_EXPERIMENT inline bool IsMonitoringExperimentEnabled() { return true; } inline bool IsMultipingEnabled() { return false; } +inline bool IsOtelExportTelemetryDomainsEnabled() { return false; } inline bool IsPickFirstIgnoreEmptyUpdatesEnabled() { return false; } +inline bool IsPickFirstReadyToConnectingEnabled() { return false; } inline bool IsPipelinedReadSecureEndpointEnabled() { return false; } inline bool IsPollsetAlternativeEnabled() { return false; } inline bool IsPrioritizeFinishedRequestsEnabled() { return false; } @@ -222,14 +241,16 @@ inline bool IsRrWrrConnectFromRandomIndexEnabled() { return false; } inline bool IsScheduleCancellationOverWriteEnabled() { return false; } inline bool IsSecureEndpointOffloadLargeReadsEnabled() { return false; } inline bool IsSecureEndpointOffloadLargeWritesEnabled() { return false; } -#define GRPC_EXPERIMENT_IS_INCLUDED_SERVER_GLOBAL_CALLBACKS_OWNERSHIP -inline bool IsServerGlobalCallbacksOwnershipEnabled() { return true; } +inline bool IsSkipClearPeerOnCancellationEnabled() { return false; } inline bool IsSleepPromiseExecCtxRemovalEnabled() { return false; } -inline bool IsSleepUseNonOwningWakerEnabled() { return false; } +#define GRPC_EXPERIMENT_IS_INCLUDED_SLEEP_USE_NON_OWNING_WAKER +inline bool IsSleepUseNonOwningWakerEnabled() { return true; } inline bool IsSubchannelWrapperCleanupOnOrphanEnabled() { return false; } inline bool IsTcpFrameSizeTuningEnabled() { return false; } inline bool IsTcpRcvLowatEnabled() { return false; } inline bool IsTrackWritesInResourceQuotaEnabled() { return false; } +inline bool IsTrackZeroCopyAllocationsInResourceQuotaEnabled() { return false; } +inline bool IsTransportStateWatcherEnabled() { return false; } inline bool IsTsiFrameProtectorWithoutLocksEnabled() { return false; } inline bool IsUnconstrainedMaxQuotaBufferSizeEnabled() { return false; } #endif @@ -239,6 +260,7 @@ enum ExperimentIds { kExperimentIdCallTracerInTransport, kExperimentIdChannelzUseV2ForV1Api, kExperimentIdChannelzUseV2ForV1Service, + kExperimentIdChaoticGoodConnectDeadline, kExperimentIdChaoticGoodFramingLayer, kExperimentIdChttp2BoundWriteSize, kExperimentIdErrorFlatten, @@ -251,15 +273,18 @@ enum ExperimentIds { kExperimentIdEventEngineForAllOtherEndpoints, kExperimentIdEventEnginePollerForPython, kExperimentIdEventEngineSecureEndpoint, + kExperimentIdFailRecvMetadataOnDeadlineExceeded, kExperimentIdFreeLargeAllocator, kExperimentIdFuseFilters, + kExperimentIdGracefulExternalConnectionFailure, kExperimentIdKeepAlivePingTimerBatch, kExperimentIdLocalConnectorSecure, - kExperimentIdMaxAgeFilterFloatToTop, kExperimentIdMaxInflightPingsStrictLimit, kExperimentIdMonitoringExperiment, kExperimentIdMultiping, + kExperimentIdOtelExportTelemetryDomains, kExperimentIdPickFirstIgnoreEmptyUpdates, + kExperimentIdPickFirstReadyToConnecting, kExperimentIdPipelinedReadSecureEndpoint, kExperimentIdPollsetAlternative, kExperimentIdPrioritizeFinishedRequests, @@ -271,13 +296,15 @@ enum ExperimentIds { kExperimentIdScheduleCancellationOverWrite, kExperimentIdSecureEndpointOffloadLargeReads, kExperimentIdSecureEndpointOffloadLargeWrites, - kExperimentIdServerGlobalCallbacksOwnership, + kExperimentIdSkipClearPeerOnCancellation, kExperimentIdSleepPromiseExecCtxRemoval, kExperimentIdSleepUseNonOwningWaker, kExperimentIdSubchannelWrapperCleanupOnOrphan, kExperimentIdTcpFrameSizeTuning, kExperimentIdTcpRcvLowat, kExperimentIdTrackWritesInResourceQuota, + kExperimentIdTrackZeroCopyAllocationsInResourceQuota, + kExperimentIdTransportStateWatcher, kExperimentIdTsiFrameProtectorWithoutLocks, kExperimentIdUnconstrainedMaxQuotaBufferSize, kNumExperiments @@ -294,6 +321,10 @@ inline bool IsChannelzUseV2ForV1ApiEnabled() { inline bool IsChannelzUseV2ForV1ServiceEnabled() { return IsExperimentEnabled(); } +#define GRPC_EXPERIMENT_IS_INCLUDED_CHAOTIC_GOOD_CONNECT_DEADLINE +inline bool IsChaoticGoodConnectDeadlineEnabled() { + return IsExperimentEnabled(); +} #define GRPC_EXPERIMENT_IS_INCLUDED_CHAOTIC_GOOD_FRAMING_LAYER inline bool IsChaoticGoodFramingLayerEnabled() { return IsExperimentEnabled(); @@ -342,6 +373,10 @@ inline bool IsEventEnginePollerForPythonEnabled() { inline bool IsEventEngineSecureEndpointEnabled() { return IsExperimentEnabled(); } +#define GRPC_EXPERIMENT_IS_INCLUDED_FAIL_RECV_METADATA_ON_DEADLINE_EXCEEDED +inline bool IsFailRecvMetadataOnDeadlineExceededEnabled() { + return IsExperimentEnabled(); +} #define GRPC_EXPERIMENT_IS_INCLUDED_FREE_LARGE_ALLOCATOR inline bool IsFreeLargeAllocatorEnabled() { return IsExperimentEnabled(); @@ -350,6 +385,10 @@ inline bool IsFreeLargeAllocatorEnabled() { inline bool IsFuseFiltersEnabled() { return IsExperimentEnabled(); } +#define GRPC_EXPERIMENT_IS_INCLUDED_GRACEFUL_EXTERNAL_CONNECTION_FAILURE +inline bool IsGracefulExternalConnectionFailureEnabled() { + return IsExperimentEnabled(); +} #define GRPC_EXPERIMENT_IS_INCLUDED_KEEP_ALIVE_PING_TIMER_BATCH inline bool IsKeepAlivePingTimerBatchEnabled() { return IsExperimentEnabled(); @@ -358,10 +397,6 @@ inline bool IsKeepAlivePingTimerBatchEnabled() { inline bool IsLocalConnectorSecureEnabled() { return IsExperimentEnabled(); } -#define GRPC_EXPERIMENT_IS_INCLUDED_MAX_AGE_FILTER_FLOAT_TO_TOP -inline bool IsMaxAgeFilterFloatToTopEnabled() { - return IsExperimentEnabled(); -} #define GRPC_EXPERIMENT_IS_INCLUDED_MAX_INFLIGHT_PINGS_STRICT_LIMIT inline bool IsMaxInflightPingsStrictLimitEnabled() { return IsExperimentEnabled(); @@ -374,10 +409,18 @@ inline bool IsMonitoringExperimentEnabled() { inline bool IsMultipingEnabled() { return IsExperimentEnabled(); } +#define GRPC_EXPERIMENT_IS_INCLUDED_OTEL_EXPORT_TELEMETRY_DOMAINS +inline bool IsOtelExportTelemetryDomainsEnabled() { + return IsExperimentEnabled(); +} #define GRPC_EXPERIMENT_IS_INCLUDED_PICK_FIRST_IGNORE_EMPTY_UPDATES inline bool IsPickFirstIgnoreEmptyUpdatesEnabled() { return IsExperimentEnabled(); } +#define GRPC_EXPERIMENT_IS_INCLUDED_PICK_FIRST_READY_TO_CONNECTING +inline bool IsPickFirstReadyToConnectingEnabled() { + return IsExperimentEnabled(); +} #define GRPC_EXPERIMENT_IS_INCLUDED_PIPELINED_READ_SECURE_ENDPOINT inline bool IsPipelinedReadSecureEndpointEnabled() { return IsExperimentEnabled(); @@ -422,9 +465,9 @@ inline bool IsSecureEndpointOffloadLargeReadsEnabled() { inline bool IsSecureEndpointOffloadLargeWritesEnabled() { return IsExperimentEnabled(); } -#define GRPC_EXPERIMENT_IS_INCLUDED_SERVER_GLOBAL_CALLBACKS_OWNERSHIP -inline bool IsServerGlobalCallbacksOwnershipEnabled() { - return IsExperimentEnabled(); +#define GRPC_EXPERIMENT_IS_INCLUDED_SKIP_CLEAR_PEER_ON_CANCELLATION +inline bool IsSkipClearPeerOnCancellationEnabled() { + return IsExperimentEnabled(); } #define GRPC_EXPERIMENT_IS_INCLUDED_SLEEP_PROMISE_EXEC_CTX_REMOVAL inline bool IsSleepPromiseExecCtxRemovalEnabled() { @@ -450,6 +493,15 @@ inline bool IsTcpRcvLowatEnabled() { inline bool IsTrackWritesInResourceQuotaEnabled() { return IsExperimentEnabled(); } +#define GRPC_EXPERIMENT_IS_INCLUDED_TRACK_ZERO_COPY_ALLOCATIONS_IN_RESOURCE_QUOTA +inline bool IsTrackZeroCopyAllocationsInResourceQuotaEnabled() { + return IsExperimentEnabled< + kExperimentIdTrackZeroCopyAllocationsInResourceQuota>(); +} +#define GRPC_EXPERIMENT_IS_INCLUDED_TRANSPORT_STATE_WATCHER +inline bool IsTransportStateWatcherEnabled() { + return IsExperimentEnabled(); +} #define GRPC_EXPERIMENT_IS_INCLUDED_TSI_FRAME_PROTECTOR_WITHOUT_LOCKS inline bool IsTsiFrameProtectorWithoutLocksEnabled() { return IsExperimentEnabled(); diff --git a/deps/grpc/src/core/lib/experiments/experiments.yaml b/deps/grpc/src/core/lib/experiments/experiments.yaml index a276409afac..35ba6714f4c 100644 --- a/deps/grpc/src/core/lib/experiments/experiments.yaml +++ b/deps/grpc/src/core/lib/experiments/experiments.yaml @@ -57,6 +57,11 @@ expiry: 2026/02/01 owner: ctiller@google.com test_tags: [channelz_test] +- name: chaotic_good_connect_deadline + description: Use the deadline from the connect args in chaotic good connector + expiry: 2026/02/01 + owner: ctiller@google.com + test_tags: [core_end2end_test] - name: chaotic_good_framing_layer description: Enable the chaotic good framing layer. expiry: 2026/02/01 @@ -70,7 +75,7 @@ test_tags: [core_end2end_test] - name: error_flatten description: Flatten errors to ordinary absl::Status form. - expiry: 2025/10/31 + expiry: 2026/02/01 owner: roth@google.com test_tags: ["core_end2end_test", "cpp_end2end_test", "xds_end2end_test", "error_tests"] @@ -78,19 +83,19 @@ - name: event_engine_callback_cq description: Use EventEngine instead of the CallbackAlternativeCQ. expiry: 2026/01/23 - owner: roth@google.com + owner: mlumish@google.com requires: ["event_engine_client", "event_engine_listener"] - name: event_engine_client description: Use EventEngine clients instead of iomgr's grpc_tcp_client expiry: 2026/01/23 - owner: roth@google.com + owner: mlumish@google.com test_tags: ["core_end2end_test", "event_engine_client_test"] uses_polling: true allow_in_fuzzing_config: false - name: event_engine_dns description: If set, use EventEngine DNSResolver for client channel resolution expiry: 2026/01/23 - owner: roth@google.com + owner: mlumish@google.com test_tags: ["cancel_ares_query_test", "resolver_component_tests_runner_invoker"] allow_in_fuzzing_config: false @@ -98,14 +103,14 @@ - name: event_engine_dns_non_client_channel description: If set, use EventEngine DNSResolver in other places besides client channel. expiry: 2026/01/23 - owner: roth@google.com + owner: mlumish@google.com test_tags: ["core_end2end_test"] allow_in_fuzzing_config: false uses_polling: true - name: event_engine_for_all_other_endpoints description: Use EventEngine endpoints for all call sites, including direct uses of grpc_tcp_create. expiry: 2026/01/23 - owner: roth@google.com + owner: mlumish@google.com test_tags: ["core_end2end_test"] allow_in_fuzzing_config: false uses_polling: true @@ -118,22 +123,22 @@ ] - name: event_engine_fork description: Enables event engine fork handling, including onfork events and file descriptor generations - expiry: 2025/10/01 - owner: eostroukhov@google.com + expiry: 2026/01/23 + owner: mlumish@google.com test_tags: ["core_end2end_test", "event_engine_fork_test"] uses_polling: true allow_in_fuzzing_config: false - name: event_engine_listener description: Use EventEngine listeners instead of iomgr's grpc_tcp_server - expiry: 2025/10/01 - owner: vigneshbabu@google.com + expiry: 2026/02/01 + owner: mlumish@google.com test_tags: ["core_end2end_test", "event_engine_listener_test"] uses_polling: true allow_in_fuzzing_config: false - name: event_engine_poller_for_python description: "Enable event engine poller in gRPC Python" expiry: 2026/01/16 - owner: eostroukhov@google.com + owner: mlumish@google.com test_tags: [] uses_polling: true - name: event_engine_secure_endpoint @@ -143,37 +148,44 @@ test_tags: ["core_end2end_test", "secure_endpoint_test", "posix_endpoint_test"] uses_polling: true allow_in_fuzzing_config: false +- name: fail_recv_metadata_on_deadline_exceeded + description: Fail recv initial metadata when the deadline is exceeded. + expiry: 2026/01/22 + owner: vigneshbabu@google.com + test_tags: [] + allow_in_fuzzing_config: false - name: free_large_allocator description: If set, return all free bytes from a "big" allocator - expiry: 2025/09/30 + expiry: 2026/03/30 owner: alishananda@google.com test_tags: [resource_quota_test] - name: fuse_filters - description: If set, individual filters are merged into fused filters - expiry: 2025/09/30 + description: If set, individual filters are merged into fused filters + expiry: 2026/02/01 owner: vigneshbabu@google.com test_tags: ["minimal_stack_test"] allow_in_fuzzing_config: false +- name: graceful_external_connection_failure + description: If set, handles external connection failures gracefully + expiry: 2026/02/01 + owner: vigneshbabu@google.com + test_tags: [] + allow_in_fuzzing_config: false - name: keep_alive_ping_timer_batch description: Avoid explicitly cancelling the keepalive timer. Instead adjust the callback to re-schedule itself to the next ping interval. - expiry: 2025/10/01 + expiry: 2026/02/01 owner: vigneshbabu@google.com test_tags: [] - name: local_connector_secure description: Local security connector uses TSI_SECURITY_NONE for LOCAL_TCP connections. - expiry: 2025/09/30 + expiry: 2026/02/01 owner: mattstev@google.com test_tags: ["core_end2end_test"] -- name: max_age_filter_float_to_top - description: If set, the max age filter is placed at the top of the stack. - expiry: 2025/10/30 - owner: vigneshbabu@google.com - test_tags: [] - name: max_inflight_pings_strict_limit description: If set, the max inflight pings limit is strictly enforced. - expiry: 2025/09/30 + expiry: 2026/02/01 owner: akshitpatel@google.com test_tags: [] - name: monitoring_experiment @@ -186,13 +198,25 @@ expiry: 2026/02/01 owner: ctiller@google.com test_tags: [flow_control_test] +- name: otel_export_telemetry_domains + description: Export telemetry domains in OpenTelemetry metrics. + expiry: 2026/02/01 + owner: ctiller@google.com + test_tags: [core_end2end_test] - name: pick_first_ignore_empty_updates description: Ignore empty resolutions in pick_first expiry: 2026/02/02 owner: ctiller@google.com +- name: pick_first_ready_to_connecting + description: + When the subchannel goes from READY to CONNECTING or TRANSIENT_FAILURE, + pick_first goes to CONNECTING and starts a new Happy Eyeballs pass. + expiry: 2026/02/01 + owner: roth@google.com + test_tags: ["lb_unit_test", "cpp_lb_end2end_test"] - name: pipelined_read_secure_endpoint description: Enable pipelined reads for EventEngine secure endpoints - expiry: 2025/10/30 + expiry: 2026/03/15 owner: alishananda@google.com test_tags: ["core_end2end_test", "secure_endpoint_test", "posix_endpoint_test"] requires: ["event_engine_client", "event_engine_listener", "event_engine_secure_endpoint"] @@ -203,7 +227,7 @@ Code outside iomgr that relies directly on pollsets will use non-pollset alternatives when enabled. expiry: 2026/01/23 - owner: roth@google.com + owner: mlumish@google.com test_tags: ["core_end2end_test"] requires: ["event_engine_client", "event_engine_listener"] allow_in_fuzzing_config: false @@ -246,12 +270,12 @@ description: RR and WRR LB policies start connecting from a random index in the address list. - expiry: 2025/10/31 + expiry: 2026/02/01 owner: roth@google.com test_tags: ["lb_unit_test", "cpp_lb_end2end_test"] - name: schedule_cancellation_over_write description: Allow cancellation op to be scheduled over a write - expiry: 2025/10/01 + expiry: 2026/02/01 owner: vigneshbabu@google.com test_tags: [] - name: secure_endpoint_offload_large_reads @@ -276,10 +300,10 @@ "event_engine_listener", "event_engine_secure_endpoint", ] -- name: server_global_callbacks_ownership - description: If set, server global callbacks ownership is fixed to not be owned by gRPC. - expiry: 2025/09/30 - owner: yashkt@google.com +- 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. @@ -304,12 +328,12 @@ TCP would not indicate completion of a read operation until a specified number of bytes have been read over the socket. Buffers are also allocated according to estimated RPC sizes. - expiry: 2025/10/01 + expiry: 2026/02/01 owner: vigneshbabu@google.com test_tags: ["endpoint_test", "flow_control_test"] - name: tcp_rcv_lowat description: Use SO_RCVLOWAT to avoid wakeups on the read path. - expiry: 2025/10/01 + expiry: 2026/02/01 owner: vigneshbabu@google.com test_tags: ["endpoint_test", "flow_control_test"] - name: track_writes_in_resource_quota @@ -317,6 +341,19 @@ expiry: 2026/02/01 owner: snohria@google.com test_tags: [resource_quota_test] +- name: track_zero_copy_allocations_in_resource_quota + description: + Track the memory allocattions under the zero copy path in + Resource Quota. This includes the encryption / decryption + for privacy-and-integrity payloads. + expiry: 2026/05/01 + owner: snohria@google.com + test_tags: [resource_quota_test] +- name: transport_state_watcher + description: New state watcher API between transport and subchannel. + expiry: 2026/02/01 + owner: roth@google.com + test_tags: ["cpp_lb_end2end_test", "chttp2_keepalive_tests"] - name: tsi_frame_protector_without_locks description: Do not hold locks while using the tsi_frame_protector. expiry: 2026/02/01 diff --git a/deps/grpc/src/core/lib/experiments/rollouts.yaml b/deps/grpc/src/core/lib/experiments/rollouts.yaml index 94021b37b3a..cff515db116 100644 --- a/deps/grpc/src/core/lib/experiments/rollouts.yaml +++ b/deps/grpc/src/core/lib/experiments/rollouts.yaml @@ -42,6 +42,8 @@ - name: call_tracer_in_transport default: true +- name: chaotic_good_connect_deadline + default: true - name: chaotic_good_framing_layer default: true - name: error_flatten @@ -62,16 +64,18 @@ default: true - name: event_engine_secure_endpoint default: true +- name: fail_recv_metadata_on_deadline_exceeded + default: false - name: free_large_allocator default: false - name: fuse_filters default: false +- name: graceful_external_connection_failure + default: true - name: keep_alive_ping_timer_batch default: false - name: local_connector_secure default: false -- name: max_age_filter_float_to_top - default: true - name: max_inflight_pings_strict_limit default: true - name: monitoring_experiment @@ -86,18 +90,20 @@ default: false - name: schedule_cancellation_over_write default: false -- name: server_global_callbacks_ownership - default: true +- name: skip_clear_peer_on_cancellation + default: false - name: sleep_promise_exec_ctx_removal default: false - name: sleep_use_non_owning_waker - default: false + default: true - name: tcp_frame_size_tuning default: false - name: tcp_rcv_lowat default: false - name: track_writes_in_resource_quota default: false +- name: track_zero_copy_allocations_in_resource_quota + default: false - name: tsi_frame_protector_without_locks default: false - name: unconstrained_max_quota_buffer_size diff --git a/deps/grpc/src/core/lib/iomgr/buffer_list.cc b/deps/grpc/src/core/lib/iomgr/buffer_list.cc index 73d225a99b0..e469d43b122 100644 --- a/deps/grpc/src/core/lib/iomgr/buffer_list.cc +++ b/deps/grpc/src/core/lib/iomgr/buffer_list.cc @@ -21,10 +21,10 @@ #include #include -#include "absl/log/log.h" #include "src/core/lib/iomgr/port.h" #include "src/core/util/crash.h" #include "src/core/util/sync.h" +#include "absl/log/log.h" #ifdef GRPC_LINUX_ERRQUEUE #include diff --git a/deps/grpc/src/core/lib/iomgr/call_combiner.cc b/deps/grpc/src/core/lib/iomgr/call_combiner.cc index 522298ebced..e8987906c4b 100644 --- a/deps/grpc/src/core/lib/iomgr/call_combiner.cc +++ b/deps/grpc/src/core/lib/iomgr/call_combiner.cc @@ -21,11 +21,11 @@ #include #include -#include "absl/log/log.h" #include "src/core/telemetry/stats.h" #include "src/core/telemetry/stats_data.h" #include "src/core/util/crash.h" #include "src/core/util/grpc_check.h" +#include "absl/log/log.h" namespace grpc_core { diff --git a/deps/grpc/src/core/lib/iomgr/call_combiner.h b/deps/grpc/src/core/lib/iomgr/call_combiner.h index 9bb8c0ed6fc..36833e054d1 100644 --- a/deps/grpc/src/core/lib/iomgr/call_combiner.h +++ b/deps/grpc/src/core/lib/iomgr/call_combiner.h @@ -23,14 +23,14 @@ #include #include -#include "absl/container/inlined_vector.h" -#include "absl/log/log.h" #include "src/core/lib/iomgr/closure.h" #include "src/core/lib/iomgr/dynamic_annotations.h" #include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/util/mpscq.h" #include "src/core/util/ref_counted.h" #include "src/core/util/ref_counted_ptr.h" +#include "absl/container/inlined_vector.h" +#include "absl/log/log.h" // A simple, lock-free mechanism for serializing activity related to a // single call. This is similar to a combiner but is more lightweight. diff --git a/deps/grpc/src/core/lib/iomgr/cfstream_handle.cc b/deps/grpc/src/core/lib/iomgr/cfstream_handle.cc index 892c8bedf47..46a25a803fb 100644 --- a/deps/grpc/src/core/lib/iomgr/cfstream_handle.cc +++ b/deps/grpc/src/core/lib/iomgr/cfstream_handle.cc @@ -27,13 +27,13 @@ #include #include -#include "absl/log/log.h" #include "src/core/lib/debug/trace.h" #import "src/core/lib/iomgr/cfstream_handle.h" #include "src/core/lib/iomgr/closure.h" #include "src/core/lib/iomgr/error_cfstream.h" #include "src/core/lib/iomgr/ev_apple.h" #include "src/core/lib/iomgr/exec_ctx.h" +#include "absl/log/log.h" GrpcLibraryInitHolder::GrpcLibraryInitHolder() { grpc_init(); } diff --git a/deps/grpc/src/core/lib/iomgr/closure.h b/deps/grpc/src/core/lib/iomgr/closure.h index e8f7a0b7812..0c152e8021c 100644 --- a/deps/grpc/src/core/lib/iomgr/closure.h +++ b/deps/grpc/src/core/lib/iomgr/closure.h @@ -24,13 +24,13 @@ #include #include -#include "absl/log/check.h" -#include "absl/log/log.h" #include "src/core/lib/iomgr/error.h" #include "src/core/util/crash.h" #include "src/core/util/debug_location.h" #include "src/core/util/manual_constructor.h" #include "src/core/util/mpscq.h" +#include "absl/log/check.h" +#include "absl/log/log.h" struct grpc_closure; typedef struct grpc_closure grpc_closure; diff --git a/deps/grpc/src/core/lib/iomgr/combiner.cc b/deps/grpc/src/core/lib/iomgr/combiner.cc index 5fd261b72ce..7a0c82d1424 100644 --- a/deps/grpc/src/core/lib/iomgr/combiner.cc +++ b/deps/grpc/src/core/lib/iomgr/combiner.cc @@ -24,12 +24,12 @@ #include #include -#include "absl/log/check.h" -#include "absl/log/log.h" #include "src/core/lib/experiments/experiments.h" #include "src/core/lib/iomgr/iomgr_internal.h" #include "src/core/util/crash.h" #include "src/core/util/mpscq.h" +#include "absl/log/check.h" +#include "absl/log/log.h" #define STATE_UNORPHANED 1 #define STATE_ELEM_COUNT_LOW_BIT 2 diff --git a/deps/grpc/src/core/lib/iomgr/endpoint.h b/deps/grpc/src/core/lib/iomgr/endpoint.h index be39b17e055..77fb0d3731a 100644 --- a/deps/grpc/src/core/lib/iomgr/endpoint.h +++ b/deps/grpc/src/core/lib/iomgr/endpoint.h @@ -25,9 +25,9 @@ #include #include -#include "absl/strings/string_view.h" #include "src/core/lib/iomgr/pollset.h" #include "src/core/lib/iomgr/pollset_set.h" +#include "absl/strings/string_view.h" // An endpoint caps a streaming channel between two communicating processes. // Examples may be: a tcp socket, , or some shared memory. diff --git a/deps/grpc/src/core/lib/iomgr/endpoint_cfstream.cc b/deps/grpc/src/core/lib/iomgr/endpoint_cfstream.cc index 2c1c50bfb11..8b06e902f1f 100644 --- a/deps/grpc/src/core/lib/iomgr/endpoint_cfstream.cc +++ b/deps/grpc/src/core/lib/iomgr/endpoint_cfstream.cc @@ -27,7 +27,6 @@ #include #include -#include "absl/log/log.h" #include "src/core/lib/address_utils/sockaddr_utils.h" #include "src/core/lib/iomgr/cfstream_handle.h" #include "src/core/lib/iomgr/closure.h" @@ -40,6 +39,7 @@ #include "src/core/lib/slice/slice_string_helpers.h" #include "src/core/util/grpc_check.h" #include "src/core/util/string.h" +#include "absl/log/log.h" struct CFStreamEndpoint { grpc_endpoint base; diff --git a/deps/grpc/src/core/lib/iomgr/endpoint_pair_posix.cc b/deps/grpc/src/core/lib/iomgr/endpoint_pair_posix.cc index 0053fe2b0d2..b0881bec853 100644 --- a/deps/grpc/src/core/lib/iomgr/endpoint_pair_posix.cc +++ b/deps/grpc/src/core/lib/iomgr/endpoint_pair_posix.cc @@ -30,7 +30,6 @@ #include -#include "absl/strings/str_cat.h" #include "src/core/config/core_configuration.h" #include "src/core/lib/event_engine/channel_args_endpoint_config.h" #include "src/core/lib/event_engine/extensions/supports_fd.h" @@ -44,6 +43,7 @@ #include "src/core/lib/iomgr/unix_sockets_posix.h" #include "src/core/util/crash.h" #include "src/core/util/grpc_check.h" +#include "absl/strings/str_cat.h" namespace { using grpc_event_engine::experimental::ChannelArgsEndpointConfig; diff --git a/deps/grpc/src/core/lib/iomgr/endpoint_pair_windows.cc b/deps/grpc/src/core/lib/iomgr/endpoint_pair_windows.cc index 2c8bf5a3563..eb3f8d2cca7 100644 --- a/deps/grpc/src/core/lib/iomgr/endpoint_pair_windows.cc +++ b/deps/grpc/src/core/lib/iomgr/endpoint_pair_windows.cc @@ -25,7 +25,6 @@ #include #include -#include "absl/log/log.h" #include "src/core/config/core_configuration.h" #include "src/core/lib/address_utils/sockaddr_utils.h" #include "src/core/lib/event_engine/channel_args_endpoint_config.h" @@ -38,6 +37,7 @@ #include "src/core/lib/iomgr/tcp_windows.h" #include "src/core/util/crash.h" #include "src/core/util/grpc_check.h" +#include "absl/log/log.h" static void create_sockets(SOCKET sv[2]) { SOCKET svr_sock = INVALID_SOCKET; diff --git a/deps/grpc/src/core/lib/iomgr/error.cc b/deps/grpc/src/core/lib/iomgr/error.cc index 246aced29fc..862cd13e6cc 100644 --- a/deps/grpc/src/core/lib/iomgr/error.cc +++ b/deps/grpc/src/core/lib/iomgr/error.cc @@ -24,11 +24,11 @@ #include #include +#include "src/core/util/crash.h" #include "absl/log/check.h" #include "absl/log/log.h" #include "absl/strings/str_cat.h" #include "absl/strings/str_format.h" -#include "src/core/util/crash.h" #ifdef GPR_WINDOWS #include diff --git a/deps/grpc/src/core/lib/iomgr/error.h b/deps/grpc/src/core/lib/iomgr/error.h index 0171c504811..a9af0233a32 100644 --- a/deps/grpc/src/core/lib/iomgr/error.h +++ b/deps/grpc/src/core/lib/iomgr/error.h @@ -26,13 +26,13 @@ #include #include -#include "absl/log/check.h" -#include "absl/status/status.h" #include "src/core/lib/debug/trace.h" #include "src/core/lib/slice/slice_internal.h" #include "src/core/util/crash.h" #include "src/core/util/spinlock.h" #include "src/core/util/status_helper.h" +#include "absl/log/check.h" +#include "absl/status/status.h" /// Opaque representation of an error. diff --git a/deps/grpc/src/core/lib/iomgr/error_cfstream.cc b/deps/grpc/src/core/lib/iomgr/error_cfstream.cc index b9f7cdf1992..b71978f72e5 100644 --- a/deps/grpc/src/core/lib/iomgr/error_cfstream.cc +++ b/deps/grpc/src/core/lib/iomgr/error_cfstream.cc @@ -24,8 +24,8 @@ #include -#include "absl/strings/str_format.h" #include "src/core/lib/iomgr/error.h" +#include "absl/strings/str_format.h" #define MAX_ERROR_DESCRIPTION 256 diff --git a/deps/grpc/src/core/lib/iomgr/ev_apple.cc b/deps/grpc/src/core/lib/iomgr/ev_apple.cc index 17d400c64a5..f65d0b4cca7 100644 --- a/deps/grpc/src/core/lib/iomgr/ev_apple.cc +++ b/deps/grpc/src/core/lib/iomgr/ev_apple.cc @@ -33,10 +33,10 @@ #include -#include "absl/time/time.h" #include "src/core/lib/iomgr/ev_apple.h" #include "src/core/util/thd.h" #include "src/core/util/time_util.h" +#include "absl/time/time.h" #define GRPC_POLLSET_KICK_BROADCAST ((grpc_pollset_worker*)1) diff --git a/deps/grpc/src/core/lib/iomgr/ev_epoll1_linux.cc b/deps/grpc/src/core/lib/iomgr/ev_epoll1_linux.cc index a39521545a5..a4db686c773 100644 --- a/deps/grpc/src/core/lib/iomgr/ev_epoll1_linux.cc +++ b/deps/grpc/src/core/lib/iomgr/ev_epoll1_linux.cc @@ -40,10 +40,6 @@ #include #include -#include "absl/log/log.h" -#include "absl/strings/str_cat.h" -#include "absl/strings/str_format.h" -#include "absl/strings/str_join.h" #include "src/core/lib/event_engine/shim.h" #include "src/core/lib/experiments/experiments.h" #include "src/core/lib/iomgr/block_annotate.h" @@ -59,6 +55,10 @@ #include "src/core/util/strerror.h" #include "src/core/util/string.h" #include "src/core/util/useful.h" +#include "absl/log/log.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/str_format.h" +#include "absl/strings/str_join.h" static grpc_wakeup_fd global_wakeup_fd; static bool g_is_shutdown = true; diff --git a/deps/grpc/src/core/lib/iomgr/ev_poll_posix.cc b/deps/grpc/src/core/lib/iomgr/ev_poll_posix.cc index 13a8d6bedc8..4e969ee48ef 100644 --- a/deps/grpc/src/core/lib/iomgr/ev_poll_posix.cc +++ b/deps/grpc/src/core/lib/iomgr/ev_poll_posix.cc @@ -34,9 +34,6 @@ #include -#include "absl/log/log.h" -#include "absl/strings/str_cat.h" -#include "absl/strings/str_format.h" #include "src/core/lib/event_engine/shim.h" #include "src/core/lib/experiments/experiments.h" #include "src/core/lib/iomgr/block_annotate.h" @@ -49,6 +46,9 @@ #include "src/core/util/grpc_check.h" #include "src/core/util/thd.h" #include "src/core/util/useful.h" +#include "absl/log/log.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/str_format.h" #define GRPC_POLLSET_KICK_BROADCAST ((grpc_pollset_worker*)1) diff --git a/deps/grpc/src/core/lib/iomgr/ev_posix.cc b/deps/grpc/src/core/lib/iomgr/ev_posix.cc index 532a611d330..48b828ea148 100644 --- a/deps/grpc/src/core/lib/iomgr/ev_posix.cc +++ b/deps/grpc/src/core/lib/iomgr/ev_posix.cc @@ -27,9 +27,6 @@ #include #include -#include "absl/log/log.h" -#include "absl/strings/str_format.h" -#include "absl/strings/str_split.h" #include "src/core/config/config_vars.h" #include "src/core/lib/debug/trace.h" #include "src/core/lib/iomgr/ev_epoll1_linux.h" @@ -38,6 +35,9 @@ #include "src/core/lib/iomgr/internal_errqueue.h" #include "src/core/util/crash.h" #include "src/core/util/useful.h" +#include "absl/log/log.h" +#include "absl/strings/str_format.h" +#include "absl/strings/str_split.h" /// Default poll() function - a pointer so that it can be overridden by some /// tests diff --git a/deps/grpc/src/core/lib/iomgr/event_engine_shims/closure.cc b/deps/grpc/src/core/lib/iomgr/event_engine_shims/closure.cc index 91ff2f47106..a678145eb23 100644 --- a/deps/grpc/src/core/lib/iomgr/event_engine_shims/closure.cc +++ b/deps/grpc/src/core/lib/iomgr/event_engine_shims/closure.cc @@ -16,12 +16,12 @@ #include #include -#include "absl/functional/any_invocable.h" -#include "absl/log/log.h" -#include "absl/status/status.h" #include "src/core/lib/iomgr/closure.h" #include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/transport/error_utils.h" +#include "absl/functional/any_invocable.h" +#include "absl/log/log.h" +#include "absl/status/status.h" namespace grpc_event_engine { namespace experimental { diff --git a/deps/grpc/src/core/lib/iomgr/event_engine_shims/closure.h b/deps/grpc/src/core/lib/iomgr/event_engine_shims/closure.h index 2272f68fed7..16e2c0aee65 100644 --- a/deps/grpc/src/core/lib/iomgr/event_engine_shims/closure.h +++ b/deps/grpc/src/core/lib/iomgr/event_engine_shims/closure.h @@ -17,9 +17,9 @@ #include #include -#include "absl/functional/any_invocable.h" #include "src/core/lib/iomgr/closure.h" #include "src/core/lib/iomgr/error.h" +#include "absl/functional/any_invocable.h" namespace grpc_event_engine { namespace experimental { diff --git a/deps/grpc/src/core/lib/iomgr/event_engine_shims/endpoint.cc b/deps/grpc/src/core/lib/iomgr/event_engine_shims/endpoint.cc index 86f02d331d9..63409393a75 100644 --- a/deps/grpc/src/core/lib/iomgr/event_engine_shims/endpoint.cc +++ b/deps/grpc/src/core/lib/iomgr/event_engine_shims/endpoint.cc @@ -24,11 +24,6 @@ #include #include -#include "absl/functional/any_invocable.h" -#include "absl/log/log.h" -#include "absl/status/status.h" -#include "absl/status/statusor.h" -#include "absl/strings/string_view.h" #include "src/core/lib/debug/trace.h" #include "src/core/lib/event_engine/extensions/can_track_errors.h" #include "src/core/lib/event_engine/extensions/supports_fd.h" @@ -47,6 +42,11 @@ #include "src/core/util/grpc_check.h" #include "src/core/util/string.h" #include "src/core/util/sync.h" +#include "absl/functional/any_invocable.h" +#include "absl/log/log.h" +#include "absl/status/status.h" +#include "absl/status/statusor.h" +#include "absl/strings/string_view.h" namespace grpc_event_engine { namespace experimental { diff --git a/deps/grpc/src/core/lib/iomgr/event_engine_shims/tcp_client.cc b/deps/grpc/src/core/lib/iomgr/event_engine_shims/tcp_client.cc index 5dca83903e5..6f90743f05b 100644 --- a/deps/grpc/src/core/lib/iomgr/event_engine_shims/tcp_client.cc +++ b/deps/grpc/src/core/lib/iomgr/event_engine_shims/tcp_client.cc @@ -17,8 +17,6 @@ #include #include -#include "absl/status/status.h" -#include "absl/status/statusor.h" #include "src/core/lib/address_utils/sockaddr_utils.h" #include "src/core/lib/debug/trace.h" #include "src/core/lib/event_engine/default_event_engine.h" @@ -30,6 +28,8 @@ #include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/resource_quota/resource_quota.h" #include "src/core/lib/transport/error_utils.h" +#include "absl/status/status.h" +#include "absl/status/statusor.h" namespace grpc_event_engine { namespace experimental { diff --git a/deps/grpc/src/core/lib/iomgr/exec_ctx.cc b/deps/grpc/src/core/lib/iomgr/exec_ctx.cc index 9e3c4709179..80f698238e8 100644 --- a/deps/grpc/src/core/lib/iomgr/exec_ctx.cc +++ b/deps/grpc/src/core/lib/iomgr/exec_ctx.cc @@ -21,12 +21,12 @@ #include #include -#include "absl/log/check.h" -#include "absl/log/log.h" -#include "absl/strings/str_format.h" #include "src/core/lib/iomgr/combiner.h" #include "src/core/lib/iomgr/error.h" #include "src/core/util/crash.h" +#include "absl/log/check.h" +#include "absl/log/log.h" +#include "absl/strings/str_format.h" static void exec_ctx_run(grpc_closure* closure) { #ifndef NDEBUG diff --git a/deps/grpc/src/core/lib/iomgr/exec_ctx.h b/deps/grpc/src/core/lib/iomgr/exec_ctx.h index da02ab0193b..b3d5e271c97 100644 --- a/deps/grpc/src/core/lib/iomgr/exec_ctx.h +++ b/deps/grpc/src/core/lib/iomgr/exec_ctx.h @@ -33,7 +33,6 @@ #include #include -#include "absl/log/check.h" #include "src/core/lib/experiments/experiments.h" #include "src/core/lib/iomgr/closure.h" #include "src/core/util/debug_location.h" @@ -41,6 +40,7 @@ #include "src/core/util/latent_see.h" #include "src/core/util/time.h" #include "src/core/util/time_precise.h" +#include "absl/log/check.h" #if !defined(_WIN32) || !defined(_DLL) #define EXEC_CTX exec_ctx_ diff --git a/deps/grpc/src/core/lib/iomgr/fork_posix.cc b/deps/grpc/src/core/lib/iomgr/fork_posix.cc index 14a5fda12ac..25e278b3477 100644 --- a/deps/grpc/src/core/lib/iomgr/fork_posix.cc +++ b/deps/grpc/src/core/lib/iomgr/fork_posix.cc @@ -30,11 +30,11 @@ #include #include -#include "absl/log/log.h" #include "src/core/lib/iomgr/ev_posix.h" #include "src/core/lib/iomgr/timer_manager.h" #include "src/core/lib/surface/init_internally.h" #include "src/core/util/fork.h" +#include "absl/log/log.h" // // NOTE: FORKING IS NOT GENERALLY SUPPORTED, THIS IS ONLY INTENDED TO WORK diff --git a/deps/grpc/src/core/lib/iomgr/internal_errqueue.cc b/deps/grpc/src/core/lib/iomgr/internal_errqueue.cc index d5386498a53..f24ea037e91 100644 --- a/deps/grpc/src/core/lib/iomgr/internal_errqueue.cc +++ b/deps/grpc/src/core/lib/iomgr/internal_errqueue.cc @@ -16,8 +16,8 @@ #include -#include "absl/log/log.h" #include "src/core/lib/iomgr/port.h" +#include "absl/log/log.h" #ifdef GRPC_POSIX_SOCKET_TCP diff --git a/deps/grpc/src/core/lib/iomgr/iocp_windows.cc b/deps/grpc/src/core/lib/iomgr/iocp_windows.cc index d2d2e812955..2bd1bcd9441 100644 --- a/deps/grpc/src/core/lib/iomgr/iocp_windows.cc +++ b/deps/grpc/src/core/lib/iomgr/iocp_windows.cc @@ -28,7 +28,6 @@ #include -#include "absl/log/log.h" #include "src/core/lib/iomgr/iocp_windows.h" #include "src/core/lib/iomgr/iomgr_internal.h" #include "src/core/lib/iomgr/socket_windows.h" @@ -38,6 +37,7 @@ #include "src/core/util/crash.h" #include "src/core/util/grpc_check.h" #include "src/core/util/thd.h" +#include "absl/log/log.h" static ULONG g_iocp_kick_token; static OVERLAPPED g_iocp_custom_overlap; diff --git a/deps/grpc/src/core/lib/iomgr/iomgr.cc b/deps/grpc/src/core/lib/iomgr/iomgr.cc index 72ac1e88417..976aba2a10d 100644 --- a/deps/grpc/src/core/lib/iomgr/iomgr.cc +++ b/deps/grpc/src/core/lib/iomgr/iomgr.cc @@ -26,7 +26,6 @@ #include #include -#include "absl/log/log.h" #include "src/core/config/config_vars.h" #include "src/core/lib/iomgr/buffer_list.h" #include "src/core/lib/iomgr/exec_ctx.h" @@ -38,6 +37,7 @@ #include "src/core/util/string.h" #include "src/core/util/thd.h" #include "src/core/util/useful.h" +#include "absl/log/log.h" static gpr_mu g_mu; static gpr_cv g_rcv; diff --git a/deps/grpc/src/core/lib/iomgr/lockfree_event.cc b/deps/grpc/src/core/lib/iomgr/lockfree_event.cc index 5aa89bec399..9a8c7fa00df 100644 --- a/deps/grpc/src/core/lib/iomgr/lockfree_event.cc +++ b/deps/grpc/src/core/lib/iomgr/lockfree_event.cc @@ -20,11 +20,11 @@ #include -#include "absl/log/log.h" #include "src/core/lib/debug/trace.h" #include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/util/crash.h" #include "src/core/util/grpc_check.h" +#include "absl/log/log.h" // 'state' holds the to call when the fd is readable or writable respectively. // It can contain one of the following values: diff --git a/deps/grpc/src/core/lib/iomgr/polling_entity.cc b/deps/grpc/src/core/lib/iomgr/polling_entity.cc index d7280fffbfa..e48289c3434 100644 --- a/deps/grpc/src/core/lib/iomgr/polling_entity.cc +++ b/deps/grpc/src/core/lib/iomgr/polling_entity.cc @@ -21,9 +21,9 @@ #include #include -#include "absl/strings/str_format.h" #include "src/core/util/crash.h" #include "src/core/util/grpc_check.h" +#include "absl/strings/str_format.h" grpc_polling_entity grpc_polling_entity_create_from_pollset_set( grpc_pollset_set* pollset_set) { diff --git a/deps/grpc/src/core/lib/iomgr/resolve_address.cc b/deps/grpc/src/core/lib/iomgr/resolve_address.cc index 3a0d1b106e1..5c16102d5d0 100644 --- a/deps/grpc/src/core/lib/iomgr/resolve_address.cc +++ b/deps/grpc/src/core/lib/iomgr/resolve_address.cc @@ -21,9 +21,9 @@ #include #include -#include "absl/strings/str_cat.h" #include "src/core/util/crash.h" #include "src/core/util/no_destruct.h" +#include "absl/strings/str_cat.h" namespace grpc_core { const char* kDefaultSecurePort = "https"; diff --git a/deps/grpc/src/core/lib/iomgr/resolve_address.h b/deps/grpc/src/core/lib/iomgr/resolve_address.h index 5a8279ae9c4..6b169b5a5e8 100644 --- a/deps/grpc/src/core/lib/iomgr/resolve_address.h +++ b/deps/grpc/src/core/lib/iomgr/resolve_address.h @@ -23,14 +23,14 @@ #include #include -#include "absl/container/flat_hash_set.h" -#include "absl/status/statusor.h" #include "src/core/lib/event_engine/handle_containers.h" #include "src/core/lib/iomgr/pollset_set.h" #include "src/core/lib/iomgr/port.h" #include "src/core/lib/iomgr/resolved_address.h" #include "src/core/util/orphanable.h" #include "src/core/util/time.h" +#include "absl/container/flat_hash_set.h" +#include "absl/status/statusor.h" #define GRPC_MAX_SOCKADDR_SIZE 128 diff --git a/deps/grpc/src/core/lib/iomgr/resolve_address_posix.cc b/deps/grpc/src/core/lib/iomgr/resolve_address_posix.cc index 57c88283f95..f593ae7fef4 100644 --- a/deps/grpc/src/core/lib/iomgr/resolve_address_posix.cc +++ b/deps/grpc/src/core/lib/iomgr/resolve_address_posix.cc @@ -35,10 +35,6 @@ #include #include -#include "absl/status/status.h" -#include "absl/status/statusor.h" -#include "absl/strings/str_cat.h" -#include "absl/strings/string_view.h" #include "src/core/lib/iomgr/block_annotate.h" #include "src/core/lib/iomgr/error.h" #include "src/core/lib/iomgr/exec_ctx.h" @@ -49,6 +45,10 @@ #include "src/core/util/host_port.h" #include "src/core/util/time.h" #include "src/core/util/useful.h" +#include "absl/status/status.h" +#include "absl/status/statusor.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/string_view.h" namespace grpc_core { grpc_event_engine::experimental::EventEngine* NativeDNSResolver::engine() { diff --git a/deps/grpc/src/core/lib/iomgr/resolve_address_windows.cc b/deps/grpc/src/core/lib/iomgr/resolve_address_windows.cc index f590e63fc65..ace790a5767 100644 --- a/deps/grpc/src/core/lib/iomgr/resolve_address_windows.cc +++ b/deps/grpc/src/core/lib/iomgr/resolve_address_windows.cc @@ -29,7 +29,6 @@ #include -#include "absl/strings/str_format.h" #include "src/core/lib/address_utils/sockaddr_utils.h" #include "src/core/lib/event_engine/default_event_engine.h" #include "src/core/lib/iomgr/block_annotate.h" @@ -43,6 +42,7 @@ #include "src/core/util/host_port.h" #include "src/core/util/string.h" #include "src/core/util/thd.h" +#include "absl/strings/str_format.h" namespace grpc_core { diff --git a/deps/grpc/src/core/lib/iomgr/sockaddr_utils_posix.cc b/deps/grpc/src/core/lib/iomgr/sockaddr_utils_posix.cc index a522df8aecd..919d54b2177 100644 --- a/deps/grpc/src/core/lib/iomgr/sockaddr_utils_posix.cc +++ b/deps/grpc/src/core/lib/iomgr/sockaddr_utils_posix.cc @@ -39,9 +39,9 @@ #include -#include "absl/log/check.h" #include "src/core/lib/iomgr/sockaddr.h" #include "src/core/util/crash.h" +#include "absl/log/check.h" uint16_t grpc_htons(uint16_t hostshort) { return htons(hostshort); } diff --git a/deps/grpc/src/core/lib/iomgr/socket_utils_common_posix.cc b/deps/grpc/src/core/lib/iomgr/socket_utils_common_posix.cc index b14e2d6296c..5f9e243259d 100644 --- a/deps/grpc/src/core/lib/iomgr/socket_utils_common_posix.cc +++ b/deps/grpc/src/core/lib/iomgr/socket_utils_common_posix.cc @@ -46,8 +46,6 @@ #include -#include "absl/log/log.h" -#include "absl/strings/str_cat.h" #include "src/core/lib/address_utils/sockaddr_utils.h" #include "src/core/lib/iomgr/sockaddr.h" #include "src/core/lib/iomgr/socket_factory_posix.h" @@ -55,6 +53,8 @@ #include "src/core/util/grpc_check.h" #include "src/core/util/strerror.h" #include "src/core/util/string.h" +#include "absl/log/log.h" +#include "absl/strings/str_cat.h" // set a socket to use zerocopy grpc_error_handle grpc_set_socket_zerocopy(int fd) { diff --git a/deps/grpc/src/core/lib/iomgr/socket_windows.cc b/deps/grpc/src/core/lib/iomgr/socket_windows.cc index 8b07497791f..122f4feed1c 100644 --- a/deps/grpc/src/core/lib/iomgr/socket_windows.cc +++ b/deps/grpc/src/core/lib/iomgr/socket_windows.cc @@ -29,8 +29,6 @@ #include #include -#include "absl/log/log.h" -#include "absl/strings/str_format.h" #include "src/core/lib/iomgr/iocp_windows.h" #include "src/core/lib/iomgr/iomgr_internal.h" #include "src/core/lib/iomgr/pollset.h" @@ -39,6 +37,8 @@ #include "src/core/lib/iomgr/socket_windows.h" #include "src/core/util/crash.h" #include "src/core/util/grpc_check.h" +#include "absl/log/log.h" +#include "absl/strings/str_format.h" static DWORD s_wsa_socket_flags; diff --git a/deps/grpc/src/core/lib/iomgr/tcp_client_cfstream.cc b/deps/grpc/src/core/lib/iomgr/tcp_client_cfstream.cc index 6788d1d0d09..99989459477 100644 --- a/deps/grpc/src/core/lib/iomgr/tcp_client_cfstream.cc +++ b/deps/grpc/src/core/lib/iomgr/tcp_client_cfstream.cc @@ -30,7 +30,6 @@ #include #include -#include "absl/log/log.h" #include "src/core/lib/address_utils/sockaddr_utils.h" #include "src/core/lib/event_engine/shim.h" #include "src/core/lib/iomgr/cfstream_handle.h" @@ -43,6 +42,7 @@ #include "src/core/lib/iomgr/timer.h" #include "src/core/util/crash.h" #include "src/core/util/host_port.h" +#include "absl/log/log.h" struct CFStreamConnect { gpr_mu mu; diff --git a/deps/grpc/src/core/lib/iomgr/tcp_client_posix.cc b/deps/grpc/src/core/lib/iomgr/tcp_client_posix.cc index 186fd0d4628..6655740ab87 100644 --- a/deps/grpc/src/core/lib/iomgr/tcp_client_posix.cc +++ b/deps/grpc/src/core/lib/iomgr/tcp_client_posix.cc @@ -32,9 +32,6 @@ #include -#include "absl/container/flat_hash_map.h" -#include "absl/log/log.h" -#include "absl/strings/str_cat.h" #include "src/core/lib/address_utils/sockaddr_utils.h" #include "src/core/lib/event_engine/resolved_address_internal.h" #include "src/core/lib/event_engine/shim.h" @@ -55,6 +52,9 @@ #include "src/core/util/grpc_check.h" #include "src/core/util/status_helper.h" #include "src/core/util/string.h" +#include "absl/container/flat_hash_map.h" +#include "absl/log/log.h" +#include "absl/strings/str_cat.h" using ::grpc_event_engine::experimental::EndpointConfig; diff --git a/deps/grpc/src/core/lib/iomgr/tcp_posix.cc b/deps/grpc/src/core/lib/iomgr/tcp_posix.cc index d7335aa4282..00a8827516f 100644 --- a/deps/grpc/src/core/lib/iomgr/tcp_posix.cc +++ b/deps/grpc/src/core/lib/iomgr/tcp_posix.cc @@ -45,11 +45,6 @@ #include #include -#include "absl/base/thread_annotations.h" -#include "absl/log/log.h" -#include "absl/status/status.h" -#include "absl/strings/str_cat.h" -#include "absl/strings/string_view.h" #include "src/core/lib/address_utils/sockaddr_utils.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/debug/trace.h" @@ -74,6 +69,11 @@ #include "src/core/util/string.h" #include "src/core/util/sync.h" #include "src/core/util/time.h" +#include "absl/base/thread_annotations.h" +#include "absl/log/log.h" +#include "absl/status/status.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/string_view.h" #ifndef SOL_TCP #define SOL_TCP IPPROTO_TCP diff --git a/deps/grpc/src/core/lib/iomgr/tcp_server_posix.cc b/deps/grpc/src/core/lib/iomgr/tcp_server_posix.cc index 3d8e142baef..75edd9bbe04 100644 --- a/deps/grpc/src/core/lib/iomgr/tcp_server_posix.cc +++ b/deps/grpc/src/core/lib/iomgr/tcp_server_posix.cc @@ -50,9 +50,6 @@ #include -#include "absl/log/log.h" -#include "absl/strings/str_cat.h" -#include "absl/strings/str_format.h" #include "src/core/lib/address_utils/sockaddr_utils.h" #include "src/core/lib/event_engine/default_event_engine.h" #include "src/core/lib/event_engine/extensions/supports_fd.h" @@ -76,6 +73,9 @@ #include "src/core/lib/transport/error_utils.h" #include "src/core/util/grpc_check.h" #include "src/core/util/strerror.h" +#include "absl/log/log.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/str_format.h" static std::atomic num_dropped_connections{0}; static constexpr grpc_core::Duration kRetryAcceptWaitTime{ @@ -91,7 +91,12 @@ using ::grpc_event_engine::experimental::SliceBuffer; static void finish_shutdown(grpc_tcp_server* s) { gpr_mu_lock(&s->mu); GRPC_CHECK(s->shutdown); - grpc_core::ExecCtx::RunList(DEBUG_LOCATION, &s->shutdown_ending); + if (grpc_core::ExecCtx::Get() == nullptr) { + grpc_core::ExecCtx exec_ctx; + grpc_core::ExecCtx::RunList(DEBUG_LOCATION, &s->shutdown_ending); + } else { + grpc_core::ExecCtx::RunList(DEBUG_LOCATION, &s->shutdown_ending); + } gpr_mu_unlock(&s->mu); if (s->shutdown_complete != nullptr) { grpc_core::ExecCtx::Run(DEBUG_LOCATION, s->shutdown_complete, @@ -280,6 +285,8 @@ static grpc_error_handle tcp_server_create(grpc_closure* shutdown_complete, s->shutdown = false; s->shutdown_starting.head = nullptr; s->shutdown_starting.tail = nullptr; + s->shutdown_ending.head = nullptr; + s->shutdown_ending.tail = nullptr; if (!grpc_event_engine::experimental::UseEventEngineListener()) { s->shutdown_complete = shutdown_complete; } else { @@ -849,7 +856,12 @@ static void tcp_server_unref(grpc_tcp_server* s) { if (gpr_unref(&s->refs)) { grpc_tcp_server_shutdown_listeners(s); gpr_mu_lock(&s->mu); - grpc_core::ExecCtx::RunList(DEBUG_LOCATION, &s->shutdown_starting); + if (grpc_core::ExecCtx::Get() == nullptr) { + grpc_core::ExecCtx exec_ctx; + grpc_core::ExecCtx::RunList(DEBUG_LOCATION, &s->shutdown_starting); + } else { + grpc_core::ExecCtx::RunList(DEBUG_LOCATION, &s->shutdown_starting); + } gpr_mu_unlock(&s->mu); tcp_server_destroy(s); } @@ -907,10 +919,9 @@ class ExternalConnectionHandler : public grpc_core::TcpServerFdHandler { grpc_event_engine::experimental::SliceBuffer::TakeCSliceBuffer( buf->data.raw.slice_buffer); } - GRPC_CHECK( - GRPC_LOG_IF_ERROR("listener_handle_external_connection", - listener_supports_fd->HandleExternalConnection( - listener_fd, fd, &pending_data))); + GRPC_LOG_IF_ERROR("listener_handle_external_connection", + listener_supports_fd->HandleExternalConnection( + listener_fd, fd, &pending_data)); return; } grpc_pollset* read_notifier_pollset; diff --git a/deps/grpc/src/core/lib/iomgr/tcp_server_utils_posix.h b/deps/grpc/src/core/lib/iomgr/tcp_server_utils_posix.h index 562ab4cc3e9..82c4a3f8e11 100644 --- a/deps/grpc/src/core/lib/iomgr/tcp_server_utils_posix.h +++ b/deps/grpc/src/core/lib/iomgr/tcp_server_utils_posix.h @@ -23,7 +23,6 @@ #include -#include "absl/container/flat_hash_map.h" #include "src/core/lib/event_engine/posix.h" #include "src/core/lib/iomgr/ev_posix.h" #include "src/core/lib/iomgr/resolve_address.h" @@ -31,6 +30,7 @@ #include "src/core/lib/iomgr/tcp_server.h" #include "src/core/lib/iomgr/timer.h" #include "src/core/lib/resource_quota/memory_quota.h" +#include "absl/container/flat_hash_map.h" // one listening port typedef struct grpc_tcp_listener { diff --git a/deps/grpc/src/core/lib/iomgr/tcp_server_utils_posix_common.cc b/deps/grpc/src/core/lib/iomgr/tcp_server_utils_posix_common.cc index 33ec0183bb0..f80b8db8b82 100644 --- a/deps/grpc/src/core/lib/iomgr/tcp_server_utils_posix_common.cc +++ b/deps/grpc/src/core/lib/iomgr/tcp_server_utils_posix_common.cc @@ -33,8 +33,6 @@ #include -#include "absl/log/log.h" -#include "absl/strings/str_cat.h" #include "src/core/lib/address_utils/sockaddr_utils.h" #include "src/core/lib/iomgr/error.h" #include "src/core/lib/iomgr/sockaddr.h" @@ -43,6 +41,8 @@ #include "src/core/lib/iomgr/vsock.h" #include "src/core/util/crash.h" #include "src/core/util/grpc_check.h" +#include "absl/log/log.h" +#include "absl/strings/str_cat.h" #define MIN_SAFE_ACCEPT_QUEUE_SIZE 100 diff --git a/deps/grpc/src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.cc b/deps/grpc/src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.cc index 748dd33a6e4..406bc8355e2 100644 --- a/deps/grpc/src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.cc +++ b/deps/grpc/src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.cc @@ -31,14 +31,14 @@ #include -#include "absl/log/log.h" -#include "absl/strings/str_cat.h" #include "src/core/lib/address_utils/sockaddr_utils.h" #include "src/core/lib/iomgr/error.h" #include "src/core/lib/iomgr/sockaddr.h" #include "src/core/lib/iomgr/tcp_server_utils_posix.h" #include "src/core/util/crash.h" #include "src/core/util/grpc_check.h" +#include "absl/log/log.h" +#include "absl/strings/str_cat.h" // Return the listener in s with address addr or NULL. static grpc_tcp_listener* find_listener_with_addr(grpc_tcp_server* s, diff --git a/deps/grpc/src/core/lib/iomgr/tcp_server_windows.cc b/deps/grpc/src/core/lib/iomgr/tcp_server_windows.cc index e867389fb64..bca1d1378ea 100644 --- a/deps/grpc/src/core/lib/iomgr/tcp_server_windows.cc +++ b/deps/grpc/src/core/lib/iomgr/tcp_server_windows.cc @@ -35,8 +35,6 @@ #include -#include "absl/log/log.h" -#include "absl/strings/str_cat.h" #include "src/core/lib/address_utils/sockaddr_utils.h" #include "src/core/lib/event_engine/memory_allocator_factory.h" #include "src/core/lib/event_engine/resolved_address_internal.h" @@ -58,6 +56,8 @@ #include "src/core/lib/slice/slice_internal.h" #include "src/core/util/crash.h" #include "src/core/util/grpc_check.h" +#include "absl/log/log.h" +#include "absl/strings/str_cat.h" #define MIN_SAFE_ACCEPT_QUEUE_SIZE 100 diff --git a/deps/grpc/src/core/lib/iomgr/tcp_windows.cc b/deps/grpc/src/core/lib/iomgr/tcp_windows.cc index 16259fb3925..72448122adb 100644 --- a/deps/grpc/src/core/lib/iomgr/tcp_windows.cc +++ b/deps/grpc/src/core/lib/iomgr/tcp_windows.cc @@ -27,7 +27,6 @@ #include #include -#include "absl/log/log.h" #include "src/core/lib/address_utils/sockaddr_utils.h" #include "src/core/lib/iomgr/iocp_windows.h" #include "src/core/lib/iomgr/sockaddr.h" @@ -42,6 +41,7 @@ #include "src/core/util/grpc_check.h" #include "src/core/util/string.h" #include "src/core/util/useful.h" +#include "absl/log/log.h" #if defined(__MSYS__) && defined(GPR_ARCH_64) // Nasty workaround for nasty bug when using the 64 bits msys compiler diff --git a/deps/grpc/src/core/lib/iomgr/timer_generic.cc b/deps/grpc/src/core/lib/iomgr/timer_generic.cc index 61bb5a5d50f..ed4c10fe4f6 100644 --- a/deps/grpc/src/core/lib/iomgr/timer_generic.cc +++ b/deps/grpc/src/core/lib/iomgr/timer_generic.cc @@ -24,9 +24,6 @@ #include -#include "absl/log/log.h" -#include "absl/strings/str_cat.h" -#include "absl/strings/str_format.h" #include "src/core/lib/debug/trace.h" #include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/iomgr/port.h" @@ -39,6 +36,9 @@ #include "src/core/util/time.h" #include "src/core/util/time_averaged_stats.h" #include "src/core/util/useful.h" +#include "absl/log/log.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/str_format.h" #define INVALID_HEAP_INDEX 0xffffffffu diff --git a/deps/grpc/src/core/lib/iomgr/timer_manager.cc b/deps/grpc/src/core/lib/iomgr/timer_manager.cc index f9d8f42633d..6d6d60c8d59 100644 --- a/deps/grpc/src/core/lib/iomgr/timer_manager.cc +++ b/deps/grpc/src/core/lib/iomgr/timer_manager.cc @@ -22,12 +22,12 @@ #include #include -#include "absl/log/log.h" #include "src/core/lib/debug/trace.h" #include "src/core/lib/iomgr/timer.h" #include "src/core/util/crash.h" #include "src/core/util/grpc_check.h" #include "src/core/util/thd.h" +#include "absl/log/log.h" struct completed_thread { grpc_core::Thread thd; diff --git a/deps/grpc/src/core/lib/iomgr/unix_sockets_posix.cc b/deps/grpc/src/core/lib/iomgr/unix_sockets_posix.cc index 21a435f061e..f3a84ef6b0e 100644 --- a/deps/grpc/src/core/lib/iomgr/unix_sockets_posix.cc +++ b/deps/grpc/src/core/lib/iomgr/unix_sockets_posix.cc @@ -35,7 +35,6 @@ #include -#include "absl/strings/str_cat.h" #include "src/core/lib/address_utils/parse_address.h" #include "src/core/lib/iomgr/sockaddr.h" #include "src/core/lib/iomgr/unix_sockets_posix.h" @@ -43,6 +42,7 @@ #include "src/core/util/crash.h" #include "src/core/util/grpc_check.h" #include "src/core/util/useful.h" +#include "absl/strings/str_cat.h" void grpc_create_socketpair_if_unix(int sv[2]) { #ifdef GPR_WINDOWS diff --git a/deps/grpc/src/core/lib/iomgr/unix_sockets_posix.h b/deps/grpc/src/core/lib/iomgr/unix_sockets_posix.h index f6e6418a312..1943a219622 100644 --- a/deps/grpc/src/core/lib/iomgr/unix_sockets_posix.h +++ b/deps/grpc/src/core/lib/iomgr/unix_sockets_posix.h @@ -24,9 +24,9 @@ #include -#include "absl/strings/string_view.h" #include "src/core/lib/iomgr/port.h" #include "src/core/lib/iomgr/resolve_address.h" +#include "absl/strings/string_view.h" void grpc_create_socketpair_if_unix(int sv[2]); diff --git a/deps/grpc/src/core/lib/iomgr/vsock.cc b/deps/grpc/src/core/lib/iomgr/vsock.cc index a830668cf4c..9d11faa75c9 100644 --- a/deps/grpc/src/core/lib/iomgr/vsock.cc +++ b/deps/grpc/src/core/lib/iomgr/vsock.cc @@ -26,12 +26,12 @@ #include #include -#include "absl/strings/str_cat.h" #include "src/core/lib/address_utils/parse_address.h" #include "src/core/lib/iomgr/sockaddr.h" #include "src/core/lib/transport/error_utils.h" #include "src/core/util/crash.h" #include "src/core/util/useful.h" +#include "absl/strings/str_cat.h" absl::StatusOr> grpc_resolve_vsock_address( absl::string_view name) { diff --git a/deps/grpc/src/core/lib/iomgr/vsock.h b/deps/grpc/src/core/lib/iomgr/vsock.h index 1bd3a2c71fe..a01aa6ab6f9 100644 --- a/deps/grpc/src/core/lib/iomgr/vsock.h +++ b/deps/grpc/src/core/lib/iomgr/vsock.h @@ -24,9 +24,9 @@ #include -#include "absl/strings/string_view.h" #include "src/core/lib/iomgr/port.h" #include "src/core/lib/iomgr/resolve_address.h" +#include "absl/strings/string_view.h" absl::StatusOr> grpc_resolve_vsock_address( absl::string_view name); diff --git a/deps/grpc/src/core/lib/iomgr/wakeup_fd_pipe.cc b/deps/grpc/src/core/lib/iomgr/wakeup_fd_pipe.cc index b21daf21d6b..7cd2f370ed2 100644 --- a/deps/grpc/src/core/lib/iomgr/wakeup_fd_pipe.cc +++ b/deps/grpc/src/core/lib/iomgr/wakeup_fd_pipe.cc @@ -26,12 +26,12 @@ #include #include -#include "absl/log/log.h" #include "src/core/lib/iomgr/socket_utils_posix.h" #include "src/core/lib/iomgr/wakeup_fd_pipe.h" #include "src/core/lib/iomgr/wakeup_fd_posix.h" #include "src/core/util/crash.h" #include "src/core/util/strerror.h" +#include "absl/log/log.h" static grpc_error_handle pipe_init(grpc_wakeup_fd* fd_info) { int pipefd[2]; diff --git a/deps/grpc/src/core/lib/promise/activity.cc b/deps/grpc/src/core/lib/promise/activity.cc index 77b34dbd795..59fdcf4dc55 100644 --- a/deps/grpc/src/core/lib/promise/activity.cc +++ b/deps/grpc/src/core/lib/promise/activity.cc @@ -19,11 +19,11 @@ #include +#include "src/core/util/atomic_utils.h" +#include "src/core/util/grpc_check.h" #include "absl/strings/str_cat.h" #include "absl/strings/str_format.h" #include "absl/strings/str_join.h" -#include "src/core/util/atomic_utils.h" -#include "src/core/util/grpc_check.h" namespace grpc_core { diff --git a/deps/grpc/src/core/lib/promise/activity.h b/deps/grpc/src/core/lib/promise/activity.h index 313de02e332..9de57809a59 100644 --- a/deps/grpc/src/core/lib/promise/activity.h +++ b/deps/grpc/src/core/lib/promise/activity.h @@ -25,9 +25,6 @@ #include #include -#include "absl/base/thread_annotations.h" -#include "absl/status/status.h" -#include "absl/strings/str_cat.h" #include "src/core/lib/debug/trace.h" #include "src/core/lib/promise/context.h" #include "src/core/lib/promise/detail/promise_factory.h" @@ -40,6 +37,9 @@ #include "src/core/util/no_destruct.h" #include "src/core/util/orphanable.h" #include "src/core/util/sync.h" +#include "absl/base/thread_annotations.h" +#include "absl/status/status.h" +#include "absl/strings/str_cat.h" namespace grpc_core { @@ -99,8 +99,9 @@ class Waker { } // Wake the underlying activity. + // A Waker object can only be woken up once. Calling Wakeup() or WakeupAsync() + // consumes the waker, rendering subsequent calls no-ops. void Wakeup() { Take().Wakeup(); } - void WakeupAsync() { Take().WakeupAsync(); } template diff --git a/deps/grpc/src/core/lib/promise/all_ok.h b/deps/grpc/src/core/lib/promise/all_ok.h index e6957f24270..77b04382beb 100644 --- a/deps/grpc/src/core/lib/promise/all_ok.h +++ b/deps/grpc/src/core/lib/promise/all_ok.h @@ -20,14 +20,14 @@ #include #include -#include "absl/meta/type_traits.h" -#include "absl/status/status.h" -#include "absl/status/statusor.h" #include "src/core/lib/promise/detail/join_state.h" #include "src/core/lib/promise/detail/promise_factory.h" #include "src/core/lib/promise/map.h" #include "src/core/lib/promise/poll.h" #include "src/core/lib/promise/status_flag.h" +#include "absl/meta/type_traits.h" +#include "absl/status/status.h" +#include "absl/status/statusor.h" namespace grpc_core { // AllOk promise combinator. diff --git a/deps/grpc/src/core/lib/promise/arena_promise.h b/deps/grpc/src/core/lib/promise/arena_promise.h index 9b7342d5276..aa0719c34f1 100644 --- a/deps/grpc/src/core/lib/promise/arena_promise.h +++ b/deps/grpc/src/core/lib/promise/arena_promise.h @@ -23,11 +23,11 @@ #include #include -#include "absl/meta/type_traits.h" #include "src/core/lib/promise/context.h" #include "src/core/lib/promise/poll.h" #include "src/core/lib/resource_quota/arena.h" #include "src/core/util/construct_destruct.h" +#include "absl/meta/type_traits.h" namespace grpc_core { @@ -44,6 +44,13 @@ T*& ArgAsPtr(ArgType* arg) { return *reinterpret_cast(arg); } +template +T const* const& ArgAsPtr(ArgType const* arg) { + static_assert(sizeof(ArgType) >= sizeof(T**), + "Must have ArgType of at least one pointer size"); + return *reinterpret_cast(arg); +} + template struct Vtable { // Poll the promise, once. @@ -54,6 +61,9 @@ struct Vtable { // Since we don't delete (the arena owns the memory) but we may need to call a // destructor, we expose this for when the ArenaPromise object is destroyed. void (*destroy)(ArgType* arg); + // Get the proto representation of the promise. + void (*to_proto)(const ArgType* arg, grpc_channelz_v2_Promise* promise_proto, + upb_Arena* arena); }; template @@ -77,10 +87,14 @@ struct Null { static void Move(ArgType*, ArgType*) {} static void Destroy(ArgType*) {} + static void ToProto(const ArgType*, grpc_channelz_v2_Promise* p, upb_Arena*) { + grpc_channelz_v2_Promise_set_unknown_promise( + p, StdStringToUpbString(TypeName())); + } }; template -const Vtable Null::vtable = {PollOnce, Move, Destroy}; +const Vtable Null::vtable = {PollOnce, Move, Destroy, ToProto}; // Implementation of ImplInterface for a callable object. template @@ -96,11 +110,17 @@ struct AllocatedCallable { } static void Destroy(ArgType* arg) { Destruct(ArgAsPtr(arg)); } + + static void ToProto(const ArgType* arg, + grpc_channelz_v2_Promise* promise_proto, + upb_Arena* arena) { + PromiseAsProto(*ArgAsPtr(arg), promise_proto, arena); + } }; template const Vtable AllocatedCallable::vtable = {PollOnce, Move, - Destroy}; + Destroy, ToProto}; // Implementation of ImplInterface for a small callable object (one that fits // within the ArgType arg) @@ -119,10 +139,18 @@ struct Inlined { static void Destroy(ArgType* arg) { Destruct(reinterpret_cast(arg)); } + + static void ToProto(const ArgType* arg, + grpc_channelz_v2_Promise* promise_proto, + upb_Arena* arena) { + PromiseAsProto(*reinterpret_cast(arg), promise_proto, + arena); + } }; template -const Vtable Inlined::vtable = {PollOnce, Move, Destroy}; +const Vtable Inlined::vtable = {PollOnce, Move, Destroy, + ToProto}; // If a callable object is empty we can substitute any instance of that callable // for the one we call (for how could we tell the difference)? @@ -138,11 +166,18 @@ struct SharedCallable { static Poll PollOnce(ArgType* arg) { return (*reinterpret_cast(arg))(); } + + static void ToProto(const ArgType* arg, + grpc_channelz_v2_Promise* promise_proto, + upb_Arena* arena) { + PromiseAsProto(*reinterpret_cast(arg), promise_proto, + arena); + } }; template -const Vtable SharedCallable::vtable = {PollOnce, Null::Move, - Null::Destroy}; +const Vtable SharedCallable::vtable = { + PollOnce, Null::Move, Null::Destroy, ToProto}; // Redirector type: given a callable type, expose a Make() function that creates // the appropriate underlying implementation. @@ -238,6 +273,12 @@ class ArenaPromise { return vtable_and_arg_.vtable != &arena_promise_detail::Null::vtable; } + void ToProto(grpc_channelz_v2_Promise* promise_proto, + upb_Arena* arena) const { + vtable_and_arg_.vtable->to_proto(&vtable_and_arg_.arg, promise_proto, + arena); + } + private: // Underlying impl object. arena_promise_detail::VtableAndArg vtable_and_arg_ = { diff --git a/deps/grpc/src/core/lib/promise/context.h b/deps/grpc/src/core/lib/promise/context.h index 87056b26242..905a19fce54 100644 --- a/deps/grpc/src/core/lib/promise/context.h +++ b/deps/grpc/src/core/lib/promise/context.h @@ -19,9 +19,9 @@ #include -#include "absl/meta/type_traits.h" #include "src/core/util/down_cast.h" #include "src/core/util/grpc_check.h" +#include "absl/meta/type_traits.h" namespace grpc_core { diff --git a/deps/grpc/src/core/lib/promise/detail/join_state.h b/deps/grpc/src/core/lib/promise/detail/join_state.h index 2b38524b194..6a01a393c59 100644 --- a/deps/grpc/src/core/lib/promise/detail/join_state.h +++ b/deps/grpc/src/core/lib/promise/detail/join_state.h @@ -23,13 +23,13 @@ #include #include -#include "absl/log/log.h" #include "src/core/lib/debug/trace.h" #include "src/core/lib/promise/detail/promise_like.h" #include "src/core/lib/promise/poll.h" #include "src/core/util/bitset.h" #include "src/core/util/construct_destruct.h" #include "src/core/util/grpc_check.h" +#include "absl/log/log.h" namespace grpc_core { namespace promise_detail { diff --git a/deps/grpc/src/core/lib/promise/detail/promise_factory.h b/deps/grpc/src/core/lib/promise/detail/promise_factory.h index 3fb5d681465..5eb4e42c5bd 100644 --- a/deps/grpc/src/core/lib/promise/detail/promise_factory.h +++ b/deps/grpc/src/core/lib/promise/detail/promise_factory.h @@ -21,8 +21,8 @@ #include #include -#include "absl/meta/type_traits.h" #include "src/core/lib/promise/detail/promise_like.h" +#include "absl/meta/type_traits.h" // PromiseFactory is an adaptor class. // diff --git a/deps/grpc/src/core/lib/promise/detail/promise_like.h b/deps/grpc/src/core/lib/promise/detail/promise_like.h index e68bc7c1068..e74714433c8 100644 --- a/deps/grpc/src/core/lib/promise/detail/promise_like.h +++ b/deps/grpc/src/core/lib/promise/detail/promise_like.h @@ -20,7 +20,6 @@ #include #include -#include "absl/meta/type_traits.h" #include "src/core/channelz/property_list.h" #include "src/core/lib/promise/poll.h" #include "src/core/util/function_signature.h" @@ -28,6 +27,7 @@ #include "src/proto/grpc/channelz/v2/promise.upb.h" #include "src/proto/grpc/channelz/v2/promise.upbdefs.h" #include "upb/reflection/def.hpp" +#include "absl/meta/type_traits.h" // A Promise is a callable object that returns Poll for some T. // Often when we're writing code that uses promises, we end up wanting to also diff --git a/deps/grpc/src/core/lib/promise/detail/seq_state.h b/deps/grpc/src/core/lib/promise/detail/seq_state.h index 4de3e7b05e9..d1137979720 100644 --- a/deps/grpc/src/core/lib/promise/detail/seq_state.h +++ b/deps/grpc/src/core/lib/promise/detail/seq_state.h @@ -22,9 +22,6 @@ #include -#include "absl/base/attributes.h" -#include "absl/log/log.h" -#include "absl/strings/str_cat.h" #include "src/core/lib/debug/trace.h" #include "src/core/lib/promise/detail/promise_factory.h" #include "src/core/lib/promise/detail/promise_like.h" @@ -33,6 +30,9 @@ #include "src/core/util/construct_destruct.h" #include "src/core/util/debug_location.h" #include "src/core/util/grpc_check.h" +#include "absl/base/attributes.h" +#include "absl/log/log.h" +#include "absl/strings/str_cat.h" // A sequence under some traits for some set of callables P, Fs. // P should be a promise-like object that yields a value. diff --git a/deps/grpc/src/core/lib/promise/detail/status.h b/deps/grpc/src/core/lib/promise/detail/status.h index 010c7f3855d..9d2a5eb6d13 100644 --- a/deps/grpc/src/core/lib/promise/detail/status.h +++ b/deps/grpc/src/core/lib/promise/detail/status.h @@ -19,9 +19,9 @@ #include +#include "src/core/util/grpc_check.h" #include "absl/status/status.h" #include "absl/status/statusor.h" -#include "src/core/util/grpc_check.h" // Helpers for dealing with absl::Status/StatusOr generically diff --git a/deps/grpc/src/core/lib/promise/exec_ctx_wakeup_scheduler.h b/deps/grpc/src/core/lib/promise/exec_ctx_wakeup_scheduler.h index c66fc233b21..cfec463906b 100644 --- a/deps/grpc/src/core/lib/promise/exec_ctx_wakeup_scheduler.h +++ b/deps/grpc/src/core/lib/promise/exec_ctx_wakeup_scheduler.h @@ -17,11 +17,11 @@ #include -#include "absl/status/status.h" #include "src/core/lib/iomgr/closure.h" #include "src/core/lib/iomgr/error.h" #include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/util/debug_location.h" +#include "absl/status/status.h" namespace grpc_core { diff --git a/deps/grpc/src/core/lib/promise/for_each.h b/deps/grpc/src/core/lib/promise/for_each.h index 19f4e5ca7a1..d9c18c8a9ad 100644 --- a/deps/grpc/src/core/lib/promise/for_each.h +++ b/deps/grpc/src/core/lib/promise/for_each.h @@ -21,9 +21,6 @@ #include #include -#include "absl/log/log.h" -#include "absl/status/status.h" -#include "absl/strings/str_cat.h" #include "src/core/lib/debug/trace.h" #include "src/core/lib/promise/activity.h" #include "src/core/lib/promise/detail/promise_factory.h" @@ -32,6 +29,9 @@ #include "src/core/lib/promise/status_flag.h" #include "src/core/util/construct_destruct.h" #include "src/core/util/grpc_check.h" +#include "absl/log/log.h" +#include "absl/status/status.h" +#include "absl/strings/str_cat.h" namespace grpc_core { diff --git a/deps/grpc/src/core/lib/promise/if.h b/deps/grpc/src/core/lib/promise/if.h index 9d3a7af1601..66bc15d727f 100644 --- a/deps/grpc/src/core/lib/promise/if.h +++ b/deps/grpc/src/core/lib/promise/if.h @@ -21,11 +21,11 @@ #include #include -#include "absl/status/statusor.h" #include "src/core/lib/promise/detail/promise_factory.h" #include "src/core/lib/promise/detail/promise_like.h" #include "src/core/lib/promise/poll.h" #include "src/core/util/construct_destruct.h" +#include "absl/status/statusor.h" namespace grpc_core { diff --git a/deps/grpc/src/core/lib/promise/inter_activity_latch.h b/deps/grpc/src/core/lib/promise/inter_activity_latch.h index 37dd9d689d8..c5f8b8fa235 100644 --- a/deps/grpc/src/core/lib/promise/inter_activity_latch.h +++ b/deps/grpc/src/core/lib/promise/inter_activity_latch.h @@ -20,14 +20,14 @@ #include -#include "absl/base/thread_annotations.h" -#include "absl/log/log.h" -#include "absl/strings/str_cat.h" #include "src/core/lib/debug/trace.h" #include "src/core/lib/promise/activity.h" #include "src/core/lib/promise/poll.h" #include "src/core/lib/promise/wait_set.h" #include "src/core/util/sync.h" +#include "absl/base/thread_annotations.h" +#include "absl/log/log.h" +#include "absl/strings/str_cat.h" namespace grpc_core { diff --git a/deps/grpc/src/core/lib/promise/inter_activity_mutex.h b/deps/grpc/src/core/lib/promise/inter_activity_mutex.h index fffc3da6a8f..bfc8bed45d4 100644 --- a/deps/grpc/src/core/lib/promise/inter_activity_mutex.h +++ b/deps/grpc/src/core/lib/promise/inter_activity_mutex.h @@ -18,11 +18,11 @@ #include #include -#include "absl/log/log.h" #include "src/core/lib/debug/trace.h" #include "src/core/lib/promise/activity.h" #include "src/core/lib/promise/poll.h" #include "src/core/util/dump_args.h" +#include "absl/log/log.h" namespace grpc_core { diff --git a/deps/grpc/src/core/lib/promise/inter_activity_pipe.h b/deps/grpc/src/core/lib/promise/inter_activity_pipe.h index 7a28340f3cb..436328fe3f8 100644 --- a/deps/grpc/src/core/lib/promise/inter_activity_pipe.h +++ b/deps/grpc/src/core/lib/promise/inter_activity_pipe.h @@ -22,13 +22,13 @@ #include #include -#include "absl/base/thread_annotations.h" #include "src/core/lib/promise/activity.h" #include "src/core/lib/promise/poll.h" #include "src/core/util/manual_constructor.h" #include "src/core/util/ref_counted.h" #include "src/core/util/ref_counted_ptr.h" #include "src/core/util/sync.h" +#include "absl/base/thread_annotations.h" namespace grpc_core { diff --git a/deps/grpc/src/core/lib/promise/interceptor_list.h b/deps/grpc/src/core/lib/promise/interceptor_list.h index 784306ba8f1..91443539c97 100644 --- a/deps/grpc/src/core/lib/promise/interceptor_list.h +++ b/deps/grpc/src/core/lib/promise/interceptor_list.h @@ -24,9 +24,6 @@ #include #include -#include "absl/log/log.h" -#include "absl/strings/str_cat.h" -#include "absl/strings/str_format.h" #include "src/core/lib/promise/context.h" #include "src/core/lib/promise/detail/promise_factory.h" #include "src/core/lib/promise/poll.h" @@ -34,6 +31,9 @@ #include "src/core/util/construct_destruct.h" #include "src/core/util/debug_location.h" #include "src/core/util/grpc_check.h" +#include "absl/log/log.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/str_format.h" namespace grpc_core { diff --git a/deps/grpc/src/core/lib/promise/join.h b/deps/grpc/src/core/lib/promise/join.h index 946923928bb..17123945966 100644 --- a/deps/grpc/src/core/lib/promise/join.h +++ b/deps/grpc/src/core/lib/promise/join.h @@ -20,10 +20,10 @@ #include -#include "absl/meta/type_traits.h" #include "src/core/lib/promise/detail/join_state.h" #include "src/core/lib/promise/detail/promise_factory.h" #include "src/core/lib/promise/map.h" +#include "absl/meta/type_traits.h" namespace grpc_core { namespace promise_detail { diff --git a/deps/grpc/src/core/lib/promise/latch.h b/deps/grpc/src/core/lib/promise/latch.h index c1d44f3da72..ac3ecd27c7c 100644 --- a/deps/grpc/src/core/lib/promise/latch.h +++ b/deps/grpc/src/core/lib/promise/latch.h @@ -22,12 +22,12 @@ #include #include -#include "absl/log/log.h" -#include "absl/strings/str_cat.h" #include "src/core/lib/debug/trace.h" #include "src/core/lib/promise/activity.h" #include "src/core/lib/promise/poll.h" #include "src/core/util/grpc_check.h" +#include "absl/log/log.h" +#include "absl/strings/str_cat.h" namespace grpc_core { diff --git a/deps/grpc/src/core/lib/promise/lock_based_mpsc.h b/deps/grpc/src/core/lib/promise/lock_based_mpsc.h index d078ca59f9a..1de213bfa10 100644 --- a/deps/grpc/src/core/lib/promise/lock_based_mpsc.h +++ b/deps/grpc/src/core/lib/promise/lock_based_mpsc.h @@ -24,7 +24,6 @@ #include #include -#include "absl/base/thread_annotations.h" #include "src/core/lib/promise/activity.h" #include "src/core/lib/promise/poll.h" #include "src/core/lib/promise/status_flag.h" @@ -34,6 +33,7 @@ #include "src/core/util/ref_counted.h" #include "src/core/util/ref_counted_ptr.h" #include "src/core/util/sync.h" +#include "absl/base/thread_annotations.h" namespace grpc_core { diff --git a/deps/grpc/src/core/lib/promise/loop.h b/deps/grpc/src/core/lib/promise/loop.h index 46e0d0aff3c..925a369a523 100644 --- a/deps/grpc/src/core/lib/promise/loop.h +++ b/deps/grpc/src/core/lib/promise/loop.h @@ -20,14 +20,14 @@ #include #include -#include "absl/status/status.h" -#include "absl/status/statusor.h" #include "src/core/lib/debug/trace.h" #include "src/core/lib/promise/activity.h" #include "src/core/lib/promise/detail/promise_factory.h" #include "src/core/lib/promise/poll.h" #include "src/core/lib/promise/seq.h" #include "src/core/util/construct_destruct.h" +#include "absl/status/status.h" +#include "absl/status/statusor.h" namespace grpc_core { diff --git a/deps/grpc/src/core/lib/promise/map.h b/deps/grpc/src/core/lib/promise/map.h index 7f2d5dcd972..e3443b5cb73 100644 --- a/deps/grpc/src/core/lib/promise/map.h +++ b/deps/grpc/src/core/lib/promise/map.h @@ -22,11 +22,11 @@ #include #include +#include "src/core/lib/promise/detail/promise_like.h" +#include "src/core/lib/promise/poll.h" #include "absl/status/status.h" #include "absl/status/statusor.h" #include "absl/strings/str_cat.h" -#include "src/core/lib/promise/detail/promise_like.h" -#include "src/core/lib/promise/poll.h" namespace grpc_core { diff --git a/deps/grpc/src/core/lib/promise/map_pipe.h b/deps/grpc/src/core/lib/promise/map_pipe.h index 13ab7a688bc..c42f82a4a91 100644 --- a/deps/grpc/src/core/lib/promise/map_pipe.h +++ b/deps/grpc/src/core/lib/promise/map_pipe.h @@ -17,14 +17,14 @@ #include -#include "absl/log/log.h" -#include "absl/status/status.h" #include "src/core/lib/promise/detail/promise_factory.h" #include "src/core/lib/promise/for_each.h" #include "src/core/lib/promise/map.h" #include "src/core/lib/promise/pipe.h" #include "src/core/lib/promise/poll.h" #include "src/core/lib/promise/try_seq.h" +#include "absl/log/log.h" +#include "absl/status/status.h" namespace grpc_core { diff --git a/deps/grpc/src/core/lib/promise/mpsc.cc b/deps/grpc/src/core/lib/promise/mpsc.cc index 402ddec7b2a..ed427c8d406 100644 --- a/deps/grpc/src/core/lib/promise/mpsc.cc +++ b/deps/grpc/src/core/lib/promise/mpsc.cc @@ -395,11 +395,12 @@ void Mpsc::ReleaseActiveTokens(bool wake_reader, uint64_t tokens) { auto prev_active = active_tokens_.fetch_sub(tokens, std::memory_order_relaxed); GRPC_DCHECK_GE(prev_active & kActiveTokensMask, tokens); - while ((prev_active & kActiveTokensWakerBit) != 0 && - (prev_active & kActiveTokensMask) - tokens <= max_queued_) { + auto cur_active = prev_active - tokens; + while ((cur_active & kActiveTokensWakerBit) != 0 && + (cur_active & kActiveTokensMask) <= max_queued_) { if (active_tokens_.compare_exchange_weak( - prev_active, - (prev_active & kActiveTokensMask) | kActiveTokensWakingBit, + cur_active, + (cur_active & kActiveTokensMask) | kActiveTokensWakingBit, std::memory_order_acquire, std::memory_order_relaxed)) { auto waker = std::move(active_tokens_waker_); GRPC_DCHECK(!waker.is_unwakeable()); diff --git a/deps/grpc/src/core/lib/promise/observable.h b/deps/grpc/src/core/lib/promise/observable.h index eff827f4121..bf761943f7a 100644 --- a/deps/grpc/src/core/lib/promise/observable.h +++ b/deps/grpc/src/core/lib/promise/observable.h @@ -17,12 +17,12 @@ #include -#include "absl/container/flat_hash_set.h" -#include "absl/functional/any_invocable.h" #include "src/core/lib/promise/activity.h" #include "src/core/lib/promise/poll.h" #include "src/core/util/grpc_check.h" #include "src/core/util/sync.h" +#include "absl/container/flat_hash_set.h" +#include "absl/functional/any_invocable.h" namespace grpc_core { diff --git a/deps/grpc/src/core/lib/promise/party.cc b/deps/grpc/src/core/lib/promise/party.cc index ab8853d5398..c097afc8513 100644 --- a/deps/grpc/src/core/lib/promise/party.cc +++ b/deps/grpc/src/core/lib/promise/party.cc @@ -20,9 +20,6 @@ #include #include -#include "absl/base/thread_annotations.h" -#include "absl/log/log.h" -#include "absl/strings/str_format.h" #include "src/core/channelz/property_list.h" #include "src/core/lib/event_engine/event_engine_context.h" #include "src/core/lib/iomgr/exec_ctx.h" @@ -31,11 +28,14 @@ #include "src/core/util/json/json_writer.h" #include "src/core/util/latent_see.h" #include "src/core/util/sync.h" +#include "absl/base/thread_annotations.h" +#include "absl/log/log.h" +#include "absl/strings/str_format.h" #ifdef GRPC_MAXIMIZE_THREADYNESS -#include "absl/random/random.h" // IWYU pragma: keep #include "src/core/lib/iomgr/exec_ctx.h" // IWYU pragma: keep #include "src/core/util/thd.h" // IWYU pragma: keep +#include "absl/random/random.h" // IWYU pragma: keep #endif namespace grpc_core { @@ -202,14 +202,20 @@ void Party::ToJson(absl::AnyInvocable f) { [](absl::Status) {}); } -void Party::ExportToChannelz(std::string name, channelz::DataSink sink) { +void Party::ExportToChannelz( + std::string name, channelz::DataSink sink, + absl::AnyInvocable export_context) { arena()->GetContext()->Run( - [self = Ref(), name = std::move(name), sink = std::move(sink)]() mutable { + [self = Ref(), name = std::move(name), sink = std::move(sink), + export_context = std::move(export_context)]() mutable { ExecCtx exec_ctx; self->Spawn( "export-to-channelz", - [name = std::move(name), sink = std::move(sink), self]() mutable { - sink.AddData(std::move(name), self->ChannelzPropertiesLocked()); + [name = std::move(name), sink = std::move(sink), self, + export_context = std::move(export_context)]() mutable { + sink.AddData( + std::move(name), + self->ChannelzPropertiesLocked().Merge(export_context())); return absl::OkStatus(); }, [](absl::Status) {}); diff --git a/deps/grpc/src/core/lib/promise/party.h b/deps/grpc/src/core/lib/promise/party.h index b27c6dd7ad0..b54696c400e 100644 --- a/deps/grpc/src/core/lib/promise/party.h +++ b/deps/grpc/src/core/lib/promise/party.h @@ -25,9 +25,6 @@ #include #include -#include "absl/base/attributes.h" -#include "absl/functional/any_invocable.h" -#include "absl/strings/string_view.h" #include "src/core/channelz/channelz.h" #include "src/core/channelz/property_list.h" #include "src/core/lib/debug/trace.h" @@ -44,6 +41,9 @@ #include "src/core/util/json/json_writer.h" #include "src/core/util/ref_counted.h" #include "src/core/util/ref_counted_ptr.h" +#include "absl/base/attributes.h" +#include "absl/functional/any_invocable.h" +#include "absl/strings/string_view.h" namespace grpc_core { @@ -394,7 +394,14 @@ class Party : public Activity, private Wakeable { void ToJson(absl::AnyInvocable); // Export the party to channelz. - void ExportToChannelz(std::string name, channelz::DataSink sink); + // The final argument is called whilst the party is locked, and so can be used + // to export contextual data alongside the party. + void ExportToChannelz( + std::string name, channelz::DataSink sink, + absl::AnyInvocable export_context = []() { + // The default implementation does nothing. + return channelz::PropertyList(); + }); protected: friend class Arena; diff --git a/deps/grpc/src/core/lib/promise/pipe.h b/deps/grpc/src/core/lib/promise/pipe.h index b97cb12422b..b14e2850a35 100644 --- a/deps/grpc/src/core/lib/promise/pipe.h +++ b/deps/grpc/src/core/lib/promise/pipe.h @@ -25,8 +25,7 @@ #include #include -#include "absl/log/log.h" -#include "absl/strings/str_cat.h" +#include "src/core/channelz/property_list.h" #include "src/core/lib/promise/activity.h" #include "src/core/lib/promise/context.h" #include "src/core/lib/promise/if.h" @@ -38,6 +37,8 @@ #include "src/core/util/debug_location.h" #include "src/core/util/grpc_check.h" #include "src/core/util/ref_counted_ptr.h" +#include "absl/log/log.h" +#include "absl/strings/str_cat.h" namespace grpc_core { @@ -360,6 +361,15 @@ class Center : public InterceptorList { } } + channelz::PropertyList ChannelzProperties() const { + return channelz::PropertyList() + .Set("refs", refs_) + .Set("state", ValueStateName(value_state_)) + .Set("on_empty", on_empty_.DebugString()) + .Set("on_full", on_full_.DebugString()) + .Set("on_closed", on_closed_.DebugString()); + } + private: // State of value_. enum class ValueState : uint8_t { @@ -460,6 +470,10 @@ class PipeSender { } } + channelz::PropertyList ChannelzProperties() { + return center_->ChannelzProperties(); + } + void Swap(PipeSender* other) { std::swap(center_, other->center_); } // Send a single message along the pipe. diff --git a/deps/grpc/src/core/lib/promise/poll.h b/deps/grpc/src/core/lib/promise/poll.h index 146a6d3d005..f26a5bd55de 100644 --- a/deps/grpc/src/core/lib/promise/poll.h +++ b/deps/grpc/src/core/lib/promise/poll.h @@ -21,11 +21,11 @@ #include #include +#include "src/core/util/construct_destruct.h" +#include "src/core/util/grpc_check.h" #include "absl/status/statusor.h" #include "absl/strings/str_format.h" #include "absl/strings/str_join.h" -#include "src/core/util/construct_destruct.h" -#include "src/core/util/grpc_check.h" namespace grpc_core { diff --git a/deps/grpc/src/core/lib/promise/promise.h b/deps/grpc/src/core/lib/promise/promise.h index 2e6f3d4f1e1..7aded4bca0e 100644 --- a/deps/grpc/src/core/lib/promise/promise.h +++ b/deps/grpc/src/core/lib/promise/promise.h @@ -20,10 +20,10 @@ #include #include -#include "absl/functional/any_invocable.h" -#include "absl/status/status.h" #include "src/core/lib/promise/detail/promise_like.h" #include "src/core/lib/promise/poll.h" +#include "absl/functional/any_invocable.h" +#include "absl/status/status.h" namespace grpc_core { diff --git a/deps/grpc/src/core/lib/promise/sleep.h b/deps/grpc/src/core/lib/promise/sleep.h index 13460abe6cf..e3b776f04eb 100644 --- a/deps/grpc/src/core/lib/promise/sleep.h +++ b/deps/grpc/src/core/lib/promise/sleep.h @@ -21,10 +21,10 @@ #include #include -#include "absl/status/status.h" #include "src/core/lib/promise/activity.h" #include "src/core/lib/promise/poll.h" #include "src/core/util/time.h" +#include "absl/status/status.h" namespace grpc_core { diff --git a/deps/grpc/src/core/lib/promise/status_flag.h b/deps/grpc/src/core/lib/promise/status_flag.h index 36aa4905633..009a6a887cc 100644 --- a/deps/grpc/src/core/lib/promise/status_flag.h +++ b/deps/grpc/src/core/lib/promise/status_flag.h @@ -20,12 +20,12 @@ #include #include +#include "src/core/lib/promise/detail/status.h" +#include "src/core/util/grpc_check.h" #include "absl/status/status.h" #include "absl/status/statusor.h" #include "absl/strings/str_cat.h" #include "absl/strings/str_join.h" -#include "src/core/lib/promise/detail/status.h" -#include "src/core/util/grpc_check.h" namespace grpc_core { diff --git a/deps/grpc/src/core/lib/promise/try_join.h b/deps/grpc/src/core/lib/promise/try_join.h index 8fc689ac25e..d82bcad7c3c 100644 --- a/deps/grpc/src/core/lib/promise/try_join.h +++ b/deps/grpc/src/core/lib/promise/try_join.h @@ -20,14 +20,14 @@ #include #include -#include "absl/meta/type_traits.h" -#include "absl/status/status.h" -#include "absl/status/statusor.h" #include "src/core/lib/promise/detail/join_state.h" #include "src/core/lib/promise/map.h" #include "src/core/lib/promise/poll.h" #include "src/core/lib/promise/status_flag.h" #include "src/core/util/grpc_check.h" +#include "absl/meta/type_traits.h" +#include "absl/status/status.h" +#include "absl/status/statusor.h" namespace grpc_core { diff --git a/deps/grpc/src/core/lib/promise/try_seq.h b/deps/grpc/src/core/lib/promise/try_seq.h index 2c007c81a72..85b255c9440 100644 --- a/deps/grpc/src/core/lib/promise/try_seq.h +++ b/deps/grpc/src/core/lib/promise/try_seq.h @@ -21,9 +21,6 @@ #include #include -#include "absl/meta/type_traits.h" -#include "absl/status/status.h" -#include "absl/status/statusor.h" #include "src/core/lib/promise/detail/basic_seq.h" #include "src/core/lib/promise/detail/promise_like.h" #include "src/core/lib/promise/detail/seq_state.h" @@ -31,6 +28,9 @@ #include "src/core/lib/promise/poll.h" #include "src/core/lib/promise/status_flag.h" #include "src/core/util/grpc_check.h" +#include "absl/meta/type_traits.h" +#include "absl/status/status.h" +#include "absl/status/statusor.h" namespace grpc_core { diff --git a/deps/grpc/src/core/lib/promise/wait_for_callback.h b/deps/grpc/src/core/lib/promise/wait_for_callback.h index cdebb5f085a..5b9c1cf7fc3 100644 --- a/deps/grpc/src/core/lib/promise/wait_for_callback.h +++ b/deps/grpc/src/core/lib/promise/wait_for_callback.h @@ -20,10 +20,10 @@ #include #include -#include "absl/base/thread_annotations.h" #include "src/core/lib/promise/activity.h" #include "src/core/lib/promise/poll.h" #include "src/core/util/sync.h" +#include "absl/base/thread_annotations.h" namespace grpc_core { diff --git a/deps/grpc/src/core/lib/promise/wait_set.h b/deps/grpc/src/core/lib/promise/wait_set.h index eb585203194..6f564aa83ec 100644 --- a/deps/grpc/src/core/lib/promise/wait_set.h +++ b/deps/grpc/src/core/lib/promise/wait_set.h @@ -19,10 +19,10 @@ #include -#include "absl/container/flat_hash_set.h" -#include "absl/hash/hash.h" #include "src/core/lib/promise/activity.h" #include "src/core/lib/promise/poll.h" +#include "absl/container/flat_hash_set.h" +#include "absl/hash/hash.h" namespace grpc_core { diff --git a/deps/grpc/src/core/lib/resource_quota/api.cc b/deps/grpc/src/core/lib/resource_quota/api.cc index 8438fdc35f5..7388d0c8816 100644 --- a/deps/grpc/src/core/lib/resource_quota/api.cc +++ b/deps/grpc/src/core/lib/resource_quota/api.cc @@ -24,13 +24,13 @@ #include #include -#include "absl/strings/str_cat.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/resource_quota/memory_quota.h" #include "src/core/lib/resource_quota/resource_quota.h" #include "src/core/lib/resource_quota/thread_quota.h" #include "src/core/util/ref_counted_ptr.h" +#include "absl/strings/str_cat.h" namespace grpc_core { diff --git a/deps/grpc/src/core/lib/resource_quota/arena.cc b/deps/grpc/src/core/lib/resource_quota/arena.cc index e3b24dc739b..9e64c1357ad 100644 --- a/deps/grpc/src/core/lib/resource_quota/arena.cc +++ b/deps/grpc/src/core/lib/resource_quota/arena.cc @@ -24,9 +24,9 @@ #include #include -#include "absl/log/log.h" #include "src/core/lib/resource_quota/resource_quota.h" #include "src/core/util/alloc.h" +#include "absl/log/log.h" namespace grpc_core { namespace { diff --git a/deps/grpc/src/core/lib/resource_quota/connection_quota.h b/deps/grpc/src/core/lib/resource_quota/connection_quota.h index f30ea218063..05eb6eecb55 100644 --- a/deps/grpc/src/core/lib/resource_quota/connection_quota.h +++ b/deps/grpc/src/core/lib/resource_quota/connection_quota.h @@ -20,11 +20,11 @@ #include #include -#include "absl/base/thread_annotations.h" #include "src/core/lib/resource_quota/memory_quota.h" #include "src/core/util/ref_counted.h" #include "src/core/util/ref_counted_ptr.h" #include "src/core/util/sync.h" +#include "absl/base/thread_annotations.h" namespace grpc_core { diff --git a/deps/grpc/src/core/lib/resource_quota/memory_quota.cc b/deps/grpc/src/core/lib/resource_quota/memory_quota.cc index 1516ecaa972..4f4413184c1 100644 --- a/deps/grpc/src/core/lib/resource_quota/memory_quota.cc +++ b/deps/grpc/src/core/lib/resource_quota/memory_quota.cc @@ -28,9 +28,6 @@ #include #include -#include "absl/log/log.h" -#include "absl/status/status.h" -#include "absl/strings/str_cat.h" #include "src/core/channelz/channelz.h" #include "src/core/channelz/property_list.h" #include "src/core/lib/debug/trace.h" @@ -44,6 +41,9 @@ #include "src/core/util/grpc_check.h" #include "src/core/util/mpscq.h" #include "src/core/util/useful.h" +#include "absl/log/log.h" +#include "absl/status/status.h" +#include "absl/strings/str_cat.h" namespace grpc_core { diff --git a/deps/grpc/src/core/lib/resource_quota/memory_quota.h b/deps/grpc/src/core/lib/resource_quota/memory_quota.h index 9d14add7ac6..cd4d486319d 100644 --- a/deps/grpc/src/core/lib/resource_quota/memory_quota.h +++ b/deps/grpc/src/core/lib/resource_quota/memory_quota.h @@ -15,8 +15,10 @@ #ifndef GRPC_SRC_CORE_LIB_RESOURCE_QUOTA_MEMORY_QUOTA_H #define GRPC_SRC_CORE_LIB_RESOURCE_QUOTA_MEMORY_QUOTA_H +#include #include #include +#include #include #include @@ -30,10 +32,6 @@ #include #include -#include "absl/base/thread_annotations.h" -#include "absl/container/flat_hash_set.h" -#include "absl/log/log.h" -#include "absl/strings/string_view.h" #include "src/core/channelz/channelz.h" #include "src/core/config/config_vars.h" #include "src/core/lib/debug/trace.h" @@ -42,12 +40,17 @@ #include "src/core/lib/promise/poll.h" #include "src/core/lib/resource_quota/periodic_update.h" #include "src/core/lib/resource_quota/telemetry.h" +#include "src/core/telemetry/instrument.h" #include "src/core/util/grpc_check.h" #include "src/core/util/orphanable.h" #include "src/core/util/ref_counted_ptr.h" #include "src/core/util/sync.h" #include "src/core/util/time.h" #include "src/core/util/useful.h" +#include "absl/base/thread_annotations.h" +#include "absl/container/flat_hash_set.h" +#include "absl/log/log.h" +#include "absl/strings/string_view.h" namespace grpc_core { @@ -593,7 +596,8 @@ class MemoryQuota final explicit MemoryQuota(RefCountedPtr channelz_node) : memory_quota_(std::make_shared( std::move(channelz_node), - ResourceQuotaDomain::GetStorage(channelz_node->name()))) { + ResourceQuotaDomain::GetStorage(GlobalCollectionScope(), + channelz_node->name()))) { memory_quota_->Start(); } ~MemoryQuota() override { diff --git a/deps/grpc/src/core/lib/resource_quota/periodic_update.h b/deps/grpc/src/core/lib/resource_quota/periodic_update.h index 336cc84ecff..a73d3f2ac34 100644 --- a/deps/grpc/src/core/lib/resource_quota/periodic_update.h +++ b/deps/grpc/src/core/lib/resource_quota/periodic_update.h @@ -20,8 +20,8 @@ #include -#include "absl/functional/function_ref.h" #include "src/core/util/time.h" +#include "absl/functional/function_ref.h" namespace grpc_core { diff --git a/deps/grpc/src/core/lib/resource_quota/resource_quota.cc b/deps/grpc/src/core/lib/resource_quota/resource_quota.cc index 5361ef3bbd0..5ef092f6fb4 100644 --- a/deps/grpc/src/core/lib/resource_quota/resource_quota.cc +++ b/deps/grpc/src/core/lib/resource_quota/resource_quota.cc @@ -16,7 +16,15 @@ #include +#include +#include + +#include "src/core/channelz/channelz.h" +#include "src/core/lib/resource_quota/memory_quota.h" +#include "src/core/lib/resource_quota/stream_quota.h" +#include "src/core/lib/resource_quota/thread_quota.h" #include "src/core/util/no_destruct.h" +#include "src/core/util/ref_counted_ptr.h" #include "src/core/util/single_set_ptr.h" namespace grpc_core { diff --git a/deps/grpc/src/core/lib/resource_quota/resource_quota.h b/deps/grpc/src/core/lib/resource_quota/resource_quota.h index 9f34ec566f6..e332921fb6b 100644 --- a/deps/grpc/src/core/lib/resource_quota/resource_quota.h +++ b/deps/grpc/src/core/lib/resource_quota/resource_quota.h @@ -22,14 +22,15 @@ #include #include -#include "absl/strings/string_view.h" #include "src/core/channelz/channelz.h" #include "src/core/lib/resource_quota/memory_quota.h" +#include "src/core/lib/resource_quota/stream_quota.h" #include "src/core/lib/resource_quota/thread_quota.h" #include "src/core/util/cpp_impl_of.h" #include "src/core/util/ref_counted.h" #include "src/core/util/ref_counted_ptr.h" #include "src/core/util/useful.h" +#include "absl/strings/string_view.h" namespace grpc_core { diff --git a/deps/grpc/src/core/lib/resource_quota/stream_quota.cc b/deps/grpc/src/core/lib/resource_quota/stream_quota.cc new file mode 100644 index 00000000000..1a6d8792483 --- /dev/null +++ b/deps/grpc/src/core/lib/resource_quota/stream_quota.cc @@ -0,0 +1,22 @@ +// Copyright 2025 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 "src/core/lib/resource_quota/stream_quota.h" + +#include +#include +#include +#include + +namespace grpc_core {} // namespace grpc_core diff --git a/deps/grpc/src/core/lib/resource_quota/stream_quota.h b/deps/grpc/src/core/lib/resource_quota/stream_quota.h new file mode 100644 index 00000000000..f37c382f7a9 --- /dev/null +++ b/deps/grpc/src/core/lib/resource_quota/stream_quota.h @@ -0,0 +1,31 @@ +// Copyright 2025 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. + +#ifndef GRPC_SRC_CORE_LIB_RESOURCE_QUOTA_STREAM_QUOTA_H +#define GRPC_SRC_CORE_LIB_RESOURCE_QUOTA_STREAM_QUOTA_H + +#include + +#include +#include +#include + +#include "src/core/lib/resource_quota/periodic_update.h" +#include "src/core/util/per_cpu.h" +#include "src/core/util/ref_counted.h" +#include "src/core/util/ref_counted_ptr.h" + +namespace grpc_core {} // namespace grpc_core + +#endif // GRPC_SRC_CORE_LIB_RESOURCE_QUOTA_STREAM_QUOTA_H diff --git a/deps/grpc/src/core/lib/resource_quota/telemetry.h b/deps/grpc/src/core/lib/resource_quota/telemetry.h index 1cc1bbccdf0..87e842227ca 100644 --- a/deps/grpc/src/core/lib/resource_quota/telemetry.h +++ b/deps/grpc/src/core/lib/resource_quota/telemetry.h @@ -22,6 +22,7 @@ namespace grpc_core { class ResourceQuotaDomain final : public InstrumentDomain { public: using Backend = HighContentionBackend; + static constexpr absl::string_view kName = "resource_quota"; static constexpr auto kLabels = Labels("grpc.resource_quota"); static inline const auto kCallsDropped = RegisterCounter( diff --git a/deps/grpc/src/core/lib/resource_quota/thread_quota.h b/deps/grpc/src/core/lib/resource_quota/thread_quota.h index 18a6e13e7f1..35a05140890 100644 --- a/deps/grpc/src/core/lib/resource_quota/thread_quota.h +++ b/deps/grpc/src/core/lib/resource_quota/thread_quota.h @@ -20,10 +20,10 @@ #include #include -#include "absl/base/thread_annotations.h" #include "src/core/util/ref_counted.h" #include "src/core/util/ref_counted_ptr.h" #include "src/core/util/sync.h" +#include "absl/base/thread_annotations.h" namespace grpc_core { diff --git a/deps/grpc/src/core/lib/security/authorization/audit_logging.cc b/deps/grpc/src/core/lib/security/authorization/audit_logging.cc index db1af0c7354..225f1985e80 100644 --- a/deps/grpc/src/core/lib/security/authorization/audit_logging.cc +++ b/deps/grpc/src/core/lib/security/authorization/audit_logging.cc @@ -26,13 +26,13 @@ #include #include +#include "src/core/lib/security/authorization/stdout_logger.h" +#include "src/core/util/grpc_check.h" +#include "src/core/util/sync.h" #include "absl/status/status.h" #include "absl/status/statusor.h" #include "absl/strings/str_format.h" #include "absl/strings/string_view.h" -#include "src/core/lib/security/authorization/stdout_logger.h" -#include "src/core/util/grpc_check.h" -#include "src/core/util/sync.h" namespace grpc_core { namespace experimental { diff --git a/deps/grpc/src/core/lib/security/authorization/audit_logging.h b/deps/grpc/src/core/lib/security/authorization/audit_logging.h index 899e0dcc131..4636f9a6c1e 100644 --- a/deps/grpc/src/core/lib/security/authorization/audit_logging.h +++ b/deps/grpc/src/core/lib/security/authorization/audit_logging.h @@ -26,10 +26,10 @@ #include #include +#include "src/core/util/sync.h" #include "absl/base/thread_annotations.h" #include "absl/status/statusor.h" #include "absl/strings/string_view.h" -#include "src/core/util/sync.h" namespace grpc_core { namespace experimental { diff --git a/deps/grpc/src/core/lib/security/authorization/authorization_policy_provider.h b/deps/grpc/src/core/lib/security/authorization/authorization_policy_provider.h index ce0a9c7604f..0c116b4f156 100644 --- a/deps/grpc/src/core/lib/security/authorization/authorization_policy_provider.h +++ b/deps/grpc/src/core/lib/security/authorization/authorization_policy_provider.h @@ -19,11 +19,11 @@ #include #include -#include "absl/strings/string_view.h" #include "src/core/lib/security/authorization/authorization_engine.h" #include "src/core/util/dual_ref_counted.h" #include "src/core/util/ref_counted_ptr.h" #include "src/core/util/useful.h" +#include "absl/strings/string_view.h" struct grpc_authorization_policy_provider : public grpc_core::DualRefCounted { diff --git a/deps/grpc/src/core/lib/security/authorization/cel_authorization_engine.cc b/deps/grpc/src/core/lib/security/authorization/cel_authorization_engine.cc index b868c5d660c..125cbe6c0ac 100644 --- a/deps/grpc/src/core/lib/security/authorization/cel_authorization_engine.cc +++ b/deps/grpc/src/core/lib/security/authorization/cel_authorization_engine.cc @@ -21,11 +21,11 @@ #include #include +#include "upb/base/string_view.h" +#include "upb/message/map.h" #include "absl/log/log.h" #include "absl/strings/string_view.h" #include "absl/types/span.h" -#include "upb/base/string_view.h" -#include "upb/message/map.h" namespace grpc_core { diff --git a/deps/grpc/src/core/lib/security/authorization/cel_authorization_engine.h b/deps/grpc/src/core/lib/security/authorization/cel_authorization_engine.h index 75130df8cea..e0a51dd41a1 100644 --- a/deps/grpc/src/core/lib/security/authorization/cel_authorization_engine.h +++ b/deps/grpc/src/core/lib/security/authorization/cel_authorization_engine.h @@ -23,13 +23,13 @@ #include #include -#include "absl/container/flat_hash_set.h" #include "envoy/config/rbac/v3/rbac.upb.h" #include "google/api/expr/v1alpha1/syntax.upb.h" #include "src/core/lib/security/authorization/evaluate_args.h" #include "src/core/lib/security/authorization/mock_cel/activation.h" #include "src/core/lib/security/authorization/mock_cel/cel_value.h" #include "upb/mem/arena.hpp" +#include "absl/container/flat_hash_set.h" namespace grpc_core { diff --git a/deps/grpc/src/core/lib/security/authorization/evaluate_args.cc b/deps/grpc/src/core/lib/security/authorization/evaluate_args.cc index c5501f1d5e4..4c93467173e 100644 --- a/deps/grpc/src/core/lib/security/authorization/evaluate_args.cc +++ b/deps/grpc/src/core/lib/security/authorization/evaluate_args.cc @@ -18,17 +18,17 @@ #include #include -#include "absl/log/log.h" -#include "absl/status/status.h" -#include "absl/status/statusor.h" -#include "absl/strings/match.h" -#include "absl/strings/numbers.h" #include "src/core/credentials/transport/tls/tls_utils.h" #include "src/core/handshaker/endpoint_info/endpoint_info_handshaker.h" #include "src/core/lib/address_utils/parse_address.h" #include "src/core/lib/slice/slice.h" #include "src/core/util/host_port.h" #include "src/core/util/uri.h" +#include "absl/log/log.h" +#include "absl/status/status.h" +#include "absl/status/statusor.h" +#include "absl/strings/match.h" +#include "absl/strings/numbers.h" namespace grpc_core { diff --git a/deps/grpc/src/core/lib/security/authorization/evaluate_args.h b/deps/grpc/src/core/lib/security/authorization/evaluate_args.h index 07e181b3d76..208b22eff40 100644 --- a/deps/grpc/src/core/lib/security/authorization/evaluate_args.h +++ b/deps/grpc/src/core/lib/security/authorization/evaluate_args.h @@ -22,10 +22,10 @@ #include #include -#include "absl/strings/string_view.h" #include "src/core/call/metadata_batch.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/iomgr/resolved_address.h" +#include "absl/strings/string_view.h" namespace grpc_core { diff --git a/deps/grpc/src/core/lib/security/authorization/grpc_authorization_policy_provider.cc b/deps/grpc/src/core/lib/security/authorization/grpc_authorization_policy_provider.cc index 5a65f822b33..4de74fdd076 100644 --- a/deps/grpc/src/core/lib/security/authorization/grpc_authorization_policy_provider.cc +++ b/deps/grpc/src/core/lib/security/authorization/grpc_authorization_policy_provider.cc @@ -25,7 +25,6 @@ #include #include -#include "absl/log/log.h" #include "src/core/lib/debug/trace.h" #include "src/core/lib/iomgr/error.h" #include "src/core/lib/security/authorization/grpc_authorization_engine.h" @@ -36,6 +35,7 @@ #include "src/core/util/grpc_check.h" #include "src/core/util/load_file.h" #include "src/core/util/status_helper.h" +#include "absl/log/log.h" namespace grpc_core { diff --git a/deps/grpc/src/core/lib/security/authorization/grpc_authorization_policy_provider.h b/deps/grpc/src/core/lib/security/authorization/grpc_authorization_policy_provider.h index bac11102126..bee14159e97 100644 --- a/deps/grpc/src/core/lib/security/authorization/grpc_authorization_policy_provider.h +++ b/deps/grpc/src/core/lib/security/authorization/grpc_authorization_policy_provider.h @@ -23,16 +23,16 @@ #include #include -#include "absl/base/thread_annotations.h" -#include "absl/status/status.h" -#include "absl/status/statusor.h" -#include "absl/strings/string_view.h" #include "src/core/lib/security/authorization/authorization_engine.h" #include "src/core/lib/security/authorization/authorization_policy_provider.h" #include "src/core/lib/security/authorization/rbac_translator.h" #include "src/core/util/ref_counted_ptr.h" #include "src/core/util/sync.h" #include "src/core/util/thd.h" +#include "absl/base/thread_annotations.h" +#include "absl/status/status.h" +#include "absl/status/statusor.h" +#include "absl/strings/string_view.h" namespace grpc_core { diff --git a/deps/grpc/src/core/lib/security/authorization/grpc_server_authz_filter.cc b/deps/grpc/src/core/lib/security/authorization/grpc_server_authz_filter.cc index 4bf48518240..7064e27426c 100644 --- a/deps/grpc/src/core/lib/security/authorization/grpc_server_authz_filter.cc +++ b/deps/grpc/src/core/lib/security/authorization/grpc_server_authz_filter.cc @@ -21,9 +21,6 @@ #include #include -#include "absl/log/log.h" -#include "absl/status/status.h" -#include "absl/strings/str_join.h" #include "src/core/call/metadata_batch.h" #include "src/core/lib/channel/channel_stack.h" #include "src/core/lib/channel/promise_based_filter.h" @@ -33,6 +30,9 @@ #include "src/core/lib/security/authorization/evaluate_args.h" #include "src/core/lib/transport/transport.h" #include "src/core/util/latent_see.h" +#include "absl/log/log.h" +#include "absl/status/status.h" +#include "absl/strings/str_join.h" namespace grpc_core { diff --git a/deps/grpc/src/core/lib/security/authorization/grpc_server_authz_filter.h b/deps/grpc/src/core/lib/security/authorization/grpc_server_authz_filter.h index b716ed515fa..fb31d179b47 100644 --- a/deps/grpc/src/core/lib/security/authorization/grpc_server_authz_filter.h +++ b/deps/grpc/src/core/lib/security/authorization/grpc_server_authz_filter.h @@ -18,7 +18,6 @@ #include #include -#include "absl/status/statusor.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/channel_fwd.h" #include "src/core/lib/channel/promise_based_filter.h" @@ -28,6 +27,7 @@ #include "src/core/lib/transport/transport.h" #include "src/core/transport/auth_context.h" #include "src/core/util/ref_counted_ptr.h" +#include "absl/status/statusor.h" namespace grpc_core { @@ -55,6 +55,9 @@ class GrpcServerAuthzFilter final static inline const NoInterceptor OnClientToServerHalfClose; static inline const NoInterceptor OnServerToClientMessage; static inline const NoInterceptor OnFinalize; + channelz::PropertyList ChannelzProperties() { + return channelz::PropertyList(); + } }; private: diff --git a/deps/grpc/src/core/lib/security/authorization/matchers.cc b/deps/grpc/src/core/lib/security/authorization/matchers.cc index c113514f233..77ac0d932b7 100644 --- a/deps/grpc/src/core/lib/security/authorization/matchers.cc +++ b/deps/grpc/src/core/lib/security/authorization/matchers.cc @@ -20,12 +20,12 @@ #include +#include "src/core/lib/address_utils/parse_address.h" +#include "src/core/lib/address_utils/sockaddr_utils.h" #include "absl/log/log.h" #include "absl/status/status.h" #include "absl/status/statusor.h" #include "absl/strings/string_view.h" -#include "src/core/lib/address_utils/parse_address.h" -#include "src/core/lib/address_utils/sockaddr_utils.h" namespace grpc_core { diff --git a/deps/grpc/src/core/lib/security/authorization/mock_cel/activation.h b/deps/grpc/src/core/lib/security/authorization/mock_cel/activation.h index ca3cb392a25..f7bc991a531 100644 --- a/deps/grpc/src/core/lib/security/authorization/mock_cel/activation.h +++ b/deps/grpc/src/core/lib/security/authorization/mock_cel/activation.h @@ -17,8 +17,8 @@ #include -#include "absl/strings/string_view.h" #include "src/core/lib/security/authorization/mock_cel/cel_value.h" +#include "absl/strings/string_view.h" namespace grpc_core { namespace mock_cel { diff --git a/deps/grpc/src/core/lib/security/authorization/mock_cel/cel_expression.h b/deps/grpc/src/core/lib/security/authorization/mock_cel/cel_expression.h index 63da5c943b9..f6d47a6cc98 100644 --- a/deps/grpc/src/core/lib/security/authorization/mock_cel/cel_expression.h +++ b/deps/grpc/src/core/lib/security/authorization/mock_cel/cel_expression.h @@ -20,11 +20,11 @@ #include #include -#include "absl/status/status.h" -#include "absl/status/statusor.h" #include "google/api/expr/v1alpha1/syntax.upb.h" #include "src/core/lib/security/authorization/mock_cel/activation.h" #include "src/core/lib/security/authorization/mock_cel/cel_value.h" +#include "absl/status/status.h" +#include "absl/status/statusor.h" namespace grpc_core { namespace mock_cel { diff --git a/deps/grpc/src/core/lib/security/authorization/mock_cel/evaluator_core.h b/deps/grpc/src/core/lib/security/authorization/mock_cel/evaluator_core.h index 232db020d66..20c86df0d91 100644 --- a/deps/grpc/src/core/lib/security/authorization/mock_cel/evaluator_core.h +++ b/deps/grpc/src/core/lib/security/authorization/mock_cel/evaluator_core.h @@ -20,11 +20,11 @@ #include #include -#include "absl/status/statusor.h" #include "google/api/expr/v1alpha1/syntax.upb.h" #include "src/core/lib/security/authorization/mock_cel/activation.h" #include "src/core/lib/security/authorization/mock_cel/cel_expression.h" #include "src/core/lib/security/authorization/mock_cel/cel_value.h" +#include "absl/status/statusor.h" namespace grpc_core { namespace mock_cel { diff --git a/deps/grpc/src/core/lib/security/authorization/mock_cel/flat_expr_builder.h b/deps/grpc/src/core/lib/security/authorization/mock_cel/flat_expr_builder.h index bd4993e3917..76399be91ee 100644 --- a/deps/grpc/src/core/lib/security/authorization/mock_cel/flat_expr_builder.h +++ b/deps/grpc/src/core/lib/security/authorization/mock_cel/flat_expr_builder.h @@ -22,11 +22,11 @@ #include #include -#include "absl/status/status.h" -#include "absl/status/statusor.h" #include "google/api/expr/v1alpha1/syntax.upb.h" #include "src/core/lib/security/authorization/mock_cel/cel_expression.h" #include "src/core/lib/security/authorization/mock_cel/evaluator_core.h" +#include "absl/status/status.h" +#include "absl/status/statusor.h" namespace grpc_core { namespace mock_cel { diff --git a/deps/grpc/src/core/lib/security/authorization/rbac_translator.cc b/deps/grpc/src/core/lib/security/authorization/rbac_translator.cc index 9b57ca3efd1..f74e522f53b 100644 --- a/deps/grpc/src/core/lib/security/authorization/rbac_translator.cc +++ b/deps/grpc/src/core/lib/security/authorization/rbac_translator.cc @@ -26,6 +26,12 @@ #include #include +#include "src/core/lib/security/authorization/audit_logging.h" +#include "src/core/util/grpc_check.h" +#include "src/core/util/json/json.h" +#include "src/core/util/json/json_reader.h" +#include "src/core/util/matchers.h" +#include "src/core/util/useful.h" #include "absl/status/status.h" #include "absl/status/statusor.h" #include "absl/strings/match.h" @@ -33,12 +39,6 @@ #include "absl/strings/str_format.h" #include "absl/strings/string_view.h" #include "absl/strings/strip.h" -#include "src/core/lib/security/authorization/audit_logging.h" -#include "src/core/util/grpc_check.h" -#include "src/core/util/json/json.h" -#include "src/core/util/json/json_reader.h" -#include "src/core/util/matchers.h" -#include "src/core/util/useful.h" namespace grpc_core { diff --git a/deps/grpc/src/core/lib/security/authorization/rbac_translator.h b/deps/grpc/src/core/lib/security/authorization/rbac_translator.h index 538aa78a5b4..7de088f1431 100644 --- a/deps/grpc/src/core/lib/security/authorization/rbac_translator.h +++ b/deps/grpc/src/core/lib/security/authorization/rbac_translator.h @@ -19,9 +19,9 @@ #include +#include "src/core/lib/security/authorization/rbac_policy.h" #include "absl/status/statusor.h" #include "absl/strings/string_view.h" -#include "src/core/lib/security/authorization/rbac_policy.h" namespace grpc_core { diff --git a/deps/grpc/src/core/lib/security/authorization/stdout_logger.cc b/deps/grpc/src/core/lib/security/authorization/stdout_logger.cc index 22d585a4602..5858989e533 100644 --- a/deps/grpc/src/core/lib/security/authorization/stdout_logger.cc +++ b/deps/grpc/src/core/lib/security/authorization/stdout_logger.cc @@ -22,12 +22,12 @@ #include #include +#include "src/core/util/grpc_check.h" #include "absl/status/statusor.h" #include "absl/strings/str_format.h" #include "absl/strings/string_view.h" #include "absl/time/clock.h" #include "absl/time/time.h" -#include "src/core/util/grpc_check.h" namespace grpc_core { namespace experimental { diff --git a/deps/grpc/src/core/lib/slice/percent_encoding.cc b/deps/grpc/src/core/lib/slice/percent_encoding.cc index 88af7e0a20f..bd901f2d4ad 100644 --- a/deps/grpc/src/core/lib/slice/percent_encoding.cc +++ b/deps/grpc/src/core/lib/slice/percent_encoding.cc @@ -24,8 +24,8 @@ #include #include -#include "absl/log/check.h" #include "src/core/util/bitset.h" +#include "absl/log/check.h" namespace grpc_core { diff --git a/deps/grpc/src/core/lib/slice/slice.cc b/deps/grpc/src/core/lib/slice/slice.cc index 52af6a4e288..e155350be14 100644 --- a/deps/grpc/src/core/lib/slice/slice.cc +++ b/deps/grpc/src/core/lib/slice/slice.cc @@ -25,10 +25,10 @@ #include -#include "absl/log/check.h" #include "src/core/lib/slice/slice_internal.h" #include "src/core/lib/slice/slice_refcount.h" #include "src/core/util/memory.h" +#include "absl/log/check.h" char* grpc_slice_to_c_string(grpc_slice slice) { char* out = static_cast(gpr_malloc(GRPC_SLICE_LENGTH(slice) + 1)); diff --git a/deps/grpc/src/core/lib/slice/slice.h b/deps/grpc/src/core/lib/slice/slice.h index 39eeff498fc..2fa1f20a886 100644 --- a/deps/grpc/src/core/lib/slice/slice.h +++ b/deps/grpc/src/core/lib/slice/slice.h @@ -25,12 +25,12 @@ #include #include -#include "absl/log/check.h" -#include "absl/strings/string_view.h" #include "src/core/lib/slice/slice_internal.h" #include "src/core/lib/slice/slice_refcount.h" #include "src/core/util/debug_location.h" #include "src/core/util/string.h" +#include "absl/log/check.h" +#include "absl/strings/string_view.h" // Herein lies grpc_core::Slice and its team of thin wrappers around grpc_slice. // They aim to keep you safe by providing strong guarantees around lifetime and diff --git a/deps/grpc/src/core/lib/slice/slice_buffer.cc b/deps/grpc/src/core/lib/slice/slice_buffer.cc index 9b6b3a3f69b..4b22982f851 100644 --- a/deps/grpc/src/core/lib/slice/slice_buffer.cc +++ b/deps/grpc/src/core/lib/slice/slice_buffer.cc @@ -26,8 +26,8 @@ #include -#include "absl/log/check.h" #include "src/core/lib/slice/slice_internal.h" +#include "absl/log/check.h" namespace grpc_core { diff --git a/deps/grpc/src/core/lib/slice/slice_internal.h b/deps/grpc/src/core/lib/slice/slice_internal.h index 9c05f6fdacd..e4ca519deca 100644 --- a/deps/grpc/src/core/lib/slice/slice_internal.h +++ b/deps/grpc/src/core/lib/slice/slice_internal.h @@ -26,10 +26,10 @@ #include #include +#include "src/core/util/memory.h" #include "absl/hash/hash.h" #include "absl/log/check.h" #include "absl/strings/string_view.h" -#include "src/core/util/memory.h" // Returns a pointer to the first slice in the slice buffer without giving // ownership to or a reference count on that slice. diff --git a/deps/grpc/src/core/lib/surface/call.cc b/deps/grpc/src/core/lib/surface/call.cc index bc948314a00..4cd98cc63b9 100644 --- a/deps/grpc/src/core/lib/surface/call.cc +++ b/deps/grpc/src/core/lib/surface/call.cc @@ -47,18 +47,12 @@ #include #include -#include "absl/base/thread_annotations.h" -#include "absl/log/log.h" -#include "absl/status/status.h" -#include "absl/strings/str_cat.h" -#include "absl/strings/str_format.h" -#include "absl/strings/str_join.h" -#include "absl/strings/string_view.h" #include "src/core/call/call_finalization.h" #include "src/core/call/metadata.h" #include "src/core/call/metadata_batch.h" #include "src/core/call/status_util.h" #include "src/core/channelz/channelz.h" +#include "src/core/config/config_vars.h" #include "src/core/lib/channel/channel_stack.h" #include "src/core/lib/compression/compression_internal.h" #include "src/core/lib/event_engine/event_engine_context.h" @@ -105,6 +99,13 @@ #include "src/core/util/sync.h" #include "src/core/util/time_precise.h" #include "src/core/util/useful.h" +#include "absl/base/thread_annotations.h" +#include "absl/log/log.h" +#include "absl/status/status.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/str_format.h" +#include "absl/strings/str_join.h" +#include "absl/strings/string_view.h" namespace grpc_core { @@ -116,16 +117,41 @@ using GrpcClosure = Closure; // Call Call::Call(bool is_client, Timestamp send_deadline, RefCountedPtr arena) - : arena_(std::move(arena)), + : channelz::DataSource(ConfigVars::Get().ChannelzCallTracer() + ? MakeRefCounted() + : nullptr), + arena_(std::move(arena)), send_deadline_(send_deadline), is_client_(is_client) { GRPC_DCHECK_NE(arena_.get(), nullptr); GRPC_DCHECK_NE( arena_->GetContext(), nullptr); + arena_->SetContext( + DownCast(channelz_node().get())); arena_->SetContext(this); } +void Call::AddData(channelz::DataSink sink) { + channelz::PropertyList properties; + properties.Set("is_client", is_client_) + .Set("send_deadline", send_deadline_) + .Set("start_time", Timestamp::FromCycleCounterRoundDown(start_time_)) + .Set("cancellation_is_inherited", cancellation_is_inherited_) + .Set("traced", traced_) + .Set("encodings_accepted_by_peer", + encodings_accepted_by_peer_.ToString()); + { + MutexLock lock(&peer_mu_); + properties.Set("peer_string", peer_string_.as_string_view()); + } + { + MutexLock lock(&deadline_mu_); + properties.Set("deadline", deadline_); + } + sink.AddData("call", properties); +} + Call::ParentCall* Call::GetOrCreateParentCall() { ParentCall* p = parent_call_.load(std::memory_order_acquire); if (p == nullptr) { @@ -337,28 +363,30 @@ void Call::HandleCompressionAlgorithmDisabled( GRPC_STATUS_UNIMPLEMENTED)); } -void Call::UpdateDeadline(Timestamp deadline) { +grpc_error_handle Call::UpdateDeadline(Timestamp deadline) { ReleasableMutexLock lock(&deadline_mu_); GRPC_TRACE_LOG(call, INFO) << "[call " << this << "] UpdateDeadline from=" << deadline_.ToString() << " to=" << deadline.ToString(); - if (deadline >= deadline_) return; + if (deadline >= deadline_) return absl::OkStatus(); if (deadline < Timestamp::Now()) { lock.Release(); - CancelWithError(grpc_error_set_int( + grpc_error_handle error = grpc_error_set_int( absl::DeadlineExceededError("Deadline Exceeded"), - StatusIntProperty::kRpcStatus, GRPC_STATUS_DEADLINE_EXCEEDED)); - return; + StatusIntProperty::kRpcStatus, GRPC_STATUS_DEADLINE_EXCEEDED); + CancelWithError(error); + return error; } auto* event_engine = arena_->GetContext(); if (deadline_ != Timestamp::InfFuture()) { - if (!event_engine->Cancel(deadline_task_)) return; + if (!event_engine->Cancel(deadline_task_)) return absl::OkStatus(); } else { InternalRef("deadline"); } deadline_ = deadline; deadline_task_ = event_engine->RunAfter(deadline - Timestamp::Now(), this); + return absl::OkStatus(); } void Call::ResetDeadline() { diff --git a/deps/grpc/src/core/lib/surface/call.h b/deps/grpc/src/core/lib/surface/call.h index 46e2b7294d5..459ade18270 100644 --- a/deps/grpc/src/core/lib/surface/call.h +++ b/deps/grpc/src/core/lib/surface/call.h @@ -28,9 +28,6 @@ #include -#include "absl/functional/any_invocable.h" -#include "absl/functional/function_ref.h" -#include "absl/strings/string_view.h" #include "src/core/lib/channel/channel_fwd.h" #include "src/core/lib/channel/channel_stack.h" #include "src/core/lib/debug/trace.h" @@ -48,6 +45,9 @@ #include "src/core/util/ref_counted_ptr.h" #include "src/core/util/time.h" #include "src/core/util/time_precise.h" +#include "absl/functional/any_invocable.h" +#include "absl/functional/function_ref.h" +#include "absl/strings/string_view.h" typedef void (*grpc_ioreq_completion_func)(grpc_call* call, int success, void* user_data); @@ -81,7 +81,11 @@ struct ArenaContextType { class Call : public CppImplOf, public grpc_event_engine::experimental::EventEngine:: - Closure /* for deadlines */ { + Closure /* for deadlines */, + public channelz::DataSource +/* for channelz - derived implementations must call + SourceConstructed/SourceDestructing */ +{ public: Arena* arena() const { return arena_.get(); } bool is_client() const { return is_client_; } @@ -102,7 +106,8 @@ class Call : public CppImplOf, virtual void InternalRef(const char* reason) = 0; virtual void InternalUnref(const char* reason) = 0; - void UpdateDeadline(Timestamp deadline) ABSL_LOCKS_EXCLUDED(deadline_mu_); + grpc_error_handle UpdateDeadline(Timestamp deadline) + ABSL_LOCKS_EXCLUDED(deadline_mu_); void ResetDeadline() ABSL_LOCKS_EXCLUDED(deadline_mu_); Timestamp deadline() { MutexLock lock(&deadline_mu_); @@ -202,6 +207,8 @@ class Call : public CppImplOf, virtual void SetIncomingCompressionAlgorithm( grpc_compression_algorithm algorithm) = 0; + void AddData(channelz::DataSink sink) override; + private: const RefCountedPtr arena_; std::atomic parent_call_{nullptr}; diff --git a/deps/grpc/src/core/lib/surface/call_log_batch.cc b/deps/grpc/src/core/lib/surface/call_log_batch.cc index 2162ac2831b..c6934c84b4a 100644 --- a/deps/grpc/src/core/lib/surface/call_log_batch.cc +++ b/deps/grpc/src/core/lib/surface/call_log_batch.cc @@ -26,12 +26,12 @@ #include #include -#include "absl/strings/str_format.h" -#include "absl/strings/str_join.h" #include "src/core/lib/slice/slice_internal.h" #include "src/core/lib/slice/slice_string_helpers.h" #include "src/core/lib/surface/call.h" #include "src/core/util/string.h" +#include "absl/strings/str_format.h" +#include "absl/strings/str_join.h" static void add_metadata(const grpc_metadata* md, size_t count, std::vector* b) { diff --git a/deps/grpc/src/core/lib/surface/call_utils.cc b/deps/grpc/src/core/lib/surface/call_utils.cc index 535d51a680f..753327b9df0 100644 --- a/deps/grpc/src/core/lib/surface/call_utils.cc +++ b/deps/grpc/src/core/lib/surface/call_utils.cc @@ -40,11 +40,6 @@ #include #include -#include "absl/log/log.h" -#include "absl/status/status.h" -#include "absl/strings/str_cat.h" -#include "absl/strings/str_format.h" -#include "absl/strings/string_view.h" #include "src/core/call/metadata.h" #include "src/core/call/metadata_batch.h" #include "src/core/call/status_util.h" @@ -61,6 +56,11 @@ #include "src/core/util/debug_location.h" #include "src/core/util/grpc_check.h" #include "src/core/util/match.h" +#include "absl/log/log.h" +#include "absl/status/status.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/str_format.h" +#include "absl/strings/string_view.h" namespace grpc_core { diff --git a/deps/grpc/src/core/lib/surface/call_utils.h b/deps/grpc/src/core/lib/surface/call_utils.h index ee67fb3566e..60927995d74 100644 --- a/deps/grpc/src/core/lib/surface/call_utils.h +++ b/deps/grpc/src/core/lib/surface/call_utils.h @@ -36,18 +36,19 @@ #include #include #include +#include #include #include #include +#include -#include "absl/status/status.h" -#include "absl/strings/str_cat.h" -#include "absl/strings/string_view.h" #include "src/core/call/message.h" #include "src/core/call/metadata.h" #include "src/core/call/metadata_batch.h" +#include "src/core/channelz/property_list.h" #include "src/core/lib/promise/activity.h" #include "src/core/lib/promise/cancel_callback.h" +#include "src/core/lib/promise/detail/promise_like.h" #include "src/core/lib/promise/map.h" #include "src/core/lib/promise/poll.h" #include "src/core/lib/promise/seq.h" @@ -55,6 +56,12 @@ #include "src/core/lib/surface/completion_queue.h" #include "src/core/util/crash.h" #include "src/core/util/grpc_check.h" +#include "src/core/util/upb_utils.h" +#include "src/proto/grpc/channelz/v2/promise.upb.h" +#include "upb/mem/arena.h" +#include "absl/status/status.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/string_view.h" namespace grpc_core { @@ -238,6 +245,32 @@ class OpHandlerImpl { PromiseFactory promise_factory_; Promise promise_; }; + + public: + void ToProto(grpc_channelz_v2_Promise* promise_proto, + upb_Arena* arena) const { + auto* custom_promise = + grpc_channelz_v2_Promise_mutable_custom_promise(promise_proto, arena); + std::string type = absl::StrCat("OpHandlerImpl<", OpName(), ">"); + grpc_channelz_v2_Promise_Custom_set_type( + custom_promise, CopyStdStringToUpbString(type, arena)); + channelz::PropertyList properties; + switch (state_) { + case State::kDismissed: + properties.Set("state", "dismissed"); + break; + case State::kPromiseFactory: + properties.Set("state", "promise_factory"); + break; + case State::kPromise: + properties.Set("state", "promise"); + properties.Set("promise", PromiseProperty(&promise_)); + break; + } + properties.FillUpbProto(grpc_channelz_v2_Promise_Custom_mutable_properties( + custom_promise, arena), + arena); + } }; template @@ -289,6 +322,21 @@ class BatchOpIndex { // to Empty{} class WaitForCqEndOp { public: + struct NotStarted { + bool is_closure; + void* tag; + grpc_error_handle error; + grpc_completion_queue* cq; + }; + struct Started { + explicit Started(Waker waker) : waker(std::move(waker)) {} + Waker waker; + grpc_cq_completion completion; + std::atomic done{false}; + }; + struct Invalid {}; + using State = std::variant; + WaitForCqEndOp(bool is_closure, void* tag, grpc_error_handle error, grpc_completion_queue* cq) : state_{NotStarted{is_closure, tag, std::move(error), cq}} {} @@ -308,24 +356,35 @@ class WaitForCqEndOp { } private: - struct NotStarted { - bool is_closure; - void* tag; - grpc_error_handle error; - grpc_completion_queue* cq; - }; - struct Started { - explicit Started(Waker waker) : waker(std::move(waker)) {} - Waker waker; - grpc_cq_completion completion; - std::atomic done{false}; - }; - struct Invalid {}; - using State = std::variant; - static std::string StateString(const State& state); State state_{Invalid{}}; + + public: + void ToProto(grpc_channelz_v2_Promise* promise_proto, + upb_Arena* arena) const { + auto* custom_promise = + grpc_channelz_v2_Promise_mutable_custom_promise(promise_proto, arena); + grpc_channelz_v2_Promise_Custom_set_type( + custom_promise, CopyStdStringToUpbString("WaitForCqEndOp", arena)); + channelz::PropertyList properties; + std::visit( + [&properties](const auto& s) { + using T = std::decay_t; + if constexpr (std::is_same_v) { + properties.Set("state", "not_started"); + } else if constexpr (std::is_same_v) { + properties.Set("state", "started"); + properties.Set("done", s.done.load(std::memory_order_relaxed)); + } else if constexpr (std::is_same_v) { + properties.Set("state", "invalid"); + } + }, + state_); + properties.FillUpbProto(grpc_channelz_v2_Promise_Custom_mutable_properties( + custom_promise, arena), + arena); + } }; template @@ -406,6 +465,12 @@ class PollBatchLogger { void* tag_; F f_; + + public: + void ToProto(grpc_channelz_v2_Promise* promise_proto, + upb_Arena* arena) const { + PromiseAsProto(f_, promise_proto, arena); + } }; template diff --git a/deps/grpc/src/core/lib/surface/channel.cc b/deps/grpc/src/core/lib/surface/channel.cc index 01f0ee86c5e..34d83a5cc41 100644 --- a/deps/grpc/src/core/lib/surface/channel.cc +++ b/deps/grpc/src/core/lib/surface/channel.cc @@ -67,7 +67,8 @@ Channel::Channel(std::string target, const ChannelArgs& channel_args) channel_args.GetObject() ->memory_quota() ->CreateMemoryOwner(), - 1024)) {} + 1024)), + memory_allocator_(&call_arena_allocator_->allocator()) {} Channel::RegisteredCall* Channel::RegisterCall(const char* method, const char* host) { diff --git a/deps/grpc/src/core/lib/surface/channel.h b/deps/grpc/src/core/lib/surface/channel.h index c1de0a8e0b9..eda40276b85 100644 --- a/deps/grpc/src/core/lib/surface/channel.h +++ b/deps/grpc/src/core/lib/surface/channel.h @@ -18,6 +18,7 @@ #define GRPC_SRC_CORE_LIB_SURFACE_CHANNEL_H #include +#include #include #include #include @@ -27,13 +28,11 @@ #include #include -#include "absl/base/thread_annotations.h" -#include "absl/status/statusor.h" -#include "absl/strings/string_view.h" #include "src/core/call/call_arena_allocator.h" #include "src/core/call/call_destination.h" #include "src/core/channelz/channelz.h" #include "src/core/lib/channel/channel_args.h" +#include "src/core/lib/experiments/experiments.h" #include "src/core/lib/iomgr/iomgr_fwd.h" #include "src/core/lib/resource_quota/arena.h" #include "src/core/lib/resource_quota/resource_quota.h" @@ -45,6 +44,9 @@ #include "src/core/util/ref_counted_ptr.h" #include "src/core/util/sync.h" #include "src/core/util/time.h" +#include "absl/base/thread_annotations.h" +#include "absl/status/statusor.h" +#include "absl/strings/string_view.h" // Forward declaration to avoid dependency loop. struct grpc_channel_stack; @@ -130,6 +132,13 @@ class Channel : public UnstartedCallDestination, return call_arena_allocator_.get(); } + grpc_event_engine::experimental::MemoryAllocator* memory_allocator() const { + if (IsTrackWritesInResourceQuotaEnabled()) { + return memory_allocator_; + } + return nullptr; + } + protected: Channel(std::string target, const ChannelArgs& channel_args); @@ -145,6 +154,7 @@ class Channel : public UnstartedCallDestination, std::map, RegisteredCall> registration_table_ ABSL_GUARDED_BY(mu_); const RefCountedPtr call_arena_allocator_; + grpc_event_engine::experimental::MemoryAllocator* memory_allocator_ = nullptr; }; } // namespace grpc_core diff --git a/deps/grpc/src/core/lib/surface/channel_create.cc b/deps/grpc/src/core/lib/surface/channel_create.cc index ec9ac5d741a..27b47c811c5 100644 --- a/deps/grpc/src/core/lib/surface/channel_create.cc +++ b/deps/grpc/src/core/lib/surface/channel_create.cc @@ -21,8 +21,6 @@ #include #include -#include "absl/strings/str_cat.h" -#include "absl/strings/str_split.h" #include "src/core/channelz/channelz.h" #include "src/core/client_channel/client_channel.h" #include "src/core/client_channel/direct_channel.h" @@ -47,6 +45,8 @@ #include "src/core/telemetry/stats_data.h" #include "src/core/transport/endpoint_transport.h" #include "src/core/util/grpc_check.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/str_split.h" namespace grpc_core { diff --git a/deps/grpc/src/core/lib/surface/channel_create.h b/deps/grpc/src/core/lib/surface/channel_create.h index c774a1a1a84..369ef974899 100644 --- a/deps/grpc/src/core/lib/surface/channel_create.h +++ b/deps/grpc/src/core/lib/surface/channel_create.h @@ -21,10 +21,10 @@ #include -#include "absl/status/statusor.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/surface/channel.h" #include "src/core/lib/surface/channel_stack_type.h" +#include "absl/status/statusor.h" #define GRPC_ARG_USE_V3_STACK "grpc.internal.use_v3_stack" diff --git a/deps/grpc/src/core/lib/surface/channel_init.cc b/deps/grpc/src/core/lib/surface/channel_init.cc index aac3fcc76b8..1ee8c273ef1 100644 --- a/deps/grpc/src/core/lib/surface/channel_init.cc +++ b/deps/grpc/src/core/lib/surface/channel_init.cc @@ -30,10 +30,6 @@ #include #include -#include "absl/log/log.h" -#include "absl/strings/str_cat.h" -#include "absl/strings/str_join.h" -#include "absl/strings/string_view.h" #include "src/core/channelz/channelz.h" #include "src/core/channelz/property_list.h" #include "src/core/lib/debug/trace.h" @@ -42,6 +38,10 @@ #include "src/core/util/grpc_check.h" #include "src/core/util/sync.h" #include "src/core/util/unique_type_name.h" +#include "absl/log/log.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/str_join.h" +#include "absl/strings/string_view.h" namespace grpc_core { @@ -287,7 +287,7 @@ void ChannelInit::MergeFusedFilters(ChannelStackBuilder* builder, int j = 0; auto& stack = *builder->mutable_stack(); std::vector filter_list; - for (const auto filter : stack) { + for (const auto& [filter, _] : stack) { filter_list.push_back({filter, ++i}); } filter_list.back().next = -1; diff --git a/deps/grpc/src/core/lib/surface/channel_init.h b/deps/grpc/src/core/lib/surface/channel_init.h index 29f6ee29c55..f562b7a4cd7 100644 --- a/deps/grpc/src/core/lib/surface/channel_init.h +++ b/deps/grpc/src/core/lib/surface/channel_init.h @@ -28,7 +28,6 @@ #include #include -#include "absl/functional/any_invocable.h" #include "src/core/call/call_filters.h" #include "src/core/call/interception_chain.h" #include "src/core/channelz/channelz.h" @@ -40,6 +39,7 @@ #include "src/core/util/debug_location.h" #include "src/core/util/grpc_check.h" #include "src/core/util/unique_type_name.h" +#include "absl/functional/any_invocable.h" /// This module provides a way for plugins (and the grpc core library itself) /// to register mutators for channel stacks. @@ -324,7 +324,9 @@ class ChannelInit { grpc_channel_stack_type type, SourceLocation registration_source = {}) { return RegisterFilter( type, UniqueTypeNameFor(), &Filter::kFilter, - [](InterceptionChainBuilder& builder) { builder.Add(); }, + [](InterceptionChainBuilder& builder) { + builder.Add(nullptr); + }, registration_source); } diff --git a/deps/grpc/src/core/lib/surface/completion_queue.cc b/deps/grpc/src/core/lib/surface/completion_queue.cc index fa7f715bcc7..83a62874015 100644 --- a/deps/grpc/src/core/lib/surface/completion_queue.cc +++ b/deps/grpc/src/core/lib/surface/completion_queue.cc @@ -32,10 +32,6 @@ #include #include -#include "absl/log/log.h" -#include "absl/status/status.h" -#include "absl/strings/str_format.h" -#include "absl/strings/str_join.h" #include "src/core/lib/event_engine/shim.h" #include "src/core/lib/iomgr/closure.h" #include "src/core/lib/iomgr/exec_ctx.h" @@ -50,6 +46,10 @@ #include "src/core/util/spinlock.h" #include "src/core/util/status_helper.h" #include "src/core/util/time.h" +#include "absl/log/log.h" +#include "absl/status/status.h" +#include "absl/strings/str_format.h" +#include "absl/strings/str_join.h" namespace { diff --git a/deps/grpc/src/core/lib/surface/filter_stack_call.cc b/deps/grpc/src/core/lib/surface/filter_stack_call.cc index 870aa7ebc59..21605580ac0 100644 --- a/deps/grpc/src/core/lib/surface/filter_stack_call.cc +++ b/deps/grpc/src/core/lib/surface/filter_stack_call.cc @@ -37,11 +37,6 @@ #include #include -#include "absl/log/log.h" -#include "absl/status/status.h" -#include "absl/strings/escaping.h" -#include "absl/strings/str_cat.h" -#include "absl/strings/string_view.h" #include "src/core/call/metadata_batch.h" #include "src/core/channelz/channelz.h" #include "src/core/lib/channel/channel_stack.h" @@ -71,6 +66,11 @@ #include "src/core/util/ref_counted_ptr.h" #include "src/core/util/status_helper.h" #include "src/core/util/time_precise.h" +#include "absl/log/log.h" +#include "absl/status/status.h" +#include "absl/strings/escaping.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/string_view.h" namespace grpc_core { @@ -84,7 +84,9 @@ FilterStackCall::FilterStackCall(RefCountedPtr arena, std::move(arena)), channel_(args.channel->RefAsSubclass()), cq_(args.cq), - stream_op_payload_{} {} + stream_op_payload_{} { + SourceConstructed(); +} grpc_error_handle FilterStackCall::Create(grpc_call_create_args* args, grpc_call** out_call) { @@ -205,7 +207,7 @@ grpc_error_handle FilterStackCall::Create(grpc_call_create_args* args, } if (args->send_deadline != Timestamp::InfFuture()) { - call->UpdateDeadline(args->send_deadline); + call->UpdateDeadline(args->send_deadline).IgnoreError(); } CSliceUnref(path); @@ -231,6 +233,7 @@ void FilterStackCall::ReleaseCall(void* call, grpc_error_handle /*error*/) { void FilterStackCall::DestroyCall(void* call, grpc_error_handle /*error*/) { auto* c = static_cast(call); + c->SourceDestructing(); c->recv_initial_metadata_.Clear(); c->recv_trailing_metadata_.Clear(); c->receiving_slice_buffer_.reset(); @@ -327,7 +330,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 diff --git a/deps/grpc/src/core/lib/surface/filter_stack_call.h b/deps/grpc/src/core/lib/surface/filter_stack_call.h index 6768f0692f2..12e00368813 100644 --- a/deps/grpc/src/core/lib/surface/filter_stack_call.h +++ b/deps/grpc/src/core/lib/surface/filter_stack_call.h @@ -38,9 +38,6 @@ #include #include -#include "absl/strings/str_cat.h" -#include "absl/strings/str_join.h" -#include "absl/strings/string_view.h" #include "src/core/call/metadata_batch.h" #include "src/core/lib/channel/channel_stack.h" #include "src/core/lib/iomgr/call_combiner.h" @@ -58,6 +55,9 @@ #include "src/core/util/grpc_check.h" #include "src/core/util/ref_counted.h" #include "src/core/util/ref_counted_ptr.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/str_join.h" +#include "absl/strings/string_view.h" namespace grpc_core { diff --git a/deps/grpc/src/core/lib/surface/init.cc b/deps/grpc/src/core/lib/surface/init.cc index 57ad3a086b9..4e123629f35 100644 --- a/deps/grpc/src/core/lib/surface/init.cc +++ b/deps/grpc/src/core/lib/surface/init.cc @@ -27,10 +27,6 @@ #include #include -#include "absl/base/thread_annotations.h" -#include "absl/log/log.h" -#include "absl/time/clock.h" -#include "absl/time/time.h" #include "src/core/client_channel/backup_poller.h" #include "src/core/config/core_configuration.h" #include "src/core/credentials/transport/security_connector.h" @@ -48,6 +44,10 @@ #include "src/core/util/fork.h" #include "src/core/util/sync.h" #include "src/core/util/thd.h" +#include "absl/base/thread_annotations.h" +#include "absl/log/log.h" +#include "absl/time/clock.h" +#include "absl/time/time.h" // Remnants of the old plugin system void grpc_resolver_dns_ares_init(void); diff --git a/deps/grpc/src/core/lib/surface/lame_client.cc b/deps/grpc/src/core/lib/surface/lame_client.cc index 2596d3f1b31..a466cac546f 100644 --- a/deps/grpc/src/core/lib/surface/lame_client.cc +++ b/deps/grpc/src/core/lib/surface/lame_client.cc @@ -26,8 +26,6 @@ #include #include -#include "absl/status/status.h" -#include "absl/status/statusor.h" #include "src/core/call/metadata_batch.h" #include "src/core/config/core_configuration.h" #include "src/core/lib/channel/channel_args.h" @@ -46,6 +44,8 @@ #include "src/core/util/ref_counted_ptr.h" #include "src/core/util/sync.h" #include "src/core/util/useful.h" +#include "absl/status/status.h" +#include "absl/status/statusor.h" // Avoid some IWYU confusion: // IWYU pragma: no_include "src/core/util/orphanable.h" diff --git a/deps/grpc/src/core/lib/surface/lame_client.h b/deps/grpc/src/core/lib/surface/lame_client.h index 85c4c6e2992..ab5e730b3b1 100644 --- a/deps/grpc/src/core/lib/surface/lame_client.h +++ b/deps/grpc/src/core/lib/surface/lame_client.h @@ -24,9 +24,6 @@ #include -#include "absl/base/thread_annotations.h" -#include "absl/status/status.h" -#include "absl/status/statusor.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/channel_fwd.h" #include "src/core/lib/channel/promise_based_filter.h" @@ -35,6 +32,9 @@ #include "src/core/lib/transport/connectivity_state.h" #include "src/core/lib/transport/transport.h" #include "src/core/util/sync.h" +#include "absl/base/thread_annotations.h" +#include "absl/status/status.h" +#include "absl/status/statusor.h" #define GRPC_ARG_LAME_FILTER_ERROR "grpc.lame_filter_error" diff --git a/deps/grpc/src/core/lib/surface/legacy_channel.cc b/deps/grpc/src/core/lib/surface/legacy_channel.cc index b4924b47ff8..d12c5681231 100644 --- a/deps/grpc/src/core/lib/surface/legacy_channel.cc +++ b/deps/grpc/src/core/lib/surface/legacy_channel.cc @@ -26,9 +26,6 @@ #include -#include "absl/base/thread_annotations.h" -#include "absl/log/log.h" -#include "absl/status/status.h" #include "src/core/channelz/channelz.h" #include "src/core/client_channel/client_channel_filter.h" #include "src/core/config/core_configuration.h" @@ -58,6 +55,9 @@ #include "src/core/util/ref_counted_ptr.h" #include "src/core/util/sync.h" #include "src/core/util/time.h" +#include "absl/base/thread_annotations.h" +#include "absl/log/log.h" +#include "absl/status/status.h" namespace grpc_core { diff --git a/deps/grpc/src/core/lib/surface/legacy_channel.h b/deps/grpc/src/core/lib/surface/legacy_channel.h index e06977586b2..0c7f74933c9 100644 --- a/deps/grpc/src/core/lib/surface/legacy_channel.h +++ b/deps/grpc/src/core/lib/surface/legacy_channel.h @@ -26,7 +26,6 @@ #include #include -#include "absl/status/statusor.h" #include "src/core/call/call_arena_allocator.h" #include "src/core/client_channel/client_channel_filter.h" #include "src/core/filter/blackboard.h" @@ -41,6 +40,7 @@ #include "src/core/telemetry/stats.h" #include "src/core/util/ref_counted_ptr.h" #include "src/core/util/time.h" +#include "absl/status/statusor.h" namespace grpc_core { diff --git a/deps/grpc/src/core/lib/surface/validate_metadata.cc b/deps/grpc/src/core/lib/surface/validate_metadata.cc index 684cad74e53..f416aa7f504 100644 --- a/deps/grpc/src/core/lib/surface/validate_metadata.cc +++ b/deps/grpc/src/core/lib/surface/validate_metadata.cc @@ -21,11 +21,11 @@ #include #include -#include "absl/status/status.h" -#include "absl/strings/string_view.h" #include "src/core/lib/iomgr/error.h" #include "src/core/lib/slice/slice_internal.h" #include "src/core/util/bitset.h" +#include "absl/status/status.h" +#include "absl/strings/string_view.h" namespace grpc_core { diff --git a/deps/grpc/src/core/lib/surface/validate_metadata.h b/deps/grpc/src/core/lib/surface/validate_metadata.h index 1473bd940be..9315b435bf6 100644 --- a/deps/grpc/src/core/lib/surface/validate_metadata.h +++ b/deps/grpc/src/core/lib/surface/validate_metadata.h @@ -25,9 +25,9 @@ #include -#include "absl/strings/string_view.h" #include "src/core/lib/iomgr/error.h" #include "src/core/util/grpc_check.h" +#include "absl/strings/string_view.h" namespace grpc_core { diff --git a/deps/grpc/src/core/lib/surface/version.cc b/deps/grpc/src/core/lib/surface/version.cc index 4ed054e9310..56c2e909c0d 100644 --- a/deps/grpc/src/core/lib/surface/version.cc +++ b/deps/grpc/src/core/lib/surface/version.cc @@ -22,6 +22,6 @@ #include #include -const char* grpc_version_string(void) { return "51.0.0"; } +const char* grpc_version_string(void) { return "52.0.0"; } -const char* grpc_g_stands_for(void) { return "genuine"; } +const char* grpc_g_stands_for(void) { return "gutsy"; } diff --git a/deps/grpc/src/core/lib/transport/bdp_estimator.cc b/deps/grpc/src/core/lib/transport/bdp_estimator.cc index 1f68188c0b9..e322e967050 100644 --- a/deps/grpc/src/core/lib/transport/bdp_estimator.cc +++ b/deps/grpc/src/core/lib/transport/bdp_estimator.cc @@ -24,8 +24,8 @@ #include -#include "absl/log/log.h" #include "src/core/util/grpc_check.h" +#include "absl/log/log.h" namespace grpc_core { diff --git a/deps/grpc/src/core/lib/transport/bdp_estimator.h b/deps/grpc/src/core/lib/transport/bdp_estimator.h index 69c9f7a6b04..16e75a921f8 100644 --- a/deps/grpc/src/core/lib/transport/bdp_estimator.h +++ b/deps/grpc/src/core/lib/transport/bdp_estimator.h @@ -25,11 +25,11 @@ #include -#include "absl/log/log.h" -#include "absl/strings/string_view.h" #include "src/core/lib/debug/trace.h" #include "src/core/util/grpc_check.h" #include "src/core/util/time.h" +#include "absl/log/log.h" +#include "absl/strings/string_view.h" namespace grpc_core { diff --git a/deps/grpc/src/core/lib/transport/connectivity_state.cc b/deps/grpc/src/core/lib/transport/connectivity_state.cc index 2a9e86c9e3d..b98918679cf 100644 --- a/deps/grpc/src/core/lib/transport/connectivity_state.cc +++ b/deps/grpc/src/core/lib/transport/connectivity_state.cc @@ -20,12 +20,12 @@ #include -#include "absl/log/log.h" #include "src/core/lib/iomgr/closure.h" #include "src/core/lib/iomgr/error.h" #include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/util/debug_location.h" #include "src/core/util/ref_counted_ptr.h" +#include "absl/log/log.h" namespace grpc_core { diff --git a/deps/grpc/src/core/lib/transport/connectivity_state.h b/deps/grpc/src/core/lib/transport/connectivity_state.h index fc9512bba10..2902c49661e 100644 --- a/deps/grpc/src/core/lib/transport/connectivity_state.h +++ b/deps/grpc/src/core/lib/transport/connectivity_state.h @@ -27,11 +27,11 @@ #include #include -#include "absl/container/flat_hash_set.h" -#include "absl/status/status.h" #include "src/core/lib/debug/trace.h" #include "src/core/util/orphanable.h" #include "src/core/util/work_serializer.h" +#include "absl/container/flat_hash_set.h" +#include "absl/status/status.h" namespace grpc_core { diff --git a/deps/grpc/src/core/lib/transport/error_utils.h b/deps/grpc/src/core/lib/transport/error_utils.h index f6577e9f18d..cd21d6cf2c1 100644 --- a/deps/grpc/src/core/lib/transport/error_utils.h +++ b/deps/grpc/src/core/lib/transport/error_utils.h @@ -24,10 +24,10 @@ #include -#include "absl/status/status.h" #include "src/core/ext/transport/chttp2/transport/http2_status.h" #include "src/core/lib/iomgr/error.h" #include "src/core/util/time.h" +#include "absl/status/status.h" /// A utility function to get the status code and message to be returned /// to the application. If not set in the top-level message, looks diff --git a/deps/grpc/src/core/lib/transport/promise_endpoint.cc b/deps/grpc/src/core/lib/transport/promise_endpoint.cc index 5518f69f57a..e234c60e6e4 100644 --- a/deps/grpc/src/core/lib/transport/promise_endpoint.cc +++ b/deps/grpc/src/core/lib/transport/promise_endpoint.cc @@ -25,10 +25,10 @@ #include #include -#include "absl/status/status.h" #include "src/core/lib/slice/slice_buffer.h" #include "src/core/util/grpc_check.h" #include "src/core/util/sync.h" +#include "absl/status/status.h" namespace grpc_core { diff --git a/deps/grpc/src/core/lib/transport/promise_endpoint.h b/deps/grpc/src/core/lib/transport/promise_endpoint.h index a7a0a50d589..d0cb0f5e0c0 100644 --- a/deps/grpc/src/core/lib/transport/promise_endpoint.h +++ b/deps/grpc/src/core/lib/transport/promise_endpoint.h @@ -30,9 +30,6 @@ #include #include -#include "absl/base/thread_annotations.h" -#include "absl/status/status.h" -#include "absl/status/statusor.h" #include "src/core/lib/event_engine/extensions/chaotic_good_extension.h" #include "src/core/lib/event_engine/query_extensions.h" #include "src/core/lib/iomgr/exec_ctx.h" @@ -46,6 +43,9 @@ #include "src/core/util/dump_args.h" #include "src/core/util/grpc_check.h" #include "src/core/util/sync.h" +#include "absl/base/thread_annotations.h" +#include "absl/status/status.h" +#include "absl/status/statusor.h" namespace grpc_core { diff --git a/deps/grpc/src/core/lib/transport/timeout_encoding.cc b/deps/grpc/src/core/lib/transport/timeout_encoding.cc index 80dcdcf833d..c8c890c335d 100644 --- a/deps/grpc/src/core/lib/transport/timeout_encoding.cc +++ b/deps/grpc/src/core/lib/transport/timeout_encoding.cc @@ -23,8 +23,8 @@ #include -#include "absl/base/attributes.h" #include "src/core/util/grpc_check.h" +#include "absl/base/attributes.h" namespace grpc_core { diff --git a/deps/grpc/src/core/lib/transport/transport.cc b/deps/grpc/src/core/lib/transport/transport.cc index 75049528c21..92d63bf10b1 100644 --- a/deps/grpc/src/core/lib/transport/transport.cc +++ b/deps/grpc/src/core/lib/transport/transport.cc @@ -26,9 +26,6 @@ #include #include -#include "absl/status/status.h" -#include "absl/strings/str_cat.h" -#include "absl/strings/string_view.h" #include "src/core/lib/event_engine/default_event_engine.h" #include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/promise/for_each.h" @@ -37,6 +34,9 @@ #include "src/core/lib/slice/slice.h" #include "src/core/lib/transport/error_utils.h" #include "src/core/util/time.h" +#include "absl/status/status.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/string_view.h" void grpc_stream_destroy(grpc_stream_refcount* refcount) { if ((grpc_core::ExecCtx::Get()->flags() & diff --git a/deps/grpc/src/core/lib/transport/transport.h b/deps/grpc/src/core/lib/transport/transport.h index 4b48c1c6181..0a071de6e8c 100644 --- a/deps/grpc/src/core/lib/transport/transport.h +++ b/deps/grpc/src/core/lib/transport/transport.h @@ -33,16 +33,13 @@ #include #include -#include "absl/functional/any_invocable.h" -#include "absl/log/log.h" -#include "absl/status/status.h" -#include "absl/strings/string_view.h" #include "src/core/call/call_destination.h" #include "src/core/call/call_spine.h" #include "src/core/call/message.h" #include "src/core/call/metadata.h" #include "src/core/call/metadata_batch.h" #include "src/core/channelz/channelz.h" +#include "src/core/ext/transport/chttp2/transport/http2_status.h" #include "src/core/lib/debug/trace.h" #include "src/core/lib/iomgr/call_combiner.h" #include "src/core/lib/iomgr/closure.h" @@ -61,6 +58,10 @@ #include "src/core/lib/transport/transport_fwd.h" #include "src/core/util/orphanable.h" #include "src/core/util/ref_counted.h" +#include "absl/functional/any_invocable.h" +#include "absl/log/log.h" +#include "absl/status/status.h" +#include "absl/strings/string_view.h" // Minimum and maximum protocol accepted versions. #define GRPC_PROTOCOL_VERSION_MAX_MAJOR 2 @@ -507,6 +508,58 @@ class ServerTransport; class Transport : public InternallyRefCounted { public: + // An interface used by channels or servers to watch the transport's state. + class StateWatcher : public RefCounted { + public: + ~StateWatcher() override = default; + + // The list of reasons is defined in + // https://github.com/grpc/proposal/blob/master/A94-subchannel-otel-metrics.md. + // Note that we do not include the "subchannel shutdown" reason + // here, since that reason is not generated by the transport. + enum DisconnectReason { + kUnknown, + kGoaway, + kConnectionReset, + kConnectionTimedOut, + kConnectionAborted, + kSocketError, + }; + + struct DisconnectInfo { + DisconnectReason reason = kUnknown; + std::optional http2_error_code; + std::optional keepalive_time; + }; + + // Called on disconnection or GOAWAY. The channel or server must + // stop sending traffic to this transport. The transport will + // automatically stop the watch after this. + virtual void OnDisconnect(absl::Status status, + DisconnectInfo disconnect_info) = 0; + + // A handle passed to the subchannel by the transport via + // OnPeerMaxConcurrentStreamsUpdate(). The subchannel must delete + // this handle when it has finished processing the update. + class MaxConcurrentStreamsUpdateDoneHandle { + public: + virtual ~MaxConcurrentStreamsUpdateDoneHandle() = default; + }; + + // Used on client transports only. + // Will be called once as soon as the watch is started to indicate + // the current value of the peer's MAX_CONCURRENT_STREAMS setting. + // Will then be called again whenever the peer changes this setting. + // The on_done handle must be deleted when the implementation is + // done processing the update. + virtual void OnPeerMaxConcurrentStreamsUpdate( + uint32_t max_concurrent_streams, + std::unique_ptr on_done) = 0; + + // TODO(roth): Remove this as part of the EventEngine migration. + virtual grpc_pollset_set* interested_parties() const = 0; + }; + struct RawPointerChannelArgTag {}; static absl::string_view ChannelArgName() { return GRPC_ARG_TRANSPORT; } @@ -547,6 +600,8 @@ class Transport : public InternallyRefCounted { // implementation of grpc_transport_perform_op virtual void PerformOp(grpc_transport_op* op) = 0; + // TODO(roth, ctiller): Migrate all callers to the new StartWatch() + // API and remove this. void StartConnectivityWatch( OrphanablePtr watcher) { grpc_transport_op* op = grpc_make_transport_op(nullptr); @@ -561,6 +616,9 @@ class Transport : public InternallyRefCounted { PerformOp(op); } + virtual void StartWatch(RefCountedPtr watcher) = 0; + virtual void StopWatch(RefCountedPtr watcher) = 0; + virtual RefCountedPtr GetSocketNode() const = 0; }; diff --git a/deps/grpc/src/core/lib/transport/transport_framing_endpoint_extension.h b/deps/grpc/src/core/lib/transport/transport_framing_endpoint_extension.h index fe46b4baf60..1ce8da29b9c 100644 --- a/deps/grpc/src/core/lib/transport/transport_framing_endpoint_extension.h +++ b/deps/grpc/src/core/lib/transport/transport_framing_endpoint_extension.h @@ -17,9 +17,9 @@ #include +#include "src/core/lib/slice/slice_buffer.h" #include "absl/functional/any_invocable.h" #include "absl/strings/string_view.h" -#include "src/core/lib/slice/slice_buffer.h" namespace grpc_core { diff --git a/deps/grpc/src/core/lib/transport/transport_op_string.cc b/deps/grpc/src/core/lib/transport/transport_op_string.cc index c1f4a07a020..87c52fca151 100644 --- a/deps/grpc/src/core/lib/transport/transport_op_string.cc +++ b/deps/grpc/src/core/lib/transport/transport_op_string.cc @@ -21,8 +21,6 @@ #include #include -#include "absl/strings/str_cat.h" -#include "absl/strings/str_format.h" #include "src/core/call/metadata_batch.h" #include "src/core/lib/channel/channel_fwd.h" #include "src/core/lib/slice/slice_buffer.h" @@ -30,6 +28,8 @@ #include "src/core/lib/transport/transport.h" #include "src/core/util/orphanable.h" #include "src/core/util/status_helper.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/str_format.h" // These routines are here to facilitate debugging - they produce string // representations of various transport data structures diff --git a/deps/grpc/src/core/load_balancing/address_filtering.cc b/deps/grpc/src/core/load_balancing/address_filtering.cc index 1a19cfca33a..ed5b1e0feb8 100644 --- a/deps/grpc/src/core/load_balancing/address_filtering.cc +++ b/deps/grpc/src/core/load_balancing/address_filtering.cc @@ -21,10 +21,10 @@ #include -#include "absl/functional/function_ref.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/iomgr/resolved_address.h" #include "src/core/util/ref_counted_ptr.h" +#include "absl/functional/function_ref.h" namespace grpc_core { diff --git a/deps/grpc/src/core/load_balancing/address_filtering.h b/deps/grpc/src/core/load_balancing/address_filtering.h index 31b45108285..f759243a615 100644 --- a/deps/grpc/src/core/load_balancing/address_filtering.h +++ b/deps/grpc/src/core/load_balancing/address_filtering.h @@ -24,11 +24,11 @@ #include #include -#include "absl/status/statusor.h" -#include "absl/strings/string_view.h" #include "src/core/resolver/endpoint_addresses.h" #include "src/core/util/ref_counted.h" #include "src/core/util/ref_counted_string.h" +#include "absl/status/statusor.h" +#include "absl/strings/string_view.h" // The resolver returns a flat list of addresses. When a hierarchy of // LB policies is in use, each leaf of the hierarchy will need a diff --git a/deps/grpc/src/core/load_balancing/backend_metric_parser.cc b/deps/grpc/src/core/load_balancing/backend_metric_parser.cc index 0ae2cc43b12..588b9c40154 100644 --- a/deps/grpc/src/core/load_balancing/backend_metric_parser.cc +++ b/deps/grpc/src/core/load_balancing/backend_metric_parser.cc @@ -21,11 +21,11 @@ #include -#include "absl/strings/string_view.h" #include "upb/base/string_view.h" #include "upb/mem/arena.hpp" #include "upb/message/map.h" #include "xds/data/orca/v3/orca_load_report.upb.h" +#include "absl/strings/string_view.h" namespace grpc_core { diff --git a/deps/grpc/src/core/load_balancing/backend_metric_parser.h b/deps/grpc/src/core/load_balancing/backend_metric_parser.h index c6bf0b08729..f7134b4ec23 100644 --- a/deps/grpc/src/core/load_balancing/backend_metric_parser.h +++ b/deps/grpc/src/core/load_balancing/backend_metric_parser.h @@ -20,8 +20,8 @@ #include #include -#include "absl/strings/string_view.h" #include "src/core/load_balancing/backend_metric_data.h" +#include "absl/strings/string_view.h" namespace grpc_core { diff --git a/deps/grpc/src/core/load_balancing/child_policy_handler.cc b/deps/grpc/src/core/load_balancing/child_policy_handler.cc index ed335e8d825..8d6bc468044 100644 --- a/deps/grpc/src/core/load_balancing/child_policy_handler.cc +++ b/deps/grpc/src/core/load_balancing/child_policy_handler.cc @@ -22,10 +22,6 @@ #include #include -#include "absl/log/log.h" -#include "absl/status/status.h" -#include "absl/strings/str_cat.h" -#include "absl/strings/string_view.h" #include "src/core/config/core_configuration.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/iomgr/pollset_set.h" @@ -36,6 +32,10 @@ #include "src/core/load_balancing/subchannel_interface.h" #include "src/core/util/debug_location.h" #include "src/core/util/grpc_check.h" +#include "absl/log/log.h" +#include "absl/status/status.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/string_view.h" namespace grpc_core { diff --git a/deps/grpc/src/core/load_balancing/child_policy_handler.h b/deps/grpc/src/core/load_balancing/child_policy_handler.h index e22da5cb322..64fd274d81b 100644 --- a/deps/grpc/src/core/load_balancing/child_policy_handler.h +++ b/deps/grpc/src/core/load_balancing/child_policy_handler.h @@ -20,13 +20,13 @@ #include -#include "absl/status/status.h" -#include "absl/strings/string_view.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/debug/trace.h" #include "src/core/load_balancing/lb_policy.h" #include "src/core/util/orphanable.h" #include "src/core/util/ref_counted_ptr.h" +#include "absl/status/status.h" +#include "absl/strings/string_view.h" namespace grpc_core { diff --git a/deps/grpc/src/core/load_balancing/delegating_helper.h b/deps/grpc/src/core/load_balancing/delegating_helper.h index e4e62cceb04..37179264c08 100644 --- a/deps/grpc/src/core/load_balancing/delegating_helper.h +++ b/deps/grpc/src/core/load_balancing/delegating_helper.h @@ -24,8 +24,6 @@ #include -#include "absl/status/status.h" -#include "absl/strings/string_view.h" #include "src/core/credentials/transport/transport_credentials.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/iomgr/resolved_address.h" @@ -33,6 +31,8 @@ #include "src/core/load_balancing/subchannel_interface.h" #include "src/core/util/debug_location.h" #include "src/core/util/ref_counted_ptr.h" +#include "absl/status/status.h" +#include "absl/strings/string_view.h" namespace grpc_core { diff --git a/deps/grpc/src/core/load_balancing/endpoint_list.cc b/deps/grpc/src/core/load_balancing/endpoint_list.cc index f9bea2dffa6..d523b0cd04c 100644 --- a/deps/grpc/src/core/load_balancing/endpoint_list.cc +++ b/deps/grpc/src/core/load_balancing/endpoint_list.cc @@ -26,10 +26,6 @@ #include #include -#include "absl/log/log.h" -#include "absl/random/random.h" -#include "absl/status/status.h" -#include "absl/status/statusor.h" #include "src/core/config/core_configuration.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/experiments/experiments.h" @@ -45,6 +41,10 @@ #include "src/core/util/orphanable.h" #include "src/core/util/ref_counted_ptr.h" #include "src/core/util/shared_bit_gen.h" +#include "absl/log/log.h" +#include "absl/random/random.h" +#include "absl/status/status.h" +#include "absl/status/statusor.h" namespace grpc_core { diff --git a/deps/grpc/src/core/load_balancing/endpoint_list.h b/deps/grpc/src/core/load_balancing/endpoint_list.h index d36c606c10f..6a6767b67fa 100644 --- a/deps/grpc/src/core/load_balancing/endpoint_list.h +++ b/deps/grpc/src/core/load_balancing/endpoint_list.h @@ -26,8 +26,6 @@ #include #include -#include "absl/functional/function_ref.h" -#include "absl/status/status.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/iomgr/resolved_address.h" #include "src/core/load_balancing/lb_policy.h" @@ -38,6 +36,8 @@ #include "src/core/util/orphanable.h" #include "src/core/util/ref_counted_ptr.h" #include "src/core/util/work_serializer.h" +#include "absl/functional/function_ref.h" +#include "absl/status/status.h" namespace grpc_core { diff --git a/deps/grpc/src/core/load_balancing/grpclb/client_load_reporting_filter.cc b/deps/grpc/src/core/load_balancing/grpclb/client_load_reporting_filter.cc index 1ebec3e8c1c..2dd2662bf03 100644 --- a/deps/grpc/src/core/load_balancing/grpclb/client_load_reporting_filter.cc +++ b/deps/grpc/src/core/load_balancing/grpclb/client_load_reporting_filter.cc @@ -52,12 +52,14 @@ void ClientLoadReportingFilter::Call::OnClientInitialMetadata( ClientMetadata& client_initial_metadata) { GRPC_LATENT_SEE_SCOPE( "ClientLoadReportingFilter::Call::OnClientInitialMetadata"); - // Handle client initial metadata. - // Grab client stats object from metadata. - auto client_stats_md = + // Grab client stats object from metadata. The metadata encodes only + // a raw pointer, but the LB policy will have returned a subchannel call + // tracker that is holding a ref to it, to ensure that it's alive here + // for us to take our own ref. + std::optional client_stats_md = client_initial_metadata.Take(GrpcLbClientStatsMetadata()); - if (client_stats_md.has_value()) { - client_stats_.reset(*client_stats_md); + if (client_stats_md.has_value() && *client_stats_md != nullptr) { + client_stats_ = (*client_stats_md)->Ref(); } } diff --git a/deps/grpc/src/core/load_balancing/grpclb/client_load_reporting_filter.h b/deps/grpc/src/core/load_balancing/grpclb/client_load_reporting_filter.h index 767cd24d8d8..7a697182559 100644 --- a/deps/grpc/src/core/load_balancing/grpclb/client_load_reporting_filter.h +++ b/deps/grpc/src/core/load_balancing/grpclb/client_load_reporting_filter.h @@ -21,13 +21,13 @@ #include -#include "absl/status/statusor.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/channel_fwd.h" #include "src/core/lib/channel/promise_based_filter.h" #include "src/core/lib/promise/arena_promise.h" #include "src/core/lib/transport/transport.h" #include "src/core/load_balancing/grpclb/grpclb_client_stats.h" +#include "absl/status/statusor.h" namespace grpc_core { @@ -47,6 +47,10 @@ class ClientLoadReportingFilter static inline const NoInterceptor OnClientToServerMessage; static inline const NoInterceptor OnClientToServerHalfClose; static inline const NoInterceptor OnFinalize; + channelz::PropertyList ChannelzProperties() { + return channelz::PropertyList().Set("saw_initial_metadata", + saw_initial_metadata_); + } private: RefCountedPtr client_stats_; diff --git a/deps/grpc/src/core/load_balancing/grpclb/grpclb.cc b/deps/grpc/src/core/load_balancing/grpclb/grpclb.cc index 45461ebea3d..a653ee4e719 100644 --- a/deps/grpc/src/core/load_balancing/grpclb/grpclb.cc +++ b/deps/grpc/src/core/load_balancing/grpclb/grpclb.cc @@ -80,16 +80,6 @@ #include #include -#include "absl/container/inlined_vector.h" -#include "absl/functional/function_ref.h" -#include "absl/log/globals.h" -#include "absl/log/log.h" -#include "absl/status/status.h" -#include "absl/status/statusor.h" -#include "absl/strings/str_cat.h" -#include "absl/strings/str_format.h" -#include "absl/strings/str_join.h" -#include "absl/strings/string_view.h" #include "src/core/call/metadata_batch.h" #include "src/core/channelz/channelz.h" #include "src/core/client_channel/client_channel_filter.h" @@ -141,6 +131,16 @@ #include "src/core/util/validation_errors.h" #include "src/core/util/work_serializer.h" #include "upb/mem/arena.hpp" +#include "absl/container/inlined_vector.h" +#include "absl/functional/function_ref.h" +#include "absl/log/globals.h" +#include "absl/log/log.h" +#include "absl/status/status.h" +#include "absl/status/statusor.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/str_format.h" +#include "absl/strings/str_join.h" +#include "absl/strings/string_view.h" #define GRPC_GRPCLB_INITIAL_CONNECT_BACKOFF_SECONDS 1 #define GRPC_GRPCLB_RECONNECT_BACKOFF_MULTIPLIER 1.6 @@ -417,10 +417,9 @@ class GrpcLb final : public LoadBalancingPolicy { PickResult Pick(PickArgs args) override; private: - // A subchannel call tracker that unrefs the GrpcLbClientStats object - // in the case where the subchannel call is never actually started, - // since the client load reporting filter will not be able to do it - // in that case. + // A subchannel call tracker that holds a ref to the + // GrpcLbClientStats object, to ensure that it still exists when the + // client load reporting filter sees it and takes its own ref to it. class SubchannelCallTracker final : public SubchannelCallTrackerInterface { public: SubchannelCallTracker( @@ -429,16 +428,6 @@ class GrpcLb final : public LoadBalancingPolicy { : client_stats_(std::move(client_stats)), original_call_tracker_(std::move(original_call_tracker)) {} - void Start() override { - if (original_call_tracker_ != nullptr) { - original_call_tracker_->Start(); - } - // If we're actually starting the subchannel call, then the - // client load reporting filter will take ownership of the ref - // passed down to it via metadata. - client_stats_.release(); - } - void Finish(FinishArgs args) override { if (original_call_tracker_ != nullptr) { original_call_tracker_->Finish(args); diff --git a/deps/grpc/src/core/load_balancing/grpclb/grpclb_client_stats.h b/deps/grpc/src/core/load_balancing/grpclb/grpclb_client_stats.h index 332f942fe52..6bd2309dabd 100644 --- a/deps/grpc/src/core/load_balancing/grpclb/grpclb_client_stats.h +++ b/deps/grpc/src/core/load_balancing/grpclb/grpclb_client_stats.h @@ -26,11 +26,11 @@ #include #include -#include "absl/base/thread_annotations.h" -#include "absl/container/inlined_vector.h" #include "src/core/util/memory.h" #include "src/core/util/ref_counted.h" #include "src/core/util/sync.h" +#include "absl/base/thread_annotations.h" +#include "absl/container/inlined_vector.h" namespace grpc_core { diff --git a/deps/grpc/src/core/load_balancing/grpclb/load_balancer_api.cc b/deps/grpc/src/core/load_balancing/grpclb/load_balancer_api.cc index 6fd1eafd9ff..124e4b741b3 100644 --- a/deps/grpc/src/core/load_balancing/grpclb/load_balancer_api.cc +++ b/deps/grpc/src/core/load_balancing/grpclb/load_balancer_api.cc @@ -24,12 +24,12 @@ #include -#include "absl/log/log.h" #include "google/protobuf/duration.upb.h" #include "google/protobuf/timestamp.upb.h" #include "src/core/util/memory.h" #include "src/proto/grpc/lb/v1/load_balancer.upb.h" #include "upb/base/string_view.h" +#include "absl/log/log.h" namespace grpc_core { diff --git a/deps/grpc/src/core/load_balancing/grpclb/load_balancer_api.h b/deps/grpc/src/core/load_balancing/grpclb/load_balancer_api.h index c2aa2db7713..89c8b647fa7 100644 --- a/deps/grpc/src/core/load_balancing/grpclb/load_balancer_api.h +++ b/deps/grpc/src/core/load_balancing/grpclb/load_balancer_api.h @@ -24,10 +24,10 @@ #include -#include "absl/strings/string_view.h" #include "src/core/load_balancing/grpclb/grpclb_client_stats.h" #include "src/core/util/time.h" #include "upb/mem/arena.h" +#include "absl/strings/string_view.h" #define GRPC_GRPCLB_SERVICE_NAME_MAX_LENGTH 128 #define GRPC_GRPCLB_SERVER_IP_ADDRESS_MAX_SIZE 16 diff --git a/deps/grpc/src/core/load_balancing/health_check_client.cc b/deps/grpc/src/core/load_balancing/health_check_client.cc index c84f6d0a489..936d1fb1ff9 100644 --- a/deps/grpc/src/core/load_balancing/health_check_client.cc +++ b/deps/grpc/src/core/load_balancing/health_check_client.cc @@ -30,11 +30,6 @@ #include #include -#include "absl/log/log.h" -#include "absl/status/status.h" -#include "absl/status/statusor.h" -#include "absl/strings/str_cat.h" -#include "absl/strings/string_view.h" #include "src/core/channelz/channel_trace.h" #include "src/core/client_channel/client_channel_internal.h" #include "src/core/client_channel/subchannel.h" @@ -60,6 +55,11 @@ #include "src/proto/grpc/health/v1/health.upb.h" #include "upb/base/string_view.h" #include "upb/mem/arena.hpp" +#include "absl/log/log.h" +#include "absl/status/status.h" +#include "absl/status/statusor.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/string_view.h" namespace grpc_core { @@ -283,6 +283,10 @@ class HealthProducer::ConnectivityWatcher final producer_->OnConnectivityStateChange(state, status); } + void OnKeepaliveUpdate(Duration) override {} + + uint32_t max_connections_per_subchannel() const override { return 1; } + grpc_pollset_set* interested_parties() override { return producer_->interested_parties_; } diff --git a/deps/grpc/src/core/load_balancing/health_check_client_internal.h b/deps/grpc/src/core/load_balancing/health_check_client_internal.h index 6af55368c4f..737b6e03405 100644 --- a/deps/grpc/src/core/load_balancing/health_check_client_internal.h +++ b/deps/grpc/src/core/load_balancing/health_check_client_internal.h @@ -27,9 +27,6 @@ #include #include -#include "absl/base/thread_annotations.h" -#include "absl/status/status.h" -#include "absl/strings/string_view.h" #include "src/core/client_channel/subchannel.h" #include "src/core/client_channel/subchannel_interface_internal.h" #include "src/core/client_channel/subchannel_stream_client.h" @@ -41,6 +38,9 @@ #include "src/core/util/sync.h" #include "src/core/util/unique_type_name.h" #include "src/core/util/work_serializer.h" +#include "absl/base/thread_annotations.h" +#include "absl/status/status.h" +#include "absl/strings/string_view.h" namespace grpc_core { diff --git a/deps/grpc/src/core/load_balancing/lb_policy.h b/deps/grpc/src/core/load_balancing/lb_policy.h index 1d0af696758..aee22e258f4 100644 --- a/deps/grpc/src/core/load_balancing/lb_policy.h +++ b/deps/grpc/src/core/load_balancing/lb_policy.h @@ -31,11 +31,6 @@ #include #include -#include "absl/base/thread_annotations.h" -#include "absl/container/inlined_vector.h" -#include "absl/status/status.h" -#include "absl/status/statusor.h" -#include "absl/strings/string_view.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/debug/trace.h" #include "src/core/lib/iomgr/iomgr_fwd.h" @@ -51,6 +46,11 @@ #include "src/core/util/ref_counted_ptr.h" #include "src/core/util/sync.h" #include "src/core/util/work_serializer.h" +#include "absl/base/thread_annotations.h" +#include "absl/container/inlined_vector.h" +#include "absl/status/status.h" +#include "absl/status/statusor.h" +#include "absl/strings/string_view.h" namespace grpc_core { @@ -178,13 +178,16 @@ class LoadBalancingPolicy : public InternallyRefCounted { public: virtual ~SubchannelCallTrackerInterface() = default; - /// Called when a subchannel call is started after an LB pick. - virtual void Start() = 0; - /// Called when a subchannel call is completed. /// The metadata may be modified by the implementation. However, the /// implementation does not take ownership, so any data that needs to be /// used after returning must be copied. + /// + /// Note that when the picker returns a complete pick, it's possible + /// that the returned subchannel has already lost its connection, in + /// which case the channel will queue the pick. In that case, + /// the SubchannelCallTrackerInterface object will be destroyed + /// without ever calling Finish(). struct FinishArgs { absl::string_view peer_address; absl::Status status; diff --git a/deps/grpc/src/core/load_balancing/lb_policy_factory.h b/deps/grpc/src/core/load_balancing/lb_policy_factory.h index c8b710b1247..d1855a45318 100644 --- a/deps/grpc/src/core/load_balancing/lb_policy_factory.h +++ b/deps/grpc/src/core/load_balancing/lb_policy_factory.h @@ -19,12 +19,12 @@ #include -#include "absl/status/statusor.h" -#include "absl/strings/string_view.h" #include "src/core/load_balancing/lb_policy.h" #include "src/core/util/json/json.h" #include "src/core/util/orphanable.h" #include "src/core/util/ref_counted_ptr.h" +#include "absl/status/statusor.h" +#include "absl/strings/string_view.h" namespace grpc_core { diff --git a/deps/grpc/src/core/load_balancing/lb_policy_registry.cc b/deps/grpc/src/core/load_balancing/lb_policy_registry.cc index cd1e9b38e79..2c3c7ba1af3 100644 --- a/deps/grpc/src/core/load_balancing/lb_policy_registry.cc +++ b/deps/grpc/src/core/load_balancing/lb_policy_registry.cc @@ -25,14 +25,14 @@ #include #include +#include "src/core/load_balancing/lb_policy.h" +#include "src/core/util/grpc_check.h" #include "absl/log/log.h" #include "absl/status/status.h" #include "absl/strings/str_cat.h" #include "absl/strings/str_format.h" #include "absl/strings/str_join.h" #include "absl/strings/string_view.h" -#include "src/core/load_balancing/lb_policy.h" -#include "src/core/util/grpc_check.h" namespace grpc_core { diff --git a/deps/grpc/src/core/load_balancing/lb_policy_registry.h b/deps/grpc/src/core/load_balancing/lb_policy_registry.h index 86bc7ccd2eb..0304f04bbf6 100644 --- a/deps/grpc/src/core/load_balancing/lb_policy_registry.h +++ b/deps/grpc/src/core/load_balancing/lb_policy_registry.h @@ -22,13 +22,13 @@ #include #include -#include "absl/status/statusor.h" -#include "absl/strings/string_view.h" #include "src/core/load_balancing/lb_policy.h" #include "src/core/load_balancing/lb_policy_factory.h" #include "src/core/util/json/json.h" #include "src/core/util/orphanable.h" #include "src/core/util/ref_counted_ptr.h" +#include "absl/status/statusor.h" +#include "absl/strings/string_view.h" namespace grpc_core { diff --git a/deps/grpc/src/core/load_balancing/oob_backend_metric.cc b/deps/grpc/src/core/load_balancing/oob_backend_metric.cc index 7a65aa521f5..e3866f16f6f 100644 --- a/deps/grpc/src/core/load_balancing/oob_backend_metric.cc +++ b/deps/grpc/src/core/load_balancing/oob_backend_metric.cc @@ -29,9 +29,6 @@ #include #include -#include "absl/log/log.h" -#include "absl/status/status.h" -#include "absl/strings/string_view.h" #include "google/protobuf/duration.upb.h" #include "src/core/channelz/channel_trace.h" #include "src/core/client_channel/subchannel.h" @@ -54,6 +51,9 @@ #include "src/core/util/time.h" #include "upb/mem/arena.hpp" #include "xds/service/orca/v3/orca.upb.h" +#include "absl/log/log.h" +#include "absl/status/status.h" +#include "absl/strings/string_view.h" namespace grpc_core { @@ -77,6 +77,10 @@ class OrcaProducer::ConnectivityWatcher final producer_->OnConnectivityStateChange(state); } + void OnKeepaliveUpdate(Duration) override {} + + uint32_t max_connections_per_subchannel() const override { return 1; } + grpc_pollset_set* interested_parties() override { return interested_parties_; } diff --git a/deps/grpc/src/core/load_balancing/oob_backend_metric_internal.h b/deps/grpc/src/core/load_balancing/oob_backend_metric_internal.h index b5e61180cc5..d2af2d2aa97 100644 --- a/deps/grpc/src/core/load_balancing/oob_backend_metric_internal.h +++ b/deps/grpc/src/core/load_balancing/oob_backend_metric_internal.h @@ -24,8 +24,6 @@ #include #include -#include "absl/base/thread_annotations.h" -#include "absl/strings/string_view.h" #include "src/core/client_channel/subchannel.h" #include "src/core/client_channel/subchannel_interface_internal.h" #include "src/core/client_channel/subchannel_stream_client.h" @@ -36,6 +34,8 @@ #include "src/core/util/sync.h" #include "src/core/util/time.h" #include "src/core/util/unique_type_name.h" +#include "absl/base/thread_annotations.h" +#include "absl/strings/string_view.h" namespace grpc_core { diff --git a/deps/grpc/src/core/load_balancing/outlier_detection/outlier_detection.cc b/deps/grpc/src/core/load_balancing/outlier_detection/outlier_detection.cc index dc5d5ec4b1f..28e387b240e 100644 --- a/deps/grpc/src/core/load_balancing/outlier_detection/outlier_detection.cc +++ b/deps/grpc/src/core/load_balancing/outlier_detection/outlier_detection.cc @@ -34,13 +34,6 @@ #include #include -#include "absl/base/thread_annotations.h" -#include "absl/log/log.h" -#include "absl/meta/type_traits.h" -#include "absl/random/random.h" -#include "absl/status/status.h" -#include "absl/status/statusor.h" -#include "absl/strings/string_view.h" #include "src/core/client_channel/subchannel_interface_internal.h" #include "src/core/config/core_configuration.h" #include "src/core/lib/address_utils/sockaddr_utils.h" @@ -71,6 +64,13 @@ #include "src/core/util/unique_type_name.h" #include "src/core/util/validation_errors.h" #include "src/core/util/work_serializer.h" +#include "absl/base/thread_annotations.h" +#include "absl/log/log.h" +#include "absl/meta/type_traits.h" +#include "absl/random/random.h" +#include "absl/status/status.h" +#include "absl/status/statusor.h" +#include "absl/strings/string_view.h" namespace grpc_core { @@ -493,14 +493,6 @@ class OutlierDetectionLb::Picker::SubchannelCallTracker final endpoint_state_.reset(DEBUG_LOCATION, "SubchannelCallTracker"); } - void Start() override { - // This tracker does not care about started calls only finished calls. - // Delegate if needed. - if (original_subchannel_call_tracker_ != nullptr) { - original_subchannel_call_tracker_->Start(); - } - } - void Finish(FinishArgs args) override { // Delegate if needed. if (original_subchannel_call_tracker_ != nullptr) { diff --git a/deps/grpc/src/core/load_balancing/pick_first/pick_first.cc b/deps/grpc/src/core/load_balancing/pick_first/pick_first.cc index 3580c7d0583..8bb5adbb155 100644 --- a/deps/grpc/src/core/load_balancing/pick_first/pick_first.cc +++ b/deps/grpc/src/core/load_balancing/pick_first/pick_first.cc @@ -31,13 +31,6 @@ #include #include -#include "absl/algorithm/container.h" -#include "absl/log/log.h" -#include "absl/random/random.h" -#include "absl/status/status.h" -#include "absl/status/statusor.h" -#include "absl/strings/str_cat.h" -#include "absl/strings/string_view.h" #include "src/core/config/core_configuration.h" #include "src/core/lib/address_utils/sockaddr_utils.h" #include "src/core/lib/channel/channel_args.h" @@ -65,6 +58,13 @@ #include "src/core/util/time.h" #include "src/core/util/useful.h" #include "src/core/util/work_serializer.h" +#include "absl/algorithm/container.h" +#include "absl/log/log.h" +#include "absl/random/random.h" +#include "absl/status/status.h" +#include "absl/status/statusor.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/string_view.h" namespace grpc_core { @@ -390,13 +390,16 @@ class PickFirst final : public LoadBalancingPolicy { // Lateset update args. UpdateArgs latest_update_args_; // The list of subchannels that we're currently trying to connect to. - // Will generally be null when selected_ is set, except when we get a - // resolver update and need to check initial connectivity states for - // the new list to decide whether we keep using the existing - // connection or go IDLE. + // Will generally be null when selected_ is set, except for two cases: + // - When we get a resolver update and need to check initial connectivity + // states for the new list to decide whether we keep using the existing + // connection or go IDLE. + // - When the selected subchannel transitions from READY to CONNECTING + // or TRANSIENT_FAILURE (instead of IDLE), in which case we create a + // new subchannel list and start connecting with a Happy Eyeballs pass. OrphanablePtr subchannel_list_; // Selected subchannel. Will generally be null when subchannel_list_ - // is non-null, with the exception mentioned above. + // is non-null, with the exceptions mentioned above. OrphanablePtr selected_; // Health watcher for the selected subchannel. SubchannelInterface::ConnectivityStateWatcherInterface* health_watcher_ = @@ -612,10 +615,12 @@ void PickFirst::GoIdle() { UnsetSelectedSubchannel(); // Drop the current subchannel list, if any. subchannel_list_.reset(); - // Request a re-resolution. - // TODO(qianchengz): We may want to request re-resolution in - // ExitIdleLocked() instead. - channel_control_helper()->RequestReresolution(); + if (!IsPickFirstReadyToConnectingEnabled()) { + // Request a re-resolution. + // TODO(roth): We may want to request re-resolution in + // ExitIdleLocked() instead. + channel_control_helper()->RequestReresolution(); + } // Enter idle. UpdateState(GRPC_CHANNEL_IDLE, absl::OkStatus(), MakeRefCounted(Ref(DEBUG_LOCATION, "QueuePicker"))); @@ -780,8 +785,33 @@ void PickFirst::SubchannelList::SubchannelData::SubchannelState:: stats_plugins.AddCounter(kMetricDisconnections, 1, {pick_first_->channel_control_helper()->GetTarget()}, {}); - // Report IDLE. - pick_first_->GoIdle(); + if (IsPickFirstReadyToConnectingEnabled()) { + // TODO(roth): We may want to request re-resolution in + // ExitIdleLocked() instead, at least if we go IDLE below. + pick_first_->channel_control_helper()->RequestReresolution(); + } + // If the subchannel went to CONNECTING or TRANSIENT_FAILURE, we go + // back to CONNECTING and start a new Happy Eyeballs pass. + // Otherwise, go IDLE. + if (IsPickFirstReadyToConnectingEnabled() && + (new_state == GRPC_CHANNEL_CONNECTING || + new_state == GRPC_CHANNEL_TRANSIENT_FAILURE)) { + pick_first_->UpdateState(GRPC_CHANNEL_CONNECTING, absl::OkStatus(), + MakeRefCounted(nullptr)); + pick_first_->AttemptToConnectUsingLatestUpdateArgsLocked(); + // Unset the selected subchannel, so that when we see the initial + // connectivity state notifications for the subchannels in the new + // subchannel list, we don't think it was caused by a resolver + // update and go IDLE if none of the subchannels report READY. + // + // Note that we do this *after* creating the new subchannel list, + // which will have taken a new ref to the originally selected + // subchannel. This ensures that we don't destroy and recreate the + // subchannel, thus preserving the backoff state inside the subchannel. + pick_first_->UnsetSelectedSubchannel(); + } else { + pick_first_->GoIdle(); + } } // diff --git a/deps/grpc/src/core/load_balancing/priority/priority.cc b/deps/grpc/src/core/load_balancing/priority/priority.cc index b2a7e7dfd81..59cc29074b3 100644 --- a/deps/grpc/src/core/load_balancing/priority/priority.cc +++ b/deps/grpc/src/core/load_balancing/priority/priority.cc @@ -30,12 +30,6 @@ #include #include -#include "absl/log/log.h" -#include "absl/status/status.h" -#include "absl/status/statusor.h" -#include "absl/strings/str_cat.h" -#include "absl/strings/str_join.h" -#include "absl/strings/string_view.h" #include "src/core/config/core_configuration.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/debug/trace.h" @@ -60,6 +54,12 @@ #include "src/core/util/time.h" #include "src/core/util/validation_errors.h" #include "src/core/util/work_serializer.h" +#include "absl/log/log.h" +#include "absl/status/status.h" +#include "absl/status/statusor.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/str_join.h" +#include "absl/strings/string_view.h" namespace grpc_core { diff --git a/deps/grpc/src/core/load_balancing/ring_hash/ring_hash.cc b/deps/grpc/src/core/load_balancing/ring_hash/ring_hash.cc index 9a380e6948b..a3abf89d0f7 100644 --- a/deps/grpc/src/core/load_balancing/ring_hash/ring_hash.cc +++ b/deps/grpc/src/core/load_balancing/ring_hash/ring_hash.cc @@ -32,14 +32,6 @@ #include #include -#include "absl/base/attributes.h" -#include "absl/container/inlined_vector.h" -#include "absl/log/log.h" -#include "absl/random/random.h" -#include "absl/status/status.h" -#include "absl/status/statusor.h" -#include "absl/strings/str_cat.h" -#include "absl/strings/string_view.h" #include "src/core/client_channel/client_channel_internal.h" #include "src/core/config/core_configuration.h" #include "src/core/lib/address_utils/sockaddr_utils.h" @@ -69,6 +61,14 @@ #include "src/core/util/unique_type_name.h" #include "src/core/util/work_serializer.h" #include "src/core/util/xxhash_inline.h" +#include "absl/base/attributes.h" +#include "absl/container/inlined_vector.h" +#include "absl/log/log.h" +#include "absl/random/random.h" +#include "absl/status/status.h" +#include "absl/status/statusor.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/string_view.h" namespace grpc_core { diff --git a/deps/grpc/src/core/load_balancing/rls/rls.cc b/deps/grpc/src/core/load_balancing/rls/rls.cc index 1901226498a..394de22fc83 100644 --- a/deps/grpc/src/core/load_balancing/rls/rls.cc +++ b/deps/grpc/src/core/load_balancing/rls/rls.cc @@ -51,16 +51,6 @@ #include #include -#include "absl/base/thread_annotations.h" -#include "absl/hash/hash.h" -#include "absl/log/log.h" -#include "absl/random/random.h" -#include "absl/status/status.h" -#include "absl/status/statusor.h" -#include "absl/strings/str_cat.h" -#include "absl/strings/str_format.h" -#include "absl/strings/str_join.h" -#include "absl/strings/string_view.h" #include "src/core/channelz/channelz.h" #include "src/core/client_channel/client_channel_filter.h" #include "src/core/config/core_configuration.h" @@ -108,6 +98,16 @@ #include "src/proto/grpc/lookup/v1/rls.upb.h" #include "upb/base/string_view.h" #include "upb/mem/arena.hpp" +#include "absl/base/thread_annotations.h" +#include "absl/hash/hash.h" +#include "absl/log/log.h" +#include "absl/random/random.h" +#include "absl/status/status.h" +#include "absl/status/statusor.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/str_format.h" +#include "absl/strings/str_join.h" +#include "absl/strings/string_view.h" using ::grpc_event_engine::experimental::EventEngine; diff --git a/deps/grpc/src/core/load_balancing/round_robin/round_robin.cc b/deps/grpc/src/core/load_balancing/round_robin/round_robin.cc index 1883664d778..b03a808a949 100644 --- a/deps/grpc/src/core/load_balancing/round_robin/round_robin.cc +++ b/deps/grpc/src/core/load_balancing/round_robin/round_robin.cc @@ -27,13 +27,6 @@ #include #include -#include "absl/log/log.h" -#include "absl/meta/type_traits.h" -#include "absl/random/random.h" -#include "absl/status/status.h" -#include "absl/status/statusor.h" -#include "absl/strings/str_cat.h" -#include "absl/strings/string_view.h" #include "src/core/config/core_configuration.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/debug/trace.h" @@ -49,6 +42,13 @@ #include "src/core/util/ref_counted_ptr.h" #include "src/core/util/shared_bit_gen.h" #include "src/core/util/work_serializer.h" +#include "absl/log/log.h" +#include "absl/meta/type_traits.h" +#include "absl/random/random.h" +#include "absl/status/status.h" +#include "absl/status/statusor.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/string_view.h" namespace grpc_core { diff --git a/deps/grpc/src/core/load_balancing/subchannel_interface.h b/deps/grpc/src/core/load_balancing/subchannel_interface.h index 0042a9f0ea2..4af6ffb0efd 100644 --- a/deps/grpc/src/core/load_balancing/subchannel_interface.h +++ b/deps/grpc/src/core/load_balancing/subchannel_interface.h @@ -23,11 +23,11 @@ #include #include -#include "absl/status/status.h" -#include "absl/strings/string_view.h" #include "src/core/lib/iomgr/iomgr_fwd.h" #include "src/core/util/dual_ref_counted.h" #include "src/core/util/ref_counted_ptr.h" +#include "absl/status/status.h" +#include "absl/strings/string_view.h" namespace grpc_core { diff --git a/deps/grpc/src/core/load_balancing/weighted_round_robin/static_stride_scheduler.cc b/deps/grpc/src/core/load_balancing/weighted_round_robin/static_stride_scheduler.cc index 13d2ea42d83..78f29fabadd 100644 --- a/deps/grpc/src/core/load_balancing/weighted_round_robin/static_stride_scheduler.cc +++ b/deps/grpc/src/core/load_balancing/weighted_round_robin/static_stride_scheduler.cc @@ -24,8 +24,8 @@ #include #include -#include "absl/functional/any_invocable.h" #include "src/core/util/grpc_check.h" +#include "absl/functional/any_invocable.h" namespace grpc_core { diff --git a/deps/grpc/src/core/load_balancing/weighted_round_robin/weighted_round_robin.cc b/deps/grpc/src/core/load_balancing/weighted_round_robin/weighted_round_robin.cc index f5ba756b199..28227e430e1 100644 --- a/deps/grpc/src/core/load_balancing/weighted_round_robin/weighted_round_robin.cc +++ b/deps/grpc/src/core/load_balancing/weighted_round_robin/weighted_round_robin.cc @@ -32,15 +32,6 @@ #include #include -#include "absl/base/thread_annotations.h" -#include "absl/log/log.h" -#include "absl/meta/type_traits.h" -#include "absl/random/random.h" -#include "absl/status/status.h" -#include "absl/status/statusor.h" -#include "absl/strings/str_cat.h" -#include "absl/strings/str_join.h" -#include "absl/strings/string_view.h" #include "src/core/config/core_configuration.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/debug/trace.h" @@ -73,6 +64,15 @@ #include "src/core/util/time.h" #include "src/core/util/validation_errors.h" #include "src/core/util/work_serializer.h" +#include "absl/base/thread_annotations.h" +#include "absl/log/log.h" +#include "absl/meta/type_traits.h" +#include "absl/random/random.h" +#include "absl/status/status.h" +#include "absl/status/statusor.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/str_join.h" +#include "absl/strings/string_view.h" namespace grpc_core { @@ -347,8 +347,6 @@ class WeightedRoundRobin final : public LoadBalancingPolicy { error_utilization_penalty_(error_utilization_penalty), child_tracker_(std::move(child_tracker)) {} - void Start() override; - void Finish(FinishArgs args) override; private: @@ -511,10 +509,6 @@ void WeightedRoundRobin::EndpointWeight::ResetNonEmptySince() { // WeightedRoundRobin::Picker::SubchannelCallTracker // -void WeightedRoundRobin::Picker::SubchannelCallTracker::Start() { - if (child_tracker_ != nullptr) child_tracker_->Start(); -} - void WeightedRoundRobin::Picker::SubchannelCallTracker::Finish( FinishArgs args) { if (child_tracker_ != nullptr) child_tracker_->Finish(args); diff --git a/deps/grpc/src/core/load_balancing/weighted_target/weighted_target.cc b/deps/grpc/src/core/load_balancing/weighted_target/weighted_target.cc index bf82bfdefb7..8234cef354c 100644 --- a/deps/grpc/src/core/load_balancing/weighted_target/weighted_target.cc +++ b/deps/grpc/src/core/load_balancing/weighted_target/weighted_target.cc @@ -30,15 +30,6 @@ #include #include -#include "absl/base/thread_annotations.h" -#include "absl/log/log.h" -#include "absl/meta/type_traits.h" -#include "absl/random/random.h" -#include "absl/status/status.h" -#include "absl/status/statusor.h" -#include "absl/strings/str_cat.h" -#include "absl/strings/str_join.h" -#include "absl/strings/string_view.h" #include "src/core/config/core_configuration.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/debug/trace.h" @@ -64,6 +55,15 @@ #include "src/core/util/time.h" #include "src/core/util/validation_errors.h" #include "src/core/util/work_serializer.h" +#include "absl/base/thread_annotations.h" +#include "absl/log/log.h" +#include "absl/meta/type_traits.h" +#include "absl/random/random.h" +#include "absl/status/status.h" +#include "absl/status/statusor.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/str_join.h" +#include "absl/strings/string_view.h" // IWYU pragma: no_include diff --git a/deps/grpc/src/core/load_balancing/xds/cds.cc b/deps/grpc/src/core/load_balancing/xds/cds.cc index 09a994cb74f..016800338e8 100644 --- a/deps/grpc/src/core/load_balancing/xds/cds.cc +++ b/deps/grpc/src/core/load_balancing/xds/cds.cc @@ -30,11 +30,6 @@ #include #include -#include "absl/log/log.h" -#include "absl/status/status.h" -#include "absl/status/statusor.h" -#include "absl/strings/str_cat.h" -#include "absl/strings/string_view.h" #include "src/core/client_channel/client_channel_internal.h" #include "src/core/config/core_configuration.h" #include "src/core/lib/channel/channel_args.h" @@ -64,6 +59,11 @@ #include "src/core/xds/grpc/xds_cluster.h" #include "src/core/xds/grpc/xds_common_types.h" #include "src/core/xds/grpc/xds_health_status.h" +#include "absl/log/log.h" +#include "absl/status/status.h" +#include "absl/status/statusor.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/string_view.h" namespace grpc_core { diff --git a/deps/grpc/src/core/load_balancing/xds/xds_cluster_impl.cc b/deps/grpc/src/core/load_balancing/xds/xds_cluster_impl.cc index bbf953c0631..8107bdb0bca 100644 --- a/deps/grpc/src/core/load_balancing/xds/xds_cluster_impl.cc +++ b/deps/grpc/src/core/load_balancing/xds/xds_cluster_impl.cc @@ -28,12 +28,6 @@ #include #include -#include "absl/base/thread_annotations.h" -#include "absl/log/log.h" -#include "absl/status/status.h" -#include "absl/status/statusor.h" -#include "absl/strings/str_cat.h" -#include "absl/strings/string_view.h" #include "src/core/client_channel/client_channel_internal.h" #include "src/core/config/core_configuration.h" #include "src/core/credentials/transport/xds/xds_credentials.h" @@ -72,6 +66,12 @@ #include "src/core/xds/xds_client/xds_bootstrap.h" #include "src/core/xds/xds_client/xds_client.h" #include "src/core/xds/xds_client/xds_locality.h" +#include "absl/base/thread_annotations.h" +#include "absl/log/log.h" +#include "absl/status/status.h" +#include "absl/status/statusor.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/string_view.h" namespace grpc_core { @@ -330,55 +330,35 @@ class XdsClusterImplLb::Picker::SubchannelCallTracker final call_counter_(std::move(call_counter)) {} ~SubchannelCallTracker() override { - locality_stats_.reset(DEBUG_LOCATION, "SubchannelCallTracker"); - call_counter_.reset(DEBUG_LOCATION, "SubchannelCallTracker"); -#ifndef NDEBUG - GRPC_DCHECK(!started_); -#endif - } - - void Start() override { - // Increment number of calls in flight. - call_counter_->Increment(); - // Record a call started. - if (locality_stats_ != nullptr) { - locality_stats_->AddCallStarted(); - } - // Delegate if needed. - if (original_subchannel_call_tracker_ != nullptr) { - original_subchannel_call_tracker_->Start(); - } -#ifndef NDEBUG - started_ = true; -#endif + MaybeFinish(/*succeeded=*/false, /*backend_metrics=*/nullptr); } void Finish(FinishArgs args) override { - // Delegate if needed. if (original_subchannel_call_tracker_ != nullptr) { original_subchannel_call_tracker_->Finish(args); } + MaybeFinish(/*succeeded=*/args.status.ok(), + args.backend_metric_accessor->GetBackendMetricData()); + } + + private: + void MaybeFinish(bool succeeded, const BackendMetricData* backend_metrics) { // Record call completion for load reporting. if (locality_stats_ != nullptr) { - locality_stats_->AddCallFinished( - args.backend_metric_accessor->GetBackendMetricData(), - !args.status.ok()); + locality_stats_->AddCallFinished(backend_metrics, /*fail=*/!succeeded); + locality_stats_.reset(DEBUG_LOCATION, "SubchannelCallTracker"); } // Decrement number of calls in flight. - call_counter_->Decrement(); -#ifndef NDEBUG - started_ = false; -#endif + if (call_counter_ != nullptr) { + call_counter_->Decrement(); + call_counter_.reset(DEBUG_LOCATION, "SubchannelCallTracker"); + } } - private: std::unique_ptr original_subchannel_call_tracker_; RefCountedPtr locality_stats_; RefCountedPtr call_counter_; -#ifndef NDEBUG - bool started_ = false; -#endif }; // @@ -449,11 +429,14 @@ LoadBalancingPolicy::PickResult XdsClusterImplLb::Picker::Pick( kLocality, subchannel_wrapper->locality()); } + // Increment number of calls in flight. + call_counter_->Increment(); // Handle load reporting. RefCountedPtr locality_stats; if (subchannel_wrapper->locality_stats() != nullptr) { locality_stats = subchannel_wrapper->locality_stats()->Ref( DEBUG_LOCATION, "SubchannelCallTracker"); + locality_stats->AddCallStarted(); } // Handle authority rewriting if needed. if (!subchannel_wrapper->hostname().empty()) { diff --git a/deps/grpc/src/core/load_balancing/xds/xds_cluster_manager.cc b/deps/grpc/src/core/load_balancing/xds/xds_cluster_manager.cc index 5f91209fe89..4332e7a6b7b 100644 --- a/deps/grpc/src/core/load_balancing/xds/xds_cluster_manager.cc +++ b/deps/grpc/src/core/load_balancing/xds/xds_cluster_manager.cc @@ -29,12 +29,6 @@ #include #include -#include "absl/log/log.h" -#include "absl/status/status.h" -#include "absl/status/statusor.h" -#include "absl/strings/str_cat.h" -#include "absl/strings/str_join.h" -#include "absl/strings/string_view.h" #include "src/core/client_channel/client_channel_internal.h" #include "src/core/config/core_configuration.h" #include "src/core/lib/channel/channel_args.h" @@ -58,6 +52,12 @@ #include "src/core/util/time.h" #include "src/core/util/validation_errors.h" #include "src/core/util/work_serializer.h" +#include "absl/log/log.h" +#include "absl/status/status.h" +#include "absl/status/statusor.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/str_join.h" +#include "absl/strings/string_view.h" namespace grpc_core { diff --git a/deps/grpc/src/core/load_balancing/xds/xds_override_host.cc b/deps/grpc/src/core/load_balancing/xds/xds_override_host.cc index 1e0c61381d4..f56d5096bc8 100644 --- a/deps/grpc/src/core/load_balancing/xds/xds_override_host.cc +++ b/deps/grpc/src/core/load_balancing/xds/xds_override_host.cc @@ -34,16 +34,6 @@ #include #include -#include "absl/base/thread_annotations.h" -#include "absl/functional/function_ref.h" -#include "absl/log/log.h" -#include "absl/status/status.h" -#include "absl/status/statusor.h" -#include "absl/strings/str_cat.h" -#include "absl/strings/str_join.h" -#include "absl/strings/str_split.h" -#include "absl/strings/string_view.h" -#include "absl/types/span.h" #include "src/core/client_channel/client_channel_internal.h" #include "src/core/config/core_configuration.h" #include "src/core/ext/filters/stateful_session/stateful_session_filter.h" @@ -80,6 +70,16 @@ #include "src/core/util/validation_errors.h" #include "src/core/util/work_serializer.h" #include "src/core/xds/grpc/xds_health_status.h" +#include "absl/base/thread_annotations.h" +#include "absl/functional/function_ref.h" +#include "absl/log/log.h" +#include "absl/status/status.h" +#include "absl/status/statusor.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/str_join.h" +#include "absl/strings/str_split.h" +#include "absl/strings/string_view.h" +#include "absl/types/span.h" namespace grpc_core { diff --git a/deps/grpc/src/core/load_balancing/xds/xds_override_host.h b/deps/grpc/src/core/load_balancing/xds/xds_override_host.h index 55317bd4756..22b1eea7d3e 100644 --- a/deps/grpc/src/core/load_balancing/xds/xds_override_host.h +++ b/deps/grpc/src/core/load_balancing/xds/xds_override_host.h @@ -19,13 +19,13 @@ #include -#include "absl/strings/string_view.h" #include "src/core/load_balancing/lb_policy.h" #include "src/core/util/json/json.h" #include "src/core/util/json/json_args.h" #include "src/core/util/json/json_object_loader.h" #include "src/core/util/ref_counted_ptr.h" #include "src/core/util/validation_errors.h" +#include "absl/strings/string_view.h" namespace grpc_core { diff --git a/deps/grpc/src/core/load_balancing/xds/xds_wrr_locality.cc b/deps/grpc/src/core/load_balancing/xds/xds_wrr_locality.cc index 25c4f95fdb5..100b4765a53 100644 --- a/deps/grpc/src/core/load_balancing/xds/xds_wrr_locality.cc +++ b/deps/grpc/src/core/load_balancing/xds/xds_wrr_locality.cc @@ -25,11 +25,6 @@ #include #include -#include "absl/log/log.h" -#include "absl/status/status.h" -#include "absl/status/statusor.h" -#include "absl/strings/str_cat.h" -#include "absl/strings/string_view.h" #include "src/core/config/core_configuration.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/debug/trace.h" @@ -50,6 +45,11 @@ #include "src/core/util/ref_counted_string.h" #include "src/core/util/validation_errors.h" #include "src/core/xds/xds_client/xds_locality.h" +#include "absl/log/log.h" +#include "absl/status/status.h" +#include "absl/status/statusor.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/string_view.h" namespace grpc_core { diff --git a/deps/grpc/src/core/resolver/dns/c_ares/dns_resolver_ares.cc b/deps/grpc/src/core/resolver/dns/c_ares/dns_resolver_ares.cc index 8e1ab42584b..55c740381e6 100644 --- a/deps/grpc/src/core/resolver/dns/c_ares/dns_resolver_ares.cc +++ b/deps/grpc/src/core/resolver/dns/c_ares/dns_resolver_ares.cc @@ -27,13 +27,6 @@ #include #include -#include "absl/base/thread_annotations.h" -#include "absl/log/log.h" -#include "absl/status/status.h" -#include "absl/status/statusor.h" -#include "absl/strings/match.h" -#include "absl/strings/string_view.h" -#include "absl/strings/strip.h" #include "src/core/config/core_configuration.h" #include "src/core/lib/debug/trace.h" #include "src/core/lib/iomgr/closure.h" @@ -52,12 +45,18 @@ #include "src/core/util/sync.h" #include "src/core/util/time.h" #include "src/core/util/uri.h" +#include "absl/base/thread_annotations.h" +#include "absl/log/log.h" +#include "absl/status/status.h" +#include "absl/status/statusor.h" +#include "absl/strings/match.h" +#include "absl/strings/string_view.h" +#include "absl/strings/strip.h" #if GRPC_ARES == 1 #include -#include "absl/strings/str_cat.h" #include "src/core/config/config_vars.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/iomgr/resolve_address.h" @@ -68,6 +67,7 @@ #include "src/core/resolver/polling_resolver.h" #include "src/core/service_config/service_config_impl.h" #include "src/core/util/backoff.h" +#include "absl/strings/str_cat.h" #define GRPC_DNS_INITIAL_CONNECT_BACKOFF_SECONDS 1 #define GRPC_DNS_RECONNECT_BACKOFF_MULTIPLIER 1.6 diff --git a/deps/grpc/src/core/resolver/dns/c_ares/dns_resolver_ares.h b/deps/grpc/src/core/resolver/dns/c_ares/dns_resolver_ares.h index ad37e610a87..d9ebe9675c9 100644 --- a/deps/grpc/src/core/resolver/dns/c_ares/dns_resolver_ares.h +++ b/deps/grpc/src/core/resolver/dns/c_ares/dns_resolver_ares.h @@ -16,8 +16,8 @@ #include -#include "absl/strings/string_view.h" #include "src/core/config/core_configuration.h" +#include "absl/strings/string_view.h" namespace grpc_core { diff --git a/deps/grpc/src/core/resolver/dns/c_ares/grpc_ares_ev_driver.h b/deps/grpc/src/core/resolver/dns/c_ares/grpc_ares_ev_driver.h index b7c6fe8f1c5..9429e6dd1e6 100644 --- a/deps/grpc/src/core/resolver/dns/c_ares/grpc_ares_ev_driver.h +++ b/deps/grpc/src/core/resolver/dns/c_ares/grpc_ares_ev_driver.h @@ -23,12 +23,12 @@ #include -#include "absl/base/thread_annotations.h" #include "src/core/lib/iomgr/closure.h" #include "src/core/lib/iomgr/error.h" #include "src/core/lib/iomgr/iomgr_fwd.h" #include "src/core/resolver/dns/c_ares/grpc_ares_wrapper.h" #include "src/core/util/sync.h" +#include "absl/base/thread_annotations.h" #if GRPC_ARES == 1 diff --git a/deps/grpc/src/core/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc b/deps/grpc/src/core/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc index 19b21ae7ae4..39ac7b795bd 100644 --- a/deps/grpc/src/core/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc +++ b/deps/grpc/src/core/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc @@ -34,8 +34,6 @@ #include #include -#include "absl/base/thread_annotations.h" -#include "absl/strings/str_cat.h" #include "src/core/lib/iomgr/closure.h" #include "src/core/lib/iomgr/error.h" #include "src/core/lib/iomgr/ev_posix.h" @@ -45,6 +43,8 @@ #include "src/core/resolver/dns/c_ares/grpc_ares_wrapper.h" #include "src/core/util/grpc_check.h" #include "src/core/util/sync.h" +#include "absl/base/thread_annotations.h" +#include "absl/strings/str_cat.h" namespace grpc_core { diff --git a/deps/grpc/src/core/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc b/deps/grpc/src/core/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc index feb2569bc45..b0ca2a5db94 100644 --- a/deps/grpc/src/core/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc +++ b/deps/grpc/src/core/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc @@ -30,8 +30,6 @@ #include #include -#include "absl/functional/any_invocable.h" -#include "absl/strings/str_format.h" #include "src/core/lib/address_utils/sockaddr_utils.h" #include "src/core/lib/iomgr/iocp_windows.h" #include "src/core/lib/iomgr/sockaddr_windows.h" @@ -39,6 +37,8 @@ #include "src/core/lib/iomgr/tcp_windows.h" #include "src/core/lib/slice/slice.h" #include "src/core/lib/slice/slice_internal.h" +#include "absl/functional/any_invocable.h" +#include "absl/strings/str_format.h" // We pull in ares.h transitively here, ares.h is not self-contained // w.r.t. windows headers though, so make sure pull them in above. #include "src/core/resolver/dns/c_ares/grpc_ares_ev_driver.h" diff --git a/deps/grpc/src/core/resolver/dns/c_ares/grpc_ares_wrapper.cc b/deps/grpc/src/core/resolver/dns/c_ares/grpc_ares_wrapper.cc index e91de6dc404..7fda1eb2b69 100644 --- a/deps/grpc/src/core/resolver/dns/c_ares/grpc_ares_wrapper.cc +++ b/deps/grpc/src/core/resolver/dns/c_ares/grpc_ares_wrapper.cc @@ -22,9 +22,9 @@ #include #include -#include "absl/strings/string_view.h" #include "src/core/lib/iomgr/sockaddr.h" #include "src/core/util/status_helper.h" +#include "absl/strings/string_view.h" // IWYU pragma: no_include // IWYU pragma: no_include @@ -47,11 +47,6 @@ #include #include -#include "absl/log/log.h" -#include "absl/status/status.h" -#include "absl/status/statusor.h" -#include "absl/strings/str_cat.h" -#include "absl/strings/str_format.h" #include "src/core/lib/address_utils/parse_address.h" #include "src/core/lib/address_utils/sockaddr_utils.h" #include "src/core/lib/channel/channel_args.h" @@ -67,6 +62,11 @@ #include "src/core/util/host_port.h" #include "src/core/util/string.h" #include "src/core/util/time.h" +#include "absl/log/log.h" +#include "absl/status/status.h" +#include "absl/status/statusor.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/str_format.h" using grpc_core::EndpointAddresses; using grpc_core::EndpointAddressesList; diff --git a/deps/grpc/src/core/resolver/dns/c_ares/grpc_ares_wrapper.h b/deps/grpc/src/core/resolver/dns/c_ares/grpc_ares_wrapper.h index 6300914f5f2..70b4e1b92b7 100644 --- a/deps/grpc/src/core/resolver/dns/c_ares/grpc_ares_wrapper.h +++ b/deps/grpc/src/core/resolver/dns/c_ares/grpc_ares_wrapper.h @@ -24,14 +24,14 @@ #include -#include "absl/base/thread_annotations.h" -#include "absl/log/log.h" #include "src/core/lib/debug/trace.h" #include "src/core/lib/iomgr/closure.h" #include "src/core/lib/iomgr/error.h" #include "src/core/lib/iomgr/iomgr_fwd.h" #include "src/core/resolver/endpoint_addresses.h" #include "src/core/util/sync.h" +#include "absl/base/thread_annotations.h" +#include "absl/log/log.h" #if GRPC_ARES == 1 diff --git a/deps/grpc/src/core/resolver/dns/dns_resolver_plugin.cc b/deps/grpc/src/core/resolver/dns/dns_resolver_plugin.cc index d00a6751f42..146d23a398c 100644 --- a/deps/grpc/src/core/resolver/dns/dns_resolver_plugin.cc +++ b/deps/grpc/src/core/resolver/dns/dns_resolver_plugin.cc @@ -17,8 +17,6 @@ #include -#include "absl/log/log.h" -#include "absl/strings/match.h" #include "src/core/config/config_vars.h" #include "src/core/lib/experiments/experiments.h" #include "src/core/resolver/dns/c_ares/dns_resolver_ares.h" @@ -26,6 +24,8 @@ #include "src/core/resolver/dns/native/dns_resolver.h" #include "src/core/resolver/resolver_factory.h" #include "src/core/util/crash.h" +#include "absl/log/log.h" +#include "absl/strings/match.h" namespace grpc_core { diff --git a/deps/grpc/src/core/resolver/dns/event_engine/event_engine_client_channel_resolver.cc b/deps/grpc/src/core/resolver/dns/event_engine/event_engine_client_channel_resolver.cc index ca3efb4182d..de21ca78361 100644 --- a/deps/grpc/src/core/resolver/dns/event_engine/event_engine_client_channel_resolver.cc +++ b/deps/grpc/src/core/resolver/dns/event_engine/event_engine_client_channel_resolver.cc @@ -27,14 +27,6 @@ #include #include -#include "absl/base/thread_annotations.h" -#include "absl/cleanup/cleanup.h" -#include "absl/log/log.h" -#include "absl/status/status.h" -#include "absl/status/statusor.h" -#include "absl/strings/match.h" -#include "absl/strings/str_cat.h" -#include "absl/strings/strip.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/debug/trace.h" #include "src/core/lib/event_engine/resolved_address_internal.h" @@ -55,6 +47,14 @@ #include "src/core/util/sync.h" #include "src/core/util/time.h" #include "src/core/util/validation_errors.h" +#include "absl/base/thread_annotations.h" +#include "absl/cleanup/cleanup.h" +#include "absl/log/log.h" +#include "absl/status/status.h" +#include "absl/status/statusor.h" +#include "absl/strings/match.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/strip.h" // IWYU pragma: no_include diff --git a/deps/grpc/src/core/resolver/dns/event_engine/event_engine_client_channel_resolver.h b/deps/grpc/src/core/resolver/dns/event_engine/event_engine_client_channel_resolver.h index 1a4fb852856..acc86672e41 100644 --- a/deps/grpc/src/core/resolver/dns/event_engine/event_engine_client_channel_resolver.h +++ b/deps/grpc/src/core/resolver/dns/event_engine/event_engine_client_channel_resolver.h @@ -15,11 +15,11 @@ #define GRPC_SRC_CORE_RESOLVER_DNS_EVENT_ENGINE_EVENT_ENGINE_CLIENT_CHANNEL_RESOLVER_H #include -#include "absl/strings/string_view.h" #include "src/core/resolver/resolver.h" #include "src/core/resolver/resolver_factory.h" #include "src/core/util/orphanable.h" #include "src/core/util/uri.h" +#include "absl/strings/string_view.h" namespace grpc_core { diff --git a/deps/grpc/src/core/resolver/dns/event_engine/service_config_helper.cc b/deps/grpc/src/core/resolver/dns/event_engine/service_config_helper.cc index 068ff200292..f8f7fc7ee91 100644 --- a/deps/grpc/src/core/resolver/dns/event_engine/service_config_helper.cc +++ b/deps/grpc/src/core/resolver/dns/event_engine/service_config_helper.cc @@ -19,8 +19,6 @@ #include #include -#include "absl/status/statusor.h" -#include "absl/strings/string_view.h" #include "src/core/util/gethostname.h" #include "src/core/util/json/json.h" #include "src/core/util/json/json_args.h" @@ -28,6 +26,8 @@ #include "src/core/util/json/json_reader.h" #include "src/core/util/json/json_writer.h" #include "src/core/util/status_helper.h" +#include "absl/status/statusor.h" +#include "absl/strings/string_view.h" namespace grpc_core { diff --git a/deps/grpc/src/core/resolver/dns/native/dns_resolver.cc b/deps/grpc/src/core/resolver/dns/native/dns_resolver.cc index 97012d43401..5b280d0b60d 100644 --- a/deps/grpc/src/core/resolver/dns/native/dns_resolver.cc +++ b/deps/grpc/src/core/resolver/dns/native/dns_resolver.cc @@ -23,13 +23,6 @@ #include #include -#include "absl/functional/bind_front.h" -#include "absl/log/log.h" -#include "absl/status/status.h" -#include "absl/status/statusor.h" -#include "absl/strings/str_cat.h" -#include "absl/strings/string_view.h" -#include "absl/strings/strip.h" #include "src/core/config/core_configuration.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/debug/trace.h" @@ -45,6 +38,13 @@ #include "src/core/util/ref_counted_ptr.h" #include "src/core/util/time.h" #include "src/core/util/uri.h" +#include "absl/functional/bind_front.h" +#include "absl/log/log.h" +#include "absl/status/status.h" +#include "absl/status/statusor.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/string_view.h" +#include "absl/strings/strip.h" #define GRPC_DNS_INITIAL_CONNECT_BACKOFF_SECONDS 1 #define GRPC_DNS_RECONNECT_BACKOFF_MULTIPLIER 1.6 diff --git a/deps/grpc/src/core/resolver/endpoint_addresses.cc b/deps/grpc/src/core/resolver/endpoint_addresses.cc index 49e097cfd5f..6163545a2a0 100644 --- a/deps/grpc/src/core/resolver/endpoint_addresses.cc +++ b/deps/grpc/src/core/resolver/endpoint_addresses.cc @@ -25,14 +25,14 @@ #include #include -#include "absl/status/status.h" -#include "absl/status/statusor.h" -#include "absl/strings/str_cat.h" -#include "absl/strings/str_join.h" #include "src/core/lib/address_utils/sockaddr_utils.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/util/grpc_check.h" #include "src/core/util/useful.h" +#include "absl/status/status.h" +#include "absl/status/statusor.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/str_join.h" // IWYU pragma: no_include diff --git a/deps/grpc/src/core/resolver/endpoint_addresses.h b/deps/grpc/src/core/resolver/endpoint_addresses.h index 2fa942207d6..517d7d53a10 100644 --- a/deps/grpc/src/core/resolver/endpoint_addresses.h +++ b/deps/grpc/src/core/resolver/endpoint_addresses.h @@ -26,9 +26,9 @@ #include #include -#include "absl/functional/function_ref.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/iomgr/resolved_address.h" +#include "absl/functional/function_ref.h" // A channel arg key prefix used for args that are intended to be used // only internally to resolvers and LB policies and should not be part diff --git a/deps/grpc/src/core/resolver/fake/fake_resolver.cc b/deps/grpc/src/core/resolver/fake/fake_resolver.cc index 1104984f7fa..99fae182999 100644 --- a/deps/grpc/src/core/resolver/fake/fake_resolver.cc +++ b/deps/grpc/src/core/resolver/fake/fake_resolver.cc @@ -25,7 +25,6 @@ #include #include -#include "absl/strings/string_view.h" #include "src/core/config/core_configuration.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/resolver/resolver_factory.h" @@ -35,6 +34,7 @@ #include "src/core/util/uri.h" #include "src/core/util/useful.h" #include "src/core/util/work_serializer.h" +#include "absl/strings/string_view.h" namespace grpc_core { diff --git a/deps/grpc/src/core/resolver/fake/fake_resolver.h b/deps/grpc/src/core/resolver/fake/fake_resolver.h index d99248f36f7..216adb49df8 100644 --- a/deps/grpc/src/core/resolver/fake/fake_resolver.h +++ b/deps/grpc/src/core/resolver/fake/fake_resolver.h @@ -23,15 +23,15 @@ #include #include -#include "absl/base/thread_annotations.h" -#include "absl/strings/string_view.h" -#include "absl/time/time.h" #include "src/core/resolver/resolver.h" #include "src/core/util/notification.h" #include "src/core/util/ref_counted.h" #include "src/core/util/ref_counted_ptr.h" #include "src/core/util/sync.h" #include "src/core/util/useful.h" +#include "absl/base/thread_annotations.h" +#include "absl/strings/string_view.h" +#include "absl/time/time.h" #define GRPC_ARG_FAKE_RESOLVER_RESPONSE_GENERATOR \ "grpc.fake_resolver.response_generator" diff --git a/deps/grpc/src/core/resolver/google_c2p/google_c2p_resolver.cc b/deps/grpc/src/core/resolver/google_c2p/google_c2p_resolver.cc index b4bfe38eb25..6f156d2c0de 100644 --- a/deps/grpc/src/core/resolver/google_c2p/google_c2p_resolver.cc +++ b/deps/grpc/src/core/resolver/google_c2p/google_c2p_resolver.cc @@ -25,11 +25,6 @@ #include #include -#include "absl/log/log.h" -#include "absl/status/statusor.h" -#include "absl/strings/str_cat.h" -#include "absl/strings/string_view.h" -#include "absl/strings/strip.h" #include "src/core/config/core_configuration.h" #include "src/core/credentials/transport/alts/check_gcp_environment.h" #include "src/core/lib/channel/channel_args.h" @@ -51,6 +46,11 @@ #include "src/core/util/work_serializer.h" #include "src/core/xds/grpc/xds_client_grpc.h" #include "src/core/xds/xds_client/xds_bootstrap.h" +#include "absl/log/log.h" +#include "absl/status/statusor.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/string_view.h" +#include "absl/strings/strip.h" namespace grpc_core { diff --git a/deps/grpc/src/core/resolver/polling_resolver.cc b/deps/grpc/src/core/resolver/polling_resolver.cc index 61c80b25930..7e1619af5c4 100644 --- a/deps/grpc/src/core/resolver/polling_resolver.cc +++ b/deps/grpc/src/core/resolver/polling_resolver.cc @@ -24,11 +24,6 @@ #include #include -#include "absl/log/log.h" -#include "absl/status/status.h" -#include "absl/status/statusor.h" -#include "absl/strings/str_cat.h" -#include "absl/strings/strip.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/resolver/endpoint_addresses.h" @@ -39,6 +34,11 @@ #include "src/core/util/ref_counted_ptr.h" #include "src/core/util/uri.h" #include "src/core/util/work_serializer.h" +#include "absl/log/log.h" +#include "absl/status/status.h" +#include "absl/status/statusor.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/strip.h" namespace grpc_core { diff --git a/deps/grpc/src/core/resolver/polling_resolver.h b/deps/grpc/src/core/resolver/polling_resolver.h index e0197265008..b93609dbaa3 100644 --- a/deps/grpc/src/core/resolver/polling_resolver.h +++ b/deps/grpc/src/core/resolver/polling_resolver.h @@ -24,7 +24,6 @@ #include #include -#include "absl/status/status.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/debug/trace.h" #include "src/core/lib/iomgr/iomgr_fwd.h" @@ -34,6 +33,7 @@ #include "src/core/util/orphanable.h" #include "src/core/util/time.h" #include "src/core/util/work_serializer.h" +#include "absl/status/status.h" namespace grpc_core { diff --git a/deps/grpc/src/core/resolver/resolver.h b/deps/grpc/src/core/resolver/resolver.h index 5cabc99b270..8518914ffda 100644 --- a/deps/grpc/src/core/resolver/resolver.h +++ b/deps/grpc/src/core/resolver/resolver.h @@ -22,8 +22,6 @@ #include #include -#include "absl/status/status.h" -#include "absl/status/statusor.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/debug/trace.h" #include "src/core/resolver/endpoint_addresses.h" @@ -31,6 +29,8 @@ #include "src/core/service_config/service_config.h" #include "src/core/util/orphanable.h" #include "src/core/util/ref_counted_ptr.h" +#include "absl/status/status.h" +#include "absl/status/statusor.h" namespace grpc_core { diff --git a/deps/grpc/src/core/resolver/resolver_factory.h b/deps/grpc/src/core/resolver/resolver_factory.h index 41df42060fc..56ff203f3bc 100644 --- a/deps/grpc/src/core/resolver/resolver_factory.h +++ b/deps/grpc/src/core/resolver/resolver_factory.h @@ -22,13 +22,13 @@ #include #include -#include "absl/strings/string_view.h" -#include "absl/strings/strip.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/iomgr/iomgr_fwd.h" #include "src/core/resolver/resolver.h" #include "src/core/util/orphanable.h" #include "src/core/util/uri.h" +#include "absl/strings/string_view.h" +#include "absl/strings/strip.h" namespace grpc_core { diff --git a/deps/grpc/src/core/resolver/resolver_registry.cc b/deps/grpc/src/core/resolver/resolver_registry.cc index 18b2cb5dde8..4090e5507ba 100644 --- a/deps/grpc/src/core/resolver/resolver_registry.cc +++ b/deps/grpc/src/core/resolver/resolver_registry.cc @@ -18,13 +18,13 @@ #include +#include "src/core/util/grpc_check.h" #include "absl/log/log.h" #include "absl/status/status.h" #include "absl/status/statusor.h" #include "absl/strings/ascii.h" #include "absl/strings/str_cat.h" #include "absl/strings/str_format.h" -#include "src/core/util/grpc_check.h" namespace grpc_core { diff --git a/deps/grpc/src/core/resolver/resolver_registry.h b/deps/grpc/src/core/resolver/resolver_registry.h index c25f2524578..1d5ca1b2388 100644 --- a/deps/grpc/src/core/resolver/resolver_registry.h +++ b/deps/grpc/src/core/resolver/resolver_registry.h @@ -24,13 +24,13 @@ #include #include -#include "absl/strings/string_view.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/iomgr/iomgr_fwd.h" #include "src/core/resolver/resolver.h" #include "src/core/resolver/resolver_factory.h" #include "src/core/util/orphanable.h" #include "src/core/util/uri.h" +#include "absl/strings/string_view.h" namespace grpc_core { diff --git a/deps/grpc/src/core/resolver/sockaddr/sockaddr_resolver.cc b/deps/grpc/src/core/resolver/sockaddr/sockaddr_resolver.cc index 989574af105..470fa12dd2e 100644 --- a/deps/grpc/src/core/resolver/sockaddr/sockaddr_resolver.cc +++ b/deps/grpc/src/core/resolver/sockaddr/sockaddr_resolver.cc @@ -21,10 +21,6 @@ #include #include -#include "absl/log/log.h" -#include "absl/status/statusor.h" -#include "absl/strings/str_split.h" -#include "absl/strings/string_view.h" #include "src/core/config/core_configuration.h" #include "src/core/lib/address_utils/parse_address.h" #include "src/core/lib/channel/channel_args.h" @@ -35,6 +31,10 @@ #include "src/core/resolver/resolver_factory.h" #include "src/core/util/orphanable.h" #include "src/core/util/uri.h" +#include "absl/log/log.h" +#include "absl/status/statusor.h" +#include "absl/strings/str_split.h" +#include "absl/strings/string_view.h" namespace grpc_core { diff --git a/deps/grpc/src/core/resolver/xds/xds_config.cc b/deps/grpc/src/core/resolver/xds/xds_config.cc index 841b90a2f44..55a60d03df8 100644 --- a/deps/grpc/src/core/resolver/xds/xds_config.cc +++ b/deps/grpc/src/core/resolver/xds/xds_config.cc @@ -21,9 +21,9 @@ #include #include +#include "src/core/util/match.h" #include "absl/strings/str_cat.h" #include "absl/strings/str_join.h" -#include "src/core/util/match.h" namespace grpc_core { diff --git a/deps/grpc/src/core/resolver/xds/xds_config.h b/deps/grpc/src/core/resolver/xds/xds_config.h index ec982592b20..1ac10b2fbc7 100644 --- a/deps/grpc/src/core/resolver/xds/xds_config.h +++ b/deps/grpc/src/core/resolver/xds/xds_config.h @@ -23,14 +23,14 @@ #include #include -#include "absl/container/flat_hash_map.h" -#include "absl/status/statusor.h" -#include "absl/strings/string_view.h" #include "src/core/util/ref_counted.h" #include "src/core/xds/grpc/xds_cluster.h" #include "src/core/xds/grpc/xds_endpoint.h" #include "src/core/xds/grpc/xds_listener.h" #include "src/core/xds/grpc/xds_route_config.h" +#include "absl/container/flat_hash_map.h" +#include "absl/status/statusor.h" +#include "absl/strings/string_view.h" namespace grpc_core { diff --git a/deps/grpc/src/core/resolver/xds/xds_dependency_manager.cc b/deps/grpc/src/core/resolver/xds/xds_dependency_manager.cc index ac791e8c9d8..a3ba0642d23 100644 --- a/deps/grpc/src/core/resolver/xds/xds_dependency_manager.cc +++ b/deps/grpc/src/core/resolver/xds/xds_dependency_manager.cc @@ -18,8 +18,6 @@ #include -#include "absl/log/log.h" -#include "absl/strings/str_join.h" #include "src/core/config/core_configuration.h" #include "src/core/load_balancing/xds/xds_channel_args.h" #include "src/core/resolver/fake/fake_resolver.h" @@ -30,6 +28,8 @@ #include "src/core/xds/grpc/xds_listener_parser.h" #include "src/core/xds/grpc/xds_route_config_parser.h" #include "src/core/xds/grpc/xds_routing.h" +#include "absl/log/log.h" +#include "absl/strings/str_join.h" namespace grpc_core { diff --git a/deps/grpc/src/core/resolver/xds/xds_dependency_manager.h b/deps/grpc/src/core/resolver/xds/xds_dependency_manager.h index eb1cd016d9d..d1451f44fdf 100644 --- a/deps/grpc/src/core/resolver/xds/xds_dependency_manager.h +++ b/deps/grpc/src/core/resolver/xds/xds_dependency_manager.h @@ -17,9 +17,6 @@ #ifndef GRPC_SRC_CORE_RESOLVER_XDS_XDS_DEPENDENCY_MANAGER_H #define GRPC_SRC_CORE_RESOLVER_XDS_XDS_DEPENDENCY_MANAGER_H -#include "absl/container/flat_hash_map.h" -#include "absl/container/flat_hash_set.h" -#include "absl/strings/string_view.h" #include "src/core/resolver/resolver.h" #include "src/core/resolver/xds/xds_config.h" #include "src/core/util/ref_counted.h" @@ -28,6 +25,9 @@ #include "src/core/xds/grpc/xds_endpoint.h" #include "src/core/xds/grpc/xds_listener.h" #include "src/core/xds/grpc/xds_route_config.h" +#include "absl/container/flat_hash_map.h" +#include "absl/container/flat_hash_set.h" +#include "absl/strings/string_view.h" namespace grpc_core { diff --git a/deps/grpc/src/core/resolver/xds/xds_resolver.cc b/deps/grpc/src/core/resolver/xds/xds_resolver.cc index a1353d67328..5a24bc980a4 100644 --- a/deps/grpc/src/core/resolver/xds/xds_resolver.cc +++ b/deps/grpc/src/core/resolver/xds/xds_resolver.cc @@ -32,18 +32,6 @@ #include #include -#include "absl/log/log.h" -#include "absl/meta/type_traits.h" -#include "absl/random/random.h" -#include "absl/status/status.h" -#include "absl/status/statusor.h" -#include "absl/strings/match.h" -#include "absl/strings/str_cat.h" -#include "absl/strings/str_format.h" -#include "absl/strings/str_join.h" -#include "absl/strings/str_replace.h" -#include "absl/strings/string_view.h" -#include "absl/strings/strip.h" #include "re2/re2.h" #include "src/core/call/metadata_batch.h" #include "src/core/call/status_util.h" @@ -91,6 +79,18 @@ #include "src/core/xds/grpc/xds_route_config.h" #include "src/core/xds/grpc/xds_routing.h" #include "src/core/xds/xds_client/xds_bootstrap.h" +#include "absl/log/log.h" +#include "absl/meta/type_traits.h" +#include "absl/random/random.h" +#include "absl/status/status.h" +#include "absl/status/statusor.h" +#include "absl/strings/match.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/str_format.h" +#include "absl/strings/str_join.h" +#include "absl/strings/str_replace.h" +#include "absl/strings/string_view.h" +#include "absl/strings/strip.h" namespace grpc_core { @@ -335,6 +335,9 @@ class XdsResolver final : public Resolver { static inline const NoInterceptor OnClientToServerHalfClose; static inline const NoInterceptor OnServerToClientMessage; static inline const NoInterceptor OnFinalize; + channelz::PropertyList ChannelzProperties() { + return channelz::PropertyList(); + } }; }; @@ -788,7 +791,7 @@ void XdsResolver::XdsConfigSelector::AddFilters( filter->UpdateBlackboard(hcm.http_filters[i].config, old_blackboard, new_blackboard); } - builder.Add(); + builder.Add(nullptr); } std::vector diff --git a/deps/grpc/src/core/resolver/xds/xds_resolver_attributes.h b/deps/grpc/src/core/resolver/xds/xds_resolver_attributes.h index c0d2795afe4..ac0b801fa1b 100644 --- a/deps/grpc/src/core/resolver/xds/xds_resolver_attributes.h +++ b/deps/grpc/src/core/resolver/xds/xds_resolver_attributes.h @@ -19,10 +19,10 @@ #include -#include "absl/strings/string_view.h" #include "src/core/service_config/service_config_call_data.h" #include "src/core/util/unique_type_name.h" #include "src/core/xds/grpc/xds_route_config.h" +#include "absl/strings/string_view.h" namespace grpc_core { diff --git a/deps/grpc/src/core/server/add_port.cc b/deps/grpc/src/core/server/add_port.cc index 44eb90d5561..dd6475c966c 100644 --- a/deps/grpc/src/core/server/add_port.cc +++ b/deps/grpc/src/core/server/add_port.cc @@ -14,13 +14,13 @@ #include -#include "absl/strings/str_cat.h" -#include "absl/strings/str_split.h" #include "src/core/config/core_configuration.h" #include "src/core/credentials/transport/transport_credentials.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/server/server.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/str_split.h" // TODO(ctiller): rename to grpc_server_add_listener_port. int grpc_server_add_http2_port(grpc_server* server, const char* addr, diff --git a/deps/grpc/src/core/server/server.cc b/deps/grpc/src/core/server/server.cc index fa3c2bf5ed8..43745ac7e26 100644 --- a/deps/grpc/src/core/server/server.cc +++ b/deps/grpc/src/core/server/server.cc @@ -39,10 +39,6 @@ #include #include -#include "absl/cleanup/cleanup.h" -#include "absl/container/flat_hash_map.h" -#include "absl/log/log.h" -#include "absl/status/status.h" #include "src/core/call/interception_chain.h" #include "src/core/call/server_call.h" #include "src/core/channelz/channel_trace.h" @@ -85,6 +81,10 @@ #include "src/core/util/shared_bit_gen.h" #include "src/core/util/status_helper.h" #include "src/core/util/useful.h" +#include "absl/cleanup/cleanup.h" +#include "absl/container/flat_hash_map.h" +#include "absl/log/log.h" +#include "absl/status/status.h" namespace grpc_core { @@ -2066,7 +2066,11 @@ void Server::CallData::RecvInitialMetadataReady(void* arg, auto op_deadline = calld->recv_initial_metadata_->get(GrpcTimeoutMetadata()); if (op_deadline.has_value()) { calld->deadline_ = *op_deadline; - Call::FromC(calld->call_)->UpdateDeadline(*op_deadline); + if (IsFailRecvMetadataOnDeadlineExceededEnabled()) { + error = Call::FromC(calld->call_)->UpdateDeadline(*op_deadline); + } else { + Call::FromC(calld->call_)->UpdateDeadline(*op_deadline).IgnoreError(); + } } if (calld->host_.has_value() && calld->path_.has_value()) { // do nothing diff --git a/deps/grpc/src/core/server/server.h b/deps/grpc/src/core/server/server.h index 6d36b052276..b94f787cd36 100644 --- a/deps/grpc/src/core/server/server.h +++ b/deps/grpc/src/core/server/server.h @@ -36,13 +36,6 @@ #include #include -#include "absl/base/thread_annotations.h" -#include "absl/container/flat_hash_map.h" -#include "absl/container/flat_hash_set.h" -#include "absl/hash/hash.h" -#include "absl/random/random.h" -#include "absl/status/statusor.h" -#include "absl/strings/string_view.h" #include "src/core/call/metadata_batch.h" #include "src/core/channelz/channelz.h" #include "src/core/filter/blackboard.h" @@ -58,6 +51,7 @@ #include "src/core/lib/iomgr/resolved_address.h" #include "src/core/lib/promise/arena_promise.h" #include "src/core/lib/resource_quota/connection_quota.h" +#include "src/core/lib/resource_quota/stream_quota.h" #include "src/core/lib/slice/slice.h" #include "src/core/lib/surface/channel.h" #include "src/core/lib/surface/completion_queue.h" @@ -72,6 +66,13 @@ #include "src/core/util/ref_counted_ptr.h" #include "src/core/util/sync.h" #include "src/core/util/time.h" +#include "absl/base/thread_annotations.h" +#include "absl/container/flat_hash_map.h" +#include "absl/container/flat_hash_set.h" +#include "absl/hash/hash.h" +#include "absl/random/random.h" +#include "absl/status/statusor.h" +#include "absl/strings/string_view.h" #define GRPC_ARG_SERVER_MAX_PENDING_REQUESTS "grpc.server.max_pending_requests" #define GRPC_ARG_SERVER_MAX_PENDING_REQUESTS_HARD_LIMIT \ diff --git a/deps/grpc/src/core/server/server_call_tracer_filter.cc b/deps/grpc/src/core/server/server_call_tracer_filter.cc index 6e359e4a720..bafa610d13c 100644 --- a/deps/grpc/src/core/server/server_call_tracer_filter.cc +++ b/deps/grpc/src/core/server/server_call_tracer_filter.cc @@ -20,12 +20,12 @@ #include -#include "absl/status/statusor.h" #include "src/core/config/core_configuration.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/channel_fwd.h" #include "src/core/lib/channel/promise_based_filter.h" #include "src/core/lib/surface/channel_stack_type.h" +#include "absl/status/statusor.h" namespace grpc_core { diff --git a/deps/grpc/src/core/server/server_call_tracer_filter.h b/deps/grpc/src/core/server/server_call_tracer_filter.h index 3a1f98754c0..8ccfd450732 100644 --- a/deps/grpc/src/core/server/server_call_tracer_filter.h +++ b/deps/grpc/src/core/server/server_call_tracer_filter.h @@ -20,7 +20,6 @@ #include #include -#include "absl/status/status.h" #include "src/core/call/call_finalization.h" #include "src/core/config/core_configuration.h" #include "src/core/lib/channel/channel_stack.h" @@ -33,6 +32,7 @@ #include "src/core/lib/transport/transport.h" #include "src/core/telemetry/call_tracer.h" #include "src/core/util/latent_see.h" +#include "absl/status/status.h" namespace grpc_core { @@ -82,6 +82,10 @@ class ServerCallTracerFilter static inline const NoInterceptor OnClientToServerMessage; static inline const NoInterceptor OnClientToServerHalfClose; static inline const NoInterceptor OnServerToClientMessage; + + channelz::PropertyList ChannelzProperties() { + return channelz::PropertyList(); + } }; }; diff --git a/deps/grpc/src/core/server/server_config_selector.h b/deps/grpc/src/core/server/server_config_selector.h index 23793152663..6ad2ef6b416 100644 --- a/deps/grpc/src/core/server/server_config_selector.h +++ b/deps/grpc/src/core/server/server_config_selector.h @@ -21,8 +21,6 @@ #include -#include "absl/status/statusor.h" -#include "absl/strings/string_view.h" #include "src/core/call/metadata_batch.h" #include "src/core/service_config/service_config.h" #include "src/core/service_config/service_config_parser.h" @@ -30,6 +28,8 @@ #include "src/core/util/ref_counted.h" #include "src/core/util/ref_counted_ptr.h" #include "src/core/util/useful.h" +#include "absl/status/statusor.h" +#include "absl/strings/string_view.h" namespace grpc_core { diff --git a/deps/grpc/src/core/server/server_config_selector_filter.cc b/deps/grpc/src/core/server/server_config_selector_filter.cc index 2a84bacfffc..e06bec56875 100644 --- a/deps/grpc/src/core/server/server_config_selector_filter.cc +++ b/deps/grpc/src/core/server/server_config_selector_filter.cc @@ -21,9 +21,6 @@ #include #include -#include "absl/base/thread_annotations.h" -#include "absl/status/status.h" -#include "absl/status/statusor.h" #include "src/core/call/metadata_batch.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/promise_based_filter.h" @@ -41,6 +38,9 @@ #include "src/core/util/ref_counted_ptr.h" #include "src/core/util/status_helper.h" #include "src/core/util/sync.h" +#include "absl/base/thread_annotations.h" +#include "absl/status/status.h" +#include "absl/status/statusor.h" namespace grpc_core { diff --git a/deps/grpc/src/core/server/xds_channel_stack_modifier.cc b/deps/grpc/src/core/server/xds_channel_stack_modifier.cc index e76b535acc4..2a74576f73f 100644 --- a/deps/grpc/src/core/server/xds_channel_stack_modifier.cc +++ b/deps/grpc/src/core/server/xds_channel_stack_modifier.cc @@ -63,11 +63,12 @@ void XdsChannelStackModifier::ModifyChannelStack(ChannelStackBuilder& builder) { for (auto it = builder.mutable_stack()->begin(); it != builder.mutable_stack()->end(); ++it) { for (absl::string_view predicate_name : {"server", "census_server"}) { - if (predicate_name == (*it)->name.name()) insert_before = it + 1; + if (predicate_name == it->filter->name.name()) insert_before = it + 1; } } for (const grpc_channel_filter* filter : filters_) { - insert_before = builder.mutable_stack()->insert(insert_before, filter); + insert_before = + builder.mutable_stack()->insert(insert_before, {filter, nullptr}); ++insert_before; } } diff --git a/deps/grpc/src/core/server/xds_channel_stack_modifier.h b/deps/grpc/src/core/server/xds_channel_stack_modifier.h index 11ec0f06325..7b375ddd1bf 100644 --- a/deps/grpc/src/core/server/xds_channel_stack_modifier.h +++ b/deps/grpc/src/core/server/xds_channel_stack_modifier.h @@ -25,12 +25,12 @@ #include #include -#include "absl/strings/string_view.h" #include "src/core/lib/channel/channel_fwd.h" #include "src/core/lib/channel/channel_stack_builder.h" #include "src/core/util/ref_counted.h" #include "src/core/util/ref_counted_ptr.h" #include "src/core/util/useful.h" +#include "absl/strings/string_view.h" namespace grpc_core { diff --git a/deps/grpc/src/core/server/xds_server_config_fetcher.cc b/deps/grpc/src/core/server/xds_server_config_fetcher.cc index f82f90fcb62..8d9de07bbd0 100644 --- a/deps/grpc/src/core/server/xds_server_config_fetcher.cc +++ b/deps/grpc/src/core/server/xds_server_config_fetcher.cc @@ -34,16 +34,6 @@ #include #include -#include "absl/base/thread_annotations.h" -#include "absl/log/log.h" -#include "absl/status/status.h" -#include "absl/status/statusor.h" -#include "absl/strings/match.h" -#include "absl/strings/numbers.h" -#include "absl/strings/str_cat.h" -#include "absl/strings/str_join.h" -#include "absl/strings/str_replace.h" -#include "absl/strings/string_view.h" #include "src/core/call/metadata_batch.h" #include "src/core/config/core_configuration.h" #include "src/core/credentials/transport/tls/grpc_tls_certificate_distributor.h" @@ -90,6 +80,16 @@ #include "src/core/xds/grpc/xds_route_config_parser.h" #include "src/core/xds/grpc/xds_routing.h" #include "src/core/xds/xds_client/xds_client.h" +#include "absl/base/thread_annotations.h" +#include "absl/log/log.h" +#include "absl/status/status.h" +#include "absl/status/statusor.h" +#include "absl/strings/match.h" +#include "absl/strings/numbers.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/str_join.h" +#include "absl/strings/str_replace.h" +#include "absl/strings/string_view.h" namespace grpc_core { namespace { diff --git a/deps/grpc/src/core/service_config/service_config.h b/deps/grpc/src/core/service_config/service_config.h index aa6bbcf00b2..d9953a93c1f 100644 --- a/deps/grpc/src/core/service_config/service_config.h +++ b/deps/grpc/src/core/service_config/service_config.h @@ -21,10 +21,10 @@ #include #include -#include "absl/strings/string_view.h" #include "src/core/service_config/service_config_parser.h" #include "src/core/util/ref_counted.h" #include "src/core/util/useful.h" +#include "absl/strings/string_view.h" // The main purpose of the code here is to parse the service config in // JSON form, which will look like this: diff --git a/deps/grpc/src/core/service_config/service_config_channel_arg_filter.h b/deps/grpc/src/core/service_config/service_config_channel_arg_filter.h index b16e4949dd3..8b7eb493b0d 100644 --- a/deps/grpc/src/core/service_config/service_config_channel_arg_filter.h +++ b/deps/grpc/src/core/service_config/service_config_channel_arg_filter.h @@ -26,13 +26,13 @@ #include -#include "absl/status/statusor.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/channel_fwd.h" #include "src/core/lib/channel/promise_based_filter.h" #include "src/core/service_config/service_config.h" #include "src/core/service_config/service_config_impl.h" #include "src/core/util/ref_counted_ptr.h" +#include "absl/status/statusor.h" namespace grpc_core { @@ -71,6 +71,9 @@ class ServiceConfigChannelArgFilter final static inline const NoInterceptor OnClientToServerHalfClose; static inline const NoInterceptor OnServerToClientMessage; static inline const NoInterceptor OnFinalize; + channelz::PropertyList ChannelzProperties() { + return channelz::PropertyList(); + } }; private: diff --git a/deps/grpc/src/core/service_config/service_config_impl.cc b/deps/grpc/src/core/service_config/service_config_impl.cc index f77b06bde38..a4174cac4f0 100644 --- a/deps/grpc/src/core/service_config/service_config_impl.cc +++ b/deps/grpc/src/core/service_config/service_config_impl.cc @@ -23,9 +23,6 @@ #include #include -#include "absl/status/status.h" -#include "absl/status/statusor.h" -#include "absl/strings/str_cat.h" #include "src/core/config/core_configuration.h" #include "src/core/lib/slice/slice.h" #include "src/core/lib/slice/slice_internal.h" @@ -37,6 +34,9 @@ #include "src/core/util/json/json_writer.h" #include "src/core/util/memory.h" #include "src/core/util/validation_errors.h" +#include "absl/status/status.h" +#include "absl/status/statusor.h" +#include "absl/strings/str_cat.h" namespace grpc_core { diff --git a/deps/grpc/src/core/service_config/service_config_impl.h b/deps/grpc/src/core/service_config/service_config_impl.h index 55f96b440b6..fa7844ccb02 100644 --- a/deps/grpc/src/core/service_config/service_config_impl.h +++ b/deps/grpc/src/core/service_config/service_config_impl.h @@ -26,8 +26,6 @@ #include #include -#include "absl/status/statusor.h" -#include "absl/strings/string_view.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/slice/slice_internal.h" #include "src/core/service_config/service_config.h" @@ -36,6 +34,8 @@ #include "src/core/util/json/json.h" #include "src/core/util/ref_counted_ptr.h" #include "src/core/util/validation_errors.h" +#include "absl/status/statusor.h" +#include "absl/strings/string_view.h" // The main purpose of the code here is to parse the service config in // JSON form, which will look like this: diff --git a/deps/grpc/src/core/service_config/service_config_parser.h b/deps/grpc/src/core/service_config/service_config_parser.h index 763e7f89785..100df51774e 100644 --- a/deps/grpc/src/core/service_config/service_config_parser.h +++ b/deps/grpc/src/core/service_config/service_config_parser.h @@ -25,10 +25,10 @@ #include #include -#include "absl/strings/string_view.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/util/json/json.h" #include "src/core/util/validation_errors.h" +#include "absl/strings/string_view.h" namespace grpc_core { diff --git a/deps/grpc/src/core/telemetry/call_tracer.h b/deps/grpc/src/core/telemetry/call_tracer.h index bf3c31056ed..f8a988c60bc 100644 --- a/deps/grpc/src/core/telemetry/call_tracer.h +++ b/deps/grpc/src/core/telemetry/call_tracer.h @@ -26,8 +26,6 @@ #include #include -#include "absl/status/status.h" -#include "absl/strings/string_view.h" #include "src/core/call/message.h" #include "src/core/call/metadata_batch.h" #include "src/core/lib/channel/channel_args.h" @@ -38,6 +36,8 @@ #include "src/core/lib/transport/call_final_info.h" #include "src/core/telemetry/tcp_tracer.h" #include "src/core/util/ref_counted_string.h" +#include "absl/status/status.h" +#include "absl/strings/string_view.h" namespace grpc_core { diff --git a/deps/grpc/src/core/telemetry/default_tcp_tracer.h b/deps/grpc/src/core/telemetry/default_tcp_tracer.h index feca135b246..84e30f57ce5 100644 --- a/deps/grpc/src/core/telemetry/default_tcp_tracer.h +++ b/deps/grpc/src/core/telemetry/default_tcp_tracer.h @@ -17,12 +17,12 @@ #include -#include "absl/base/thread_annotations.h" -#include "absl/time/time.h" -#include "absl/types/optional.h" #include "src/core/telemetry/metrics.h" #include "src/core/telemetry/tcp_tracer.h" #include "src/core/util/sync.h" +#include "absl/base/thread_annotations.h" +#include "absl/time/time.h" +#include "absl/types/optional.h" namespace grpc_core { diff --git a/deps/grpc/src/core/telemetry/histogram.h b/deps/grpc/src/core/telemetry/histogram.h index 25c8558ec87..0da249237bd 100644 --- a/deps/grpc/src/core/telemetry/histogram.h +++ b/deps/grpc/src/core/telemetry/histogram.h @@ -21,10 +21,10 @@ #include #include +#include "src/core/util/grpc_check.h" #include "absl/log/log.h" #include "absl/strings/str_join.h" #include "absl/types/span.h" -#include "src/core/util/grpc_check.h" namespace grpc_core { diff --git a/deps/grpc/src/core/telemetry/instrument.cc b/deps/grpc/src/core/telemetry/instrument.cc index 6557cf177a4..a1c4943f2a9 100644 --- a/deps/grpc/src/core/telemetry/instrument.cc +++ b/deps/grpc/src/core/telemetry/instrument.cc @@ -16,6 +16,7 @@ #include +#include #include #include #include @@ -23,14 +24,27 @@ #include #include #include +#include #include +#include "src/core/channelz/channelz.h" +#include "src/core/channelz/property_list.h" +#include "src/core/telemetry/histogram.h" +#include "src/core/util/grpc_check.h" +#include "src/core/util/match.h" +#include "src/core/util/ref_counted_ptr.h" +#include "src/core/util/single_set_ptr.h" +#include "src/core/util/sync.h" +#include "absl/base/thread_annotations.h" #include "absl/container/flat_hash_map.h" +#include "absl/container/flat_hash_set.h" +#include "absl/functional/function_ref.h" +#include "absl/hash/hash.h" #include "absl/log/log.h" +#include "absl/strings/str_cat.h" #include "absl/strings/str_join.h" #include "absl/strings/string_view.h" #include "absl/types/span.h" -#include "src/core/util/grpc_check.h" namespace grpc_core { @@ -65,34 +79,122 @@ void CallHistogramCollectionHooks( } // namespace instrument_detail +namespace { +std::vector FilterLabels( + absl::Span domain_label_names, + const absl::flat_hash_set& scope_labels_of_interest, + absl::Span full_label_values) { + std::vector result; + result.reserve(domain_label_names.size()); + for (size_t i = 0; i < domain_label_names.size(); ++i) { + if (scope_labels_of_interest.contains(domain_label_names[i])) { + result.push_back(full_label_values[i]); + } else { + result.push_back(std::string(kOmittedLabel)); + } + } + return result; +} +} // namespace + CollectionScope::CollectionScope( - std::vector> storage_sets) - : storage_sets_(std::move(storage_sets)) {} + std::vector> parents, + absl::Span labels, size_t child_shards_count, + size_t storage_shards_count) + : parents_(std::move(parents)), + labels_of_interest_(labels.begin(), labels.end()), + child_shards_(child_shards_count), + storage_shards_(storage_shards_count) { + // Sort parents (by address) and then remove any duplicates. + std::sort(parents_.begin(), parents_.end()); + parents_.erase(std::unique(parents_.begin(), parents_.end()), parents_.end()); + for (const auto& parent : parents_) { + if (parent != nullptr) { + labels_of_interest_.insert(parent->labels_of_interest_.begin(), + parent->labels_of_interest_.end()); + auto& shard = parent->child_shard(this); + MutexLock lock(&shard.mu); + shard.children.insert(this); + } + } +} + +CollectionScope::~CollectionScope() { + for (const auto& parent : parents_) { + if (parent != nullptr) { + auto& shard = parent->child_shard(this); + MutexLock lock(&shard.mu); + shard.children.erase(this); + } + } + for (auto& shard : storage_shards_) { + // TODO(ctiller): Consider a different entry point than GetDomainStorage + // for this post-aggregation. We ought to be able to do this step without + // accessing full_labels. + MutexLock lock(&shard.mu); + for (auto& storage_pair : shard.storage) { + for (const auto& parent : parents_) { + if (parent != nullptr) { + storage_pair.second->domain() + ->GetDomainStorage(parent, storage_pair.second->label()) + ->Add(storage_pair.second.get()); + } + } + } + } +} size_t CollectionScope::TestOnlyCountStorageHeld() const { size_t count = 0; - for (const auto& set : storage_sets_) { - count += set->TestOnlyCountStorageHeld(); + for (const auto& shard : storage_shards_) { + MutexLock lock(&shard.mu); + count += shard.storage.size(); } return count; } -std::vector CollectionScope::GetStorageSets() { - std::vector result; - result.reserve(storage_sets_.size()); - for (const auto& storage_set : storage_sets_) { - result.push_back(storage_set.get()); +void CollectionScope::ForEachUniqueStorage( + absl::FunctionRef cb) { + absl::flat_hash_set visited; + ForEachUniqueStorage(cb, visited); +} + +void CollectionScope::ForEachUniqueStorage( + absl::FunctionRef cb, + absl::flat_hash_set& visited) { + for (auto& shard : storage_shards_) { + MutexLock lock(&shard.mu); + for (const auto& s : shard.storage) { + if (visited.insert(s.second.get()).second) { + cb(s.second.get()); + } + } + } + for (auto& shard : child_shards_) { + MutexLock lock(&shard.mu); + for (auto* child : shard.children) { + child->ForEachUniqueStorage(cb, visited); + } } - return result; } -std::unique_ptr -instrument_detail::QueryableDomain::CreateCollectionScope() { - std::vector> storage_sets; - for (auto* domain = last_; domain != nullptr; domain = domain->prev_) { - storage_sets.push_back(domain->CreateStorageSet()); +void CollectionScope::TestOnlyReset() { + for (auto& shard : storage_shards_) { + MutexLock lock(&shard.mu); + shard.storage.clear(); + } + for (auto& shard : child_shards_) { + MutexLock lock(&shard.mu); + shard.children.clear(); } - return std::make_unique(std::move(storage_sets)); +} + +RefCountedPtr CreateCollectionScope( + std::vector> parents, + absl::Span labels, size_t child_shards_count, + size_t storage_shards_count) { + return MakeRefCounted( + std::move(parents), labels, child_shards_count, storage_shards_count); } //////////////////////////////////////////////////////////////////////////////// @@ -115,102 +217,6 @@ GaugeStorage::GaugeStorage(QueryableDomain* domain) } // namespace instrument_detail -//////////////////////////////////////////////////////////////////////////////// -// StorageSet - -namespace instrument_detail { - -StorageSet::StorageSet(QueryableDomain* domain, size_t map_shards_size) - : domain_(domain), - map_shards_(std::make_unique(map_shards_size)), - map_shards_size_(map_shards_size) { - domain_->RegisterStorageSet(this); -} - -StorageSet::~StorageSet() { domain_->UnregisterStorageSet(this); } - -void StorageSet::ExportMetrics( - MetricsSink& sink, - absl::Span metrics) { - for (size_t i = 0; i < map_shards_size_; ++i) { - MutexLock lock(&map_shards_[i].mu); - map_shards_[i].storage_map.ForEach([&](const auto& label, - const auto& weak_storage) { - // It's safe to use `get()` here because the `StorageSet` itself - // holds a weak reference, guaranteeing the object's memory is - // alive. We can't get a strong ref if the object is orphaned, but - // we still need to read its final metric values. - DomainStorage* storage = weak_storage.get(); - GaugeStorage gauge_storage(storage->domain()); - storage->FillGaugeStorage(gauge_storage); - for (const auto* metric : metrics) { - Match( - metric->shape, - [metric, &sink, storage, &label](InstrumentMetadata::CounterShape) { - sink.Counter(label, metric->name, - storage->SumCounter(metric->offset)); - }, - [metric, &sink, storage, - &label](InstrumentMetadata::HistogramShape bounds) { - std::vector counts(bounds.size()); - for (size_t i = 0; i < bounds.size(); ++i) { - counts[i] = storage->SumCounter(metric->offset + i); - } - sink.Histogram(label, metric->name, bounds, counts); - }, - [metric, &sink, &gauge_storage, - &label](InstrumentMetadata::DoubleGaugeShape) { - if (auto value = gauge_storage.GetDouble(metric->offset); - value.has_value()) { - sink.DoubleGauge(label, metric->name, *value); - } - }, - [metric, &sink, &gauge_storage, - &label](InstrumentMetadata::IntGaugeShape) { - if (auto value = gauge_storage.GetInt(metric->offset); - value.has_value()) { - sink.IntGauge(label, metric->name, *value); - } - }, - [metric, &sink, &gauge_storage, - &label](InstrumentMetadata::UintGaugeShape) { - if (auto value = gauge_storage.GetUint(metric->offset); - value.has_value()) { - sink.UintGauge(label, metric->name, *value); - } - }); - } - }); - } -} - -size_t StorageSet::TestOnlyCountStorageHeld() const { - size_t count = 0; - for (size_t i = 0; i < map_shards_size_; ++i) { - MutexLock lock(&map_shards_[i].mu); - map_shards_[i].storage_map.ForEach([&](const auto&, const auto& weak) { - count += weak->RefIfNonZero() != nullptr; - }); - } - return count; -} - -void StorageSet::AddStorage(WeakRefCountedPtr storage) { - size_t shard; - auto label = storage->label(); - if (map_shards_size_ == 1) { - shard = 0; - } else { - GRPC_CHECK(!label.empty()); - shard = absl::HashOf(label[0], this) % map_shards_size_; - } - MapShard& map_shard = map_shards_[shard]; - MutexLock lock(&map_shard.mu); - map_shard.storage_map = map_shard.storage_map.Add(label, std::move(storage)); -} - -} // namespace instrument_detail - //////////////////////////////////////////////////////////////////////////////// // MetricsQuery @@ -228,39 +234,103 @@ MetricsQuery& MetricsQuery::CollapseLabels( return *this; } -MetricsQuery& MetricsQuery::OnlyMetrics(absl::Span metrics) { - only_metrics_.emplace(metrics.begin(), metrics.end()); +MetricsQuery& MetricsQuery::OnlyMetrics(std::vector metrics) { + only_metrics_.emplace(std::move(metrics)); return *this; } -void MetricsQuery::Run(std::unique_ptr scope, +void MetricsQuery::Run(RefCountedPtr scope, MetricsSink& sink) const { GRPC_CHECK_NE(scope.get(), nullptr); + struct DomainInfo { + std::vector metrics; + std::vector> storage; + }; + absl::flat_hash_map + domain_info_map; auto selected_metrics = this->selected_metrics(); - absl::flat_hash_map> - metrics_by_domain; + // Calculate list of desired metrics, per domain. if (selected_metrics.has_value()) { for (const auto& metric : *selected_metrics) { const auto* desc = instrument_detail::InstrumentIndex::Get().Find(metric); - if (desc == nullptr) continue; - metrics_by_domain[desc->domain].push_back(desc); + GRPC_CHECK_NE(desc, nullptr) << "Metric not found: " << metric; + domain_info_map[desc->domain].metrics.push_back(desc); } } else { instrument_detail::QueryableDomain::ForEachInstrument( [&](const InstrumentMetadata::Description* desc) { - metrics_by_domain[desc->domain].push_back(desc); + domain_info_map[desc->domain].metrics.push_back(desc); }); } - for (auto* storage_set : scope->GetStorageSets()) { - instrument_detail::QueryableDomain* domain = storage_set->domain(); - if (domain == nullptr) continue; - auto it = metrics_by_domain.find(domain); - if (it == metrics_by_domain.end()) continue; + // Calculate list of storage objects, per domain, that have at least one + // desired metric. + scope->ForEachUniqueStorage([&](instrument_detail::DomainStorage* storage) { + auto it = domain_info_map.find(storage->domain()); + if (it == domain_info_map.end()) return; + it->second.storage.push_back(storage->Ref()); + }); + for (const auto& pair : domain_info_map) { + instrument_detail::QueryableDomain* domain = pair.first; + const auto& metrics = pair.second.metrics; + const auto& storages = pair.second.storage; + GRPC_CHECK(!metrics.empty()); + if (storages.empty()) continue; this->Apply( domain->label_names(), [&](MetricsSink& sink) { - storage_set->ExportMetrics(sink, it->second); + for (auto& storage : storages) { + const auto label_values = storage->label(); + const auto label_keys = domain->label_names(); + instrument_detail::GaugeStorage gauge_storage(storage->domain()); + storage->FillGaugeStorage(gauge_storage); + for (const auto* metric : metrics) { + Match( + metric->shape, + [metric, &sink, storage, &label_values, + &label_keys](InstrumentMetadata::CounterShape) { + sink.Counter(label_keys, label_values, metric->name, + storage->SumCounter(metric->offset)); + }, + [metric, &sink, storage, &label_values, + &label_keys](InstrumentMetadata::UpDownCounterShape) { + sink.UpDownCounter(label_keys, label_values, metric->name, + storage->SumCounter(metric->offset)); + }, + [metric, &sink, storage, &label_values, + &label_keys](InstrumentMetadata::HistogramShape bounds) { + std::vector counts(bounds.size()); + for (size_t i = 0; i < bounds.size(); ++i) { + counts[i] = storage->SumCounter(metric->offset + i); + } + sink.Histogram(label_keys, label_values, metric->name, + bounds, counts); + }, + [metric, &sink, &gauge_storage, &label_values, + &label_keys](InstrumentMetadata::DoubleGaugeShape) { + if (auto value = gauge_storage.GetDouble(metric->offset); + value.has_value()) { + sink.DoubleGauge(label_keys, label_values, metric->name, + *value); + } + }, + [metric, &sink, &gauge_storage, &label_values, + &label_keys](InstrumentMetadata::IntGaugeShape) { + if (auto value = gauge_storage.GetInt(metric->offset); + value.has_value()) { + sink.IntGauge(label_keys, label_values, metric->name, + *value); + } + }, + [metric, &sink, &gauge_storage, &label_values, + &label_keys](InstrumentMetadata::UintGaugeShape) { + if (auto value = gauge_storage.GetUint(metric->offset); + value.has_value()) { + sink.UintGauge(label_keys, label_values, metric->name, + *value); + } + }); + } + } }, sink); } @@ -274,9 +344,11 @@ void MetricsQuery::Apply(absl::Span label_names, return; } std::vector include_labels; + std::vector label_keys; for (size_t i = 0; i < label_names.size(); ++i) { if (!collapsed_labels_.contains(label_names[i])) { include_labels.push_back(i); + label_keys.push_back(label_names[i]); } } if (include_labels.size() == label_names.size()) { @@ -285,22 +357,31 @@ void MetricsQuery::Apply(absl::Span label_names, } class Filter final : public MetricsSink { public: - explicit Filter(absl::Span include_labels) - : include_labels_(include_labels) {} + explicit Filter(absl::Span include_labels, + absl::Span label_keys) + : include_labels_(include_labels), label_keys_(label_keys) {} + + void Counter(absl::Span /* label_keys */, + absl::Span label_values, + absl::string_view name, uint64_t value) override { + uint64_counters_[ConstructKey(label_values, name)] += value; + } - void Counter(absl::Span label, absl::string_view name, - uint64_t value) override { - uint64_counters_[ConstructKey(label, name)] += value; + void UpDownCounter(absl::Span /* label_keys */, + absl::Span label_values, + absl::string_view name, uint64_t value) override { + uint64_up_down_counters_[ConstructKey(label_values, name)] += value; } - void Histogram(absl::Span label, absl::string_view name, - HistogramBuckets bounds, + void Histogram(absl::Span /* label_keys */, + absl::Span label_values, + absl::string_view name, HistogramBuckets bounds, absl::Span counts) override { GRPC_CHECK_EQ(counts.size(), bounds.size()); - auto it = histograms_.find(ConstructKey(label, name)); + auto it = histograms_.find(ConstructKey(label_values, name)); if (it == histograms_.end()) { histograms_.emplace(std::piecewise_construct, - std::tuple(ConstructKey(label, name)), + std::tuple(ConstructKey(label_values, name)), std::tuple(bounds, counts)); } else { if (it->second.bounds != bounds) { @@ -314,44 +395,56 @@ void MetricsQuery::Apply(absl::Span label_names, } } - void DoubleGauge(absl::Span, absl::string_view, + void DoubleGauge(absl::Span /* label_keys */, + absl::Span, absl::string_view, double) override { // Not aggregatable } - void IntGauge(absl::Span, absl::string_view, + void IntGauge(absl::Span /* label_keys */, + absl::Span, absl::string_view, int64_t) override { // Not aggregatable } - void UintGauge(absl::Span, absl::string_view, + void UintGauge(absl::Span /* label_keys */, + absl::Span, absl::string_view, uint64_t) override { // Not aggregatable } void Publish(MetricsSink& sink) const { for (const auto& [key, value] : uint64_counters_) { - sink.Counter(std::get<0>(key), std::get<1>(key), value); + sink.Counter(label_keys_, std::get<0>(key), std::get<1>(key), value); + } + for (const auto& [key, value] : uint64_up_down_counters_) { + sink.UpDownCounter(label_keys_, std::get<0>(key), std::get<1>(key), + value); } for (const auto& [key, value] : histograms_) { - sink.Histogram(std::get<0>(key), std::get<1>(key), value.bounds, - value.counts); + sink.Histogram(label_keys_, std::get<0>(key), std::get<1>(key), + value.bounds, value.counts); } } private: std::tuple, absl::string_view> ConstructKey( - absl::Span label, absl::string_view name) const { + absl::Span label_values, + absl::string_view name) const { std::vector key; key.reserve(include_labels_.size()); for (auto i : include_labels_) { - key.push_back(label[i]); + key.push_back(label_values[i]); } return std::tuple(std::move(key), name); } absl::Span include_labels_; + absl::Span label_keys_; absl::flat_hash_map, absl::string_view>, uint64_t> uint64_counters_; + absl::flat_hash_map, absl::string_view>, + uint64_t> + uint64_up_down_counters_; struct HistogramValue { HistogramValue(HistogramBuckets bounds, absl::Span counts) : bounds(bounds), counts(counts.begin(), counts.end()) {} @@ -362,7 +455,7 @@ void MetricsQuery::Apply(absl::Span label_names, HistogramValue> histograms_; }; - Filter filter(include_labels); + Filter filter(include_labels, label_keys); ApplyLabelChecks(label_names, fn, filter); filter.Publish(sink); } @@ -393,39 +486,51 @@ void MetricsQuery::ApplyLabelChecks(absl::Span label_names, absl::Span inclusion_checks) : inclusion_checks_(inclusion_checks), sink_(sink) {} - void Counter(absl::Span label, absl::string_view name, - uint64_t value) override { - if (!Matches(label)) return; - sink_.Counter(label, name, value); + void Counter(absl::Span label_keys, + absl::Span label_values, + absl::string_view name, uint64_t value) override { + if (!Matches(label_values)) return; + sink_.Counter(label_keys, label_values, name, value); } - void Histogram(absl::Span label, absl::string_view name, - HistogramBuckets bounds, + void UpDownCounter(absl::Span label_keys, + absl::Span label_values, + absl::string_view name, uint64_t value) override { + if (!Matches(label_values)) return; + sink_.UpDownCounter(label_keys, label_values, name, value); + } + + void Histogram(absl::Span label_keys, + absl::Span label_values, + absl::string_view name, HistogramBuckets bounds, absl::Span counts) override { - if (!Matches(label)) return; - sink_.Histogram(label, name, bounds, counts); + if (!Matches(label_values)) return; + sink_.Histogram(label_keys, label_values, name, bounds, counts); } - void DoubleGauge(absl::Span label, + void DoubleGauge(absl::Span label_keys, + absl::Span label_values, absl::string_view name, double value) override { - if (!Matches(label)) return; - sink_.DoubleGauge(label, name, value); + if (!Matches(label_values)) return; + sink_.DoubleGauge(label_keys, label_values, name, value); } - void IntGauge(absl::Span label, absl::string_view name, - int64_t value) override { - if (!Matches(label)) return; - sink_.IntGauge(label, name, value); + void IntGauge(absl::Span label_keys, + absl::Span label_values, + absl::string_view name, int64_t value) override { + if (!Matches(label_values)) return; + sink_.IntGauge(label_keys, label_values, name, value); } - void UintGauge(absl::Span label, absl::string_view name, - uint64_t value) override { - if (!Matches(label)) return; - sink_.UintGauge(label, name, value); + void UintGauge(absl::Span label_keys, + absl::Span label_values, + absl::string_view name, uint64_t value) override { + if (!Matches(label_values)) return; + sink_.UintGauge(label_keys, label_values, name, value); } private: - bool Matches(absl::Span label) const { + bool Matches(absl::Span label_values) const { for (const auto& check : inclusion_checks_) { - if (label[check.offset] != check.value) return false; + if (label_values[check.offset] != check.value) return false; } return true; } @@ -475,13 +580,129 @@ const InstrumentMetadata::Description* InstrumentIndex::Find( DomainStorage::DomainStorage(QueryableDomain* domain, std::vector label) - : domain_(domain), label_(std::move(label)) {} - -void DomainStorage::Orphaned() { domain_->DomainStorageOrphaned(this); } + : DataSource(MakeRefCounted( + absl::StrCat(domain->name(), ":", absl::StrJoin(label, ",")))), + domain_(domain), + label_(std::move(label)) { + channelz_node()->AddParent(domain->channelz_node().get()); + SourceConstructed(); +} + +void DomainStorage::Orphaned() { SourceDestructing(); } + +void DomainStorage::AddData(channelz::DataSink sink) { + sink.AddData( + "domain_storage", + channelz::PropertyList() + .Set("label", + [this]() { + channelz::PropertyGrid grid; + for (size_t i = 0; i < label_.size(); ++i) { + grid.SetRow( + domain_->label_names()[i], + channelz::PropertyList().Set("value", label_[i])); + } + return grid; + }()) + .Set("metrics", [this]() { + GaugeStorage storage(domain_); + FillGaugeStorage(storage); + channelz::PropertyGrid grid; + for (const auto* metric : domain_->metrics_) { + Match( + metric->shape, + [&, this](InstrumentMetadata::CounterShape) { + grid.SetRow(metric->name, + channelz::PropertyList().Set( + "value", SumCounter(metric->offset))); + }, + [&, this](InstrumentMetadata::UpDownCounterShape) { + grid.SetRow(metric->name, + channelz::PropertyList().Set( + "value", SumCounter(metric->offset))); + }, + [&](InstrumentMetadata::DoubleGaugeShape) { + grid.SetRow( + metric->name, + channelz::PropertyList().Set( + "value", storage.GetDouble(metric->offset))); + }, + [&](InstrumentMetadata::IntGaugeShape) { + grid.SetRow(metric->name, + channelz::PropertyList().Set( + "value", storage.GetInt(metric->offset))); + }, + [&](InstrumentMetadata::UintGaugeShape) { + grid.SetRow(metric->name, + channelz::PropertyList().Set( + "value", storage.GetUint(metric->offset))); + }, + [&](const InstrumentMetadata::HistogramShape& h) { + channelz::PropertyTable table; + for (size_t i = 0; i < h.size(); ++i) { + table.AppendRow( + channelz::PropertyList() + .Set("bucket_max", h[i]) + .Set("count", SumCounter(metric->offset + i))); + } + grid.SetRow(metric->name, channelz::PropertyList().Set( + "value", std::move(table))); + }); + } + return grid; + }())); +} //////////////////////////////////////////////////////////////////////////////// // QueryableDomain +void QueryableDomain::AddData(channelz::DataSink sink) { + sink.AddData( + "domain", + channelz::PropertyList() + .Set("allocated_counter_slots", allocated_counter_slots_) + .Set("allocated_double_gauge_slots", allocated_double_gauge_slots_) + .Set("allocated_int_gauge_slots", allocated_int_gauge_slots_) + .Set("allocated_uint_gauge_slots", allocated_uint_gauge_slots_) + .Set("map_shards", map_shards_size_) + .Set("metrics", + [this]() { + channelz::PropertyGrid grid; + for (auto* metric : metrics_) { + grid.SetRow( + metric->name, + channelz::PropertyList() + .Set("description", metric->description) + .Set("unit", metric->unit) + .Set("offset", metric->offset) + .Set("shape", + Match( + metric->shape, + [](InstrumentMetadata::CounterShape) + -> std::string { return "counter"; }, + [](InstrumentMetadata::UpDownCounterShape) + -> std::string { + return "up_down_counter"; + }, + [](InstrumentMetadata::DoubleGaugeShape) + -> std::string { + return "double_gauge"; + }, + [](InstrumentMetadata::IntGaugeShape) + -> std::string { return "int_gauge"; }, + [](InstrumentMetadata::UintGaugeShape) + -> std::string { return "uint_gauge"; }, + [](const InstrumentMetadata::HistogramShape& + h) -> std::string { + return absl::StrCat( + "histogram:", absl::StrJoin(h, ",")); + }))); + } + return grid; + }()) + .Set("labels", absl::StrJoin(label_names_, ","))); +} + void QueryableDomain::Constructed() { GRPC_CHECK_EQ(prev_, nullptr); prev_ = last_; @@ -507,15 +728,7 @@ size_t QueryableDomain::TestOnlyCountStorageHeld() const { return count; } -void QueryableDomain::DomainStorageOrphaned(DomainStorage* storage) { - auto label = storage->label(); - auto& map_shard = GetMapShard(label); - MutexLock lock(&map_shard.mu); - auto* found_storage = map_shard.storage_map.Lookup(label); - if (found_storage == nullptr) return; - if (found_storage->get() != storage) return; - map_shard.storage_map = map_shard.storage_map.Remove(label); -} +void QueryableDomain::DomainStorageOrphaned(DomainStorage* /*storage*/) {} QueryableDomain::MapShard& QueryableDomain::GetMapShard( absl::Span label) { @@ -530,40 +743,9 @@ QueryableDomain::MapShard& QueryableDomain::GetMapShard( return map_shards_[shard]; } -std::unique_ptr QueryableDomain::CreateStorageSet() { - return std::make_unique(this, map_shards_size_); -} - -void QueryableDomain::RegisterStorageSet(StorageSet* storage_set) { - // Now register the new set. - std::vector> added_storage; - MutexLock lock(&active_storage_sets_mu_); - active_storage_sets_.push_back(storage_set); - for (size_t i = 0; i < map_shards_size_; ++i) { - MutexLock lock(&map_shards_[i].mu); - map_shards_[i].storage_map.ForEach( - [&](const auto&, const auto& weak_storage) { - // Only add storage that is not already orphaned. - if (auto storage = weak_storage->RefIfNonZero(); storage != nullptr) { - added_storage.emplace_back(storage); - storage_set->AddStorage(weak_storage); - } - }); - } -} - -void QueryableDomain::UnregisterStorageSet(StorageSet* storage_set) { - MutexLock lock(&active_storage_sets_mu_); - active_storage_sets_.erase( - std::remove(active_storage_sets_.begin(), active_storage_sets_.end(), - storage_set), - active_storage_sets_.end()); -} - void QueryableDomain::TestOnlyReset() { + channelz_.Reset(); map_shards_ = std::make_unique(map_shards_size_); - MutexLock lock(&active_storage_sets_mu_); - active_storage_sets_.clear(); } const InstrumentMetadata::Description* QueryableDomain::AllocateCounter( @@ -577,6 +759,17 @@ const InstrumentMetadata::Description* QueryableDomain::AllocateCounter( return desc; } +const InstrumentMetadata::Description* QueryableDomain::AllocateUpDownCounter( + absl::string_view name, absl::string_view description, + absl::string_view unit) { + const size_t offset = allocated_counter_slots_++; + auto* desc = + InstrumentIndex::Get().Register(this, offset, name, description, unit, + InstrumentMetadata::UpDownCounterShape{}); + metrics_.push_back(desc); + return desc; +} + const InstrumentMetadata::Description* QueryableDomain::AllocateHistogram( absl::string_view name, absl::string_view description, absl::string_view unit, HistogramBuckets bounds) { @@ -627,68 +820,31 @@ void QueryableDomain::TestOnlyResetAll() { } RefCountedPtr QueryableDomain::GetDomainStorage( - std::vector label) { - MapShard& map_shard = GetMapShard(label); - // First try to get an existing storage. - map_shard.mu.Lock(); - auto storage_map = map_shard.storage_map; - map_shard.mu.Unlock(); - // With an AVL we can search outside the lock. - auto* weak_storage = storage_map.Lookup(label); - if (weak_storage != nullptr) { - // Found a weak pointer, try to upgrade it to a strong pointer. - RefCountedPtr strong_storage = - (*weak_storage)->RefIfNonZero(); - if (strong_storage != nullptr) { - // Upgrade successful, return the strong pointer. - return strong_storage; - } - } - // No hit, or the storage is orphaned: now we lock and search again. - RefCountedPtr new_storage; - { - MutexLock lock(&map_shard.mu); - storage_map = map_shard.storage_map; - // We must look up the storage map again, as it may have been created - // by another thread while we were not holding the lock. - weak_storage = storage_map.Lookup(label); - if (weak_storage != nullptr) { - // Found a weak pointer, try to upgrade it to a strong pointer. - RefCountedPtr strong_storage = - (*weak_storage)->RefIfNonZero(); - if (strong_storage != nullptr) { - // Upgrade successful, return the strong pointer. - return strong_storage; - } + RefCountedPtr scope, + absl::Span label_values) { + auto key_labels = + FilterLabels(label_names_, scope->labels_of_interest_, label_values); + if (scope->parents_.size() == 1 && scope->parents_[0] != nullptr) { + auto parent_key_labels = FilterLabels( + label_names_, scope->parents_[0]->labels_of_interest_, label_values); + if (key_labels == parent_key_labels) { + return GetDomainStorage(scope->parents_[0], label_values); } - // Still no hit or orphaned: with the lock held we allocate a new storage - // and insert it into the map. - new_storage = CreateDomainStorage(std::move(label)); - auto new_weak_storage = new_storage->WeakRef(); - map_shard.storage_map = - map_shard.storage_map.Add(new_weak_storage->label(), new_weak_storage); } - // Add to active storage sets - MutexLock lock(&active_storage_sets_mu_); - for (auto* storage_set : active_storage_sets_) { - storage_set->AddStorage(new_storage->WeakRef()); + size_t shard_idx = absl::HashOf(key_labels) % scope->storage_shards_.size(); + auto& shard = scope->storage_shards_[shard_idx]; + MutexLock lock(&shard.mu); + auto it = shard.storage.find({this, key_labels}); + if (it != shard.storage.end()) { + return it->second; } - return new_storage; + auto storage = CreateDomainStorage(key_labels); + shard.storage.emplace(std::pair(this, key_labels), storage); + return storage; } } // namespace instrument_detail -void TestOnlyResetInstruments() { - Hook* hook = hooks.load(std::memory_order_acquire); - while (hook != nullptr) { - Hook* next = hook->next; - delete hook; - hook = next; - } - hooks.store(nullptr, std::memory_order_release); - instrument_detail::QueryableDomain::TestOnlyResetAll(); -} - LowContentionBackend::LowContentionBackend(size_t size) : counters_(new std::atomic[size]) { for (size_t i = 0; i < size; ++i) { @@ -702,7 +858,7 @@ uint64_t LowContentionBackend::Sum(size_t index) { HighContentionBackend::HighContentionBackend(size_t size) { for (auto& shard : counters_) { - shard = std::make_unique[]>(size); + shard = std::make_unique[]>(size); for (size_t i = 0; i < size; ++i) { shard[i].store(0, std::memory_order_relaxed); } @@ -710,10 +866,134 @@ HighContentionBackend::HighContentionBackend(size_t size) { } uint64_t HighContentionBackend::Sum(size_t index) { - uint64_t sum = 0; + uint64_t positive_sum = 0; + uint64_t negative_sum = 0; for (auto& shard : counters_) { - sum += shard[index].load(std::memory_order_relaxed); + int64_t value = shard[index].load(std::memory_order_relaxed); + if (value > 0) { + positive_sum += value; + } else if (value < 0) { + negative_sum += -value; + } } - return sum; + // Every decrement should have a corresponding increment. + GRPC_CHECK(positive_sum >= negative_sum); + return positive_sum - negative_sum; } + +class GlobalCollectionScopeManager { + public: + GlobalCollectionScopeManager(const GlobalCollectionScopeManager&) = delete; + GlobalCollectionScopeManager& operator=(const GlobalCollectionScopeManager&) = + delete; + + static GlobalCollectionScopeManager& Get() { + static GlobalCollectionScopeManager* manager = + new GlobalCollectionScopeManager(); + return *manager; + } + + RefCountedPtr CreateRootScope( + absl::Span labels, size_t child_shards_count, + size_t storage_shards_count) { + MutexLock lock(&mu_); + if (auto* building = std::get_if(&state_); building != nullptr) { + auto scope = CreateCollectionScope({}, labels, child_shards_count, + storage_shards_count); + building->root_scopes.push_back(scope); + return scope; + } else { + // Global scope is already created, we can no longer subset labels. + auto& published = std::get(state_); + std::vector missing_labels; + for (const auto& label : labels) { + if (!published.global_scope->ObservesLabel(label)) { + missing_labels.push_back(label); + } + } + if (missing_labels.empty()) { + LOG(ERROR) << "Attempt to create a root scope with labels [" + << absl::StrJoin(labels, ", ") + << "] after the global scope was already created. " + "All requested labels are collected by the global scope, " + "so this scope will be returned instead. " + "To eliminate this message, ensure the root scope " + "creation that triggered it occurs before the first call " + "to GlobalCollectionScope()."; + } else { + LOG(ERROR) << "Attempt to create a root scope with labels [" + << absl::StrJoin(labels, ", ") + << "] after the global scope was already created. " + "The following labels are not collected by the global " + "scope, and so will not be available: [" + << absl::StrJoin(missing_labels, ", ") + << "]." + "To eliminate this message, ensure the root scope " + "creation that triggered it occurs before the first call " + "to GlobalCollectionScope()."; + } + return published.global_scope; + } + } + + RefCountedPtr GetGlobalScope() { + MutexLock lock(&mu_); + if (auto* building = std::get_if(&state_); building != nullptr) { + auto global_scope = + CreateCollectionScope(building->root_scopes, {}, 32, 32); + state_ = Published{global_scope}; + return global_scope; + } else { + return std::get(state_).global_scope; + } + } + + void TestOnlyReset() { + std::variant state; + MutexLock lock(&mu_); + state = std::exchange(state_, Building{}); + if (auto* published = std::get_if(&state); + published != nullptr) { + published->global_scope->TestOnlyReset(); + } + } + + private: + GlobalCollectionScopeManager() = default; + + struct Building { + std::vector> root_scopes; + }; + + struct Published { + RefCountedPtr global_scope; + }; + + Mutex mu_; + std::variant state_ ABSL_GUARDED_BY(mu_); +}; + +RefCountedPtr CreateRootCollectionScope( + absl::Span labels, size_t child_shards_count, + size_t storage_shards_count) { + return GlobalCollectionScopeManager::Get().CreateRootScope( + labels, child_shards_count, storage_shards_count); +} + +RefCountedPtr GlobalCollectionScope() { + return GlobalCollectionScopeManager::Get().GetGlobalScope(); +} + +void TestOnlyResetInstruments() { + Hook* hook = hooks.load(std::memory_order_acquire); + while (hook != nullptr) { + Hook* next = hook->next; + delete hook; + hook = next; + } + hooks.store(nullptr, std::memory_order_release); + instrument_detail::QueryableDomain::TestOnlyResetAll(); + GlobalCollectionScopeManager::Get().TestOnlyReset(); +} + } // namespace grpc_core diff --git a/deps/grpc/src/core/telemetry/instrument.h b/deps/grpc/src/core/telemetry/instrument.h index 14d447176c4..0a6cc94e1ac 100644 --- a/deps/grpc/src/core/telemetry/instrument.h +++ b/deps/grpc/src/core/telemetry/instrument.h @@ -29,11 +29,20 @@ // unique combination of label values within a domain creates a separate // instance of the instrumentation storage. // +// * **Collection Scope:** Defines a scope for collecting metrics, identified +// by a set of labels of interest. Metric collection via +// `GetStorage`+`Increment` will be filtered according to these labels. +// Scopes can be hierarchical. +// On destruction, metrics collected in this scope are aggregated into the +// parent scopes. +// // * **Storage:** An object holding the current values for all instruments -// within a domain, for a *specific combination* of label values. Storage -// objects are ref-counted and managed by the domain. You obtain a -// `RefCountedPtr` using `Domain::GetStorage(...)`, passing the -// current label values. +// within a domain, for a *specific combination* of filtered label values. +// Its lifetime is managed by one or more `CollectionScope`s. You obtain a +// `RefCountedPtr` using `Domain::GetStorage(scope, ...)`, passing +// the current label values. If a child scope's filtered labels match its +// parent's filtered labels for a given metric, the parent's `Storage` +// instance is reused (shared). // // * **Backend:** Determines how the metric data is stored and aggregated // within a Storage object. Examples include `LowContentionBackend` and @@ -105,7 +114,8 @@ // }; // // To increment the counter: -// auto storage = MyDomain::GetStorage("label_val1", "label_val2"); +// auto scope = CreateCollectionScope({}, {}); // Or some other scope +// auto storage = MyDomain::GetStorage(scope, "label_val1", "label_val2"); // storage->Increment(MyDomain::kMyCounter); // // To set the gauge (inside a callback): @@ -116,6 +126,9 @@ // The `MetricsQuery` class is used to fetch metric data. You can filter by // label values, select specific metrics, and collapse labels (aggregate over // them). The results are emitted to a `MetricsSink` interface. +// `MetricsQuery::Run(scope, sink)` operates on a given `CollectionScope`, +// querying all unique storage instances reachable from that scope and its +// children. // // ## Aggregability // @@ -126,6 +139,35 @@ // includes gauges is not meaningful, as summing up current values from // different sources makes no sense. The `MetricsSink` will receive // individual gauge readings for each label set matching the filter. +// +// ## Collection Scope Hierarchy +// +// Collection scopes form a DAG. The typical layout is to have a collection of +// root scopes, a trunk scope ("the global scope"), and a set of leaf scopes: +// +// ┌────────┐ ┌────────┐ +// │ Root 1 │ │ Root 2 │ ... +// └───┬────┘ └───┬────┘ +// │ │ +// └──────────────┤ +// │ +// ┌──────▼───────┐ +// │ Global Scope │ +// └──────┬───────┘ +// │ +// ┌──────────────┤ +// │ │ +// ┌───▼────┐ ┌───▼────┐ +// │ Leaf 1 │ │ Leaf 2 │ ... +// └────────┘ └────────┘ +// +// The root scopes correspond to global stats plugins in the higher level +// system. The leaf scopes correspond to per-channel stats plugins. The global +// (trunk) scope is not associated with any stats plugin, but allows +// non-channel-related metrics to be aggregated into the global stats plugins. +// +// When creating a storage instance systems should use the most specific scope +// (lowest in the tree) that matches the current context. #ifndef GRPC_SRC_CORE_TELEMETRY_INSTRUMENT_H #define GRPC_SRC_CORE_TELEMETRY_INSTRUMENT_H @@ -134,40 +176,50 @@ #include #include -#include #include +#include #include #include #include #include #include +#include #include #include #include +#include "src/core/channelz/channelz.h" +#include "src/core/telemetry/histogram.h" +#include "src/core/util/avl.h" +#include "src/core/util/dual_ref_counted.h" +#include "src/core/util/grpc_check.h" +#include "src/core/util/per_cpu.h" +#include "src/core/util/ref_counted.h" +#include "src/core/util/ref_counted_ptr.h" +#include "src/core/util/single_set_ptr.h" +#include "src/core/util/sync.h" #include "absl/base/thread_annotations.h" #include "absl/container/flat_hash_map.h" #include "absl/container/flat_hash_set.h" #include "absl/container/node_hash_map.h" +#include "absl/functional/any_invocable.h" +#include "absl/functional/function_ref.h" +#include "absl/hash/hash.h" #include "absl/log/log.h" #include "absl/strings/str_cat.h" #include "absl/strings/string_view.h" #include "absl/types/span.h" -#include "src/core/telemetry/histogram.h" -#include "src/core/util/avl.h" -#include "src/core/util/dual_ref_counted.h" -#include "src/core/util/match.h" -#include "src/core/util/per_cpu.h" -#include "src/core/util/ref_counted_ptr.h" -#include "src/core/util/sync.h" namespace grpc_core { class InstrumentTest; +class GlobalCollectionScopeManager; + +static constexpr absl::string_view kOmittedLabel = ""; namespace instrument_detail { class QueryableDomain; -class StorageSet; +class DomainStorage; } // namespace instrument_detail class CollectionScope; @@ -175,13 +227,14 @@ class CollectionScope; class InstrumentMetadata { public: struct CounterShape {}; + struct UpDownCounterShape {}; struct DoubleGaugeShape {}; struct IntGaugeShape {}; struct UintGaugeShape {}; using HistogramShape = HistogramBuckets; - using Shape = std::variant; + using Shape = std::variant; // A description of a metric. struct Description { @@ -218,20 +271,60 @@ using HistogramCollectionHook = absl::AnyInvocable labels, int64_t value)>; void RegisterHistogramCollectionHook(HistogramCollectionHook hook); -// A CollectionScope ensures that all metric updates in its lifetime are visible -// to a MetricsQuery. -class CollectionScope { +// Defines a scope for collecting metrics, identified by a set of labels of +// interest. Metric collection via GetStorage+Increment will be filtered +// according to these labels. Scopes can be hierarchical. On destruction, +// metrics collected in this scope are aggregated into the parent scope. +class CollectionScope : public RefCounted { public: - explicit CollectionScope( - std::vector> storage_sets); + CollectionScope(std::vector> parents, + absl::Span labels, + size_t child_shards_count, size_t storage_shards_count); + ~CollectionScope() override; size_t TestOnlyCountStorageHeld() const; + void ForEachUniqueStorage( + absl::FunctionRef cb); + + bool ObservesLabel(absl::string_view label) const { + return labels_of_interest_.contains(label); + } + + bool IsRoot() const { return parents_.empty(); } + private: + friend class GlobalCollectionScopeManager; friend class MetricsQuery; - std::vector GetStorageSets(); + friend class instrument_detail::QueryableDomain; + + struct StorageShard { + mutable Mutex mu; + absl::flat_hash_map>, + RefCountedPtr> + storage ABSL_GUARDED_BY(mu); + }; - std::vector> storage_sets_; + struct ChildShard { + Mutex mu; + absl::flat_hash_set children ABSL_GUARDED_BY(mu); + }; + + ChildShard& child_shard(CollectionScope* child) { + return child_shards_[absl::HashOf(child) % child_shards_.size()]; + } + + std::vector> parents_; + absl::flat_hash_set labels_of_interest_; + std::vector child_shards_; + std::vector storage_shards_; + + void ForEachUniqueStorage( + absl::FunctionRef cb, + absl::flat_hash_set& visited); + + void TestOnlyReset(); }; namespace instrument_detail { @@ -245,28 +338,28 @@ class GaugeStorage { explicit GaugeStorage(QueryableDomain* domain); void SetDouble(uint64_t offset, double value) { - DCHECK_LT(offset, double_gauges_.size()); + GRPC_DCHECK_LT(offset, double_gauges_.size()); double_gauges_[offset] = value; } void SetInt(uint64_t offset, int64_t value) { - DCHECK_LT(offset, int_gauges_.size()); + GRPC_DCHECK_LT(offset, int_gauges_.size()); int_gauges_[offset] = value; } void SetUint(uint64_t offset, uint64_t value) { - DCHECK_LT(offset, uint_gauges_.size()); + GRPC_DCHECK_LT(offset, uint_gauges_.size()); uint_gauges_[offset] = value; } std::optional GetDouble(uint64_t offset) const { - DCHECK_LT(offset, double_gauges_.size()); + GRPC_DCHECK_LT(offset, double_gauges_.size()); return double_gauges_[offset]; } std::optional GetInt(uint64_t offset) const { - DCHECK_LT(offset, int_gauges_.size()); + GRPC_DCHECK_LT(offset, int_gauges_.size()); return int_gauges_[offset]; } std::optional GetUint(uint64_t offset) const { - DCHECK_LT(offset, uint_gauges_.size()); + GRPC_DCHECK_LT(offset, uint_gauges_.size()); return uint_gauges_[offset]; } @@ -276,51 +369,29 @@ class GaugeStorage { std::vector> uint_gauges_; }; -class DomainStorage : public DualRefCounted { +class DomainStorage : public DualRefCounted, + public channelz::DataSource { public: DomainStorage(QueryableDomain* domain, std::vector label); void Orphaned() override; virtual uint64_t SumCounter(size_t index) = 0; + virtual void Add(DomainStorage* other) = 0; + // Returns the label values of the CollectionScope that owns this storage. + // This is the full set of labels published by the domain, with unused labels + // in the scope set to kOmittedLabel. absl::Span label() const { return label_; } QueryableDomain* domain() const { return domain_; } virtual void FillGaugeStorage(GaugeStorage& gauge_storage) = 0; - private: - QueryableDomain* domain_; - const std::vector label_; -}; - -// Interface for a set of storage objects for a domain. -// Each StorageSet is a collection of storage objects for a domain, one storage -// object per unique set of labels. -// The StorageSet subscribes to new label sets being created, so that all -// storage in a time period can be exported. -class StorageSet { - public: - StorageSet(QueryableDomain* domain, size_t map_shards_size); - virtual ~StorageSet(); - void ExportMetrics( - MetricsSink& sink, - absl::Span metrics); - size_t TestOnlyCountStorageHeld() const; - QueryableDomain* domain() const { return domain_; } - - void AddStorage(WeakRefCountedPtr storage); + void AddData(channelz::DataSink sink) override; private: - struct MapShard { - mutable Mutex mu; - AVL, WeakRefCountedPtr> - storage_map ABSL_GUARDED_BY(mu); - }; - QueryableDomain* domain_; - std::unique_ptr map_shards_; - const size_t map_shards_size_; + const std::vector label_; }; // A registry of metrics. @@ -372,20 +443,44 @@ class QueryableDomain { // Reset the internal state of this domain. For test use only. void TestOnlyReset(); - static std::unique_ptr CreateCollectionScope(); size_t TestOnlyCountStorageHeld() const; + // Returns the number of slots allocated for each metric type. + uint64_t allocated_counter_slots() const { return allocated_counter_slots_; } + uint64_t allocated_double_gauge_slots() const { + return allocated_double_gauge_slots_; + } + uint64_t allocated_int_gauge_slots() const { + return allocated_int_gauge_slots_; + } + uint64_t allocated_uint_gauge_slots() const { + return allocated_uint_gauge_slots_; + } + + RefCountedPtr GetDomainStorage( + RefCountedPtr scope, + absl::Span label); + + absl::string_view name() const { return name_; } + + RefCountedPtr channelz_node() { + if (!channelz_.is_set()) { + return channelz_.Set(new ChannelzState(this))->channelz_node(); + } + return channelz_->channelz_node(); + } + protected: - QueryableDomain(std::vector label_names, size_t map_shards_size) + QueryableDomain(std::string name, std::vector label_names, + size_t map_shards_size) : label_names_(std::move(label_names)), map_shards_size_(label_names_.empty() ? 1 : map_shards_size), - map_shards_(std::make_unique(map_shards_size_)) {} + map_shards_(std::make_unique(map_shards_size_)), + name_(std::move(name)) {} // QueryableDomain should never be destroyed. ~QueryableDomain() { LOG(FATAL) << "QueryableDomain destroyed."; } - RefCountedPtr GetDomainStorage(std::vector label); - // Called by InstrumentDomain when construction is complete. void Constructed(); @@ -393,6 +488,9 @@ class QueryableDomain { const InstrumentMetadata::Description* AllocateCounter( absl::string_view name, absl::string_view description, absl::string_view unit); + const InstrumentMetadata::Description* AllocateUpDownCounter( + absl::string_view name, absl::string_view description, + absl::string_view unit); const InstrumentMetadata::Description* AllocateHistogram( absl::string_view name, absl::string_view description, absl::string_view unit, HistogramBuckets bounds); @@ -406,20 +504,7 @@ class QueryableDomain { absl::string_view name, absl::string_view description, absl::string_view unit); - // Returns the number of slots allocated for each metric type. - uint64_t allocated_counter_slots() const { return allocated_counter_slots_; } - uint64_t allocated_double_gauge_slots() const { - return allocated_double_gauge_slots_; - } - uint64_t allocated_int_gauge_slots() const { - return allocated_int_gauge_slots_; - } - uint64_t allocated_uint_gauge_slots() const { - return allocated_uint_gauge_slots_; - } - private: - friend class StorageSet; friend class DomainStorage; friend class GaugeStorage; @@ -429,15 +514,28 @@ class QueryableDomain { storage_map ABSL_GUARDED_BY(mu); }; - void RegisterStorageSet(StorageSet* storage_set); - void UnregisterStorageSet(StorageSet* storage_set); + struct ChannelzState final : public channelz::DataSource { + explicit ChannelzState(QueryableDomain* domain) + : DataSource(MakeRefCounted( + std::string(domain->name()))), + domain(domain) { + SourceConstructed(); + } + ~ChannelzState() { SourceDestructing(); } + QueryableDomain* const domain; + void AddData(channelz::DataSink sink) override { domain->AddData(sink); } + RefCountedPtr channelz_node() { + return DataSource::channelz_node(); + } + }; - std::unique_ptr CreateStorageSet(); virtual RefCountedPtr CreateDomainStorage( std::vector label) = 0; void DomainStorageOrphaned(DomainStorage* storage); MapShard& GetMapShard(absl::Span label); + void AddData(channelz::DataSink sink); + // Allocate `size` elements in the domain. // Counters will allocate one element. Histograms will allocate one per // bucket. @@ -459,15 +557,11 @@ class QueryableDomain { uint64_t allocated_int_gauge_slots_ = 0; uint64_t allocated_uint_gauge_slots_ = 0; - Mutex storage_sets_mu_; - std::vector storage_sets_ ABSL_GUARDED_BY(storage_sets_mu_); - const size_t map_shards_size_; std::unique_ptr map_shards_; - mutable Mutex active_storage_sets_mu_; - std::vector active_storage_sets_ - ABSL_GUARDED_BY(active_storage_sets_mu_); + std::string name_; + SingleSetPtr channelz_; }; // An InstrumentDomain is a collection of metrics with a common set of labels. @@ -486,11 +580,14 @@ struct Counter { }; // An InstrumentHandle is a handle to a single metric in an -// InstrumentDomainImpl. kType is used in using statements to disambiguate -// between different InstrumentHandle specializations. Backed, Label... are -// per InstrumentDomainImpl. +// instrument domain. It has a Shape (how the metric behaves). template class InstrumentHandle { + public: + absl::string_view name() const { return description_->name; } + absl::string_view description() const { return description_->description; } + absl::string_view unit() const { return description_->unit; } + private: friend Domain; @@ -512,7 +609,7 @@ template using StdString = std::string; template -using ConstCharPtr = const char*; +using AbslStringView = absl::string_view; } // namespace instrument_detail @@ -523,9 +620,17 @@ class LowContentionBackend final { public: explicit LowContentionBackend(size_t size); - void Increment(size_t index) { - counters_[index].fetch_add(1, std::memory_order_relaxed); + void Add(size_t index, uint64_t amount) { + counters_[index].fetch_add(amount, std::memory_order_relaxed); + } + void Subtract(size_t index, uint64_t amount) { + uint64_t old_value = + counters_[index].fetch_sub(amount, std::memory_order_relaxed); + // Every decrement should have a corresponding increment. + GRPC_DCHECK(old_value >= amount); } + void Increment(size_t index) { Add(index, 1); } + void Decrement(size_t index) { Subtract(index, 1); } uint64_t Sum(size_t index); @@ -541,14 +646,21 @@ class HighContentionBackend final { public: explicit HighContentionBackend(size_t size); - void Increment(size_t index) { - counters_.this_cpu()[index].fetch_add(1, std::memory_order_relaxed); + void Add(size_t index, uint64_t amount) { + counters_.this_cpu()[index].fetch_add(amount, std::memory_order_relaxed); + } + void Subtract(size_t index, uint64_t amount) { + counters_.this_cpu()[index].fetch_sub(amount, std::memory_order_relaxed); } + void Increment(size_t index) { Add(index, 1); } + void Decrement(size_t index) { Subtract(index, 1); } uint64_t Sum(size_t index); private: - PerCpu[]>> counters_{ + // Since Increments and Decrements can happen on different CPUs, we need to + // use a int64_t counter. The sum should still be a uint64_t. + PerCpu[]>> counters_{ PerCpuOptions().SetMaxShards(16)}; }; @@ -558,16 +670,24 @@ class MetricsSink { public: // Called once per label per metric, with the value of that metric for that // label. - virtual void Counter(absl::Span label, + virtual void Counter(absl::Span label_keys, + absl::Span label_values, absl::string_view name, uint64_t value) = 0; - virtual void Histogram(absl::Span label, + virtual void UpDownCounter(absl::Span label_keys, + absl::Span label_values, + absl::string_view name, uint64_t value) = 0; + virtual void Histogram(absl::Span label_keys, + absl::Span label_values, absl::string_view name, HistogramBuckets bounds, absl::Span counts) = 0; - virtual void DoubleGauge(absl::Span labels, + virtual void DoubleGauge(absl::Span label_keys, + absl::Span label_values, absl::string_view name, double value) = 0; - virtual void IntGauge(absl::Span labels, + virtual void IntGauge(absl::Span label_keys, + absl::Span label_values, absl::string_view name, int64_t value) = 0; - virtual void UintGauge(absl::Span labels, + virtual void UintGauge(absl::Span label_keys, + absl::Span label_values, absl::string_view name, uint64_t value) = 0; protected: @@ -589,22 +709,22 @@ class MetricsQuery { // remaining dimensions, etc. MetricsQuery& CollapseLabels(absl::Span labels); // Only include metrics that are in `metrics`. - MetricsQuery& OnlyMetrics(absl::Span metrics); + MetricsQuery& OnlyMetrics(std::vector metrics); // Returns the metrics that are selected by this query. std::optional> selected_metrics() const { return only_metrics_; } + // Runs the query, outputting the results to `sink`. + void Run(RefCountedPtr scope, MetricsSink& sink) const; + + private: // Adapts `sink` by including the filtering requested, and then calls `fn` // with the filtering sink. This is mainly an implementation detail. void Apply(absl::Span label_names, absl::FunctionRef fn, MetricsSink& sink) const; - // Runs the query, outputting the results to `sink`. - void Run(std::unique_ptr scope, MetricsSink& sink) const; - - private: void ApplyLabelChecks(absl::Span label_names, absl::FunctionRef fn, MetricsSink& sink) const; @@ -642,6 +762,8 @@ class InstrumentDomainImpl final : public QueryableDomain { public: using Self = InstrumentDomainImpl; using CounterHandle = InstrumentHandle; + using UpDownCounterHandle = + InstrumentHandle; using DoubleGaugeHandle = InstrumentHandle; using IntGaugeHandle = @@ -682,16 +804,16 @@ class InstrumentDomainImpl final : public QueryableDomain { protected: explicit GaugeProvider(RefCountedPtr storage) : storage_(std::move(storage)) { - DCHECK(storage_ != nullptr); + GRPC_DCHECK(storage_ != nullptr); } - ~GaugeProvider() { DCHECK(storage_ == nullptr); } + ~GaugeProvider() { GRPC_DCHECK(storage_ == nullptr); } void ProviderConstructed() { - DCHECK(storage_ != nullptr); + GRPC_DCHECK(storage_ != nullptr); storage_->RegisterGaugeProvider(this); } void ProviderDestructing() { - DCHECK(storage_ != nullptr); + GRPC_DCHECK(storage_ != nullptr); storage_->UnregisterGaugeProvider(this); storage_.reset(); } @@ -708,16 +830,35 @@ class InstrumentDomainImpl final : public QueryableDomain { // Increments the counter specified by `handle` by 1 for this storages // labels. - void Increment(CounterHandle handle) { - DCHECK_EQ(handle.instrument_domain_, domain()); - backend_.Increment(handle.offset_); + void Increment(CounterHandle handle, uint64_t amount = 1) { + GRPC_DCHECK_EQ(handle.instrument_domain_, domain()); + backend_.Add(handle.offset_, amount); + } + + void Increment(UpDownCounterHandle handle, uint64_t amount = 1) { + GRPC_DCHECK_EQ(handle.instrument_domain_, domain()); + backend_.Add(handle.offset_, amount); + } + + void Decrement(UpDownCounterHandle handle, uint64_t amount = 1) { + GRPC_DCHECK_EQ(handle.instrument_domain_, domain()); + backend_.Subtract(handle.offset_, amount); + } + + void Add(DomainStorage* other) override { + GRPC_DCHECK_EQ(domain(), other->domain()); + for (size_t i = 0; i < domain()->allocated_counter_slots(); ++i) { + uint64_t amount = other->SumCounter(i); + if (amount == 0) continue; + backend_.Add(i, amount); + } } template void Increment(const HistogramHandle& handle, int64_t value) { - DCHECK_EQ(handle.instrument_domain_, domain()); + GRPC_DCHECK_EQ(handle.instrument_domain_, domain()); CallHistogramCollectionHooks(handle.description_, label(), value); - backend_.Increment(handle.offset_ + handle.shape_->BucketFor(value)); + backend_.Add(handle.offset_ + handle.shape_->BucketFor(value), 1); } private: @@ -758,10 +899,10 @@ class InstrumentDomainImpl final : public QueryableDomain { }; GPR_ATTRIBUTE_NOINLINE explicit InstrumentDomainImpl( - std::vector label_names, + std::string name, std::vector label_names, size_t map_shards = std::min(16u, gpr_cpu_num_cores())) - : QueryableDomain(std::move(label_names), map_shards) { - CHECK_EQ(this->label_names().size(), N); + : QueryableDomain(std::move(name), std::move(label_names), map_shards) { + GRPC_CHECK_EQ(this->label_names().size(), N); Constructed(); } @@ -777,6 +918,14 @@ class InstrumentDomainImpl final : public QueryableDomain { Counter{}}; } + UpDownCounterHandle RegisterUpDownCounter(absl::string_view name, + absl::string_view description, + absl::string_view unit) { + return UpDownCounterHandle{this, + AllocateUpDownCounter(name, description, unit), + InstrumentMetadata::UpDownCounterShape{}}; + } + template HistogramHandle RegisterHistogram(absl::string_view name, absl::string_view description, @@ -812,13 +961,14 @@ class InstrumentDomainImpl final : public QueryableDomain { // GetStorage: returns a pointer to the storage for the given key, creating // it if necessary. template - RefCountedPtr GetStorage(Args&&... labels) { + RefCountedPtr GetStorage(RefCountedPtr scope, + Args&&... labels) { static_assert(sizeof...(Args) == N, "Incorrect number of labels provided"); - std::vector label_names; - label_names.reserve(N); - (label_names.emplace_back(absl::StrCat(labels)), ...); + std::vector label_values; + label_values.reserve(N); + (label_values.emplace_back(absl::StrCat(labels)), ...); return DownCastRefCountedPtr( - GetDomainStorage(std::move(label_names))); + GetDomainStorage(std::move(scope), label_values)); } RefCountedPtr CreateDomainStorage( @@ -852,20 +1002,23 @@ class InstrumentDomain { static auto* domain = new instrument_detail::InstrumentDomainImpl< typename Derived::Backend, std::tuple_size_v, Derived>( + absl::StrCat(Derived::kName), instrument_detail::MakeLabelFromTuple(Derived::kLabels)); return domain; } // Returns an InstrumentStorageRefPtr. template - static auto GetStorage(Args&&... labels) { - return Domain()->GetStorage(std::forward(labels)...); + static auto GetStorage(RefCountedPtr scope, + Args&&... labels) { + return Domain()->GetStorage(std::move(scope), + std::forward(labels)...); } protected: template static constexpr auto Labels(Label... labels) { - return std::tuple...>{labels...}; + return std::tuple...>{labels...}; } static auto RegisterCounter(absl::string_view name, @@ -874,6 +1027,12 @@ class InstrumentDomain { return Domain()->RegisterCounter(name, description, unit); } + static auto RegisterUpDownCounter(absl::string_view name, + absl::string_view description, + absl::string_view unit) { + return Domain()->RegisterUpDownCounter(name, description, unit); + } + template static auto RegisterHistogram(absl::string_view name, absl::string_view description, @@ -923,9 +1082,23 @@ using GaugeProvider = typename InstrumentDomainImpl::GaugeProvider; // Reset all registered instruments. For test use only. void TestOnlyResetInstruments(); -inline std::unique_ptr CreateCollectionScope() { - return instrument_detail::QueryableDomain::CreateCollectionScope(); -} +// Create a new collection scope. +// `parent` is the parent scope, or nullptr for a root scope. +// `labels` is a list of labels that this scope is interested in. The scope's +// labels of interest will be the union of its own labels and its parent's +// labels. +// `child_shards_count` and `storage_shards_count` are performance tuning +// parameters for sharding internal data structures. +RefCountedPtr CreateCollectionScope( + std::vector> parents, + absl::Span labels, size_t child_shards_count = 1, + size_t storage_shards_count = 1); + +RefCountedPtr CreateRootCollectionScope( + absl::Span labels, size_t child_shards_count = 1, + size_t storage_shards_count = 1); + +RefCountedPtr GlobalCollectionScope(); } // namespace grpc_core diff --git a/deps/grpc/src/core/telemetry/metrics.cc b/deps/grpc/src/core/telemetry/metrics.cc index 02b3c91de9b..f64f3ac48dc 100644 --- a/deps/grpc/src/core/telemetry/metrics.cc +++ b/deps/grpc/src/core/telemetry/metrics.cc @@ -174,6 +174,7 @@ GlobalStatsPluginRegistry::GetStatsPluginsForChannel( group->AddStatsPlugin(node->plugin, std::move(config)); } } + group->Finish(); return group; } @@ -187,6 +188,7 @@ GlobalStatsPluginRegistry::GetStatsPluginsForServer(const ChannelArgs& args) { group->AddStatsPlugin(node->plugin, std::move(config)); } } + group->Finish(); return group; } diff --git a/deps/grpc/src/core/telemetry/metrics.h b/deps/grpc/src/core/telemetry/metrics.h index 6fa155542aa..1e8971cbc85 100644 --- a/deps/grpc/src/core/telemetry/metrics.h +++ b/deps/grpc/src/core/telemetry/metrics.h @@ -23,16 +23,18 @@ #include #include -#include "absl/functional/any_invocable.h" -#include "absl/functional/function_ref.h" -#include "absl/strings/string_view.h" -#include "absl/types/span.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/slice/slice.h" #include "src/core/telemetry/call_tracer.h" +#include "src/core/telemetry/instrument.h" +#include "src/core/util/grpc_check.h" #include "src/core/util/no_destruct.h" #include "src/core/util/sync.h" #include "src/core/util/time.h" +#include "absl/functional/any_invocable.h" +#include "absl/functional/function_ref.h" +#include "absl/strings/string_view.h" +#include "absl/types/span.h" namespace grpc_core { @@ -302,6 +304,13 @@ class StatsPlugin { virtual std::shared_ptr GetServerScopeConfig( const ChannelArgs& args) const = 0; + // Fetch the collection scope for this stats plugin. The scope allows creating + // instrument storage objects for the instrument domains, and partitions + // the instrument collection so that different stats plugins only see the + // subset of metrics they're allowed to see. + // The returned scope must be a root scope (i.e. have no parents). + virtual RefCountedPtr GetCollectionScope() const = 0; + // Adds \a value to the uint64 counter specified by \a handle. \a label_values // and \a optional_label_values specify attributes that are associated with // this measurement and must match with their corresponding keys in @@ -385,6 +394,20 @@ class GlobalStatsPluginRegistry { plugin_state.scope_config = std::move(config); plugins_state_.push_back(std::move(plugin_state)); } + // Finish construction: must be called after all plugins have been added. + void Finish() { + std::vector> collection_scopes; + collection_scopes.reserve(plugins_state_.size() + 1); + collection_scopes.push_back(GlobalCollectionScope()); + for (auto& state : plugins_state_) { + if (auto scope = state.plugin->GetCollectionScope(); scope != nullptr) { + GRPC_DCHECK(scope->IsRoot()); + collection_scopes.push_back(scope); + } + } + collection_scope_ = + CreateCollectionScope(std::move(collection_scopes), {}); + } // Adds a counter in all stats plugins within the group. See the StatsPlugin // interface for more documentation and valid types. template @@ -484,6 +507,11 @@ class GlobalStatsPluginRegistry { static int ChannelArgsCompare(const StatsPluginGroup* a, const StatsPluginGroup* b); + RefCountedPtr GetCollectionScope() const { + CHECK_NE(collection_scope_.get(), nullptr); + return collection_scope_; + } + private: friend class RegisteredMetricCallback; @@ -505,6 +533,7 @@ class GlobalStatsPluginRegistry { } std::vector plugins_state_; + RefCountedPtr collection_scope_; }; // Registers a stats plugin with the global stats plugin registry. diff --git a/deps/grpc/src/core/telemetry/stats.h b/deps/grpc/src/core/telemetry/stats.h index 43ac7c4344e..044a9c7da43 100644 --- a/deps/grpc/src/core/telemetry/stats.h +++ b/deps/grpc/src/core/telemetry/stats.h @@ -25,10 +25,10 @@ #include #include -#include "absl/strings/string_view.h" -#include "absl/types/span.h" #include "src/core/telemetry/histogram_view.h" #include "src/core/telemetry/stats_data.h" +#include "absl/strings/string_view.h" +#include "absl/types/span.h" namespace grpc_core { diff --git a/deps/grpc/src/core/telemetry/stats_data.cc b/deps/grpc/src/core/telemetry/stats_data.cc index ddb2729f726..31939b5921d 100644 --- a/deps/grpc/src/core/telemetry/stats_data.cc +++ b/deps/grpc/src/core/telemetry/stats_data.cc @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// Automatically generated by tools/codegen/core/gen_stats_data.py +// Automatically generated by tools/codegen/core/gen_stats_utils.cc #include "src/core/telemetry/stats_data.h" diff --git a/deps/grpc/src/core/telemetry/stats_data.h b/deps/grpc/src/core/telemetry/stats_data.h index cef82a5ba20..4cdbe7d3bb9 100644 --- a/deps/grpc/src/core/telemetry/stats_data.h +++ b/deps/grpc/src/core/telemetry/stats_data.h @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// Automatically generated by tools/codegen/core/gen_stats_data.py +// Automatically generated by tools/codegen/core/gen_stats_utils.cc #ifndef GRPC_SRC_CORE_TELEMETRY_STATS_DATA_H #define GRPC_SRC_CORE_TELEMETRY_STATS_DATA_H @@ -23,10 +23,10 @@ #include #include -#include "absl/strings/string_view.h" #include "src/core/telemetry/histogram_view.h" #include "src/core/util/no_destruct.h" #include "src/core/util/per_cpu.h" +#include "absl/strings/string_view.h" namespace grpc_core { class GlobalStatsCollector; diff --git a/deps/grpc/src/core/transport/auth_context.cc b/deps/grpc/src/core/transport/auth_context.cc index a9468e627ed..026742f121f 100644 --- a/deps/grpc/src/core/transport/auth_context.cc +++ b/deps/grpc/src/core/transport/auth_context.cc @@ -25,7 +25,6 @@ #include -#include "absl/log/log.h" #include "src/core/config/core_configuration.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/debug/trace.h" @@ -33,6 +32,7 @@ #include "src/core/lib/resource_quota/arena.h" #include "src/core/util/grpc_check.h" #include "src/core/util/ref_counted_ptr.h" +#include "absl/log/log.h" void grpc_auth_context_release(grpc_auth_context* context) { GRPC_TRACE_LOG(api, INFO) diff --git a/deps/grpc/src/core/transport/auth_context.h b/deps/grpc/src/core/transport/auth_context.h index dbadba9744e..33c6dc60577 100644 --- a/deps/grpc/src/core/transport/auth_context.h +++ b/deps/grpc/src/core/transport/auth_context.h @@ -27,7 +27,6 @@ #include #include -#include "absl/strings/string_view.h" #include "src/core/lib/debug/trace.h" #include "src/core/lib/resource_quota/arena.h" #include "src/core/lib/surface/connection_context.h" @@ -36,6 +35,7 @@ #include "src/core/util/ref_counted.h" #include "src/core/util/ref_counted_ptr.h" #include "src/core/util/useful.h" +#include "absl/strings/string_view.h" // --- grpc_auth_context --- @@ -120,6 +120,7 @@ struct grpc_auth_context void ensure_capacity(); void add_property(const char* name, const char* value, size_t value_length); void add_cstring_property(const char* name, const char* value); + absl::string_view protocol() const { return protocol_; } void set_protocol(absl::string_view protocol); // Returns std::nullopt if auth context comparison is not supported. std::optional CompareAuthContext(const grpc_auth_context* other); diff --git a/deps/grpc/src/core/transport/auth_context_comparator_registry.h b/deps/grpc/src/core/transport/auth_context_comparator_registry.h index 187b9a08ad4..d4fab4b34bc 100644 --- a/deps/grpc/src/core/transport/auth_context_comparator_registry.h +++ b/deps/grpc/src/core/transport/auth_context_comparator_registry.h @@ -19,8 +19,8 @@ #include -#include "absl/functional/any_invocable.h" #include "src/core/lib/channel/channel_args.h" +#include "absl/functional/any_invocable.h" struct grpc_auth_context; diff --git a/deps/grpc/src/core/tsi/alts/crypt/aes_gcm.cc b/deps/grpc/src/core/tsi/alts/crypt/aes_gcm.cc index d768f85b216..5f3150d59d9 100644 --- a/deps/grpc/src/core/tsi/alts/crypt/aes_gcm.cc +++ b/deps/grpc/src/core/tsi/alts/crypt/aes_gcm.cc @@ -27,8 +27,8 @@ #include -#include "absl/types/span.h" #include "src/core/tsi/alts/crypt/gsec.h" +#include "absl/types/span.h" constexpr size_t kKdfKeyLen = 32; constexpr size_t kKdfCounterLen = 6; diff --git a/deps/grpc/src/core/tsi/alts/frame_protector/alts_frame_protector.cc b/deps/grpc/src/core/tsi/alts/frame_protector/alts_frame_protector.cc index 534e8555465..9cd4a603996 100644 --- a/deps/grpc/src/core/tsi/alts/frame_protector/alts_frame_protector.cc +++ b/deps/grpc/src/core/tsi/alts/frame_protector/alts_frame_protector.cc @@ -26,13 +26,13 @@ #include #include -#include "absl/log/log.h" -#include "absl/types/span.h" #include "src/core/tsi/alts/crypt/gsec.h" #include "src/core/tsi/alts/frame_protector/alts_crypter.h" #include "src/core/tsi/alts/frame_protector/frame_handler.h" #include "src/core/tsi/transport_security.h" #include "src/core/util/memory.h" +#include "absl/log/log.h" +#include "absl/types/span.h" constexpr size_t kMinFrameLength = 1024; constexpr size_t kDefaultFrameLength = 16 * 1024; diff --git a/deps/grpc/src/core/tsi/alts/frame_protector/frame_handler.cc b/deps/grpc/src/core/tsi/alts/frame_protector/frame_handler.cc index 7fcbcce34bb..ebc15e99862 100644 --- a/deps/grpc/src/core/tsi/alts/frame_protector/frame_handler.cc +++ b/deps/grpc/src/core/tsi/alts/frame_protector/frame_handler.cc @@ -26,9 +26,9 @@ #include -#include "absl/log/log.h" #include "src/core/util/crash.h" #include "src/core/util/memory.h" +#include "absl/log/log.h" // Use little endian to interpret a string of bytes as uint32_t. static uint32_t load_32_le(const unsigned char* buffer) { diff --git a/deps/grpc/src/core/tsi/alts/handshaker/alts_handshaker_client.cc b/deps/grpc/src/core/tsi/alts/handshaker/alts_handshaker_client.cc index 8f6d54900c1..e2cf8b27984 100644 --- a/deps/grpc/src/core/tsi/alts/handshaker/alts_handshaker_client.cc +++ b/deps/grpc/src/core/tsi/alts/handshaker/alts_handshaker_client.cc @@ -26,9 +26,6 @@ #include #include -#include "absl/log/log.h" -#include "absl/strings/numbers.h" -#include "absl/strings/str_split.h" #include "src/core/lib/surface/call.h" #include "src/core/lib/surface/channel.h" #include "src/core/tsi/alts/handshaker/alts_tsi_handshaker_private.h" @@ -37,6 +34,9 @@ #include "src/core/util/grpc_check.h" #include "src/core/util/sync.h" #include "upb/mem/arena.hpp" +#include "absl/log/log.h" +#include "absl/strings/numbers.h" +#include "absl/strings/str_split.h" #define TSI_ALTS_INITIAL_BUFFER_SIZE 256 diff --git a/deps/grpc/src/core/tsi/alts/handshaker/alts_handshaker_client.h b/deps/grpc/src/core/tsi/alts/handshaker/alts_handshaker_client.h index 4d2ca0e1e42..d09e55a87c7 100644 --- a/deps/grpc/src/core/tsi/alts/handshaker/alts_handshaker_client.h +++ b/deps/grpc/src/core/tsi/alts/handshaker/alts_handshaker_client.h @@ -32,7 +32,7 @@ #define ALTS_SERVICE_METHOD "/grpc.gcp.HandshakerService/DoHandshake" #define ALTS_APPLICATION_PROTOCOL "grpc" #define ALTS_RECORD_PROTOCOL "ALTSRP_GCM_AES128_REKEY" -#define ALTS_INTEGRITY_ONLY_RECORD_PROTOCOL "ALTSRP_GCM_GMAC_128" +#define ALTS_INTEGRITY_ONLY_RECORD_PROTOCOL "ALTSRP_GMAC_128" #define ALTS_HANDSHAKER_SERVICE_URL_FOR_TESTING "lame" const size_t kAltsAes128GcmRekeyKeyLength = 44; diff --git a/deps/grpc/src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc b/deps/grpc/src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc index 3fa3dc1c94a..402a432ede5 100644 --- a/deps/grpc/src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc +++ b/deps/grpc/src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc @@ -29,7 +29,6 @@ #include #include -#include "absl/log/log.h" #include "src/core/lib/iomgr/closure.h" #include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/surface/channel.h" @@ -42,6 +41,7 @@ #include "src/core/util/memory.h" #include "src/core/util/sync.h" #include "upb/mem/arena.hpp" +#include "absl/log/log.h" namespace { constexpr absl::string_view kUseGrpcExperimentalAltsHandshakerKeepaliveParams = @@ -220,13 +220,15 @@ static tsi_result handshaker_result_create_zero_copy_grpc_protector( VLOG(2) << "After Frame Size Negotiation, maximum frame size used by frame " "protector equals " << *max_output_protected_frame_size; + bool is_integrity_only = + (result->record_protocol == ALTS_INTEGRITY_ONLY_RECORD_PROTOCOL); tsi_result ok = alts_zero_copy_grpc_protector_create( - grpc_core::GsecKeyFactory({reinterpret_cast(result->key_data), - kAltsAes128GcmRekeyKeyLength}, - /*is_rekey=*/true), - result->is_client, - /*is_integrity_only=*/ - (result->record_protocol == ALTS_INTEGRITY_ONLY_RECORD_PROTOCOL), + grpc_core::GsecKeyFactory( + {reinterpret_cast(result->key_data), + is_integrity_only ? kAes128GcmKeyLength + : kAltsAes128GcmRekeyKeyLength}, + !is_integrity_only), + result->is_client, is_integrity_only, /*enable_extra_copy=*/false, max_output_protected_frame_size, protector); if (ok != TSI_OK) { LOG(ERROR) << "Failed to create zero-copy grpc protector"; diff --git a/deps/grpc/src/core/tsi/alts/handshaker/alts_tsi_utils.cc b/deps/grpc/src/core/tsi/alts/handshaker/alts_tsi_utils.cc index ba783ca3324..3d65df3bbc3 100644 --- a/deps/grpc/src/core/tsi/alts/handshaker/alts_tsi_utils.cc +++ b/deps/grpc/src/core/tsi/alts/handshaker/alts_tsi_utils.cc @@ -21,10 +21,10 @@ #include #include -#include "absl/log/log.h" #include "src/core/lib/slice/slice.h" #include "src/core/lib/slice/slice_internal.h" #include "src/core/util/grpc_check.h" +#include "absl/log/log.h" tsi_result alts_tsi_utils_convert_to_tsi_result(grpc_status_code code) { switch (code) { diff --git a/deps/grpc/src/core/tsi/alts/handshaker/transport_security_common_api.cc b/deps/grpc/src/core/tsi/alts/handshaker/transport_security_common_api.cc index a7881e0d71f..5f9c7803898 100644 --- a/deps/grpc/src/core/tsi/alts/handshaker/transport_security_common_api.cc +++ b/deps/grpc/src/core/tsi/alts/handshaker/transport_security_common_api.cc @@ -20,8 +20,8 @@ #include -#include "absl/log/log.h" #include "upb/mem/arena.hpp" +#include "absl/log/log.h" bool grpc_gcp_rpc_protocol_versions_set_max( grpc_gcp_rpc_protocol_versions* versions, uint32_t max_major, diff --git a/deps/grpc/src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_integrity_only_record_protocol.cc b/deps/grpc/src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_integrity_only_record_protocol.cc index 03dacc3667a..3a83c94e296 100644 --- a/deps/grpc/src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_integrity_only_record_protocol.cc +++ b/deps/grpc/src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_integrity_only_record_protocol.cc @@ -22,13 +22,13 @@ #include #include -#include "absl/log/log.h" #include "src/core/lib/slice/slice.h" #include "src/core/lib/slice/slice_internal.h" #include "src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_record_protocol_common.h" #include "src/core/tsi/alts/zero_copy_frame_protector/alts_iovec_record_protocol.h" #include "src/core/util/crash.h" #include "src/core/util/grpc_check.h" +#include "absl/log/log.h" // Main struct for alts_grpc_integrity_only_record_protocol. typedef struct alts_grpc_integrity_only_record_protocol { diff --git a/deps/grpc/src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_privacy_integrity_record_protocol.cc b/deps/grpc/src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_privacy_integrity_record_protocol.cc index cc10ddb8eb4..7386846135d 100644 --- a/deps/grpc/src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_privacy_integrity_record_protocol.cc +++ b/deps/grpc/src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_privacy_integrity_record_protocol.cc @@ -21,18 +21,26 @@ #include #include -#include "absl/log/log.h" #include "src/core/lib/slice/slice.h" #include "src/core/lib/slice/slice_internal.h" #include "src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_record_protocol_common.h" #include "src/core/tsi/alts/zero_copy_frame_protector/alts_iovec_record_protocol.h" #include "src/core/util/crash.h" +#include "absl/log/log.h" // Privacy-integrity alts_grpc_record_protocol object uses the same struct // defined in alts_grpc_record_protocol_common.h. // --- alts_grpc_record_protocol methods implementation. --- +static grpc_slice allocate_slice(alts_grpc_record_protocol* rp, size_t size) { + if (rp->alloc_cb != nullptr) { + return rp->alloc_cb(size, rp->alloc_user_data); + } else { + return GRPC_SLICE_MALLOC(size); + } +} + static tsi_result alts_grpc_privacy_integrity_protect( alts_grpc_record_protocol* rp, grpc_slice_buffer* unprotected_slices, grpc_slice_buffer* protected_slices) { @@ -48,7 +56,7 @@ static tsi_result alts_grpc_privacy_integrity_protect( size_t protected_frame_size = unprotected_slices->length + rp->header_length + alts_iovec_record_protocol_get_tag_length(rp->iovec_rp); - grpc_slice protected_slice = GRPC_SLICE_MALLOC(protected_frame_size); + grpc_slice protected_slice = allocate_slice(rp, protected_frame_size); iovec_t protected_iovec = {GRPC_SLICE_START_PTR(protected_slice), GRPC_SLICE_LENGTH(protected_slice)}; // Calls alts_iovec_record_protocol protect. @@ -88,7 +96,7 @@ static tsi_result alts_grpc_privacy_integrity_unprotect( } size_t unprotected_frame_size = protected_slices->length - rp->header_length - rp->tag_length; - grpc_slice unprotected_slice = GRPC_SLICE_MALLOC(unprotected_frame_size); + grpc_slice unprotected_slice = allocate_slice(rp, unprotected_frame_size); iovec_t unprotected_iovec = {GRPC_SLICE_START_PTR(unprotected_slice), GRPC_SLICE_LENGTH(unprotected_slice)}; // Strips frame header from protected slices. diff --git a/deps/grpc/src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_record_protocol.h b/deps/grpc/src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_record_protocol.h index 5838eb4696c..a20b6dbba31 100644 --- a/deps/grpc/src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_record_protocol.h +++ b/deps/grpc/src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_record_protocol.h @@ -22,6 +22,7 @@ #include #include +#include "src/core/tsi/transport_security_grpc.h" #include "src/core/tsi/transport_security_interface.h" /// @@ -86,4 +87,13 @@ size_t alts_grpc_record_protocol_max_unprotected_data_size( /// void alts_grpc_record_protocol_destroy(alts_grpc_record_protocol* self); +/// +/// This method sets the allocation callback for the alts_grpc_record_protocol +/// instance. +/// +void alts_grpc_record_protocol_set_allocation_callback( + alts_grpc_record_protocol* self, + tsi_zero_copy_grpc_protector_allocator_cb allocator_cb, + void* allocator_user_data); + #endif // GRPC_SRC_CORE_TSI_ALTS_ZERO_COPY_FRAME_PROTECTOR_ALTS_GRPC_RECORD_PROTOCOL_H diff --git a/deps/grpc/src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_record_protocol_common.cc b/deps/grpc/src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_record_protocol_common.cc index 338ec0f9341..9ec58c852f5 100644 --- a/deps/grpc/src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_record_protocol_common.cc +++ b/deps/grpc/src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_record_protocol_common.cc @@ -22,12 +22,12 @@ #include #include -#include "absl/log/log.h" #include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/slice/slice_internal.h" #include "src/core/util/crash.h" #include "src/core/util/grpc_check.h" #include "src/core/util/useful.h" +#include "absl/log/log.h" const size_t kInitialIovecBufferSize = 8; @@ -173,3 +173,11 @@ size_t alts_grpc_record_protocol_max_unprotected_data_size( return alts_iovec_record_protocol_max_unprotected_data_size( self->iovec_rp, max_protected_frame_size); } + +void alts_grpc_record_protocol_set_allocation_callback( + alts_grpc_record_protocol* self, + tsi_zero_copy_grpc_protector_allocator_cb allocator_cb, void* user_data) { + if (self == nullptr) return; + self->alloc_cb = allocator_cb; + self->alloc_user_data = user_data; +} diff --git a/deps/grpc/src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_record_protocol_common.h b/deps/grpc/src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_record_protocol_common.h index 9f7f4fee738..1202bdd1111 100644 --- a/deps/grpc/src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_record_protocol_common.h +++ b/deps/grpc/src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_record_protocol_common.h @@ -29,6 +29,7 @@ #include "src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_record_protocol.h" #include "src/core/tsi/alts/zero_copy_frame_protector/alts_iovec_record_protocol.h" +#include "src/core/tsi/transport_security_grpc.h" // V-table for alts_grpc_record_protocol implementations. struct alts_grpc_record_protocol_vtable { @@ -53,6 +54,8 @@ struct alts_grpc_record_protocol { size_t tag_length; iovec_t* iovec_buf; size_t iovec_buf_length; + tsi_zero_copy_grpc_protector_allocator_cb alloc_cb; + void* alloc_user_data; }; /// diff --git a/deps/grpc/src/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector.cc b/deps/grpc/src/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector.cc index 78e54f54e3b..108023bea0d 100644 --- a/deps/grpc/src/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector.cc +++ b/deps/grpc/src/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector.cc @@ -25,7 +25,6 @@ #include #include -#include "absl/log/log.h" #include "src/core/tsi/alts/crypt/gsec.h" #include "src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_integrity_only_record_protocol.h" #include "src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_privacy_integrity_record_protocol.h" @@ -33,6 +32,7 @@ #include "src/core/tsi/alts/zero_copy_frame_protector/alts_iovec_record_protocol.h" #include "src/core/tsi/transport_security_grpc.h" #include "src/core/util/grpc_check.h" +#include "absl/log/log.h" constexpr size_t kMinFrameLength = 1024; constexpr size_t kDefaultFrameLength = 16 * 1024; @@ -256,13 +256,26 @@ static bool alts_zero_copy_grpc_protector_read_frame_size( return read_frame_size(protected_slices, frame_size); } +static void alts_zero_copy_grpc_protector_set_allocator( + tsi_zero_copy_grpc_protector* self, + tsi_zero_copy_grpc_protector_allocator_cb alloc_cb, void* user_data) { + alts_zero_copy_grpc_protector* impl = + reinterpret_cast(self); + // Set on both protect and unprotect protocols + alts_grpc_record_protocol_set_allocation_callback(impl->record_protocol, + alloc_cb, user_data); + alts_grpc_record_protocol_set_allocation_callback(impl->unrecord_protocol, + alloc_cb, user_data); +} + static const tsi_zero_copy_grpc_protector_vtable alts_zero_copy_grpc_protector_vtable = { alts_zero_copy_grpc_protector_protect, alts_zero_copy_grpc_protector_unprotect, alts_zero_copy_grpc_protector_destroy, alts_zero_copy_grpc_protector_max_frame_size, - alts_zero_copy_grpc_protector_read_frame_size}; + alts_zero_copy_grpc_protector_read_frame_size, + alts_zero_copy_grpc_protector_set_allocator}; tsi_result alts_zero_copy_grpc_protector_create( const grpc_core::GsecKeyFactoryInterface& key_factory, bool is_client, diff --git a/deps/grpc/src/core/tsi/fake_transport_security.cc b/deps/grpc/src/core/tsi/fake_transport_security.cc index be1d60e75fb..3b1162c42f5 100644 --- a/deps/grpc/src/core/tsi/fake_transport_security.cc +++ b/deps/grpc/src/core/tsi/fake_transport_security.cc @@ -23,13 +23,13 @@ #include #include -#include "absl/log/log.h" #include "src/core/lib/slice/slice_internal.h" #include "src/core/tsi/transport_security_grpc.h" #include "src/core/tsi/transport_security_interface.h" #include "src/core/util/crash.h" #include "src/core/util/grpc_check.h" #include "src/core/util/memory.h" +#include "absl/log/log.h" // --- Constants. --- #define TSI_FAKE_FRAME_HEADER_SIZE 4 @@ -543,6 +543,7 @@ static const tsi_zero_copy_grpc_protector_vtable fake_zero_copy_grpc_protector_destroy, fake_zero_copy_grpc_protector_max_frame_size, fake_zero_copy_grpc_protector_read_frame_size, + nullptr /* set_allocator */ }; // --- tsi_handshaker_result methods implementation. --- diff --git a/deps/grpc/src/core/tsi/local_transport_security.cc b/deps/grpc/src/core/tsi/local_transport_security.cc index ced2ef2baa1..34e9ba78ff8 100644 --- a/deps/grpc/src/core/tsi/local_transport_security.cc +++ b/deps/grpc/src/core/tsi/local_transport_security.cc @@ -25,10 +25,10 @@ #include #include -#include "absl/log/log.h" #include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/tsi/transport_security_grpc.h" #include "src/core/util/crash.h" +#include "absl/log/log.h" namespace { diff --git a/deps/grpc/src/core/tsi/ssl/key_logging/ssl_key_logging.cc b/deps/grpc/src/core/tsi/ssl/key_logging/ssl_key_logging.cc index 54b4d2cfd38..66ee5cd7420 100644 --- a/deps/grpc/src/core/tsi/ssl/key_logging/ssl_key_logging.cc +++ b/deps/grpc/src/core/tsi/ssl/key_logging/ssl_key_logging.cc @@ -18,12 +18,12 @@ #include -#include "absl/log/log.h" #include "src/core/lib/iomgr/error.h" #include "src/core/lib/slice/slice_internal.h" #include "src/core/util/crash.h" #include "src/core/util/grpc_check.h" #include "src/core/util/sync.h" +#include "absl/log/log.h" using TlsSessionKeyLogger = tsi::TlsSessionKeyLoggerCache::TlsSessionKeyLogger; diff --git a/deps/grpc/src/core/tsi/ssl/key_logging/ssl_key_logging.h b/deps/grpc/src/core/tsi/ssl/key_logging/ssl_key_logging.h index 472ddc70a09..60b0e62e6c5 100644 --- a/deps/grpc/src/core/tsi/ssl/key_logging/ssl_key_logging.h +++ b/deps/grpc/src/core/tsi/ssl/key_logging/ssl_key_logging.h @@ -24,10 +24,10 @@ #include #include -#include "absl/base/thread_annotations.h" #include "src/core/util/memory.h" #include "src/core/util/ref_counted.h" #include "src/core/util/sync.h" +#include "absl/base/thread_annotations.h" namespace tsi { diff --git a/deps/grpc/src/core/tsi/ssl/session_cache/ssl_session_cache.cc b/deps/grpc/src/core/tsi/ssl/session_cache/ssl_session_cache.cc index 015b21fe9a7..94a47fab89c 100644 --- a/deps/grpc/src/core/tsi/ssl/session_cache/ssl_session_cache.cc +++ b/deps/grpc/src/core/tsi/ssl/session_cache/ssl_session_cache.cc @@ -21,12 +21,12 @@ #include #include -#include "absl/log/log.h" #include "src/core/lib/slice/slice_internal.h" #include "src/core/tsi/ssl/session_cache/ssl_session.h" #include "src/core/util/crash.h" #include "src/core/util/grpc_check.h" #include "src/core/util/sync.h" +#include "absl/log/log.h" namespace tsi { diff --git a/deps/grpc/src/core/tsi/ssl/session_cache/ssl_session_openssl.cc b/deps/grpc/src/core/tsi/ssl/session_cache/ssl_session_openssl.cc index 4fba365b4db..d67289fd04a 100644 --- a/deps/grpc/src/core/tsi/ssl/session_cache/ssl_session_openssl.cc +++ b/deps/grpc/src/core/tsi/ssl/session_cache/ssl_session_openssl.cc @@ -23,8 +23,8 @@ #ifndef OPENSSL_IS_BORINGSSL -#include "absl/memory/memory.h" #include "src/core/lib/slice/slice.h" +#include "absl/memory/memory.h" // OpenSSL invalidates SSL_SESSION on SSL destruction making it pointless // to cache sessions. The workaround is to serialize (relatively expensive) diff --git a/deps/grpc/src/core/tsi/ssl_transport_security.cc b/deps/grpc/src/core/tsi/ssl_transport_security.cc index 3ed4cc8f2f7..6526d3feb69 100644 --- a/deps/grpc/src/core/tsi/ssl_transport_security.cc +++ b/deps/grpc/src/core/tsi/ssl_transport_security.cc @@ -53,12 +53,6 @@ #include #include -#include "absl/log/log.h" -#include "absl/strings/match.h" -#include "absl/strings/numbers.h" -#include "absl/strings/str_cat.h" -#include "absl/strings/str_split.h" -#include "absl/strings/string_view.h" #include "src/core/credentials/transport/tls/grpc_tls_crl_provider.h" #include "src/core/credentials/transport/tls/ssl_utils.h" #include "src/core/lib/surface/init.h" @@ -74,6 +68,12 @@ #include "src/core/util/match.h" #include "src/core/util/sync.h" #include "src/core/util/useful.h" +#include "absl/log/log.h" +#include "absl/strings/match.h" +#include "absl/strings/numbers.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/str_split.h" +#include "absl/strings/string_view.h" // Name of the environment variable controlling OpenSSL cleanup timeout. // This variable allows users to specify the timeout (in seconds) for OpenSSL diff --git a/deps/grpc/src/core/tsi/ssl_transport_security.h b/deps/grpc/src/core/tsi/ssl_transport_security.h index 820d562d05e..8379e49296d 100644 --- a/deps/grpc/src/core/tsi/ssl_transport_security.h +++ b/deps/grpc/src/core/tsi/ssl_transport_security.h @@ -26,11 +26,11 @@ #include -#include "absl/strings/string_view.h" #include "src/core/credentials/transport/tls/spiffe_utils.h" #include "src/core/tsi/ssl/key_logging/ssl_key_logging.h" #include "src/core/tsi/ssl_transport_security_utils.h" #include "src/core/tsi/transport_security_interface.h" +#include "absl/strings/string_view.h" // Value for the TSI_CERTIFICATE_TYPE_PEER_PROPERTY property for X509 certs. #define TSI_X509_CERTIFICATE_TYPE "X509" diff --git a/deps/grpc/src/core/tsi/ssl_transport_security_utils.cc b/deps/grpc/src/core/tsi/ssl_transport_security_utils.cc index bb3df93ace8..8f6607c2153 100644 --- a/deps/grpc/src/core/tsi/ssl_transport_security_utils.cc +++ b/deps/grpc/src/core/tsi/ssl_transport_security_utils.cc @@ -30,11 +30,11 @@ #include #include +#include "src/core/tsi/transport_security_interface.h" +#include "src/core/util/grpc_check.h" #include "absl/log/log.h" #include "absl/status/status.h" #include "absl/status/statusor.h" -#include "src/core/tsi/transport_security_interface.h" -#include "src/core/util/grpc_check.h" namespace grpc_core { diff --git a/deps/grpc/src/core/tsi/ssl_transport_security_utils.h b/deps/grpc/src/core/tsi/ssl_transport_security_utils.h index d71847accc7..5fad26f658b 100644 --- a/deps/grpc/src/core/tsi/ssl_transport_security_utils.h +++ b/deps/grpc/src/core/tsi/ssl_transport_security_utils.h @@ -25,11 +25,11 @@ #include #include +#include "src/core/tsi/ssl/key_logging/ssl_key_logging.h" +#include "src/core/tsi/transport_security_interface.h" #include "absl/status/status.h" #include "absl/status/statusor.h" #include "absl/strings/string_view.h" -#include "src/core/tsi/ssl/key_logging/ssl_key_logging.h" -#include "src/core/tsi/transport_security_interface.h" namespace grpc_core { diff --git a/deps/grpc/src/core/tsi/test_creds/BUILD b/deps/grpc/src/core/tsi/test_creds/BUILD index eeac5e35d7b..ea86dece28c 100644 --- a/deps/grpc/src/core/tsi/test_creds/BUILD +++ b/deps/grpc/src/core/tsi/test_creds/BUILD @@ -12,6 +12,11 @@ # See the License for the specific language governing permissions and # limitations under the License. +package(features = [ + "layering_check", + "parse_headers", +]) + licenses(["notice"]) exports_files([ diff --git a/deps/grpc/src/core/tsi/transport_security_grpc.cc b/deps/grpc/src/core/tsi/transport_security_grpc.cc index e711cc8588e..398de8a6b45 100644 --- a/deps/grpc/src/core/tsi/transport_security_grpc.cc +++ b/deps/grpc/src/core/tsi/transport_security_grpc.cc @@ -80,3 +80,11 @@ bool tsi_zero_copy_grpc_protector_read_frame_size( if (self->vtable->read_frame_size == nullptr) return false; return self->vtable->read_frame_size(self, protected_slices, frame_size); } + +void tsi_zero_copy_grpc_protector_set_allocator( + tsi_zero_copy_grpc_protector* self, + tsi_zero_copy_grpc_protector_allocator_cb alloc_cb, void* user_data) { + if (self != nullptr && self->vtable->set_allocator != nullptr) { + self->vtable->set_allocator(self, alloc_cb, user_data); + } +} diff --git a/deps/grpc/src/core/tsi/transport_security_grpc.h b/deps/grpc/src/core/tsi/transport_security_grpc.h index 0a81cc7335c..b6a965f11ac 100644 --- a/deps/grpc/src/core/tsi/transport_security_grpc.h +++ b/deps/grpc/src/core/tsi/transport_security_grpc.h @@ -24,6 +24,9 @@ #include "src/core/tsi/transport_security.h" +typedef grpc_slice (*tsi_zero_copy_grpc_protector_allocator_cb)( + size_t size, void* user_data); + // This method creates a tsi_zero_copy_grpc_protector object. It return TSI_OK // assuming there is no fatal error. // The caller is responsible for destroying the protector. @@ -75,6 +78,15 @@ bool tsi_zero_copy_grpc_protector_read_frame_size( tsi_zero_copy_grpc_protector* self, grpc_slice_buffer* protected_slices, uint32_t* frame_size); +// Sets the allocator callback for the tsi_zero_copy_grpc_protector object. +// The allocator callback is used to allocate memory for the protected and +// unprotected slices. +// - alloc_cb is the allocator callback. +// - user_data is the user data to be passed to the allocator callback. +void tsi_zero_copy_grpc_protector_set_allocator( + tsi_zero_copy_grpc_protector* self, + tsi_zero_copy_grpc_protector_allocator_cb alloc_cb, void* user_data); + // Base for tsi_zero_copy_grpc_protector implementations. // Implementations must guarantee that protect and unprotect can be called // concurrently. @@ -92,6 +104,9 @@ struct tsi_zero_copy_grpc_protector_vtable { bool (*read_frame_size)(tsi_zero_copy_grpc_protector* self, grpc_slice_buffer* protected_slices, uint32_t* frame_size); + void (*set_allocator)(tsi_zero_copy_grpc_protector* self, + tsi_zero_copy_grpc_protector_allocator_cb alloc_cb, + void* user_data); }; struct tsi_zero_copy_grpc_protector { diff --git a/deps/grpc/src/core/util/alloc.cc b/deps/grpc/src/core/util/alloc.cc index 2ce94f9db78..aa11d37b344 100644 --- a/deps/grpc/src/core/util/alloc.cc +++ b/deps/grpc/src/core/util/alloc.cc @@ -21,8 +21,8 @@ #include #include -#include "absl/log/check.h" #include "src/core/util/crash.h" +#include "absl/log/check.h" void* gpr_malloc(size_t size) { void* p; diff --git a/deps/grpc/src/core/util/backoff.h b/deps/grpc/src/core/util/backoff.h index 2c11c2c8c11..cbbfd653a2a 100644 --- a/deps/grpc/src/core/util/backoff.h +++ b/deps/grpc/src/core/util/backoff.h @@ -19,8 +19,8 @@ #ifndef GRPC_SRC_CORE_UTIL_BACKOFF_H #define GRPC_SRC_CORE_UTIL_BACKOFF_H -#include "absl/random/random.h" #include "src/core/util/time.h" +#include "absl/random/random.h" namespace grpc_core { diff --git a/deps/grpc/src/core/util/crash.h b/deps/grpc/src/core/util/crash.h index ece32088903..d4a756b7491 100644 --- a/deps/grpc/src/core/util/crash.h +++ b/deps/grpc/src/core/util/crash.h @@ -17,8 +17,8 @@ #include -#include "absl/strings/string_view.h" #include "src/core/util/debug_location.h" +#include "absl/strings/string_view.h" namespace grpc_core { diff --git a/deps/grpc/src/core/util/dual_ref_counted.h b/deps/grpc/src/core/util/dual_ref_counted.h index 491bcc77e2b..72ef952ac39 100644 --- a/deps/grpc/src/core/util/dual_ref_counted.h +++ b/deps/grpc/src/core/util/dual_ref_counted.h @@ -22,13 +22,13 @@ #include #include -#include "absl/log/check.h" -#include "absl/log/log.h" #include "src/core/util/debug_location.h" #include "src/core/util/down_cast.h" #include "src/core/util/orphanable.h" #include "src/core/util/ref_counted.h" #include "src/core/util/ref_counted_ptr.h" +#include "absl/log/check.h" +#include "absl/log/log.h" namespace grpc_core { diff --git a/deps/grpc/src/core/util/event_log.cc b/deps/grpc/src/core/util/event_log.cc index 4a90318a560..3fa0513ee19 100644 --- a/deps/grpc/src/core/util/event_log.cc +++ b/deps/grpc/src/core/util/event_log.cc @@ -19,9 +19,9 @@ #include #include +#include "src/core/util/grpc_check.h" #include "absl/strings/str_cat.h" #include "absl/strings/str_join.h" -#include "src/core/util/grpc_check.h" namespace grpc_core { diff --git a/deps/grpc/src/core/util/event_log.h b/deps/grpc/src/core/util/event_log.h index 47254348db5..542c557ed35 100644 --- a/deps/grpc/src/core/util/event_log.h +++ b/deps/grpc/src/core/util/event_log.h @@ -22,12 +22,12 @@ #include #include -#include "absl/base/thread_annotations.h" -#include "absl/strings/string_view.h" -#include "absl/types/span.h" #include "src/core/util/per_cpu.h" #include "src/core/util/sync.h" #include "src/core/util/time_precise.h" +#include "absl/base/thread_annotations.h" +#include "absl/strings/string_view.h" +#include "absl/types/span.h" namespace grpc_core { diff --git a/deps/grpc/src/core/util/gcp_metadata_query.cc b/deps/grpc/src/core/util/gcp_metadata_query.cc index 3bf28d44b66..2e4de699afe 100644 --- a/deps/grpc/src/core/util/gcp_metadata_query.cc +++ b/deps/grpc/src/core/util/gcp_metadata_query.cc @@ -27,11 +27,6 @@ #include #include -#include "absl/log/log.h" -#include "absl/status/status.h" -#include "absl/status/statusor.h" -#include "absl/strings/str_format.h" -#include "absl/strings/string_view.h" #include "src/core/credentials/transport/transport_credentials.h" #include "src/core/lib/debug/trace.h" #include "src/core/util/grpc_check.h" @@ -39,6 +34,11 @@ #include "src/core/util/status_helper.h" #include "src/core/util/time.h" #include "src/core/util/uri.h" +#include "absl/log/log.h" +#include "absl/status/status.h" +#include "absl/status/statusor.h" +#include "absl/strings/str_format.h" +#include "absl/strings/string_view.h" namespace grpc_core { diff --git a/deps/grpc/src/core/util/gcp_metadata_query.h b/deps/grpc/src/core/util/gcp_metadata_query.h index a72ff5ae4d0..413ad8aad99 100644 --- a/deps/grpc/src/core/util/gcp_metadata_query.h +++ b/deps/grpc/src/core/util/gcp_metadata_query.h @@ -21,8 +21,6 @@ #include -#include "absl/functional/any_invocable.h" -#include "absl/status/statusor.h" #include "src/core/lib/iomgr/closure.h" #include "src/core/lib/iomgr/error.h" #include "src/core/lib/iomgr/polling_entity.h" @@ -30,6 +28,8 @@ #include "src/core/util/http_client/parser.h" #include "src/core/util/orphanable.h" #include "src/core/util/time.h" +#include "absl/functional/any_invocable.h" +#include "absl/status/statusor.h" namespace grpc_core { diff --git a/deps/grpc/src/core/util/glob.cc b/deps/grpc/src/core/util/glob.cc index 1b1c16e23d3..22e54259f06 100644 --- a/deps/grpc/src/core/util/glob.cc +++ b/deps/grpc/src/core/util/glob.cc @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include + #include "absl/strings/string_view.h" namespace grpc_core { diff --git a/deps/grpc/src/core/util/grpc_check.cc b/deps/grpc/src/core/util/grpc_check.cc index 4adbfa02099..8a31d5998bd 100644 --- a/deps/grpc/src/core/util/grpc_check.cc +++ b/deps/grpc/src/core/util/grpc_check.cc @@ -19,4 +19,6 @@ bool PostMortemEmitAndReturnTrue() { grpc_core::PostMortemEmit(); return true; } +#else +bool PostMortemEmitAndReturnTrue() { return true; } #endif \ No newline at end of file diff --git a/deps/grpc/src/core/util/grpc_check.h b/deps/grpc/src/core/util/grpc_check.h index a53ea6d6253..6ea849a1f38 100644 --- a/deps/grpc/src/core/util/grpc_check.h +++ b/deps/grpc/src/core/util/grpc_check.h @@ -18,8 +18,8 @@ #ifdef GRPC_POSTMORTEM_CHECKS #include -#include "absl/log/log.h" #include "src/core/util/postmortem_emit.h" +#include "absl/log/log.h" bool PostMortemEmitAndReturnTrue(); diff --git a/deps/grpc/src/core/util/grpc_if_nametoindex_posix.cc b/deps/grpc/src/core/util/grpc_if_nametoindex_posix.cc index 1d5b866e5e0..e45622d7e04 100644 --- a/deps/grpc/src/core/util/grpc_if_nametoindex_posix.cc +++ b/deps/grpc/src/core/util/grpc_if_nametoindex_posix.cc @@ -25,9 +25,9 @@ #include #include -#include "absl/log/log.h" #include "src/core/util/crash.h" #include "src/core/util/grpc_if_nametoindex.h" +#include "absl/log/log.h" uint32_t grpc_if_nametoindex(char* name) { uint32_t out = if_nametoindex(name); diff --git a/deps/grpc/src/core/util/grpc_if_nametoindex_unsupported.cc b/deps/grpc/src/core/util/grpc_if_nametoindex_unsupported.cc index cabca947c60..8e358a9dd55 100644 --- a/deps/grpc/src/core/util/grpc_if_nametoindex_unsupported.cc +++ b/deps/grpc/src/core/util/grpc_if_nametoindex_unsupported.cc @@ -22,9 +22,9 @@ #if GRPC_IF_NAMETOINDEX == 0 || !defined(GRPC_POSIX_SOCKET_IF_NAMETOINDEX) -#include "absl/log/log.h" #include "src/core/util/crash.h" #include "src/core/util/grpc_if_nametoindex.h" +#include "absl/log/log.h" uint32_t grpc_if_nametoindex(char* name) { VLOG(2) << "Not attempting to convert interface name " << name diff --git a/deps/grpc/src/core/util/http_client/format_request.cc b/deps/grpc/src/core/util/http_client/format_request.cc index 8c56935dad0..3deb8512027 100644 --- a/deps/grpc/src/core/util/http_client/format_request.cc +++ b/deps/grpc/src/core/util/http_client/format_request.cc @@ -27,11 +27,11 @@ #include #include +#include "src/core/util/http_client/httpcli.h" #include "absl/strings/str_cat.h" #include "absl/strings/str_format.h" #include "absl/strings/str_join.h" #include "absl/strings/string_view.h" -#include "src/core/util/http_client/httpcli.h" static void fill_common_header(const grpc_http_request* request, const char* host, const char* path, diff --git a/deps/grpc/src/core/util/http_client/httpcli.cc b/deps/grpc/src/core/util/http_client/httpcli.cc index bf1931b69ce..b6953f3f33a 100644 --- a/deps/grpc/src/core/util/http_client/httpcli.cc +++ b/deps/grpc/src/core/util/http_client/httpcli.cc @@ -27,9 +27,6 @@ #include #include -#include "absl/functional/bind_front.h" -#include "absl/status/status.h" -#include "absl/strings/str_format.h" #include "src/core/config/core_configuration.h" #include "src/core/credentials/transport/security_connector.h" #include "src/core/credentials/transport/transport_credentials.h" @@ -52,6 +49,9 @@ #include "src/core/util/http_client/format_request.h" #include "src/core/util/http_client/parser.h" #include "src/core/util/status_helper.h" +#include "absl/functional/bind_front.h" +#include "absl/status/status.h" +#include "absl/strings/str_format.h" namespace grpc_core { diff --git a/deps/grpc/src/core/util/http_client/httpcli.h b/deps/grpc/src/core/util/http_client/httpcli.h index eeb61bd9927..7840320ec51 100644 --- a/deps/grpc/src/core/util/http_client/httpcli.h +++ b/deps/grpc/src/core/util/http_client/httpcli.h @@ -30,10 +30,6 @@ #include #include -#include "absl/base/thread_annotations.h" -#include "absl/status/status.h" -#include "absl/status/statusor.h" -#include "absl/strings/string_view.h" #include "src/core/handshaker/handshaker.h" #include "src/core/lib/event_engine/shim.h" #include "src/core/lib/iomgr/closure.h" @@ -52,6 +48,10 @@ #include "src/core/util/sync.h" #include "src/core/util/time.h" #include "src/core/util/uri.h" +#include "absl/base/thread_annotations.h" +#include "absl/status/status.h" +#include "absl/status/statusor.h" +#include "absl/strings/string_view.h" // User agent this library reports #define GRPC_HTTPCLI_USER_AGENT "grpc-httpcli/0.0" diff --git a/deps/grpc/src/core/util/http_client/httpcli_security_connector.cc b/deps/grpc/src/core/util/http_client/httpcli_security_connector.cc index cc8ec14dbba..a577a096d4c 100644 --- a/deps/grpc/src/core/util/http_client/httpcli_security_connector.cc +++ b/deps/grpc/src/core/util/http_client/httpcli_security_connector.cc @@ -28,10 +28,6 @@ #include #include -#include "absl/log/log.h" -#include "absl/status/status.h" -#include "absl/strings/str_cat.h" -#include "absl/strings/string_view.h" #include "src/core/credentials/transport/security_connector.h" #include "src/core/credentials/transport/tls/ssl_utils.h" #include "src/core/credentials/transport/transport_credentials.h" @@ -50,6 +46,10 @@ #include "src/core/util/debug_location.h" #include "src/core/util/ref_counted_ptr.h" #include "src/core/util/unique_type_name.h" +#include "absl/log/log.h" +#include "absl/status/status.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/string_view.h" namespace grpc_core { diff --git a/deps/grpc/src/core/util/http_client/parser.cc b/deps/grpc/src/core/util/http_client/parser.cc index cfe22aba9f3..72158e6e2d7 100644 --- a/deps/grpc/src/core/util/http_client/parser.cc +++ b/deps/grpc/src/core/util/http_client/parser.cc @@ -24,9 +24,9 @@ #include +#include "src/core/util/grpc_check.h" #include "absl/log/log.h" #include "absl/status/status.h" -#include "src/core/util/grpc_check.h" static char* buf2str(void* buffer, size_t length) { char* out = static_cast(gpr_malloc(length + 1)); diff --git a/deps/grpc/src/core/util/json/json_channel_args.h b/deps/grpc/src/core/util/json/json_channel_args.h index 9b70ea3f53c..a4de1437025 100644 --- a/deps/grpc/src/core/util/json/json_channel_args.h +++ b/deps/grpc/src/core/util/json/json_channel_args.h @@ -19,9 +19,9 @@ #include -#include "absl/strings/string_view.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/util/json/json_args.h" +#include "absl/strings/string_view.h" namespace grpc_core { diff --git a/deps/grpc/src/core/util/json/json_object_loader.h b/deps/grpc/src/core/util/json/json_object_loader.h index 908c62fe1cb..a95032d8f53 100644 --- a/deps/grpc/src/core/util/json/json_object_loader.h +++ b/deps/grpc/src/core/util/json/json_object_loader.h @@ -25,18 +25,18 @@ #include #include -#include "absl/meta/type_traits.h" -#include "absl/status/status.h" -#include "absl/status/statusor.h" -#include "absl/strings/numbers.h" -#include "absl/strings/str_cat.h" -#include "absl/strings/string_view.h" #include "src/core/util/json/json.h" #include "src/core/util/json/json_args.h" #include "src/core/util/no_destruct.h" #include "src/core/util/ref_counted_ptr.h" #include "src/core/util/time.h" #include "src/core/util/validation_errors.h" +#include "absl/meta/type_traits.h" +#include "absl/status/status.h" +#include "absl/status/statusor.h" +#include "absl/strings/numbers.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/string_view.h" // Provides a means to load JSON objects into C++ objects, with the aim of // minimizing object code size. diff --git a/deps/grpc/src/core/util/json/json_reader.cc b/deps/grpc/src/core/util/json/json_reader.cc index 5b437af925e..f1458ff14a1 100644 --- a/deps/grpc/src/core/util/json/json_reader.cc +++ b/deps/grpc/src/core/util/json/json_reader.cc @@ -26,6 +26,8 @@ #include #include +#include "src/core/util/json/json.h" +#include "src/core/util/match.h" #include "absl/base/attributes.h" #include "absl/log/check.h" #include "absl/status/status.h" @@ -34,8 +36,6 @@ #include "absl/strings/str_format.h" #include "absl/strings/str_join.h" #include "absl/strings/string_view.h" -#include "src/core/util/json/json.h" -#include "src/core/util/match.h" #define GRPC_JSON_MAX_DEPTH 255 #define GRPC_JSON_MAX_ERRORS 16 diff --git a/deps/grpc/src/core/util/json/json_reader.h b/deps/grpc/src/core/util/json/json_reader.h index 127b3808807..7ba5220a5ee 100644 --- a/deps/grpc/src/core/util/json/json_reader.h +++ b/deps/grpc/src/core/util/json/json_reader.h @@ -19,9 +19,9 @@ #include +#include "src/core/util/json/json.h" #include "absl/status/statusor.h" #include "absl/strings/string_view.h" -#include "src/core/util/json/json.h" namespace grpc_core { diff --git a/deps/grpc/src/core/util/json/json_util.h b/deps/grpc/src/core/util/json/json_util.h index 7cb5b8b1103..70e61b51cf0 100644 --- a/deps/grpc/src/core/util/json/json_util.h +++ b/deps/grpc/src/core/util/json/json_util.h @@ -28,12 +28,12 @@ #include #include -#include "absl/strings/numbers.h" -#include "absl/strings/str_cat.h" -#include "absl/strings/string_view.h" #include "src/core/lib/iomgr/error.h" #include "src/core/util/json/json.h" #include "src/core/util/time.h" +#include "absl/strings/numbers.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/string_view.h" namespace grpc_core { diff --git a/deps/grpc/src/core/util/json/json_writer.cc b/deps/grpc/src/core/util/json/json_writer.cc index ebe075172b7..04dfb113338 100644 --- a/deps/grpc/src/core/util/json/json_writer.cc +++ b/deps/grpc/src/core/util/json/json_writer.cc @@ -25,8 +25,8 @@ #include #include -#include "absl/strings/string_view.h" #include "src/core/util/json/json.h" +#include "absl/strings/string_view.h" namespace grpc_core { diff --git a/deps/grpc/src/core/util/latent_see.cc b/deps/grpc/src/core/util/latent_see.cc index 2710827c286..0e8dcbef6d2 100644 --- a/deps/grpc/src/core/util/latent_see.cc +++ b/deps/grpc/src/core/util/latent_see.cc @@ -16,15 +16,19 @@ #include #include +#include #include #include #include -#include "absl/log/log.h" -#include "absl/strings/str_cat.h" +#include "src/core/channelz/property_list.h" #include "src/core/util/backoff.h" +#include "src/core/util/json/json.h" +#include "src/core/util/json/json_writer.h" #include "src/core/util/notification.h" #include "src/core/util/sync.h" +#include "absl/log/log.h" +#include "absl/strings/str_cat.h" namespace grpc_core::latent_see { @@ -38,10 +42,13 @@ std::string JsonOutput::MicrosString(int64_t nanos) { return absl::StrFormat("%d.%03d", micros, remainder); } -void JsonOutput::Mark(absl::string_view name, int64_t tid, int64_t timestamp) { +void JsonOutput::Mark(absl::string_view name, int64_t tid, int64_t timestamp, + channelz::PropertyList property_list) { + auto properties_json = Json::FromObject(property_list.TakeJsonObject()); out_ << absl::StrCat(sep_, "{\"name\":\"", name, "\",\"ph\":\"i\",\"ts\":", MicrosString(timestamp), - ",\"pid\":0,\"tid\":", tid, "}"); + ",\"pid\":0,\"tid\":", tid, + ",\"args\":", JsonDump(properties_json), "}"); sep_ = ",\n"; } @@ -55,9 +62,10 @@ void JsonOutput::FlowBegin(absl::string_view name, int64_t tid, void JsonOutput::FlowEnd(absl::string_view name, int64_t tid, int64_t timestamp, int64_t flow_id) { - out_ << absl::StrCat(sep_, "{\"name\":\"", name, - "\",\"ph\":\"f\",\"ts\":", MicrosString(timestamp), - ",\"pid\":0,\"tid\":", tid, ",\"id\":", flow_id, "}"); + out_ << absl::StrCat( + sep_, "{\"name\":\"", name, + "\",\"ph\":\"f\",\"bp\":\"e\",\"ts\":", MicrosString(timestamp), + ",\"pid\":0,\"tid\":", tid, ",\"id\":", flow_id, "}"); sep_ = ",\n"; } @@ -130,7 +138,7 @@ std::unique_ptr Sink::Stop() { void Sink::Record(std::unique_ptr bin) { MutexLock lock(&mu_); if (events_ == nullptr) return; - CHECK_LE(bin->num_events, Bin::kEventsPerBin); + CHECK_LE(bin->used_space, Bin::kMaxBinSize); events_->emplace_back(std::move(bin)); if (events_->size() > max_bins_) events_->pop_front(); } @@ -177,11 +185,16 @@ void Collect(Notification* n, absl::Duration timeout, size_t memory_limit, earliest_timestamp = std::min( {earliest_timestamp, event.timestamp_begin, event.timestamp_end}); } else { - earliest_timestamp = std::min(earliest_timestamp, -event.timestamp_end); + earliest_timestamp = + std::min(earliest_timestamp, abs(event.timestamp_end)); } } } std::string json = "[\n"; + // Add a mark for the actual timestamp when collection started. + output->Mark( + "LatentseeCollectionStart", /*tid=*/0, /*timestamp=*/0, + channelz::PropertyList().Set("actual_start_time", earliest_timestamp)); // TODO(ctiller): Fuschia Trace Format backend absl::flat_hash_map thread_id_map; for (const auto& bin : *events) { @@ -193,22 +206,30 @@ void Collect(Notification* n, absl::Duration timeout, size_t memory_limit, } else { displayed_thread_id = it->second; } - for (const auto& event : *bin) { - if (event.timestamp_begin == event.timestamp_end) { - output->Mark(event.metadata->name, displayed_thread_id, - event.timestamp_begin - earliest_timestamp); - } else if (event.timestamp_begin < 0 && event.timestamp_end > 0) { - output->FlowBegin(event.metadata->name, displayed_thread_id, - event.timestamp_end - earliest_timestamp, - -event.timestamp_begin); - } else if (event.timestamp_begin < 0) { - output->FlowEnd(event.metadata->name, displayed_thread_id, - -event.timestamp_end - earliest_timestamp, - -event.timestamp_begin); + for (auto it = bin->begin(); it != bin->end(); ++it) { + if (it->timestamp_begin == it->timestamp_end) { + if (it->metadata->extra_event_size > 0) { + output->Mark( + it->metadata->name, displayed_thread_id, + it->timestamp_begin - earliest_timestamp, + it->metadata->to_property_list(it.ptr() + sizeof(Bin::Event))); + } else { + output->Mark(it->metadata->name, displayed_thread_id, + it->timestamp_begin - earliest_timestamp, + channelz::PropertyList()); + } + } else if (it->timestamp_begin < 0 && it->timestamp_end > 0) { + output->FlowBegin(it->metadata->name, displayed_thread_id, + it->timestamp_end - earliest_timestamp, + -it->timestamp_begin); + } else if (it->timestamp_begin < 0) { + output->FlowEnd(it->metadata->name, displayed_thread_id, + -it->timestamp_end - earliest_timestamp, + -it->timestamp_begin); } else { - output->Span(event.metadata->name, displayed_thread_id, - event.timestamp_begin - earliest_timestamp, - event.timestamp_end - event.timestamp_begin); + output->Span(it->metadata->name, displayed_thread_id, + it->timestamp_begin - earliest_timestamp, + it->timestamp_end - it->timestamp_begin); } } } diff --git a/deps/grpc/src/core/util/latent_see.h b/deps/grpc/src/core/util/latent_see.h index 1c987f5db90..b21f43241f4 100644 --- a/deps/grpc/src/core/util/latent_see.h +++ b/deps/grpc/src/core/util/latent_see.h @@ -19,25 +19,32 @@ #include #include +#include #include #include #include +#include #include +#include #include -#include "absl/container/flat_hash_map.h" -#include "absl/strings/string_view.h" -#include "absl/time/clock.h" +#include "src/core/channelz/property_list.h" +#include "src/core/util/alloc.h" +#include "src/core/util/function_signature.h" #include "src/core/util/mpscq.h" #include "src/core/util/notification.h" #include "src/core/util/thd.h" +#include "absl/container/flat_hash_map.h" +#include "absl/strings/string_view.h" +#include "absl/time/clock.h" namespace grpc_core { namespace latent_see { class Output { public: - virtual void Mark(absl::string_view name, int64_t tid, int64_t timestamp) = 0; + virtual void Mark(absl::string_view name, int64_t tid, int64_t timestamp, + channelz::PropertyList property_list) = 0; virtual void FlowBegin(absl::string_view name, int64_t tid, int64_t timestamp, int64_t flow_id) = 0; virtual void FlowEnd(absl::string_view name, int64_t tid, int64_t timestamp, @@ -52,7 +59,8 @@ class Output { class DiscardOutput final : public Output { public: - void Mark(absl::string_view, int64_t, int64_t) override {} + void Mark(absl::string_view, int64_t, int64_t, + channelz::PropertyList) override {} void FlowBegin(absl::string_view, int64_t, int64_t, int64_t) override {} void FlowEnd(absl::string_view, int64_t, int64_t, int64_t) override {} void Span(absl::string_view, int64_t, int64_t, int64_t) override {} @@ -63,7 +71,8 @@ class JsonOutput final : public Output { public: explicit JsonOutput(std::ostream& out) : out_(out) { out_ << "[\n"; } - void Mark(absl::string_view name, int64_t tid, int64_t timestamp) override; + void Mark(absl::string_view name, int64_t tid, int64_t timestamp, + channelz::PropertyList property_list) override; void FlowBegin(absl::string_view name, int64_t tid, int64_t timestamp, int64_t flow_id) override; void FlowEnd(absl::string_view name, int64_t tid, int64_t timestamp, @@ -91,11 +100,14 @@ struct Metadata { const char* file; int line; absl::string_view name; + int extra_event_size; + void (*destruct_extra_event)(void* extra_event); + channelz::PropertyList (*to_property_list)(void* extra_event); }; // A bin collects all events that occur within a parent scope. struct Bin : public MultiProducerSingleConsumerQueue::Node { - struct Event { + struct alignas(GPR_MAX_ALIGNMENT) Event { const Metadata* metadata; int64_t timestamp_begin; int64_t timestamp_end; @@ -103,24 +115,109 @@ struct Bin : public MultiProducerSingleConsumerQueue::Node { static constexpr uint64_t kSpan = 0; static constexpr uint64_t kFlow = 1; }; + enum class AppendResult : uint8_t { + kSuccess = 0, + kFailed = 1, + kFull = 2, + }; + class Iterator { + public: + // Type definitions required by STL + using value_type = Event; + using pointer = Event*; + using reference = Event&; + using difference_type = std::ptrdiff_t; + using iterator_category = std::forward_iterator_tag; // Or other categories + + // Constructor + explicit Iterator(const uint8_t* ptr) : ptr_(ptr) {} + + // Dereference operator + const Event& operator*() const { + return *reinterpret_cast(ptr_); + } + const Event* operator->() const { + return reinterpret_cast(ptr_); + } - bool Append(const Metadata* metadata, int64_t timestamp_begin, - int64_t timestamp_end) { - Event* ev = &events[num_events]; - ++num_events; + uint8_t* ptr() const { return const_cast(ptr_); } + + // Increment operators + Iterator& operator++() { // Pre-increment + const Event* curr_event = reinterpret_cast(ptr_); + if (curr_event->metadata->extra_event_size == 0) { + ptr_ += sizeof(Event); + } else { + ptr_ += curr_event->metadata->extra_event_size + sizeof(Event); + } + return *this; + } + Iterator operator++(int) { // Post-increment + Iterator temp = *this; + operator++(); + return temp; + } + + // Comparison operators + bool operator==(const Iterator& other) const { return ptr_ == other.ptr_; } + bool operator!=(const Iterator& other) const { return ptr_ != other.ptr_; } + + private: + const uint8_t* ptr_; + }; + + AppendResult Append(const Metadata* metadata, int64_t timestamp_begin, + int64_t timestamp_end) { + Event* ev = reinterpret_cast(&events[used_space]); + if (used_space + sizeof(Event) > kMaxBinSize) { + // No space left in the bin to append the event. + return AppendResult::kFailed; + } + ev->metadata = metadata; + ev->timestamp_begin = timestamp_begin; + ev->timestamp_end = timestamp_end; + used_space += sizeof(Event); + return used_space == kMaxBinSize ? AppendResult::kFull + : AppendResult::kSuccess; + } + + template + AppendResult Append(const Metadata* metadata, int64_t timestamp_begin, + int64_t timestamp_end, const X& x) { + if (used_space + sizeof(Event) + + GPR_ROUND_UP_TO_ALIGNMENT_SIZE(metadata->extra_event_size) > + kMaxBinSize) { + // No space left in the bin to append this event. + return AppendResult::kFailed; + } + uint8_t* ptr = &events[used_space]; + // Copy construct the extra_event in the space immediately after this + // Event struct. + new (reinterpret_cast(ptr + sizeof(Event))) X(x); + Event* ev = reinterpret_cast(ptr); ev->metadata = metadata; ev->timestamp_begin = timestamp_begin; ev->timestamp_end = timestamp_end; - return num_events == kEventsPerBin; + used_space += sizeof(Event) + metadata->extra_event_size; + return used_space == kMaxBinSize ? AppendResult::kFull + : AppendResult::kSuccess; } - const Event* begin() const { return events.data(); } - const Event* end() const { return events.data() + num_events; } + ~Bin() { + for (auto it = this->begin(); it != this->end(); ++it) { + if (it->metadata->extra_event_size > 0) { + it->metadata->destruct_extra_event(it.ptr() + sizeof(Event)); + } + } + } - static constexpr size_t kEventsPerBin = 8192 / sizeof(Event) - 1; - size_t num_events = 0; + Iterator begin() const { return Iterator(&events[0]); } + Iterator end() const { return Iterator(&events[used_space]); } + static constexpr size_t kMaxBinSize = 8192; + static constexpr size_t kEventsPerBin = kMaxBinSize / sizeof(Event); + size_t used_space = 0; gpr_thd_id thd_id = gpr_thd_currentid(); - std::array events; + alignas(Event) uint8_t events[kMaxBinSize]; }; void Collect(Notification* notification, absl::Duration timeout, @@ -166,8 +263,38 @@ class Appender { int64_t timestamp_end) { DCHECK(Enabled()); DCHECK_NE(metadata, nullptr); - if (GPR_UNLIKELY(bin_ == nullptr)) bin_ = std::make_unique(); - if (GPR_UNLIKELY(bin_->Append(metadata, timestamp_begin, timestamp_end))) { + Bin::AppendResult result; + do { + if (GPR_UNLIKELY(bin_ == nullptr)) bin_ = std::make_unique(); + result = bin_->Append(metadata, timestamp_begin, timestamp_end); + if (GPR_UNLIKELY(result == Bin::AppendResult::kFailed)) { + sink_->Append(std::move(bin_)); + // Retry with a new bin. + bin_ = nullptr; + } + } while (result == Bin::AppendResult::kFailed); + + if (GPR_UNLIKELY(result == Bin::AppendResult::kFull)) { + sink_->Append(std::move(bin_)); + } + } + template + void Append(const Metadata* metadata, int64_t timestamp_begin, + int64_t timestamp_end, const X& x) { + DCHECK(Enabled()); + DCHECK_NE(metadata, nullptr); + Bin::AppendResult result; + do { + if (GPR_UNLIKELY(bin_ == nullptr)) bin_ = std::make_unique(); + result = bin_->Append(metadata, timestamp_begin, timestamp_end, x); + if (GPR_UNLIKELY(result == Bin::AppendResult::kFailed)) { + sink_->Append(std::move(bin_)); + // Retry with a new bin. + bin_ = nullptr; + } + } while (result == Bin::AppendResult::kFailed); + + if (GPR_UNLIKELY(result == Bin::AppendResult::kFull)) { sink_->Append(std::move(bin_)); } } @@ -224,6 +351,15 @@ GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION static inline void Mark( appender.Append(metadata, ts, ts); } +template +GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION static inline void MarkExtraEvent( + const Metadata* metadata, const X& x) { + Appender appender; + if (GPR_LIKELY(!appender.Enabled())) return; + const auto ts = absl::GetCurrentTimeNanos(); + appender.Append(metadata, ts, ts, x); +} + class Flow { public: GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION Flow() : id_(0) {} @@ -312,11 +448,29 @@ GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION auto Promise(const Metadata* md_poll, #define GRPC_LATENT_SEE_SYMBOL2(name, line) name##_##line #define GRPC_LATENT_SEE_SYMBOL1(name, line) GRPC_LATENT_SEE_SYMBOL2(name, line) #define GRPC_LATENT_SEE_SYMBOL(name) GRPC_LATENT_SEE_SYMBOL1(name, __LINE__) -#define GRPC_LATENT_SEE_METADATA(name) \ - []() { \ - static grpc_core::latent_see::Metadata metadata = {__FILE__, __LINE__, \ - name}; \ - return &metadata; \ +#define GRPC_LATENT_SEE_METADATA(name) \ + []() { \ + static grpc_core::latent_see::Metadata metadata = { \ + __FILE__, __LINE__, name, 0, nullptr, nullptr}; \ + return &metadata; \ + }() +// NOLINTNEXTLINE(bugprone-macro-parentheses) +#define GRPC_LATENT_SEE_EXTRA_EVENT_METADATA(type) \ + []() { \ + static grpc_core::latent_see::Metadata metadata = { \ + __FILE__, \ + __LINE__, \ + TypeName(), \ + GPR_ROUND_UP_TO_ALIGNMENT_SIZE(sizeof(type)), \ + [](void* extra_event) { \ + /* NOLINTNEXTLINE(bugprone-macro-parentheses) */ \ + reinterpret_cast(extra_event)->~type(); \ + }, \ + [](void* extra_event) { \ + /* NOLINTNEXTLINE(bugprone-macro-parentheses) */ \ + return reinterpret_cast(extra_event)->ChannelzProperties(); \ + }}; \ + return &metadata; \ }() // Scope: marks a begin/end event in the log. #define GRPC_LATENT_SEE_ALWAYS_ON_SCOPE(name) \ @@ -325,6 +479,9 @@ GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION auto Promise(const Metadata* md_poll, // Mark: logs a single event. #define GRPC_LATENT_SEE_ALWAYS_ON_MARK(name) \ grpc_core::latent_see::Mark(GRPC_LATENT_SEE_METADATA(name)) +#define GRPC_LATENT_SEE_ALWAYS_ON_MARK_EXTRA_EVENT(type, extra_event) \ + grpc_core::latent_see::MarkExtraEvent( \ + GRPC_LATENT_SEE_EXTRA_EVENT_METADATA(type), extra_event) #define GRPC_LATENT_SEE_ALWAYS_ON_PROMISE(name, promise) \ grpc_core::latent_see::Promise( \ GRPC_LATENT_SEE_METADATA("Poll:" name), GRPC_LATENT_SEE_METADATA(name), \ @@ -335,6 +492,8 @@ GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION auto Promise(const Metadata* md_poll, #ifdef GRPC_EXTRA_LATENT_SEE #define GRPC_LATENT_SEE_SCOPE(name) GRPC_LATENT_SEE_ALWAYS_ON_SCOPE(name) #define GRPC_LATENT_SEE_MARK(name) GRPC_LATENT_SEE_ALWAYS_ON_MARK(name) +#define GRPC_LATENT_SEE_MARK_EXTRA_EVENT(type, extra_event) \ + GRPC_LATENT_SEE_ALWAYS_ON_MARK_EXTRA_EVENT(type, extra_event) #define GRPC_LATENT_SEE_PROMISE(name, promise) \ GRPC_LATENT_SEE_ALWAYS_ON_PROMISE(name, promise) #else @@ -344,6 +503,9 @@ GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION auto Promise(const Metadata* md_poll, #define GRPC_LATENT_SEE_MARK(name) \ do { \ } while (0) +#define GRPC_LATENT_SEE_MARK_EXTRA_EVENT(type, extra_event) \ + do { \ + } while (0) #define GRPC_LATENT_SEE_PROMISE(name, promise) promise #endif #else // def(GRPC_DISABLE_LATENT_SEE) @@ -372,6 +534,9 @@ inline void Collect(Notification*, absl::Duration, size_t, Output* output) { #define GRPC_LATENT_SEE_ALWAYS_ON_MARK(name) \ do { \ } while (0) +#define GRPC_LATENT_SEE_ALWAYS_ON_MARK_EXTRA_EVENT(type, extra_event) \ + do { \ + } while (0) #define GRPC_LATENT_SEE_ALWAYS_ON_PROMISE(name, promise) promise #define GRPC_LATENT_SEE_SCOPE(name) \ do { \ @@ -379,6 +544,9 @@ inline void Collect(Notification*, absl::Duration, size_t, Output* output) { #define GRPC_LATENT_SEE_MARK(name) \ do { \ } while (0) +#define GRPC_LATENT_MARK_EXTRA_EVENT(type, extra_event) \ + do { \ + } while (0) #define GRPC_LATENT_SEE_PROMISE(name, promise) promise #endif // GRPC_DISABLE_LATENT_SEE diff --git a/deps/grpc/src/core/util/linux/cpu.cc b/deps/grpc/src/core/util/linux/cpu.cc index 41730292e89..40ff1e1a248 100644 --- a/deps/grpc/src/core/util/linux/cpu.cc +++ b/deps/grpc/src/core/util/linux/cpu.cc @@ -31,9 +31,9 @@ #include #include -#include "absl/log/log.h" #include "src/core/util/crash.h" #include "src/core/util/strerror.h" +#include "absl/log/log.h" static int ncpus = 0; diff --git a/deps/grpc/src/core/util/load_file.cc b/deps/grpc/src/core/util/load_file.cc index 445452c6e9d..c9e6a204063 100644 --- a/deps/grpc/src/core/util/load_file.cc +++ b/deps/grpc/src/core/util/load_file.cc @@ -21,10 +21,10 @@ #include #include +#include "src/core/util/strerror.h" #include "absl/cleanup/cleanup.h" #include "absl/status/status.h" #include "absl/strings/str_cat.h" -#include "src/core/util/strerror.h" namespace grpc_core { diff --git a/deps/grpc/src/core/util/load_file.h b/deps/grpc/src/core/util/load_file.h index 980e0c11af6..26163f5100b 100644 --- a/deps/grpc/src/core/util/load_file.h +++ b/deps/grpc/src/core/util/load_file.h @@ -19,8 +19,8 @@ #include -#include "absl/status/statusor.h" #include "src/core/lib/slice/slice.h" +#include "absl/status/statusor.h" namespace grpc_core { diff --git a/deps/grpc/src/core/util/log.cc b/deps/grpc/src/core/util/log.cc index 641513f60e0..df8e9f8c572 100644 --- a/deps/grpc/src/core/util/log.cc +++ b/deps/grpc/src/core/util/log.cc @@ -25,13 +25,13 @@ #include #include +#include "src/core/config/config_vars.h" +#include "src/core/util/crash.h" +#include "src/core/util/string.h" #include "absl/log/check.h" #include "absl/log/globals.h" #include "absl/strings/match.h" #include "absl/strings/str_cat.h" -#include "src/core/config/config_vars.h" -#include "src/core/util/crash.h" -#include "src/core/util/string.h" void gpr_unreachable_code(const char* reason, const char* file, int line) { grpc_core::Crash(absl::StrCat("UNREACHABLE CODE: ", reason), diff --git a/deps/grpc/src/core/util/lru_cache.h b/deps/grpc/src/core/util/lru_cache.h index 6bde1b4156b..924d73eaeab 100644 --- a/deps/grpc/src/core/util/lru_cache.h +++ b/deps/grpc/src/core/util/lru_cache.h @@ -22,9 +22,9 @@ #include #include +#include "src/core/util/grpc_check.h" #include "absl/container/flat_hash_map.h" #include "absl/functional/any_invocable.h" -#include "src/core/util/grpc_check.h" namespace grpc_core { diff --git a/deps/grpc/src/core/util/matchers.h b/deps/grpc/src/core/util/matchers.h index d98d3c90f44..20cf5c48069 100644 --- a/deps/grpc/src/core/util/matchers.h +++ b/deps/grpc/src/core/util/matchers.h @@ -22,9 +22,9 @@ #include #include +#include "re2/re2.h" #include "absl/status/statusor.h" #include "absl/strings/string_view.h" -#include "re2/re2.h" namespace grpc_core { diff --git a/deps/grpc/src/core/util/memory_usage.h b/deps/grpc/src/core/util/memory_usage.h index 927c4c4afbc..3425531fb80 100644 --- a/deps/grpc/src/core/util/memory_usage.h +++ b/deps/grpc/src/core/util/memory_usage.h @@ -23,14 +23,14 @@ #include #include +#include "src/core/lib/slice/slice.h" +#include "src/core/lib/slice/slice_buffer.h" +#include "src/core/util/time.h" #include "absl/log/log.h" #include "absl/status/status.h" #include "absl/status/statusor.h" #include "absl/strings/string_view.h" #include "absl/time/time.h" -#include "src/core/lib/slice/slice.h" -#include "src/core/lib/slice/slice_buffer.h" -#include "src/core/util/time.h" namespace grpc_core { diff --git a/deps/grpc/src/core/util/mpscq.h b/deps/grpc/src/core/util/mpscq.h index 44502a0b352..bd48f88940e 100644 --- a/deps/grpc/src/core/util/mpscq.h +++ b/deps/grpc/src/core/util/mpscq.h @@ -23,8 +23,8 @@ #include -#include "absl/log/check.h" #include "src/core/util/sync.h" +#include "absl/log/check.h" namespace grpc_core { diff --git a/deps/grpc/src/core/util/notification.h b/deps/grpc/src/core/util/notification.h index 4fca3d26cb5..0dcce670c2d 100644 --- a/deps/grpc/src/core/util/notification.h +++ b/deps/grpc/src/core/util/notification.h @@ -17,9 +17,9 @@ #include +#include "src/core/util/sync.h" #include "absl/time/clock.h" #include "absl/time/time.h" -#include "src/core/util/sync.h" namespace grpc_core { diff --git a/deps/grpc/src/core/util/posix/cpu.cc b/deps/grpc/src/core/util/posix/cpu.cc index 92a9e45635e..4e7d7ceaf13 100644 --- a/deps/grpc/src/core/util/posix/cpu.cc +++ b/deps/grpc/src/core/util/posix/cpu.cc @@ -27,9 +27,9 @@ #include #include -#include "absl/log/log.h" #include "src/core/util/crash.h" #include "src/core/util/useful.h" +#include "absl/log/log.h" static long ncpus = 0; diff --git a/deps/grpc/src/core/util/posix/stat.cc b/deps/grpc/src/core/util/posix/stat.cc index 5de6f456321..aad6eb6d2cd 100644 --- a/deps/grpc/src/core/util/posix/stat.cc +++ b/deps/grpc/src/core/util/posix/stat.cc @@ -27,10 +27,10 @@ #include #include -#include "absl/log/check.h" -#include "absl/log/log.h" #include "src/core/util/stat.h" #include "src/core/util/strerror.h" +#include "absl/log/check.h" +#include "absl/log/log.h" namespace grpc_core { diff --git a/deps/grpc/src/core/util/posix/thd.cc b/deps/grpc/src/core/util/posix/thd.cc index 764882dd676..cc9956c9936 100644 --- a/deps/grpc/src/core/util/posix/thd.cc +++ b/deps/grpc/src/core/util/posix/thd.cc @@ -34,13 +34,13 @@ #include #include -#include "absl/log/check.h" -#include "absl/log/log.h" #include "src/core/util/crash.h" #include "src/core/util/fork.h" #include "src/core/util/strerror.h" #include "src/core/util/thd.h" #include "src/core/util/useful.h" +#include "absl/log/check.h" +#include "absl/log/log.h" namespace grpc_core { namespace { diff --git a/deps/grpc/src/core/util/posix/tmpfile.cc b/deps/grpc/src/core/util/posix/tmpfile.cc index 832391f1599..2becde2c40a 100644 --- a/deps/grpc/src/core/util/posix/tmpfile.cc +++ b/deps/grpc/src/core/util/posix/tmpfile.cc @@ -27,12 +27,12 @@ #include #include -#include "absl/log/check.h" -#include "absl/log/log.h" #include "src/core/util/crash.h" #include "src/core/util/strerror.h" #include "src/core/util/string.h" #include "src/core/util/tmpfile.h" +#include "absl/log/check.h" +#include "absl/log/log.h" FILE* gpr_tmpfile(const char* prefix, char** tmp_filename) { FILE* result = nullptr; diff --git a/deps/grpc/src/core/util/ref_counted.h b/deps/grpc/src/core/util/ref_counted.h index b82a99b83f7..66674ff364b 100644 --- a/deps/grpc/src/core/util/ref_counted.h +++ b/deps/grpc/src/core/util/ref_counted.h @@ -25,12 +25,12 @@ #include #include -#include "absl/log/check.h" -#include "absl/log/log.h" #include "src/core/util/atomic_utils.h" #include "src/core/util/debug_location.h" #include "src/core/util/down_cast.h" #include "src/core/util/ref_counted_ptr.h" +#include "absl/log/check.h" +#include "absl/log/log.h" namespace grpc_core { diff --git a/deps/grpc/src/core/util/ref_counted_ptr.h b/deps/grpc/src/core/util/ref_counted_ptr.h index c4c7ac87f24..d6394d0f49c 100644 --- a/deps/grpc/src/core/util/ref_counted_ptr.h +++ b/deps/grpc/src/core/util/ref_counted_ptr.h @@ -26,9 +26,9 @@ #include #include -#include "absl/hash/hash.h" #include "src/core/util/debug_location.h" #include "src/core/util/down_cast.h" +#include "absl/hash/hash.h" namespace grpc_core { diff --git a/deps/grpc/src/core/util/ref_counted_string.h b/deps/grpc/src/core/util/ref_counted_string.h index 936d9c5742f..186256c93f7 100644 --- a/deps/grpc/src/core/util/ref_counted_string.h +++ b/deps/grpc/src/core/util/ref_counted_string.h @@ -22,9 +22,9 @@ #include -#include "absl/strings/string_view.h" #include "src/core/util/ref_counted.h" #include "src/core/util/ref_counted_ptr.h" +#include "absl/strings/string_view.h" namespace grpc_core { diff --git a/deps/grpc/src/core/util/single_set_ptr.h b/deps/grpc/src/core/util/single_set_ptr.h index 073535e6468..afbad90e45a 100644 --- a/deps/grpc/src/core/util/single_set_ptr.h +++ b/deps/grpc/src/core/util/single_set_ptr.h @@ -20,8 +20,8 @@ #include #include -#include "absl/log/check.h" #include "src/core/util/ref_counted_ptr.h" +#include "absl/log/check.h" namespace grpc_core { @@ -60,6 +60,8 @@ class SingleSetPtr { T* Set(std::unique_ptr ptr) { return Set(ptr.release()); } // Clear the pointer. + // Caller must ensure that no other thread is concurrently trying to set the + // pointer, or read the pointer. void Reset() { Delete(p_.exchange(nullptr, std::memory_order_acq_rel)); } bool is_set() const { return p_.load(std::memory_order_relaxed) != nullptr; } diff --git a/deps/grpc/src/core/util/status_helper.cc b/deps/grpc/src/core/util/status_helper.cc index e7c956e5ec9..c75cbc1c195 100644 --- a/deps/grpc/src/core/util/status_helper.cc +++ b/deps/grpc/src/core/util/status_helper.cc @@ -23,14 +23,6 @@ #include -#include "absl/log/check.h" -#include "absl/strings/cord.h" -#include "absl/strings/escaping.h" -#include "absl/strings/match.h" -#include "absl/strings/numbers.h" -#include "absl/strings/str_cat.h" -#include "absl/strings/str_join.h" -#include "absl/time/clock.h" #include "google/protobuf/any.upb.h" #include "google/rpc/status.upb.h" #include "src/core/lib/experiments/experiments.h" @@ -40,6 +32,14 @@ #include "src/core/util/time.h" #include "upb/base/string_view.h" #include "upb/mem/arena.hpp" +#include "absl/log/check.h" +#include "absl/strings/cord.h" +#include "absl/strings/escaping.h" +#include "absl/strings/match.h" +#include "absl/strings/numbers.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/str_join.h" +#include "absl/time/clock.h" namespace grpc_core { diff --git a/deps/grpc/src/core/util/status_helper.h b/deps/grpc/src/core/util/status_helper.h index ea580d7ae79..9dd07c11cec 100644 --- a/deps/grpc/src/core/util/status_helper.h +++ b/deps/grpc/src/core/util/status_helper.h @@ -26,10 +26,10 @@ #include #include +#include "src/core/util/debug_location.h" #include "absl/status/status.h" #include "absl/strings/string_view.h" #include "absl/time/time.h" -#include "src/core/util/debug_location.h" extern "C" { struct google_rpc_Status; diff --git a/deps/grpc/src/core/util/string.cc b/deps/grpc/src/core/util/string.cc index 00cf0b00269..c96c99e67da 100644 --- a/deps/grpc/src/core/util/string.cc +++ b/deps/grpc/src/core/util/string.cc @@ -29,10 +29,10 @@ #include #include -#include "absl/strings/str_cat.h" -#include "absl/time/time.h" #include "src/core/util/crash.h" #include "src/core/util/useful.h" +#include "absl/strings/str_cat.h" +#include "absl/time/time.h" char* gpr_strdup(const char* src) { char* dst; diff --git a/deps/grpc/src/core/util/subprocess_posix.cc b/deps/grpc/src/core/util/subprocess_posix.cc index 42fa4befe59..a09c4ea72ba 100644 --- a/deps/grpc/src/core/util/subprocess_posix.cc +++ b/deps/grpc/src/core/util/subprocess_posix.cc @@ -29,12 +29,12 @@ #include -#include "absl/log/log.h" -#include "absl/strings/substitute.h" #include "src/core/util/grpc_check.h" #include "src/core/util/memory.h" #include "src/core/util/strerror.h" #include "src/core/util/subprocess.h" +#include "absl/log/log.h" +#include "absl/strings/substitute.h" struct gpr_subprocess { int pid; diff --git a/deps/grpc/src/core/util/subprocess_windows.cc b/deps/grpc/src/core/util/subprocess_windows.cc index 4db3d3f9d41..4516bb57f19 100644 --- a/deps/grpc/src/core/util/subprocess_windows.cc +++ b/deps/grpc/src/core/util/subprocess_windows.cc @@ -27,13 +27,13 @@ #include -#include "absl/log/log.h" -#include "absl/strings/str_join.h" -#include "absl/types/span.h" #include "src/core/util/crash.h" #include "src/core/util/string.h" #include "src/core/util/subprocess.h" #include "src/core/util/tchar.h" +#include "absl/log/log.h" +#include "absl/strings/str_join.h" +#include "absl/types/span.h" struct gpr_subprocess { PROCESS_INFORMATION pi; diff --git a/deps/grpc/src/core/util/sync_abseil.cc b/deps/grpc/src/core/util/sync_abseil.cc index e39085197d2..d1cd7f71a33 100644 --- a/deps/grpc/src/core/util/sync_abseil.cc +++ b/deps/grpc/src/core/util/sync_abseil.cc @@ -26,11 +26,11 @@ #include #include +#include "src/core/util/time_util.h" #include "absl/base/call_once.h" #include "absl/synchronization/mutex.h" #include "absl/time/clock.h" #include "absl/time/time.h" -#include "src/core/util/time_util.h" void gpr_mu_init(gpr_mu* mu) { static_assert(sizeof(gpr_mu) == sizeof(absl::Mutex), diff --git a/deps/grpc/src/core/util/table.h b/deps/grpc/src/core/util/table.h index a9b27379d55..f2e962ada26 100644 --- a/deps/grpc/src/core/util/table.h +++ b/deps/grpc/src/core/util/table.h @@ -23,9 +23,9 @@ #include #include +#include "src/core/util/bitset.h" #include "absl/meta/type_traits.h" #include "absl/utility/utility.h" -#include "src/core/util/bitset.h" namespace grpc_core { diff --git a/deps/grpc/src/core/util/tdigest.cc b/deps/grpc/src/core/util/tdigest.cc index b14a4e3ef0d..3d48604324a 100644 --- a/deps/grpc/src/core/util/tdigest.cc +++ b/deps/grpc/src/core/util/tdigest.cc @@ -14,10 +14,10 @@ #include "src/core/util/tdigest.h" +#include "src/core/util/grpc_check.h" #include "absl/log/log.h" #include "absl/strings/str_cat.h" #include "absl/strings/str_split.h" -#include "src/core/util/grpc_check.h" namespace grpc_core { diff --git a/deps/grpc/src/core/util/time.cc b/deps/grpc/src/core/util/time.cc index f14ae8c0388..cd439039635 100644 --- a/deps/grpc/src/core/util/time.cc +++ b/deps/grpc/src/core/util/time.cc @@ -23,10 +23,10 @@ #include #include +#include "src/core/util/no_destruct.h" #include "absl/log/check.h" #include "absl/log/log.h" #include "absl/strings/str_format.h" -#include "src/core/util/no_destruct.h" // IWYU pragma: no_include diff --git a/deps/grpc/src/core/util/time_precise.cc b/deps/grpc/src/core/util/time_precise.cc index 76dce6d57df..49c9c5de2b7 100644 --- a/deps/grpc/src/core/util/time_precise.cc +++ b/deps/grpc/src/core/util/time_precise.cc @@ -27,8 +27,8 @@ #include -#include "absl/log/log.h" #include "src/core/util/time_precise.h" +#include "absl/log/log.h" #ifndef GPR_CYCLE_COUNTER_CUSTOM #if GPR_CYCLE_COUNTER_RDTSC_32 || GPR_CYCLE_COUNTER_RDTSC_64 diff --git a/deps/grpc/src/core/util/unique_ptr_with_bitset.h b/deps/grpc/src/core/util/unique_ptr_with_bitset.h index 606ca8c8973..bce34742a97 100644 --- a/deps/grpc/src/core/util/unique_ptr_with_bitset.h +++ b/deps/grpc/src/core/util/unique_ptr_with_bitset.h @@ -18,8 +18,8 @@ #include #include -#include "absl/numeric/bits.h" #include "src/core/util/grpc_check.h" +#include "absl/numeric/bits.h" namespace grpc_core { diff --git a/deps/grpc/src/core/util/unique_type_name.h b/deps/grpc/src/core/util/unique_type_name.h index fa723dc8d0c..d762483180c 100644 --- a/deps/grpc/src/core/util/unique_type_name.h +++ b/deps/grpc/src/core/util/unique_type_name.h @@ -21,8 +21,8 @@ #include -#include "absl/strings/string_view.h" #include "src/core/util/useful.h" +#include "absl/strings/string_view.h" // Provides a type name that is unique by instance rather than by // string content. This is useful in cases where there are different diff --git a/deps/grpc/src/core/util/upb_utils.h b/deps/grpc/src/core/util/upb_utils.h index b21c23152ff..7d86f16349d 100644 --- a/deps/grpc/src/core/util/upb_utils.h +++ b/deps/grpc/src/core/util/upb_utils.h @@ -21,11 +21,11 @@ #include -#include "absl/strings/string_view.h" #include "google/protobuf/duration.upb.h" #include "google/protobuf/timestamp.upb.h" #include "upb/base/string_view.h" #include "upb/mem/arena.h" +#include "absl/strings/string_view.h" namespace grpc_core { @@ -46,6 +46,11 @@ inline upb_StringView CopyStdStringToUpbString(const T& str, upb_Arena* arena) { return upb_StringView_FromDataAndSize(copy, str.size()); } +inline upb_StringView CopyStdStringToUpbString(const char* str, + upb_Arena* arena) { + return CopyStdStringToUpbString(absl::string_view(str), arena); +} + inline absl::string_view UpbStringToAbsl(const upb_StringView& str) { return absl::string_view(str.data, str.size); } diff --git a/deps/grpc/src/core/util/validation_errors.cc b/deps/grpc/src/core/util/validation_errors.cc index 850ea674a5f..5d9f7f1420c 100644 --- a/deps/grpc/src/core/util/validation_errors.cc +++ b/deps/grpc/src/core/util/validation_errors.cc @@ -42,7 +42,7 @@ void ValidationErrors::AddError(absl::string_view error) { << max_error_count_ << ")"; return; } - field_errors_[key].emplace_back(error); + field_errors_[key].emplace(error); } bool ValidationErrors::FieldHasErrors() const { @@ -64,7 +64,7 @@ std::string ValidationErrors::message(absl::string_view prefix) const { absl::StrJoin(field_errors, "; "), "]")); } else { errors.emplace_back( - absl::StrCat("field:", field, " error:", field_errors[0])); + absl::StrCat("field:", field, " error:", *field_errors.begin())); } } return absl::StrCat(prefix, ": [", absl::StrJoin(errors, "; "), "]"); diff --git a/deps/grpc/src/core/util/validation_errors.h b/deps/grpc/src/core/util/validation_errors.h index 4038d927c9a..b9348c3ceaa 100644 --- a/deps/grpc/src/core/util/validation_errors.h +++ b/deps/grpc/src/core/util/validation_errors.h @@ -19,6 +19,7 @@ #include #include +#include #include #include #include @@ -129,9 +130,7 @@ class ValidationErrors { void PopField() GPR_ATTRIBUTE_NOINLINE; // Errors that we have encountered so far, keyed by field name. - // TODO(roth): If we don't actually have any fields for which we - // report more than one error, simplify this data structure. - std::map> field_errors_; + std::map> field_errors_; // Stack of field names indicating the field that we are currently // validating. std::vector fields_; diff --git a/deps/grpc/src/core/util/wait_for_single_owner.h b/deps/grpc/src/core/util/wait_for_single_owner.h index 2f4ab4dfa8a..299492e8a0a 100644 --- a/deps/grpc/src/core/util/wait_for_single_owner.h +++ b/deps/grpc/src/core/util/wait_for_single_owner.h @@ -17,10 +17,10 @@ #include -#include "absl/functional/any_invocable.h" -#include "absl/log/log.h" #include "src/core/util/crash.h" #include "src/core/util/time.h" +#include "absl/functional/any_invocable.h" +#include "absl/log/log.h" namespace grpc_core { diff --git a/deps/grpc/src/core/util/windows/directory_reader.cc b/deps/grpc/src/core/util/windows/directory_reader.cc index 2848d01924e..f25850832f9 100644 --- a/deps/grpc/src/core/util/windows/directory_reader.cc +++ b/deps/grpc/src/core/util/windows/directory_reader.cc @@ -27,10 +27,10 @@ #include #include +#include "src/core/util/directory_reader.h" #include "absl/status/statusor.h" #include "absl/strings/str_cat.h" #include "absl/strings/string_view.h" -#include "src/core/util/directory_reader.h" namespace grpc_core { diff --git a/deps/grpc/src/core/util/windows/stat.cc b/deps/grpc/src/core/util/windows/stat.cc index 5ac15a407cf..5404459469d 100644 --- a/deps/grpc/src/core/util/windows/stat.cc +++ b/deps/grpc/src/core/util/windows/stat.cc @@ -22,11 +22,11 @@ #include #include -#include "absl/log/check.h" -#include "absl/log/log.h" #include "src/core/util/crash.h" #include "src/core/util/stat.h" #include "src/core/util/strerror.h" +#include "absl/log/check.h" +#include "absl/log/log.h" namespace grpc_core { diff --git a/deps/grpc/src/core/util/windows/thd.cc b/deps/grpc/src/core/util/windows/thd.cc index 98cd406bffb..eafa79a4fbb 100644 --- a/deps/grpc/src/core/util/windows/thd.cc +++ b/deps/grpc/src/core/util/windows/thd.cc @@ -27,11 +27,11 @@ #include #include -#include "absl/log/check.h" -#include "absl/log/log.h" #include "src/core/util/crash.h" #include "src/core/util/memory.h" #include "src/core/util/thd.h" +#include "absl/log/check.h" +#include "absl/log/log.h" namespace { class ThreadInternalsWindows; diff --git a/deps/grpc/src/core/util/windows/time.cc b/deps/grpc/src/core/util/windows/time.cc index 1e8bb4b0687..181074ee096 100644 --- a/deps/grpc/src/core/util/windows/time.cc +++ b/deps/grpc/src/core/util/windows/time.cc @@ -27,8 +27,8 @@ #include #include -#include "absl/log/check.h" #include "src/core/util/time_precise.h" +#include "absl/log/check.h" static LARGE_INTEGER g_start_time = []() { LARGE_INTEGER x; diff --git a/deps/grpc/src/core/util/work_serializer.cc b/deps/grpc/src/core/util/work_serializer.cc index 582a402ec6e..8dbcfd20e7f 100644 --- a/deps/grpc/src/core/util/work_serializer.cc +++ b/deps/grpc/src/core/util/work_serializer.cc @@ -28,9 +28,6 @@ #include #include -#include "absl/container/inlined_vector.h" -#include "absl/log/check.h" -#include "absl/log/log.h" #include "src/core/lib/debug/trace.h" #include "src/core/lib/experiments/experiments.h" #include "src/core/lib/iomgr/exec_ctx.h" @@ -41,6 +38,9 @@ #include "src/core/util/mpscq.h" #include "src/core/util/orphanable.h" #include "src/core/util/sync.h" +#include "absl/container/inlined_vector.h" +#include "absl/log/check.h" +#include "absl/log/log.h" namespace grpc_core { diff --git a/deps/grpc/src/core/util/work_serializer.h b/deps/grpc/src/core/util/work_serializer.h index 3232fa8d8ee..3c1cf696047 100644 --- a/deps/grpc/src/core/util/work_serializer.h +++ b/deps/grpc/src/core/util/work_serializer.h @@ -23,10 +23,10 @@ #include #include -#include "absl/base/thread_annotations.h" -#include "absl/functional/any_invocable.h" #include "src/core/util/debug_location.h" #include "src/core/util/orphanable.h" +#include "absl/base/thread_annotations.h" +#include "absl/functional/any_invocable.h" namespace grpc_core { diff --git a/deps/grpc/src/core/xds/grpc/certificate_provider_store.cc b/deps/grpc/src/core/xds/grpc/certificate_provider_store.cc index 028e1cb047a..0aeee159448 100644 --- a/deps/grpc/src/core/xds/grpc/certificate_provider_store.cc +++ b/deps/grpc/src/core/xds/grpc/certificate_provider_store.cc @@ -21,10 +21,10 @@ #include #include -#include "absl/log/log.h" -#include "absl/strings/str_cat.h" #include "src/core/config/core_configuration.h" #include "src/core/credentials/transport/tls/certificate_provider_registry.h" +#include "absl/log/log.h" +#include "absl/strings/str_cat.h" namespace grpc_core { diff --git a/deps/grpc/src/core/xds/grpc/certificate_provider_store.h b/deps/grpc/src/core/xds/grpc/certificate_provider_store.h index 481141ede8e..515f7774c5c 100644 --- a/deps/grpc/src/core/xds/grpc/certificate_provider_store.h +++ b/deps/grpc/src/core/xds/grpc/certificate_provider_store.h @@ -26,8 +26,6 @@ #include #include -#include "absl/base/thread_annotations.h" -#include "absl/strings/string_view.h" #include "src/core/credentials/transport/tls/certificate_provider_factory.h" #include "src/core/credentials/transport/tls/grpc_tls_certificate_distributor.h" #include "src/core/credentials/transport/tls/grpc_tls_certificate_provider.h" @@ -40,6 +38,8 @@ #include "src/core/util/unique_type_name.h" #include "src/core/util/useful.h" #include "src/core/util/validation_errors.h" +#include "absl/base/thread_annotations.h" +#include "absl/strings/string_view.h" namespace grpc_core { diff --git a/deps/grpc/src/core/xds/grpc/file_watcher_certificate_provider_factory.cc b/deps/grpc/src/core/xds/grpc/file_watcher_certificate_provider_factory.cc index 40466d59343..23b7ea0d57c 100644 --- a/deps/grpc/src/core/xds/grpc/file_watcher_certificate_provider_factory.cc +++ b/deps/grpc/src/core/xds/grpc/file_watcher_certificate_provider_factory.cc @@ -25,13 +25,13 @@ #include #include -#include "absl/log/log.h" -#include "absl/strings/str_format.h" -#include "absl/strings/str_join.h" #include "src/core/config/core_configuration.h" #include "src/core/credentials/transport/tls/grpc_tls_certificate_provider.h" #include "src/core/util/down_cast.h" #include "src/core/util/env.h" +#include "absl/log/log.h" +#include "absl/strings/str_format.h" +#include "absl/strings/str_join.h" namespace grpc_core { diff --git a/deps/grpc/src/core/xds/grpc/file_watcher_certificate_provider_factory.h b/deps/grpc/src/core/xds/grpc/file_watcher_certificate_provider_factory.h index 6f828c06438..e0092b0e721 100644 --- a/deps/grpc/src/core/xds/grpc/file_watcher_certificate_provider_factory.h +++ b/deps/grpc/src/core/xds/grpc/file_watcher_certificate_provider_factory.h @@ -24,7 +24,6 @@ #include -#include "absl/strings/string_view.h" #include "src/core/credentials/transport/tls/certificate_provider_factory.h" #include "src/core/util/json/json.h" #include "src/core/util/json/json_args.h" @@ -32,6 +31,7 @@ #include "src/core/util/ref_counted_ptr.h" #include "src/core/util/time.h" #include "src/core/util/validation_errors.h" +#include "absl/strings/string_view.h" namespace grpc_core { diff --git a/deps/grpc/src/core/xds/grpc/xds_audit_logger_registry.cc b/deps/grpc/src/core/xds/grpc/xds_audit_logger_registry.cc index dfb8149c41e..4e0ef969ca3 100644 --- a/deps/grpc/src/core/xds/grpc/xds_audit_logger_registry.cc +++ b/deps/grpc/src/core/xds/grpc/xds_audit_logger_registry.cc @@ -22,9 +22,6 @@ #include #include -#include "absl/status/status.h" -#include "absl/status/statusor.h" -#include "absl/strings/string_view.h" #include "envoy/config/core/v3/extension.upb.h" #include "envoy/config/rbac/v3/rbac.upb.h" #include "src/core/lib/security/authorization/audit_logging.h" @@ -32,6 +29,9 @@ #include "src/core/util/validation_errors.h" #include "src/core/xds/grpc/xds_common_types.h" #include "src/core/xds/grpc/xds_common_types_parser.h" +#include "absl/status/status.h" +#include "absl/status/statusor.h" +#include "absl/strings/string_view.h" namespace grpc_core { diff --git a/deps/grpc/src/core/xds/grpc/xds_audit_logger_registry.h b/deps/grpc/src/core/xds/grpc/xds_audit_logger_registry.h index cb35fd53d86..5a4538d2347 100644 --- a/deps/grpc/src/core/xds/grpc/xds_audit_logger_registry.h +++ b/deps/grpc/src/core/xds/grpc/xds_audit_logger_registry.h @@ -22,11 +22,11 @@ #include #include -#include "absl/strings/string_view.h" #include "envoy/config/rbac/v3/rbac.upb.h" #include "src/core/util/json/json.h" #include "src/core/util/validation_errors.h" #include "src/core/xds/xds_client/xds_resource_type.h" +#include "absl/strings/string_view.h" namespace grpc_core { diff --git a/deps/grpc/src/core/xds/grpc/xds_bootstrap_grpc.cc b/deps/grpc/src/core/xds/grpc/xds_bootstrap_grpc.cc index 94190fa4682..53bbc6b44f3 100644 --- a/deps/grpc/src/core/xds/grpc/xds_bootstrap_grpc.cc +++ b/deps/grpc/src/core/xds/grpc/xds_bootstrap_grpc.cc @@ -24,13 +24,6 @@ #include #include -#include "absl/status/status.h" -#include "absl/status/statusor.h" -#include "absl/strings/match.h" -#include "absl/strings/str_cat.h" -#include "absl/strings/str_format.h" -#include "absl/strings/str_join.h" -#include "absl/strings/string_view.h" #include "src/core/util/down_cast.h" #include "src/core/util/json/json.h" #include "src/core/util/json/json_object_loader.h" @@ -38,6 +31,13 @@ #include "src/core/util/json/json_writer.h" #include "src/core/util/ref_counted_ptr.h" #include "src/core/util/string.h" +#include "absl/status/status.h" +#include "absl/status/statusor.h" +#include "absl/strings/match.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/str_format.h" +#include "absl/strings/str_join.h" +#include "absl/strings/string_view.h" namespace grpc_core { diff --git a/deps/grpc/src/core/xds/grpc/xds_bootstrap_grpc.h b/deps/grpc/src/core/xds/grpc/xds_bootstrap_grpc.h index 84cd11b007a..1909a6b9f83 100644 --- a/deps/grpc/src/core/xds/grpc/xds_bootstrap_grpc.h +++ b/deps/grpc/src/core/xds/grpc/xds_bootstrap_grpc.h @@ -25,8 +25,6 @@ #include #include -#include "absl/status/statusor.h" -#include "absl/strings/string_view.h" #include "src/core/util/json/json.h" #include "src/core/util/json/json_args.h" #include "src/core/util/json/json_object_loader.h" @@ -39,6 +37,8 @@ #include "src/core/xds/grpc/xds_matcher_input.h" #include "src/core/xds/grpc/xds_server_grpc.h" #include "src/core/xds/xds_client/xds_bootstrap.h" +#include "absl/status/statusor.h" +#include "absl/strings/string_view.h" namespace grpc_core { diff --git a/deps/grpc/src/core/xds/grpc/xds_certificate_provider.cc b/deps/grpc/src/core/xds/grpc/xds_certificate_provider.cc index 1b5b3e16514..bffce910672 100644 --- a/deps/grpc/src/core/xds/grpc/xds_certificate_provider.cc +++ b/deps/grpc/src/core/xds/grpc/xds_certificate_provider.cc @@ -23,11 +23,11 @@ #include #include -#include "absl/functional/bind_front.h" #include "src/core/credentials/transport/tls/ssl_utils.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/iomgr/error.h" #include "src/core/util/grpc_check.h" +#include "absl/functional/bind_front.h" namespace grpc_core { diff --git a/deps/grpc/src/core/xds/grpc/xds_certificate_provider.h b/deps/grpc/src/core/xds/grpc/xds_certificate_provider.h index 1ee87746386..4d7f95ff591 100644 --- a/deps/grpc/src/core/xds/grpc/xds_certificate_provider.h +++ b/deps/grpc/src/core/xds/grpc/xds_certificate_provider.h @@ -28,8 +28,6 @@ #include #include -#include "absl/base/thread_annotations.h" -#include "absl/strings/string_view.h" #include "src/core/credentials/transport/tls/grpc_tls_certificate_distributor.h" #include "src/core/credentials/transport/tls/grpc_tls_certificate_provider.h" #include "src/core/util/matchers.h" @@ -37,6 +35,8 @@ #include "src/core/util/sync.h" #include "src/core/util/unique_type_name.h" #include "src/core/util/useful.h" +#include "absl/base/thread_annotations.h" +#include "absl/strings/string_view.h" namespace grpc_core { diff --git a/deps/grpc/src/core/xds/grpc/xds_client_grpc.cc b/deps/grpc/src/core/xds/grpc/xds_client_grpc.cc index 1b7f6018a42..74d1d0c0b24 100644 --- a/deps/grpc/src/core/xds/grpc/xds_client_grpc.cc +++ b/deps/grpc/src/core/xds/grpc/xds_client_grpc.cc @@ -30,11 +30,6 @@ #include #include -#include "absl/base/thread_annotations.h" -#include "absl/log/log.h" -#include "absl/status/status.h" -#include "absl/strings/str_cat.h" -#include "absl/strings/string_view.h" #include "envoy/service/status/v3/csds.upb.h" #include "src/core/config/core_configuration.h" #include "src/core/lib/channel/channel_args.h" @@ -63,6 +58,11 @@ #include "src/core/xds/xds_client/xds_client.h" #include "src/core/xds/xds_client/xds_transport.h" #include "upb/base/string_view.h" +#include "absl/base/thread_annotations.h" +#include "absl/log/log.h" +#include "absl/status/status.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/string_view.h" // If gRPC is built with -DGRPC_XDS_USER_AGENT_NAME_SUFFIX="...", that string // will be appended to the user agent name reported to the xDS server. diff --git a/deps/grpc/src/core/xds/grpc/xds_client_grpc.h b/deps/grpc/src/core/xds/grpc/xds_client_grpc.h index 2bb00a1025d..56d6bd5caad 100644 --- a/deps/grpc/src/core/xds/grpc/xds_client_grpc.h +++ b/deps/grpc/src/core/xds/grpc/xds_client_grpc.h @@ -22,8 +22,6 @@ #include -#include "absl/status/statusor.h" -#include "absl/strings/string_view.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/iomgr/iomgr_fwd.h" #include "src/core/resolver/endpoint_addresses.h" @@ -36,6 +34,8 @@ #include "src/core/xds/xds_client/lrs_client.h" #include "src/core/xds/xds_client/xds_client.h" #include "src/core/xds/xds_client/xds_transport.h" +#include "absl/status/statusor.h" +#include "absl/strings/string_view.h" namespace grpc_core { diff --git a/deps/grpc/src/core/xds/grpc/xds_cluster.cc b/deps/grpc/src/core/xds/grpc/xds_cluster.cc index 6a3e5c8bbf7..7306964b52c 100644 --- a/deps/grpc/src/core/xds/grpc/xds_cluster.cc +++ b/deps/grpc/src/core/xds/grpc/xds_cluster.cc @@ -16,12 +16,12 @@ #include "src/core/xds/grpc/xds_cluster.h" -#include "absl/strings/str_cat.h" -#include "absl/strings/str_join.h" #include "src/core/util/json/json_writer.h" #include "src/core/util/match.h" #include "src/core/util/time.h" #include "src/core/xds/grpc/xds_common_types.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/str_join.h" namespace grpc_core { diff --git a/deps/grpc/src/core/xds/grpc/xds_cluster.h b/deps/grpc/src/core/xds/grpc/xds_cluster.h index 475d4b55555..d89ed1a936e 100644 --- a/deps/grpc/src/core/xds/grpc/xds_cluster.h +++ b/deps/grpc/src/core/xds/grpc/xds_cluster.h @@ -22,7 +22,6 @@ #include #include -#include "absl/container/flat_hash_map.h" #include "src/core/load_balancing/outlier_detection/outlier_detection.h" #include "src/core/util/json/json.h" #include "src/core/xds/grpc/xds_common_types.h" @@ -32,6 +31,7 @@ #include "src/core/xds/xds_client/xds_backend_metric_propagation.h" #include "src/core/xds/xds_client/xds_resource_type.h" #include "src/core/xds/xds_client/xds_resource_type_impl.h" +#include "absl/container/flat_hash_map.h" namespace grpc_core { diff --git a/deps/grpc/src/core/xds/grpc/xds_cluster_parser.cc b/deps/grpc/src/core/xds/grpc/xds_cluster_parser.cc index fc7c1a25910..83c2a14adfc 100644 --- a/deps/grpc/src/core/xds/grpc/xds_cluster_parser.cc +++ b/deps/grpc/src/core/xds/grpc/xds_cluster_parser.cc @@ -19,11 +19,6 @@ #include #include -#include "absl/log/log.h" -#include "absl/status/status.h" -#include "absl/status/statusor.h" -#include "absl/strings/str_cat.h" -#include "absl/strings/strip.h" #include "envoy/config/cluster/v3/circuit_breaker.upb.h" #include "envoy/config/cluster/v3/cluster.upb.h" #include "envoy/config/cluster/v3/cluster.upbdefs.h" @@ -63,6 +58,11 @@ #include "src/core/xds/xds_client/xds_backend_metric_propagation.h" #include "upb/base/string_view.h" #include "upb/text/encode.h" +#include "absl/log/log.h" +#include "absl/status/status.h" +#include "absl/status/statusor.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/strip.h" namespace grpc_core { diff --git a/deps/grpc/src/core/xds/grpc/xds_cluster_parser.h b/deps/grpc/src/core/xds/grpc/xds_cluster_parser.h index 5ef66b5c864..6cd3e7641f7 100644 --- a/deps/grpc/src/core/xds/grpc/xds_cluster_parser.h +++ b/deps/grpc/src/core/xds/grpc/xds_cluster_parser.h @@ -17,7 +17,6 @@ #ifndef GRPC_SRC_CORE_XDS_GRPC_XDS_CLUSTER_PARSER_H #define GRPC_SRC_CORE_XDS_GRPC_XDS_CLUSTER_PARSER_H -#include "absl/strings/string_view.h" #include "envoy/config/cluster/v3/cluster.upbdefs.h" #include "envoy/extensions/clusters/aggregate/v3/cluster.upbdefs.h" #include "envoy/extensions/transport_sockets/http_11_proxy/v3/upstream_http_11_connect.upbdefs.h" @@ -28,6 +27,7 @@ #include "src/core/xds/xds_client/xds_resource_type.h" #include "src/core/xds/xds_client/xds_resource_type_impl.h" #include "upb/reflection/def.h" +#include "absl/strings/string_view.h" namespace grpc_core { diff --git a/deps/grpc/src/core/xds/grpc/xds_cluster_specifier_plugin.cc b/deps/grpc/src/core/xds/grpc/xds_cluster_specifier_plugin.cc index f972e06dff0..a864ace8ea7 100644 --- a/deps/grpc/src/core/xds/grpc/xds_cluster_specifier_plugin.cc +++ b/deps/grpc/src/core/xds/grpc/xds_cluster_specifier_plugin.cc @@ -24,8 +24,6 @@ #include #include -#include "absl/status/statusor.h" -#include "absl/strings/str_cat.h" #include "src/core/util/grpc_check.h" #include "src/core/util/json/json.h" #include "src/core/util/json/json_reader.h" @@ -34,6 +32,8 @@ #include "upb/base/status.hpp" #include "upb/json/encode.h" #include "upb/mem/arena.hpp" +#include "absl/status/statusor.h" +#include "absl/strings/str_cat.h" namespace grpc_core { diff --git a/deps/grpc/src/core/xds/grpc/xds_cluster_specifier_plugin.h b/deps/grpc/src/core/xds/grpc/xds_cluster_specifier_plugin.h index 4ae87310904..fe801c00650 100644 --- a/deps/grpc/src/core/xds/grpc/xds_cluster_specifier_plugin.h +++ b/deps/grpc/src/core/xds/grpc/xds_cluster_specifier_plugin.h @@ -23,12 +23,12 @@ #include #include -#include "absl/strings/string_view.h" #include "src/core/util/json/json.h" #include "src/core/util/validation_errors.h" #include "src/core/xds/grpc/xds_common_types.h" #include "upb/mem/arena.h" #include "upb/reflection/def.h" +#include "absl/strings/string_view.h" namespace grpc_core { diff --git a/deps/grpc/src/core/xds/grpc/xds_common_types.cc b/deps/grpc/src/core/xds/grpc/xds_common_types.cc index b6344aa9254..b75eecac9bd 100644 --- a/deps/grpc/src/core/xds/grpc/xds_common_types.cc +++ b/deps/grpc/src/core/xds/grpc/xds_common_types.cc @@ -16,10 +16,10 @@ #include "src/core/xds/grpc/xds_common_types.h" +#include "src/core/util/match.h" #include "absl/strings/str_cat.h" #include "absl/strings/str_format.h" #include "absl/strings/str_join.h" -#include "src/core/util/match.h" namespace grpc_core { diff --git a/deps/grpc/src/core/xds/grpc/xds_common_types.h b/deps/grpc/src/core/xds/grpc/xds_common_types.h index 955395bba63..71ab561ad6a 100644 --- a/deps/grpc/src/core/xds/grpc/xds_common_types.h +++ b/deps/grpc/src/core/xds/grpc/xds_common_types.h @@ -21,10 +21,10 @@ #include #include -#include "absl/strings/string_view.h" #include "src/core/util/json/json.h" #include "src/core/util/matchers.h" #include "src/core/util/validation_errors.h" +#include "absl/strings/string_view.h" namespace grpc_core { diff --git a/deps/grpc/src/core/xds/grpc/xds_common_types_parser.cc b/deps/grpc/src/core/xds/grpc/xds_common_types_parser.cc index bd263cf83e5..db30c56e5d1 100644 --- a/deps/grpc/src/core/xds/grpc/xds_common_types_parser.cc +++ b/deps/grpc/src/core/xds/grpc/xds_common_types_parser.cc @@ -24,11 +24,6 @@ #include #include -#include "absl/status/status.h" -#include "absl/status/statusor.h" -#include "absl/strings/str_cat.h" -#include "absl/strings/str_format.h" -#include "absl/strings/str_join.h" #include "envoy/config/core/v3/address.upb.h" #include "envoy/extensions/transport_sockets/tls/v3/common.upb.h" #include "envoy/extensions/transport_sockets/tls/v3/tls.upb.h" @@ -49,6 +44,11 @@ #include "upb/mem/arena.h" #include "xds/type/matcher/v3/regex.upb.h" #include "xds/type/v3/typed_struct.upb.h" +#include "absl/status/status.h" +#include "absl/status/statusor.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/str_format.h" +#include "absl/strings/str_join.h" namespace grpc_core { diff --git a/deps/grpc/src/core/xds/grpc/xds_endpoint.h b/deps/grpc/src/core/xds/grpc/xds_endpoint.h index 99ad92da8d3..dc6c7096222 100644 --- a/deps/grpc/src/core/xds/grpc/xds_endpoint.h +++ b/deps/grpc/src/core/xds/grpc/xds_endpoint.h @@ -22,8 +22,6 @@ #include #include -#include "absl/base/thread_annotations.h" -#include "absl/random/random.h" #include "src/core/resolver/endpoint_addresses.h" #include "src/core/util/ref_counted.h" #include "src/core/util/ref_counted_ptr.h" @@ -31,6 +29,8 @@ #include "src/core/xds/xds_client/xds_locality.h" #include "src/core/xds/xds_client/xds_resource_type.h" #include "src/core/xds/xds_client/xds_resource_type_impl.h" +#include "absl/base/thread_annotations.h" +#include "absl/random/random.h" // Per-endpoint channel arg key for xDS-configured HTTP CONNECT proxy. #define GRPC_ARG_XDS_HTTP_PROXY "grpc.internal.xds_http_proxy" diff --git a/deps/grpc/src/core/xds/grpc/xds_endpoint_parser.cc b/deps/grpc/src/core/xds/grpc/xds_endpoint_parser.cc index 64f52771350..91d68161fef 100644 --- a/deps/grpc/src/core/xds/grpc/xds_endpoint_parser.cc +++ b/deps/grpc/src/core/xds/grpc/xds_endpoint_parser.cc @@ -27,11 +27,6 @@ #include #include -#include "absl/log/log.h" -#include "absl/status/status.h" -#include "absl/status/statusor.h" -#include "absl/strings/str_cat.h" -#include "absl/strings/str_join.h" #include "envoy/config/core/v3/address.upb.h" #include "envoy/config/core/v3/base.upb.h" #include "envoy/config/endpoint/v3/endpoint.upb.h" @@ -59,6 +54,11 @@ #include "src/core/xds/grpc/xds_metadata_parser.h" #include "src/core/xds/xds_client/xds_resource_type.h" #include "upb/text/encode.h" +#include "absl/log/log.h" +#include "absl/status/status.h" +#include "absl/status/statusor.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/str_join.h" // IWYU pragma: no_include "absl/meta/type_traits.h" diff --git a/deps/grpc/src/core/xds/grpc/xds_endpoint_parser.h b/deps/grpc/src/core/xds/grpc/xds_endpoint_parser.h index e543bab6356..7991613e8f1 100644 --- a/deps/grpc/src/core/xds/grpc/xds_endpoint_parser.h +++ b/deps/grpc/src/core/xds/grpc/xds_endpoint_parser.h @@ -17,13 +17,13 @@ #ifndef GRPC_SRC_CORE_XDS_GRPC_XDS_ENDPOINT_PARSER_H #define GRPC_SRC_CORE_XDS_GRPC_XDS_ENDPOINT_PARSER_H -#include "absl/strings/string_view.h" #include "envoy/config/endpoint/v3/endpoint.upbdefs.h" #include "src/core/xds/grpc/xds_endpoint.h" #include "src/core/xds/xds_client/xds_client.h" #include "src/core/xds/xds_client/xds_resource_type.h" #include "src/core/xds/xds_client/xds_resource_type_impl.h" #include "upb/reflection/def.h" +#include "absl/strings/string_view.h" namespace grpc_core { diff --git a/deps/grpc/src/core/xds/grpc/xds_health_status.cc b/deps/grpc/src/core/xds/grpc/xds_health_status.cc index 6c69fa8b70e..61196b2a4f2 100644 --- a/deps/grpc/src/core/xds/grpc/xds_health_status.cc +++ b/deps/grpc/src/core/xds/grpc/xds_health_status.cc @@ -18,9 +18,9 @@ #include +#include "envoy/config/core/v3/health_check.upb.h" #include "absl/strings/str_cat.h" #include "absl/strings/str_join.h" -#include "envoy/config/core/v3/health_check.upb.h" namespace grpc_core { diff --git a/deps/grpc/src/core/xds/grpc/xds_health_status.h b/deps/grpc/src/core/xds/grpc/xds_health_status.h index df7148d5285..4e461bc4fcf 100644 --- a/deps/grpc/src/core/xds/grpc/xds_health_status.h +++ b/deps/grpc/src/core/xds/grpc/xds_health_status.h @@ -21,9 +21,9 @@ #include +#include "src/core/resolver/endpoint_addresses.h" #include "absl/strings/string_view.h" #include "absl/types/span.h" -#include "src/core/resolver/endpoint_addresses.h" // Channel arg key for xDS health status. // Value is an XdsHealthStatus::HealthStatus enum. diff --git a/deps/grpc/src/core/xds/grpc/xds_http_fault_filter.cc b/deps/grpc/src/core/xds/grpc/xds_http_fault_filter.cc index 913269b553e..05dbb29d1e4 100644 --- a/deps/grpc/src/core/xds/grpc/xds_http_fault_filter.cc +++ b/deps/grpc/src/core/xds/grpc/xds_http_fault_filter.cc @@ -25,9 +25,6 @@ #include #include -#include "absl/status/statusor.h" -#include "absl/strings/str_cat.h" -#include "absl/strings/string_view.h" #include "envoy/extensions/filters/common/fault/v3/fault.upb.h" #include "envoy/extensions/filters/http/fault/v3/fault.upb.h" #include "envoy/extensions/filters/http/fault/v3/fault.upbdefs.h" @@ -45,6 +42,9 @@ #include "src/core/xds/grpc/xds_common_types.h" #include "src/core/xds/grpc/xds_common_types_parser.h" #include "src/core/xds/grpc/xds_http_filter.h" +#include "absl/status/statusor.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/string_view.h" namespace grpc_core { @@ -215,7 +215,7 @@ XdsHttpFaultFilter::GenerateFilterConfigOverride( } void XdsHttpFaultFilter::AddFilter(InterceptionChainBuilder& builder) const { - builder.Add(); + builder.Add(nullptr); } const grpc_channel_filter* XdsHttpFaultFilter::channel_filter() const { diff --git a/deps/grpc/src/core/xds/grpc/xds_http_fault_filter.h b/deps/grpc/src/core/xds/grpc/xds_http_fault_filter.h index f4a25a7c0cd..7670900af0b 100644 --- a/deps/grpc/src/core/xds/grpc/xds_http_fault_filter.h +++ b/deps/grpc/src/core/xds/grpc/xds_http_fault_filter.h @@ -21,8 +21,6 @@ #include -#include "absl/status/statusor.h" -#include "absl/strings/string_view.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/channel_fwd.h" #include "src/core/util/validation_errors.h" @@ -30,6 +28,8 @@ #include "src/core/xds/grpc/xds_http_filter.h" #include "src/core/xds/xds_client/xds_resource_type.h" #include "upb/reflection/def.h" +#include "absl/status/statusor.h" +#include "absl/strings/string_view.h" namespace grpc_core { diff --git a/deps/grpc/src/core/xds/grpc/xds_http_filter.h b/deps/grpc/src/core/xds/grpc/xds_http_filter.h index d77ca1a63aa..1762b578767 100644 --- a/deps/grpc/src/core/xds/grpc/xds_http_filter.h +++ b/deps/grpc/src/core/xds/grpc/xds_http_filter.h @@ -20,9 +20,6 @@ #include #include -#include "absl/status/statusor.h" -#include "absl/strings/str_cat.h" -#include "absl/strings/string_view.h" #include "src/core/call/interception_chain.h" #include "src/core/filter/blackboard.h" #include "src/core/lib/channel/channel_args.h" @@ -33,6 +30,9 @@ #include "src/core/xds/grpc/xds_common_types.h" #include "src/core/xds/xds_client/xds_resource_type.h" #include "upb/reflection/def.h" +#include "absl/status/statusor.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/string_view.h" namespace grpc_core { diff --git a/deps/grpc/src/core/xds/grpc/xds_http_filter_registry.h b/deps/grpc/src/core/xds/grpc/xds_http_filter_registry.h index e22bf5d515b..cc959cae5dd 100644 --- a/deps/grpc/src/core/xds/grpc/xds_http_filter_registry.h +++ b/deps/grpc/src/core/xds/grpc/xds_http_filter_registry.h @@ -24,8 +24,6 @@ #include #include -#include "absl/status/statusor.h" -#include "absl/strings/string_view.h" #include "src/core/call/interception_chain.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/channel_fwd.h" @@ -34,6 +32,8 @@ #include "src/core/xds/grpc/xds_http_filter.h" #include "src/core/xds/xds_client/xds_resource_type.h" #include "upb/reflection/def.h" +#include "absl/status/statusor.h" +#include "absl/strings/string_view.h" namespace grpc_core { diff --git a/deps/grpc/src/core/xds/grpc/xds_http_gcp_authn_filter.cc b/deps/grpc/src/core/xds/grpc/xds_http_gcp_authn_filter.cc index 3aef0c140aa..2b8dfd95880 100644 --- a/deps/grpc/src/core/xds/grpc/xds_http_gcp_authn_filter.cc +++ b/deps/grpc/src/core/xds/grpc/xds_http_gcp_authn_filter.cc @@ -22,8 +22,6 @@ #include #include -#include "absl/status/statusor.h" -#include "absl/strings/string_view.h" #include "envoy/extensions/filters/http/gcp_authn/v3/gcp_authn.upb.h" #include "envoy/extensions/filters/http/gcp_authn/v3/gcp_authn.upbdefs.h" #include "src/core/ext/filters/gcp_authentication/gcp_authentication_filter.h" @@ -35,6 +33,8 @@ #include "src/core/xds/grpc/xds_common_types.h" #include "src/core/xds/grpc/xds_common_types_parser.h" #include "src/core/xds/grpc/xds_http_filter.h" +#include "absl/status/statusor.h" +#include "absl/strings/string_view.h" namespace grpc_core { @@ -112,7 +112,7 @@ XdsHttpGcpAuthnFilter::GenerateFilterConfigOverride( } void XdsHttpGcpAuthnFilter::AddFilter(InterceptionChainBuilder& builder) const { - builder.Add(); + builder.Add(nullptr); } const grpc_channel_filter* XdsHttpGcpAuthnFilter::channel_filter() const { diff --git a/deps/grpc/src/core/xds/grpc/xds_http_gcp_authn_filter.h b/deps/grpc/src/core/xds/grpc/xds_http_gcp_authn_filter.h index 957f434e447..cb6c5b00b03 100644 --- a/deps/grpc/src/core/xds/grpc/xds_http_gcp_authn_filter.h +++ b/deps/grpc/src/core/xds/grpc/xds_http_gcp_authn_filter.h @@ -19,8 +19,6 @@ #include -#include "absl/status/statusor.h" -#include "absl/strings/string_view.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/channel_fwd.h" #include "src/core/util/validation_errors.h" @@ -28,6 +26,8 @@ #include "src/core/xds/grpc/xds_http_filter.h" #include "src/core/xds/xds_client/xds_resource_type.h" #include "upb/reflection/def.h" +#include "absl/status/statusor.h" +#include "absl/strings/string_view.h" namespace grpc_core { diff --git a/deps/grpc/src/core/xds/grpc/xds_http_rbac_filter.cc b/deps/grpc/src/core/xds/grpc/xds_http_rbac_filter.cc index db0e3654b7e..cdd6d04c82f 100644 --- a/deps/grpc/src/core/xds/grpc/xds_http_rbac_filter.cc +++ b/deps/grpc/src/core/xds/grpc/xds_http_rbac_filter.cc @@ -25,9 +25,6 @@ #include #include -#include "absl/strings/match.h" -#include "absl/strings/str_cat.h" -#include "absl/strings/string_view.h" #include "envoy/config/core/v3/address.upb.h" #include "envoy/config/rbac/v3/rbac.upb.h" #include "envoy/config/route/v3/route_components.upb.h" @@ -55,6 +52,9 @@ #include "upb/base/string_view.h" #include "upb/message/array.h" #include "upb/message/map.h" +#include "absl/strings/match.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/string_view.h" namespace grpc_core { @@ -570,7 +570,7 @@ XdsHttpRbacFilter::GenerateFilterConfigOverride( } void XdsHttpRbacFilter::AddFilter(InterceptionChainBuilder& builder) const { - builder.Add(); + builder.Add(nullptr); } const grpc_channel_filter* XdsHttpRbacFilter::channel_filter() const { diff --git a/deps/grpc/src/core/xds/grpc/xds_http_rbac_filter.h b/deps/grpc/src/core/xds/grpc/xds_http_rbac_filter.h index 2db5a7f3d76..dd4a05416ea 100644 --- a/deps/grpc/src/core/xds/grpc/xds_http_rbac_filter.h +++ b/deps/grpc/src/core/xds/grpc/xds_http_rbac_filter.h @@ -21,8 +21,6 @@ #include -#include "absl/status/statusor.h" -#include "absl/strings/string_view.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/channel_fwd.h" #include "src/core/util/validation_errors.h" @@ -30,6 +28,8 @@ #include "src/core/xds/grpc/xds_http_filter.h" #include "src/core/xds/xds_client/xds_resource_type.h" #include "upb/reflection/def.h" +#include "absl/status/statusor.h" +#include "absl/strings/string_view.h" namespace grpc_core { diff --git a/deps/grpc/src/core/xds/grpc/xds_http_stateful_session_filter.cc b/deps/grpc/src/core/xds/grpc/xds_http_stateful_session_filter.cc index 6f8cbd83c39..5f21792cd32 100644 --- a/deps/grpc/src/core/xds/grpc/xds_http_stateful_session_filter.cc +++ b/deps/grpc/src/core/xds/grpc/xds_http_stateful_session_filter.cc @@ -23,8 +23,6 @@ #include #include -#include "absl/status/statusor.h" -#include "absl/strings/string_view.h" #include "envoy/config/core/v3/extension.upb.h" #include "envoy/extensions/filters/http/stateful_session/v3/stateful_session.upb.h" #include "envoy/extensions/filters/http/stateful_session/v3/stateful_session.upbdefs.h" @@ -42,6 +40,8 @@ #include "src/core/xds/grpc/xds_common_types.h" #include "src/core/xds/grpc/xds_common_types_parser.h" #include "src/core/xds/grpc/xds_http_filter.h" +#include "absl/status/statusor.h" +#include "absl/strings/string_view.h" namespace grpc_core { @@ -198,7 +198,7 @@ XdsHttpStatefulSessionFilter::GenerateFilterConfigOverride( void XdsHttpStatefulSessionFilter::AddFilter( InterceptionChainBuilder& builder) const { - builder.Add(); + builder.Add(nullptr); } const grpc_channel_filter* XdsHttpStatefulSessionFilter::channel_filter() diff --git a/deps/grpc/src/core/xds/grpc/xds_http_stateful_session_filter.h b/deps/grpc/src/core/xds/grpc/xds_http_stateful_session_filter.h index 09fa04bd66a..9aad34d2770 100644 --- a/deps/grpc/src/core/xds/grpc/xds_http_stateful_session_filter.h +++ b/deps/grpc/src/core/xds/grpc/xds_http_stateful_session_filter.h @@ -21,8 +21,6 @@ #include -#include "absl/status/statusor.h" -#include "absl/strings/string_view.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/channel_fwd.h" #include "src/core/util/validation_errors.h" @@ -30,6 +28,8 @@ #include "src/core/xds/grpc/xds_http_filter.h" #include "src/core/xds/xds_client/xds_resource_type.h" #include "upb/reflection/def.h" +#include "absl/status/statusor.h" +#include "absl/strings/string_view.h" namespace grpc_core { diff --git a/deps/grpc/src/core/xds/grpc/xds_lb_policy_registry.cc b/deps/grpc/src/core/xds/grpc/xds_lb_policy_registry.cc index dc54a821a87..2097b2745b3 100644 --- a/deps/grpc/src/core/xds/grpc/xds_lb_policy_registry.cc +++ b/deps/grpc/src/core/xds/grpc/xds_lb_policy_registry.cc @@ -26,7 +26,6 @@ #include #include -#include "absl/strings/str_cat.h" #include "envoy/config/core/v3/extension.upb.h" #include "envoy/extensions/load_balancing_policies/client_side_weighted_round_robin/v3/client_side_weighted_round_robin.upb.h" #include "envoy/extensions/load_balancing_policies/pick_first/v3/pick_first.upb.h" @@ -39,6 +38,7 @@ #include "src/core/util/validation_errors.h" #include "src/core/xds/grpc/xds_common_types.h" #include "src/core/xds/grpc/xds_common_types_parser.h" +#include "absl/strings/str_cat.h" namespace grpc_core { diff --git a/deps/grpc/src/core/xds/grpc/xds_lb_policy_registry.h b/deps/grpc/src/core/xds/grpc/xds_lb_policy_registry.h index 5b1fe7913f0..a81f1def4fb 100644 --- a/deps/grpc/src/core/xds/grpc/xds_lb_policy_registry.h +++ b/deps/grpc/src/core/xds/grpc/xds_lb_policy_registry.h @@ -22,11 +22,11 @@ #include #include -#include "absl/strings/string_view.h" #include "envoy/config/cluster/v3/cluster.upb.h" #include "src/core/util/json/json.h" #include "src/core/util/validation_errors.h" #include "src/core/xds/xds_client/xds_resource_type.h" +#include "absl/strings/string_view.h" namespace grpc_core { diff --git a/deps/grpc/src/core/xds/grpc/xds_listener.cc b/deps/grpc/src/core/xds/grpc/xds_listener.cc index 4dbb359c782..2ac21a70602 100644 --- a/deps/grpc/src/core/xds/grpc/xds_listener.cc +++ b/deps/grpc/src/core/xds/grpc/xds_listener.cc @@ -16,11 +16,11 @@ #include "src/core/xds/grpc/xds_listener.h" +#include "src/core/lib/address_utils/sockaddr_utils.h" +#include "src/core/util/match.h" #include "absl/strings/str_cat.h" #include "absl/strings/str_format.h" #include "absl/strings/str_join.h" -#include "src/core/lib/address_utils/sockaddr_utils.h" -#include "src/core/util/match.h" namespace grpc_core { diff --git a/deps/grpc/src/core/xds/grpc/xds_listener_parser.cc b/deps/grpc/src/core/xds/grpc/xds_listener_parser.cc index 179ea5e2f22..6789cc9c5d2 100644 --- a/deps/grpc/src/core/xds/grpc/xds_listener_parser.cc +++ b/deps/grpc/src/core/xds/grpc/xds_listener_parser.cc @@ -21,12 +21,6 @@ #include #include -#include "absl/log/log.h" -#include "absl/status/status.h" -#include "absl/status/statusor.h" -#include "absl/strings/str_cat.h" -#include "absl/strings/str_format.h" -#include "absl/strings/str_join.h" #include "envoy/config/core/v3/address.upb.h" #include "envoy/config/core/v3/base.upb.h" #include "envoy/config/core/v3/config_source.upb.h" @@ -57,6 +51,12 @@ #include "src/core/xds/grpc/xds_route_config_parser.h" #include "src/core/xds/xds_client/xds_resource_type.h" #include "upb/text/encode.h" +#include "absl/log/log.h" +#include "absl/status/status.h" +#include "absl/status/statusor.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/str_format.h" +#include "absl/strings/str_join.h" namespace grpc_core { diff --git a/deps/grpc/src/core/xds/grpc/xds_listener_parser.h b/deps/grpc/src/core/xds/grpc/xds_listener_parser.h index ed0c88b85d6..1a73c91f089 100644 --- a/deps/grpc/src/core/xds/grpc/xds_listener_parser.h +++ b/deps/grpc/src/core/xds/grpc/xds_listener_parser.h @@ -17,7 +17,6 @@ #ifndef GRPC_SRC_CORE_XDS_GRPC_XDS_LISTENER_PARSER_H #define GRPC_SRC_CORE_XDS_GRPC_XDS_LISTENER_PARSER_H -#include "absl/strings/string_view.h" #include "envoy/config/listener/v3/listener.upbdefs.h" #include "envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upbdefs.h" #include "src/core/util/down_cast.h" @@ -28,6 +27,7 @@ #include "src/core/xds/xds_client/xds_resource_type.h" #include "src/core/xds/xds_client/xds_resource_type_impl.h" #include "upb/reflection/def.h" +#include "absl/strings/string_view.h" namespace grpc_core { diff --git a/deps/grpc/src/core/xds/grpc/xds_matcher.cc b/deps/grpc/src/core/xds/grpc/xds_matcher.cc index 20eed5e2f79..9298bffcb6a 100644 --- a/deps/grpc/src/core/xds/grpc/xds_matcher.cc +++ b/deps/grpc/src/core/xds/grpc/xds_matcher.cc @@ -20,9 +20,9 @@ #include #include +#include "src/core/util/match.h" #include "absl/strings/str_cat.h" #include "absl/strings/str_join.h" -#include "src/core/util/match.h" namespace grpc_core { diff --git a/deps/grpc/src/core/xds/grpc/xds_matcher.h b/deps/grpc/src/core/xds/grpc/xds_matcher.h index d902513ce7a..e92c309afd4 100644 --- a/deps/grpc/src/core/xds/grpc/xds_matcher.h +++ b/deps/grpc/src/core/xds/grpc/xds_matcher.h @@ -24,13 +24,13 @@ #include #include -#include "absl/container/flat_hash_map.h" -#include "absl/container/inlined_vector.h" -#include "absl/strings/str_cat.h" #include "src/core/util/down_cast.h" #include "src/core/util/matchers.h" #include "src/core/util/trie_lookup.h" #include "src/core/util/unique_type_name.h" +#include "absl/container/flat_hash_map.h" +#include "absl/container/inlined_vector.h" +#include "absl/strings/str_cat.h" namespace grpc_core { diff --git a/deps/grpc/src/core/xds/grpc/xds_matcher_input.h b/deps/grpc/src/core/xds/grpc/xds_matcher_input.h index bf598c5ea05..4a5763bb449 100644 --- a/deps/grpc/src/core/xds/grpc/xds_matcher_input.h +++ b/deps/grpc/src/core/xds/grpc/xds_matcher_input.h @@ -15,11 +15,11 @@ #ifndef GRPC_SRC_CORE_XDS_GRPC_XDS_MATCHER_INPUT_H #define GRPC_SRC_CORE_XDS_GRPC_XDS_MATCHER_INPUT_H -#include "absl/strings/str_cat.h" #include "src/core/xds/grpc/xds_common_types.h" #include "src/core/xds/grpc/xds_matcher.h" #include "src/core/xds/grpc/xds_matcher_context.h" #include "src/core/xds/xds_client/xds_resource_type.h" +#include "absl/strings/str_cat.h" namespace grpc_core { diff --git a/deps/grpc/src/core/xds/grpc/xds_metadata.cc b/deps/grpc/src/core/xds/grpc/xds_metadata.cc index 2902801cb97..d4ce5e9cb70 100644 --- a/deps/grpc/src/core/xds/grpc/xds_metadata.cc +++ b/deps/grpc/src/core/xds/grpc/xds_metadata.cc @@ -21,10 +21,10 @@ #include #include +#include "src/core/util/grpc_check.h" #include "absl/strings/str_cat.h" #include "absl/strings/str_join.h" #include "absl/strings/string_view.h" -#include "src/core/util/grpc_check.h" namespace grpc_core { diff --git a/deps/grpc/src/core/xds/grpc/xds_metadata.h b/deps/grpc/src/core/xds/grpc/xds_metadata.h index 419540cb363..66fbc9530f3 100644 --- a/deps/grpc/src/core/xds/grpc/xds_metadata.h +++ b/deps/grpc/src/core/xds/grpc/xds_metadata.h @@ -21,13 +21,13 @@ #include #include -#include "absl/container/flat_hash_map.h" -#include "absl/strings/str_cat.h" -#include "absl/strings/string_view.h" #include "src/core/util/down_cast.h" #include "src/core/util/json/json.h" #include "src/core/util/json/json_writer.h" #include "src/core/util/validation_errors.h" +#include "absl/container/flat_hash_map.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/string_view.h" namespace grpc_core { diff --git a/deps/grpc/src/core/xds/grpc/xds_metadata_parser.cc b/deps/grpc/src/core/xds/grpc/xds_metadata_parser.cc index af19e40de27..e6be14f4b03 100644 --- a/deps/grpc/src/core/xds/grpc/xds_metadata_parser.cc +++ b/deps/grpc/src/core/xds/grpc/xds_metadata_parser.cc @@ -19,8 +19,6 @@ #include #include -#include "absl/strings/str_cat.h" -#include "absl/strings/string_view.h" #include "envoy/config/core/v3/address.upb.h" #include "envoy/config/core/v3/address.upbdefs.h" #include "envoy/extensions/filters/http/gcp_authn/v3/gcp_authn.upb.h" @@ -38,6 +36,8 @@ #include "upb/message/map.h" #include "upb/message/message.h" #include "upb/text/encode.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/string_view.h" namespace grpc_core { diff --git a/deps/grpc/src/core/xds/grpc/xds_route_config.cc b/deps/grpc/src/core/xds/grpc/xds_route_config.cc index 29abfdecb87..4d8f36db9ac 100644 --- a/deps/grpc/src/core/xds/grpc/xds_route_config.cc +++ b/deps/grpc/src/core/xds/grpc/xds_route_config.cc @@ -22,12 +22,12 @@ #include #include -#include "absl/strings/str_cat.h" -#include "absl/strings/str_format.h" -#include "absl/strings/str_join.h" #include "re2/re2.h" #include "src/core/util/match.h" #include "src/core/util/matchers.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/str_format.h" +#include "absl/strings/str_join.h" namespace grpc_core { diff --git a/deps/grpc/src/core/xds/grpc/xds_route_config_parser.cc b/deps/grpc/src/core/xds/grpc/xds_route_config_parser.cc index c19ee4b7ea8..ab2859bf418 100644 --- a/deps/grpc/src/core/xds/grpc/xds_route_config_parser.cc +++ b/deps/grpc/src/core/xds/grpc/xds_route_config_parser.cc @@ -30,14 +30,6 @@ #include #include -#include "absl/log/log.h" -#include "absl/status/status.h" -#include "absl/status/statusor.h" -#include "absl/strings/str_cat.h" -#include "absl/strings/str_format.h" -#include "absl/strings/str_join.h" -#include "absl/strings/str_split.h" -#include "absl/strings/string_view.h" #include "envoy/config/core/v3/base.upb.h" #include "envoy/config/core/v3/extension.upb.h" #include "envoy/config/route/v3/route.upb.h" @@ -76,6 +68,14 @@ #include "upb/base/string_view.h" #include "upb/message/map.h" #include "upb/text/encode.h" +#include "absl/log/log.h" +#include "absl/status/status.h" +#include "absl/status/statusor.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/str_format.h" +#include "absl/strings/str_join.h" +#include "absl/strings/str_split.h" +#include "absl/strings/string_view.h" namespace grpc_core { diff --git a/deps/grpc/src/core/xds/grpc/xds_route_config_parser.h b/deps/grpc/src/core/xds/grpc/xds_route_config_parser.h index 68d400e9d03..47ded293fa1 100644 --- a/deps/grpc/src/core/xds/grpc/xds_route_config_parser.h +++ b/deps/grpc/src/core/xds/grpc/xds_route_config_parser.h @@ -27,7 +27,6 @@ #include #include -#include "absl/strings/string_view.h" #include "envoy/config/route/v3/route.upb.h" #include "envoy/config/route/v3/route.upbdefs.h" #include "re2/re2.h" @@ -43,6 +42,7 @@ #include "src/core/xds/xds_client/xds_resource_type.h" #include "src/core/xds/xds_client/xds_resource_type_impl.h" #include "upb/reflection/def.h" +#include "absl/strings/string_view.h" namespace grpc_core { diff --git a/deps/grpc/src/core/xds/grpc/xds_routing.cc b/deps/grpc/src/core/xds/grpc/xds_routing.cc index edcbf7ad931..4d713d3e6a0 100644 --- a/deps/grpc/src/core/xds/grpc/xds_routing.cc +++ b/deps/grpc/src/core/xds/grpc/xds_routing.cc @@ -26,14 +26,14 @@ #include #include -#include "absl/status/status.h" -#include "absl/status/statusor.h" -#include "absl/strings/match.h" -#include "absl/strings/str_cat.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/util/grpc_check.h" #include "src/core/util/matchers.h" #include "src/core/xds/grpc/xds_http_filter.h" +#include "absl/status/status.h" +#include "absl/status/statusor.h" +#include "absl/strings/match.h" +#include "absl/strings/str_cat.h" namespace grpc_core { diff --git a/deps/grpc/src/core/xds/grpc/xds_routing.h b/deps/grpc/src/core/xds/grpc/xds_routing.h index 44060b8fe0c..4f097e0ba09 100644 --- a/deps/grpc/src/core/xds/grpc/xds_routing.h +++ b/deps/grpc/src/core/xds/grpc/xds_routing.h @@ -27,13 +27,13 @@ #include #include -#include "absl/status/statusor.h" -#include "absl/strings/string_view.h" #include "src/core/call/metadata_batch.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/xds/grpc/xds_http_filter_registry.h" #include "src/core/xds/grpc/xds_listener.h" #include "src/core/xds/grpc/xds_route_config.h" +#include "absl/status/statusor.h" +#include "absl/strings/string_view.h" namespace grpc_core { diff --git a/deps/grpc/src/core/xds/grpc/xds_server_grpc.cc b/deps/grpc/src/core/xds/grpc/xds_server_grpc.cc index 5d153733712..bbd93cea177 100644 --- a/deps/grpc/src/core/xds/grpc/xds_server_grpc.cc +++ b/deps/grpc/src/core/xds/grpc/xds_server_grpc.cc @@ -23,13 +23,13 @@ #include #include -#include "absl/strings/str_cat.h" -#include "absl/strings/string_view.h" #include "src/core/config/core_configuration.h" #include "src/core/util/down_cast.h" #include "src/core/util/env.h" #include "src/core/util/json/json_reader.h" #include "src/core/util/json/json_writer.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/string_view.h" namespace grpc_core { diff --git a/deps/grpc/src/core/xds/grpc/xds_transport_grpc.cc b/deps/grpc/src/core/xds/grpc/xds_transport_grpc.cc index 84920314f7b..e87f857288a 100644 --- a/deps/grpc/src/core/xds/grpc/xds_transport_grpc.cc +++ b/deps/grpc/src/core/xds/grpc/xds_transport_grpc.cc @@ -31,7 +31,6 @@ #include #include -#include "absl/strings/str_cat.h" #include "src/core/client_channel/client_channel_filter.h" #include "src/core/config/core_configuration.h" #include "src/core/credentials/call/composite/composite_call_credentials.h" @@ -61,6 +60,7 @@ #include "src/core/util/time.h" #include "src/core/xds/grpc/xds_server_grpc_interface.h" #include "src/core/xds/xds_client/xds_bootstrap.h" +#include "absl/strings/str_cat.h" namespace grpc_core { diff --git a/deps/grpc/src/core/xds/grpc/xds_transport_grpc.h b/deps/grpc/src/core/xds/grpc/xds_transport_grpc.h index b2454488ea8..5556de4ff1e 100644 --- a/deps/grpc/src/core/xds/grpc/xds_transport_grpc.h +++ b/deps/grpc/src/core/xds/grpc/xds_transport_grpc.h @@ -26,8 +26,6 @@ #include #include -#include "absl/container/flat_hash_map.h" -#include "absl/status/status.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/iomgr/closure.h" #include "src/core/lib/iomgr/error.h" @@ -38,6 +36,8 @@ #include "src/core/util/sync.h" #include "src/core/xds/xds_client/xds_bootstrap.h" #include "src/core/xds/xds_client/xds_transport.h" +#include "absl/container/flat_hash_map.h" +#include "absl/status/status.h" namespace grpc_core { diff --git a/deps/grpc/src/core/xds/xds_client/lrs_client.cc b/deps/grpc/src/core/xds/xds_client/lrs_client.cc index 72a7bd8da27..1812514a64c 100644 --- a/deps/grpc/src/core/xds/xds_client/lrs_client.cc +++ b/deps/grpc/src/core/xds/xds_client/lrs_client.cc @@ -24,9 +24,6 @@ #include #include -#include "absl/cleanup/cleanup.h" -#include "absl/log/log.h" -#include "absl/strings/string_view.h" #include "envoy/config/core/v3/base.upb.h" #include "envoy/config/endpoint/v3/load_report.upb.h" #include "envoy/service/load_stats/v3/lrs.upb.h" @@ -51,6 +48,9 @@ #include "upb/mem/arena.h" #include "upb/reflection/def.h" #include "upb/text/encode.h" +#include "absl/cleanup/cleanup.h" +#include "absl/log/log.h" +#include "absl/strings/string_view.h" #define GRPC_XDS_INITIAL_CONNECT_BACKOFF_SECONDS 1 #define GRPC_XDS_RECONNECT_BACKOFF_MULTIPLIER 1.6 diff --git a/deps/grpc/src/core/xds/xds_client/lrs_client.h b/deps/grpc/src/core/xds/xds_client/lrs_client.h index ce25993a5eb..8ffcd8b41b0 100644 --- a/deps/grpc/src/core/xds/xds_client/lrs_client.h +++ b/deps/grpc/src/core/xds/xds_client/lrs_client.h @@ -26,10 +26,6 @@ #include #include -#include "absl/base/thread_annotations.h" -#include "absl/status/status.h" -#include "absl/status/statusor.h" -#include "absl/strings/string_view.h" #include "src/core/lib/debug/trace.h" #include "src/core/load_balancing/backend_metric_data.h" #include "src/core/util/dual_ref_counted.h" @@ -49,6 +45,10 @@ #include "src/core/xds/xds_client/xds_resource_type.h" #include "src/core/xds/xds_client/xds_transport.h" #include "upb/reflection/def.hpp" +#include "absl/base/thread_annotations.h" +#include "absl/status/status.h" +#include "absl/status/statusor.h" +#include "absl/strings/string_view.h" namespace grpc_core { diff --git a/deps/grpc/src/core/xds/xds_client/xds_api.h b/deps/grpc/src/core/xds/xds_client/xds_api.h index 3a0b59732c1..754792f1c45 100644 --- a/deps/grpc/src/core/xds/xds_client/xds_api.h +++ b/deps/grpc/src/core/xds/xds_client/xds_api.h @@ -17,10 +17,10 @@ #ifndef GRPC_SRC_CORE_XDS_XDS_CLIENT_XDS_API_H #define GRPC_SRC_CORE_XDS_XDS_CLIENT_XDS_API_H -#include "absl/strings/string_view.h" #include "envoy/config/core/v3/base.upb.h" #include "src/core/xds/xds_client/xds_bootstrap.h" #include "upb/mem/arena.h" +#include "absl/strings/string_view.h" namespace grpc_core { diff --git a/deps/grpc/src/core/xds/xds_client/xds_backend_metric_propagation.cc b/deps/grpc/src/core/xds/xds_client/xds_backend_metric_propagation.cc index edb2f852f71..6b8f10d9c86 100644 --- a/deps/grpc/src/core/xds/xds_client/xds_backend_metric_propagation.cc +++ b/deps/grpc/src/core/xds/xds_client/xds_backend_metric_propagation.cc @@ -18,9 +18,9 @@ #include +#include "src/core/util/useful.h" #include "absl/strings/str_cat.h" #include "absl/strings/str_join.h" -#include "src/core/util/useful.h" namespace grpc_core { diff --git a/deps/grpc/src/core/xds/xds_client/xds_backend_metric_propagation.h b/deps/grpc/src/core/xds/xds_client/xds_backend_metric_propagation.h index 3b9af885f71..12c58403854 100644 --- a/deps/grpc/src/core/xds/xds_client/xds_backend_metric_propagation.h +++ b/deps/grpc/src/core/xds/xds_client/xds_backend_metric_propagation.h @@ -19,9 +19,9 @@ #include -#include "absl/container/flat_hash_set.h" #include "src/core/util/ref_counted.h" #include "src/core/util/ref_counted_ptr.h" +#include "absl/container/flat_hash_set.h" namespace grpc_core { diff --git a/deps/grpc/src/core/xds/xds_client/xds_client.cc b/deps/grpc/src/core/xds/xds_client/xds_client.cc index de509209042..91701e5a470 100644 --- a/deps/grpc/src/core/xds/xds_client/xds_client.cc +++ b/deps/grpc/src/core/xds/xds_client/xds_client.cc @@ -29,14 +29,6 @@ #include #include -#include "absl/cleanup/cleanup.h" -#include "absl/log/log.h" -#include "absl/strings/match.h" -#include "absl/strings/str_cat.h" -#include "absl/strings/str_join.h" -#include "absl/strings/str_split.h" -#include "absl/strings/string_view.h" -#include "absl/strings/strip.h" #include "envoy/config/core/v3/base.upb.h" #include "envoy/service/discovery/v3/discovery.upb.h" #include "envoy/service/discovery/v3/discovery.upbdefs.h" @@ -61,6 +53,14 @@ #include "upb/mem/arena.h" #include "upb/reflection/def.h" #include "upb/text/encode.h" +#include "absl/cleanup/cleanup.h" +#include "absl/log/log.h" +#include "absl/strings/match.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/str_join.h" +#include "absl/strings/str_split.h" +#include "absl/strings/string_view.h" +#include "absl/strings/strip.h" #define GRPC_XDS_INITIAL_CONNECT_BACKOFF_SECONDS 1 #define GRPC_XDS_RECONNECT_BACKOFF_MULTIPLIER 1.6 diff --git a/deps/grpc/src/core/xds/xds_client/xds_client.h b/deps/grpc/src/core/xds/xds_client/xds_client.h index 31fe33a592d..f521a780d86 100644 --- a/deps/grpc/src/core/xds/xds_client/xds_client.h +++ b/deps/grpc/src/core/xds/xds_client/xds_client.h @@ -27,11 +27,6 @@ #include #include -#include "absl/base/thread_annotations.h" -#include "absl/container/flat_hash_set.h" -#include "absl/status/status.h" -#include "absl/status/statusor.h" -#include "absl/strings/string_view.h" #include "envoy/admin/v3/config_dump_shared.upb.h" #include "envoy/service/status/v3/csds.upb.h" #include "src/core/lib/debug/trace.h" @@ -50,6 +45,11 @@ #include "src/core/xds/xds_client/xds_resource_type.h" #include "src/core/xds/xds_client/xds_transport.h" #include "upb/reflection/def.hpp" +#include "absl/base/thread_annotations.h" +#include "absl/container/flat_hash_set.h" +#include "absl/status/status.h" +#include "absl/status/statusor.h" +#include "absl/strings/string_view.h" namespace grpc_core { diff --git a/deps/grpc/src/core/xds/xds_client/xds_locality.h b/deps/grpc/src/core/xds/xds_client/xds_locality.h index 7fb469ba415..9b5b11c8435 100644 --- a/deps/grpc/src/core/xds/xds_client/xds_locality.h +++ b/deps/grpc/src/core/xds/xds_client/xds_locality.h @@ -22,13 +22,13 @@ #include #include -#include "absl/strings/str_format.h" -#include "absl/strings/string_view.h" #include "src/core/resolver/endpoint_addresses.h" #include "src/core/util/ref_counted.h" #include "src/core/util/ref_counted_ptr.h" #include "src/core/util/ref_counted_string.h" #include "src/core/util/useful.h" +#include "absl/strings/str_format.h" +#include "absl/strings/string_view.h" namespace grpc_core { diff --git a/deps/grpc/src/core/xds/xds_client/xds_resource_type.h b/deps/grpc/src/core/xds/xds_client/xds_resource_type.h index ab45ac79da0..45a90d3abf4 100644 --- a/deps/grpc/src/core/xds/xds_client/xds_resource_type.h +++ b/deps/grpc/src/core/xds/xds_client/xds_resource_type.h @@ -22,12 +22,12 @@ #include #include -#include "absl/status/statusor.h" -#include "absl/strings/string_view.h" #include "src/core/lib/debug/trace.h" #include "src/core/xds/xds_client/xds_bootstrap.h" #include "upb/mem/arena.h" #include "upb/reflection/def.h" +#include "absl/status/statusor.h" +#include "absl/strings/string_view.h" namespace grpc_core { diff --git a/deps/grpc/src/core/xds/xds_client/xds_resource_type_impl.h b/deps/grpc/src/core/xds/xds_client/xds_resource_type_impl.h index bb54cbc650e..f386cc8378b 100644 --- a/deps/grpc/src/core/xds/xds_client/xds_resource_type_impl.h +++ b/deps/grpc/src/core/xds/xds_client/xds_resource_type_impl.h @@ -20,11 +20,11 @@ #include #include -#include "absl/strings/string_view.h" #include "src/core/util/down_cast.h" #include "src/core/util/ref_counted_ptr.h" #include "src/core/xds/xds_client/xds_client.h" #include "src/core/xds/xds_client/xds_resource_type.h" +#include "absl/strings/string_view.h" namespace grpc_core { diff --git a/deps/grpc/src/core/xds/xds_client/xds_transport.h b/deps/grpc/src/core/xds/xds_client/xds_transport.h index c7a569d3c14..ade31d65859 100644 --- a/deps/grpc/src/core/xds/xds_client/xds_transport.h +++ b/deps/grpc/src/core/xds/xds_client/xds_transport.h @@ -20,11 +20,11 @@ #include #include -#include "absl/status/status.h" -#include "absl/strings/string_view.h" #include "src/core/util/dual_ref_counted.h" #include "src/core/util/orphanable.h" #include "src/core/xds/xds_client/xds_bootstrap.h" +#include "absl/status/status.h" +#include "absl/strings/string_view.h" namespace grpc_core { diff --git a/deps/grpc/src/cpp/client/call_credentials.cc b/deps/grpc/src/cpp/client/call_credentials.cc index e2dffe72e71..f21f981581a 100644 --- a/deps/grpc/src/cpp/client/call_credentials.cc +++ b/deps/grpc/src/cpp/client/call_credentials.cc @@ -17,8 +17,8 @@ #include #include -#include "absl/strings/str_cat.h" #include "src/core/util/grpc_check.h" +#include "absl/strings/str_cat.h" namespace grpc { diff --git a/deps/grpc/src/cpp/client/channel_cc.cc b/deps/grpc/src/cpp/client/channel_cc.cc index 09c952f8181..ba4f88db3f8 100644 --- a/deps/grpc/src/cpp/client/channel_cc.cc +++ b/deps/grpc/src/cpp/client/channel_cc.cc @@ -16,6 +16,7 @@ // // +#include #include #include #include @@ -67,6 +68,11 @@ Channel::~Channel() { } } +grpc_event_engine::experimental::MemoryAllocator* Channel::memory_allocator() + const { + return grpc_core::Channel::FromC(c_channel_)->memory_allocator(); +} + namespace { inline grpc_slice SliceFromArray(const char* arr, size_t len) { diff --git a/deps/grpc/src/cpp/client/client_context.cc b/deps/grpc/src/cpp/client/client_context.cc index d7d269359b3..6e7ee93a3b2 100644 --- a/deps/grpc/src/cpp/client/client_context.cc +++ b/deps/grpc/src/cpp/client/client_context.cc @@ -37,9 +37,9 @@ #include #include -#include "absl/strings/str_format.h" #include "src/core/util/crash.h" #include "src/core/util/grpc_check.h" +#include "absl/strings/str_format.h" namespace grpc { diff --git a/deps/grpc/src/cpp/client/global_callback_hook.cc b/deps/grpc/src/cpp/client/global_callback_hook.cc index 6bcb70d3329..605bb657023 100644 --- a/deps/grpc/src/cpp/client/global_callback_hook.cc +++ b/deps/grpc/src/cpp/client/global_callback_hook.cc @@ -16,8 +16,8 @@ #include -#include "absl/base/no_destructor.h" #include "src/core/util/grpc_check.h" +#include "absl/base/no_destructor.h" namespace grpc { diff --git a/deps/grpc/src/cpp/client/secure_credentials.cc b/deps/grpc/src/cpp/client/secure_credentials.cc index d025b2d7149..81c48b91e95 100644 --- a/deps/grpc/src/cpp/client/secure_credentials.cc +++ b/deps/grpc/src/cpp/client/secure_credentials.cc @@ -39,10 +39,6 @@ #include #include -#include "absl/log/log.h" -#include "absl/status/status.h" -#include "absl/status/statusor.h" -#include "absl/strings/str_join.h" #include "src/core/credentials/call/json_util.h" #include "src/core/lib/event_engine/default_event_engine.h" #include "src/core/lib/iomgr/exec_ctx.h" @@ -53,6 +49,10 @@ #include "src/core/util/load_file.h" #include "src/cpp/common/secure_auth_context.h" #include "src/cpp/server/thread_pool_interface.h" +#include "absl/log/log.h" +#include "absl/status/status.h" +#include "absl/status/statusor.h" +#include "absl/strings/str_join.h" namespace grpc { diff --git a/deps/grpc/src/cpp/common/alarm.cc b/deps/grpc/src/cpp/common/alarm.cc index 29825aaa0e8..24bfd4529d1 100644 --- a/deps/grpc/src/cpp/common/alarm.cc +++ b/deps/grpc/src/cpp/common/alarm.cc @@ -29,13 +29,13 @@ #include #include -#include "absl/status/status.h" #include "src/core/lib/event_engine/default_event_engine.h" #include "src/core/lib/iomgr/error.h" #include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/surface/completion_queue.h" #include "src/core/util/grpc_check.h" #include "src/core/util/time.h" +#include "absl/status/status.h" namespace grpc { diff --git a/deps/grpc/src/cpp/common/alts_util.cc b/deps/grpc/src/cpp/common/alts_util.cc index 1a0a2149b1f..b9fa06a49eb 100644 --- a/deps/grpc/src/cpp/common/alts_util.cc +++ b/deps/grpc/src/cpp/common/alts_util.cc @@ -28,10 +28,10 @@ #include #include -#include "absl/log/log.h" #include "src/core/tsi/alts/handshaker/alts_tsi_handshaker.h" #include "src/proto/grpc/gcp/altscontext.upb.h" #include "upb/mem/arena.hpp" +#include "absl/log/log.h" namespace grpc { namespace experimental { diff --git a/deps/grpc/src/cpp/common/completion_queue_cc.cc b/deps/grpc/src/cpp/common/completion_queue_cc.cc index 7e2781054bc..45eb5567f64 100644 --- a/deps/grpc/src/cpp/common/completion_queue_cc.cc +++ b/deps/grpc/src/cpp/common/completion_queue_cc.cc @@ -25,14 +25,14 @@ #include -#include "absl/base/thread_annotations.h" -#include "absl/log/log.h" #include "src/core/lib/experiments/experiments.h" #include "src/core/util/crash.h" #include "src/core/util/grpc_check.h" #include "src/core/util/sync.h" #include "src/core/util/thd.h" #include "src/core/util/useful.h" +#include "absl/base/thread_annotations.h" +#include "absl/log/log.h" namespace grpc { namespace { diff --git a/deps/grpc/src/cpp/common/validate_service_config.cc b/deps/grpc/src/cpp/common/validate_service_config.cc index 6869617036a..be8a7c77298 100644 --- a/deps/grpc/src/cpp/common/validate_service_config.cc +++ b/deps/grpc/src/cpp/common/validate_service_config.cc @@ -21,12 +21,12 @@ #include -#include "absl/status/status.h" -#include "absl/status/statusor.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/service_config/service_config.h" #include "src/core/service_config/service_config_impl.h" #include "src/core/util/ref_counted_ptr.h" +#include "absl/status/status.h" +#include "absl/status/statusor.h" namespace grpc { namespace experimental { diff --git a/deps/grpc/src/cpp/ext/csm/BUILD b/deps/grpc/src/cpp/ext/csm/BUILD index c1688138b43..6165627b390 100644 --- a/deps/grpc/src/cpp/ext/csm/BUILD +++ b/deps/grpc/src/cpp/ext/csm/BUILD @@ -25,6 +25,7 @@ package( default_visibility = ["//visibility:public"], features = [ "layering_check", + "parse_headers", ], ) diff --git a/deps/grpc/src/cpp/ext/csm/csm_observability.cc b/deps/grpc/src/cpp/ext/csm/csm_observability.cc index c2acd8f0ece..a1c7ba820c4 100644 --- a/deps/grpc/src/cpp/ext/csm/csm_observability.cc +++ b/deps/grpc/src/cpp/ext/csm/csm_observability.cc @@ -26,9 +26,6 @@ #include #include -#include "absl/functional/any_invocable.h" -#include "absl/log/log.h" -#include "absl/status/statusor.h" #include "google/cloud/opentelemetry/resource_detector.h" #include "opentelemetry/sdk/metrics/meter_provider.h" #include "opentelemetry/sdk/resource/resource.h" @@ -38,6 +35,9 @@ #include "src/core/xds/grpc/xds_enabled_server.h" #include "src/cpp/ext/csm/metadata_exchange.h" #include "src/cpp/ext/otel/otel_plugin.h" +#include "absl/functional/any_invocable.h" +#include "absl/log/log.h" +#include "absl/status/statusor.h" namespace grpc { diff --git a/deps/grpc/src/cpp/ext/csm/csm_observability.h b/deps/grpc/src/cpp/ext/csm/csm_observability.h index a42831a4f4a..8ae58817f54 100644 --- a/deps/grpc/src/cpp/ext/csm/csm_observability.h +++ b/deps/grpc/src/cpp/ext/csm/csm_observability.h @@ -21,8 +21,8 @@ #include -#include "absl/strings/string_view.h" #include "src/core/lib/channel/channel_args.h" +#include "absl/strings/string_view.h" namespace grpc { namespace internal { diff --git a/deps/grpc/src/cpp/ext/csm/metadata_exchange.cc b/deps/grpc/src/cpp/ext/csm/metadata_exchange.cc index e49074fbbef..0ffce31a3b5 100644 --- a/deps/grpc/src/cpp/ext/csm/metadata_exchange.cc +++ b/deps/grpc/src/cpp/ext/csm/metadata_exchange.cc @@ -29,11 +29,6 @@ #include #include -#include "absl/status/statusor.h" -#include "absl/strings/escaping.h" -#include "absl/strings/str_split.h" -#include "absl/strings/string_view.h" -#include "absl/strings/strip.h" #include "opentelemetry/sdk/resource/semantic_conventions.h" #include "src/core/lib/iomgr/error.h" #include "src/core/lib/slice/slice_internal.h" @@ -42,6 +37,11 @@ #include "src/core/util/grpc_check.h" #include "src/cpp/ext/otel/key_value_iterable.h" #include "upb/base/string_view.h" +#include "absl/status/statusor.h" +#include "absl/strings/escaping.h" +#include "absl/strings/str_split.h" +#include "absl/strings/string_view.h" +#include "absl/strings/strip.h" namespace grpc { namespace internal { diff --git a/deps/grpc/src/cpp/ext/csm/metadata_exchange.h b/deps/grpc/src/cpp/ext/csm/metadata_exchange.h index 40988327a90..b0a6f1b5d94 100644 --- a/deps/grpc/src/cpp/ext/csm/metadata_exchange.h +++ b/deps/grpc/src/cpp/ext/csm/metadata_exchange.h @@ -26,13 +26,13 @@ #include #include -#include "absl/strings/string_view.h" #include "google/protobuf/struct.upb.h" #include "opentelemetry/sdk/common/attribute_utils.h" #include "src/core/call/metadata_batch.h" #include "src/core/lib/slice/slice.h" #include "src/cpp/ext/otel/otel_plugin.h" #include "upb/mem/arena.hpp" +#include "absl/strings/string_view.h" namespace grpc { namespace internal { diff --git a/deps/grpc/src/cpp/ext/filters/census/client_filter.cc b/deps/grpc/src/cpp/ext/filters/census/client_filter.cc index 5253689b92f..56647b5add7 100644 --- a/deps/grpc/src/cpp/ext/filters/census/client_filter.cc +++ b/deps/grpc/src/cpp/ext/filters/census/client_filter.cc @@ -35,12 +35,6 @@ #include #include -#include "absl/status/status.h" -#include "absl/strings/str_cat.h" -#include "absl/strings/str_format.h" -#include "absl/strings/string_view.h" -#include "absl/time/clock.h" -#include "absl/time/time.h" #include "opencensus/stats/stats.h" #include "opencensus/tags/tag_key.h" #include "opencensus/tags/tag_map.h" @@ -64,6 +58,12 @@ #include "src/cpp/ext/filters/census/grpc_plugin.h" #include "src/cpp/ext/filters/census/measures.h" #include "src/cpp/ext/filters/census/open_census_call_tracer.h" +#include "absl/status/status.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/str_format.h" +#include "absl/strings/string_view.h" +#include "absl/time/clock.h" +#include "absl/time/time.h" namespace grpc { namespace internal { diff --git a/deps/grpc/src/cpp/ext/filters/census/client_filter.h b/deps/grpc/src/cpp/ext/filters/census/client_filter.h index e1ee13b087f..38043347eaa 100644 --- a/deps/grpc/src/cpp/ext/filters/census/client_filter.h +++ b/deps/grpc/src/cpp/ext/filters/census/client_filter.h @@ -23,12 +23,12 @@ #include #include -#include "absl/status/statusor.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/channel_fwd.h" #include "src/core/lib/channel/promise_based_filter.h" #include "src/core/lib/promise/arena_promise.h" #include "src/core/lib/transport/transport.h" +#include "absl/status/statusor.h" namespace grpc { namespace internal { diff --git a/deps/grpc/src/cpp/ext/filters/census/context.h b/deps/grpc/src/cpp/ext/filters/census/context.h index fcee9407139..c72723b08b6 100644 --- a/deps/grpc/src/cpp/ext/filters/census/context.h +++ b/deps/grpc/src/cpp/ext/filters/census/context.h @@ -27,12 +27,12 @@ #include #include -#include "absl/strings/string_view.h" -#include "absl/strings/strip.h" #include "opencensus/trace/span.h" #include "opencensus/trace/span_context.h" #include "src/core/lib/channel/channel_stack.h" #include "src/core/lib/slice/slice.h" +#include "absl/strings/string_view.h" +#include "absl/strings/strip.h" namespace grpc { diff --git a/deps/grpc/src/cpp/ext/filters/census/grpc_plugin.cc b/deps/grpc/src/cpp/ext/filters/census/grpc_plugin.cc index f5410316810..b5bd6c64293 100644 --- a/deps/grpc/src/cpp/ext/filters/census/grpc_plugin.cc +++ b/deps/grpc/src/cpp/ext/filters/census/grpc_plugin.cc @@ -24,8 +24,6 @@ #include -#include "absl/base/attributes.h" -#include "absl/strings/string_view.h" #include "opencensus/tags/tag_key.h" #include "opencensus/trace/span.h" #include "src/core/config/core_configuration.h" @@ -35,6 +33,8 @@ #include "src/cpp/ext/filters/census/client_filter.h" #include "src/cpp/ext/filters/census/measures.h" #include "src/cpp/ext/filters/census/server_call_tracer.h" +#include "absl/base/attributes.h" +#include "absl/strings/string_view.h" namespace grpc { diff --git a/deps/grpc/src/cpp/ext/filters/census/grpc_plugin.h b/deps/grpc/src/cpp/ext/filters/census/grpc_plugin.h index af647d33af1..a9c40676c3a 100644 --- a/deps/grpc/src/cpp/ext/filters/census/grpc_plugin.h +++ b/deps/grpc/src/cpp/ext/filters/census/grpc_plugin.h @@ -28,10 +28,10 @@ #include #include -#include "absl/strings/string_view.h" #include "opencensus/stats/stats.h" #include "opencensus/tags/tag_key.h" #include "opencensus/tags/tag_map.h" +#include "absl/strings/string_view.h" namespace grpc { diff --git a/deps/grpc/src/cpp/ext/filters/census/open_census_call_tracer.h b/deps/grpc/src/cpp/ext/filters/census/open_census_call_tracer.h index 75559a7df58..5e3d5865ada 100644 --- a/deps/grpc/src/cpp/ext/filters/census/open_census_call_tracer.h +++ b/deps/grpc/src/cpp/ext/filters/census/open_census_call_tracer.h @@ -28,10 +28,6 @@ #include #include -#include "absl/base/thread_annotations.h" -#include "absl/status/status.h" -#include "absl/strings/string_view.h" -#include "absl/time/time.h" #include "opencensus/trace/span.h" #include "opencensus/trace/span_context.h" #include "opencensus/trace/span_id.h" @@ -45,6 +41,10 @@ #include "src/core/telemetry/call_tracer.h" #include "src/core/telemetry/tcp_tracer.h" #include "src/core/util/sync.h" +#include "absl/base/thread_annotations.h" +#include "absl/status/status.h" +#include "absl/strings/string_view.h" +#include "absl/time/time.h" // TODO(yashykt): This might not be the right place for this channel arg, but we // don't have a better place for this right now. diff --git a/deps/grpc/src/cpp/ext/filters/census/server_call_tracer.cc b/deps/grpc/src/cpp/ext/filters/census/server_call_tracer.cc index ab4c456409c..d9216f34af9 100644 --- a/deps/grpc/src/cpp/ext/filters/census/server_call_tracer.cc +++ b/deps/grpc/src/cpp/ext/filters/census/server_call_tracer.cc @@ -31,11 +31,6 @@ #include #include -#include "absl/strings/str_cat.h" -#include "absl/strings/str_format.h" -#include "absl/strings/string_view.h" -#include "absl/time/clock.h" -#include "absl/time/time.h" #include "opencensus/stats/stats.h" #include "opencensus/tags/tag_key.h" #include "opencensus/tags/tag_map.h" @@ -55,6 +50,11 @@ #include "src/cpp/ext/filters/census/context.h" #include "src/cpp/ext/filters/census/grpc_plugin.h" #include "src/cpp/ext/filters/census/measures.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/str_format.h" +#include "absl/strings/string_view.h" +#include "absl/time/clock.h" +#include "absl/time/time.h" namespace grpc { namespace internal { diff --git a/deps/grpc/src/cpp/ext/filters/census/views.cc b/deps/grpc/src/cpp/ext/filters/census/views.cc index 3fa27ff57a6..ffec907e3c9 100644 --- a/deps/grpc/src/cpp/ext/filters/census/views.cc +++ b/deps/grpc/src/cpp/ext/filters/census/views.cc @@ -21,9 +21,9 @@ #include -#include "absl/time/time.h" #include "opencensus/stats/stats.h" #include "src/cpp/ext/filters/census/grpc_plugin.h" +#include "absl/time/time.h" namespace grpc { diff --git a/deps/grpc/src/cpp/ext/gcp/BUILD b/deps/grpc/src/cpp/ext/gcp/BUILD index 21a83c5ef80..5fafab03f39 100644 --- a/deps/grpc/src/cpp/ext/gcp/BUILD +++ b/deps/grpc/src/cpp/ext/gcp/BUILD @@ -25,6 +25,7 @@ package( default_visibility = ["//visibility:public"], features = [ "layering_check", + "parse_headers", ], ) diff --git a/deps/grpc/src/cpp/ext/gcp/environment_autodetect.cc b/deps/grpc/src/cpp/ext/gcp/environment_autodetect.cc index 0b111bf0f34..e2b2dedb80d 100644 --- a/deps/grpc/src/cpp/ext/gcp/environment_autodetect.cc +++ b/deps/grpc/src/cpp/ext/gcp/environment_autodetect.cc @@ -27,10 +27,6 @@ #include #include -#include "absl/container/flat_hash_map.h" -#include "absl/log/log.h" -#include "absl/status/status.h" -#include "absl/status/statusor.h" #include "src/core/lib/debug/trace.h" #include "src/core/lib/event_engine/shim.h" #include "src/core/lib/iomgr/closure.h" @@ -48,6 +44,10 @@ #include "src/core/util/orphanable.h" #include "src/core/util/status_helper.h" #include "src/core/util/time.h" +#include "absl/container/flat_hash_map.h" +#include "absl/log/log.h" +#include "absl/status/status.h" +#include "absl/status/statusor.h" namespace grpc { namespace internal { diff --git a/deps/grpc/src/cpp/ext/gcp/environment_autodetect.h b/deps/grpc/src/cpp/ext/gcp/environment_autodetect.h index 21ccfdf47a7..6203876cd1d 100644 --- a/deps/grpc/src/cpp/ext/gcp/environment_autodetect.h +++ b/deps/grpc/src/cpp/ext/gcp/environment_autodetect.h @@ -25,10 +25,10 @@ #include #include +#include "src/core/util/sync.h" #include "absl/base/thread_annotations.h" #include "absl/functional/any_invocable.h" #include "absl/status/status.h" -#include "src/core/util/sync.h" namespace grpc { diff --git a/deps/grpc/src/cpp/ext/gcp/observability.cc b/deps/grpc/src/cpp/ext/gcp/observability.cc index 10e119e327a..848dca0b5a5 100644 --- a/deps/grpc/src/cpp/ext/gcp/observability.cc +++ b/deps/grpc/src/cpp/ext/gcp/observability.cc @@ -31,11 +31,6 @@ #include #include -#include "absl/status/status.h" -#include "absl/status/statusor.h" -#include "absl/strings/str_cat.h" -#include "absl/time/clock.h" -#include "absl/time/time.h" #include "google/api/monitored_resource.pb.h" #include "google/devtools/cloudtrace/v2/tracing.grpc.pb.h" #include "google/monitoring/v3/metric_service.grpc.pb.h" @@ -54,6 +49,11 @@ #include "src/cpp/ext/gcp/environment_autodetect.h" #include "src/cpp/ext/gcp/observability_config.h" #include "src/cpp/ext/gcp/observability_logging_sink.h" +#include "absl/status/status.h" +#include "absl/status/statusor.h" +#include "absl/strings/str_cat.h" +#include "absl/time/clock.h" +#include "absl/time/time.h" namespace grpc { diff --git a/deps/grpc/src/cpp/ext/gcp/observability_config.cc b/deps/grpc/src/cpp/ext/gcp/observability_config.cc index f1c247ebe0c..0a39b0c21e1 100644 --- a/deps/grpc/src/cpp/ext/gcp/observability_config.cc +++ b/deps/grpc/src/cpp/ext/gcp/observability_config.cc @@ -25,11 +25,6 @@ #include #include -#include "absl/status/status.h" -#include "absl/strings/match.h" -#include "absl/strings/str_cat.h" -#include "absl/strings/str_split.h" -#include "absl/strings/string_view.h" #include "src/core/lib/iomgr/error.h" #include "src/core/lib/slice/slice_internal.h" #include "src/core/lib/transport/error_utils.h" @@ -39,6 +34,11 @@ #include "src/core/util/load_file.h" #include "src/core/util/status_helper.h" #include "src/core/util/validation_errors.h" +#include "absl/status/status.h" +#include "absl/strings/match.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/str_split.h" +#include "absl/strings/string_view.h" namespace grpc { namespace internal { diff --git a/deps/grpc/src/cpp/ext/gcp/observability_config.h b/deps/grpc/src/cpp/ext/gcp/observability_config.h index 243aa79775c..b04a6a092ee 100644 --- a/deps/grpc/src/cpp/ext/gcp/observability_config.h +++ b/deps/grpc/src/cpp/ext/gcp/observability_config.h @@ -25,12 +25,12 @@ #include #include -#include "absl/status/statusor.h" -#include "absl/strings/string_view.h" #include "src/core/util/json/json.h" #include "src/core/util/json/json_args.h" #include "src/core/util/json/json_object_loader.h" #include "src/core/util/validation_errors.h" +#include "absl/status/statusor.h" +#include "absl/strings/string_view.h" namespace grpc { namespace internal { diff --git a/deps/grpc/src/cpp/ext/gcp/observability_logging_sink.cc b/deps/grpc/src/cpp/ext/gcp/observability_logging_sink.cc index 9b3488a649c..4204671bb5f 100644 --- a/deps/grpc/src/cpp/ext/gcp/observability_logging_sink.cc +++ b/deps/grpc/src/cpp/ext/gcp/observability_logging_sink.cc @@ -31,11 +31,6 @@ #include #include -#include "absl/log/log.h" -#include "absl/numeric/int128.h" -#include "absl/strings/escaping.h" -#include "absl/strings/match.h" -#include "absl/strings/str_format.h" #include "google/api/monitored_resource.pb.h" #include "google/logging/v2/log_entry.pb.h" #include "google/logging/v2/logging.grpc.pb.h" @@ -47,6 +42,11 @@ #include "src/core/util/time.h" #include "src/core/util/uuid_v4.h" #include "src/cpp/ext/filters/census/open_census_call_tracer.h" +#include "absl/log/log.h" +#include "absl/numeric/int128.h" +#include "absl/strings/escaping.h" +#include "absl/strings/match.h" +#include "absl/strings/str_format.h" // IWYU pragma: no_include "google/protobuf/struct.pb.h" // IWYU pragma: no_include "google/protobuf/timestamp.pb.h" diff --git a/deps/grpc/src/cpp/ext/gcp/observability_logging_sink.h b/deps/grpc/src/cpp/ext/gcp/observability_logging_sink.h index a61765118c2..457a6bab591 100644 --- a/deps/grpc/src/cpp/ext/gcp/observability_logging_sink.h +++ b/deps/grpc/src/cpp/ext/gcp/observability_logging_sink.h @@ -29,13 +29,13 @@ #include #include -#include "absl/base/thread_annotations.h" -#include "absl/strings/string_view.h" #include "google/logging/v2/logging.grpc.pb.h" #include "src/core/ext/filters/logging/logging_sink.h" #include "src/core/util/sync.h" #include "src/cpp/ext/gcp/environment_autodetect.h" #include "src/cpp/ext/gcp/observability_config.h" +#include "absl/base/thread_annotations.h" +#include "absl/strings/string_view.h" namespace grpc { namespace internal { diff --git a/deps/grpc/src/cpp/ext/otel/BUILD b/deps/grpc/src/cpp/ext/otel/BUILD index 209690d0930..761e8719372 100644 --- a/deps/grpc/src/cpp/ext/otel/BUILD +++ b/deps/grpc/src/cpp/ext/otel/BUILD @@ -25,6 +25,7 @@ package( default_visibility = ["//visibility:public"], features = [ "layering_check", + "parse_headers", ], ) @@ -81,6 +82,7 @@ grpc_cc_library( "//src/core:event_engine_utils", "//src/core:experiments", "//src/core:grpc_check", + "//src/core:instrument", "//src/core:match", "//src/core:metadata_batch", "//src/core:metrics", diff --git a/deps/grpc/src/cpp/ext/otel/key_value_iterable.h b/deps/grpc/src/cpp/ext/otel/key_value_iterable.h index b5c035ae060..b92d6ae1ad4 100644 --- a/deps/grpc/src/cpp/ext/otel/key_value_iterable.h +++ b/deps/grpc/src/cpp/ext/otel/key_value_iterable.h @@ -25,14 +25,14 @@ #include #include -#include "absl/strings/string_view.h" -#include "absl/types/span.h" #include "opentelemetry/common/attribute_value.h" #include "opentelemetry/common/key_value_iterable.h" #include "opentelemetry/nostd/function_ref.h" #include "opentelemetry/nostd/string_view.h" #include "src/core/util/grpc_check.h" #include "src/cpp/ext/otel/otel_plugin.h" +#include "absl/strings/string_view.h" +#include "absl/types/span.h" namespace grpc { namespace internal { diff --git a/deps/grpc/src/cpp/ext/otel/otel_client_call_tracer.cc b/deps/grpc/src/cpp/ext/otel/otel_client_call_tracer.cc index c2aa2cd5605..5e49cebed33 100644 --- a/deps/grpc/src/cpp/ext/otel/otel_client_call_tracer.cc +++ b/deps/grpc/src/cpp/ext/otel/otel_client_call_tracer.cc @@ -31,14 +31,6 @@ #include #include -#include "absl/functional/any_invocable.h" -#include "absl/status/status.h" -#include "absl/strings/str_format.h" -#include "absl/strings/string_view.h" -#include "absl/strings/strip.h" -#include "absl/time/clock.h" -#include "absl/time/time.h" -#include "absl/types/span.h" #include "opentelemetry/context/context.h" #include "opentelemetry/metrics/sync_instruments.h" #include "opentelemetry/trace/context.h" @@ -60,6 +52,14 @@ #include "src/core/util/sync.h" #include "src/cpp/ext/otel/key_value_iterable.h" #include "src/cpp/ext/otel/otel_plugin.h" +#include "absl/functional/any_invocable.h" +#include "absl/status/status.h" +#include "absl/strings/str_format.h" +#include "absl/strings/string_view.h" +#include "absl/strings/strip.h" +#include "absl/time/clock.h" +#include "absl/time/time.h" +#include "absl/types/span.h" namespace grpc { namespace internal { diff --git a/deps/grpc/src/cpp/ext/otel/otel_client_call_tracer.h b/deps/grpc/src/cpp/ext/otel/otel_client_call_tracer.h index b6240e4e2d8..98a32c5f7c1 100644 --- a/deps/grpc/src/cpp/ext/otel/otel_client_call_tracer.h +++ b/deps/grpc/src/cpp/ext/otel/otel_client_call_tracer.h @@ -26,10 +26,6 @@ #include #include -#include "absl/base/thread_annotations.h" -#include "absl/status/status.h" -#include "absl/strings/string_view.h" -#include "absl/time/time.h" #include "opentelemetry/trace/span.h" #include "src/core/call/metadata_batch.h" #include "src/core/lib/iomgr/error.h" @@ -41,6 +37,10 @@ #include "src/core/telemetry/tcp_tracer.h" #include "src/core/util/sync.h" #include "src/cpp/ext/otel/otel_plugin.h" +#include "absl/base/thread_annotations.h" +#include "absl/status/status.h" +#include "absl/strings/string_view.h" +#include "absl/time/time.h" namespace grpc { namespace internal { diff --git a/deps/grpc/src/cpp/ext/otel/otel_plugin.cc b/deps/grpc/src/cpp/ext/otel/otel_plugin.cc index 657695ec464..2e3e26606a7 100644 --- a/deps/grpc/src/cpp/ext/otel/otel_plugin.cc +++ b/deps/grpc/src/cpp/ext/otel/otel_plugin.cc @@ -25,8 +25,9 @@ #include #include #include +#include -#include "absl/strings/escaping.h" +#include "opentelemetry/metrics/async_instruments.h" #include "opentelemetry/metrics/meter.h" #include "opentelemetry/metrics/meter_provider.h" #include "opentelemetry/metrics/sync_instruments.h" @@ -39,11 +40,13 @@ #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/surface/channel_stack_type.h" #include "src/core/telemetry/call_tracer.h" +#include "src/core/telemetry/instrument.h" #include "src/core/util/grpc_check.h" #include "src/core/util/match.h" #include "src/cpp/ext/otel/key_value_iterable.h" #include "src/cpp/ext/otel/otel_client_call_tracer.h" #include "src/cpp/ext/otel/otel_server_call_tracer.h" +#include "absl/strings/escaping.h" using opentelemetry::context::propagation::TextMapPropagator; using opentelemetry::trace::SpanContext; @@ -53,6 +56,16 @@ using opentelemetry::trace::TraceId; namespace grpc { namespace internal { +namespace { +bool IsMetricEnabledByDefault(absl::string_view) { return false; } +} // namespace + +bool IsOpenTelemetryLabelOptional(absl::string_view label_key) { + // TODO(ctiller): register other optional labels here with + // `if (label_key =="xyz") return true;` checks. + return absl::StartsWith(label_key, "test_optional."); +} + absl::string_view OpenTelemetryMethodKey() { return "grpc.method"; } absl::string_view OpenTelemetryStatusKey() { return "grpc.status"; } @@ -87,6 +100,12 @@ absl::flat_hash_set BaseMetrics() { base_metrics.emplace(descriptor.name); } }); + grpc_core::InstrumentMetadata::ForEachInstrument( + [&](const grpc_core::InstrumentMetadata::Description* description) { + if (IsMetricEnabledByDefault(description->name)) { + base_metrics.emplace(description->name); + } + }); return base_metrics; } @@ -392,6 +411,155 @@ void OpenTelemetryPluginImpl::ServerBuilderOption::UpdateArguments( plugin_->AddToChannelArguments(args); } +class OpenTelemetryPluginImpl::ExporterCallback { + public: + virtual ~ExporterCallback() = default; +}; + +template +class OpenTelemetryPluginImpl::ExporterCallbackImpl final + : public ExporterCallback { + public: + template + explicit ExporterCallbackImpl( + opentelemetry::nostd::shared_ptr< + opentelemetry::metrics::ObservableInstrument> + instrument, + Args&&... args) + : exporter_(std::forward(args)...), + instrument_(std::move(instrument)) { + instrument_->AddCallback(Callback, this); + } + + ~ExporterCallbackImpl() override { + instrument_->RemoveCallback(Callback, this); + } + + private: + static void Callback(opentelemetry::metrics::ObserverResult result, + void* arg) { + static_cast(arg)->exporter_.Export( + std::move(result)); + } + + Exporter exporter_; + const opentelemetry::nostd::shared_ptr< + opentelemetry::metrics::ObservableInstrument> + instrument_; +}; + +class OpenTelemetryPluginImpl::ExportedMetricKeyValueIterable final + : public opentelemetry::common::KeyValueIterable { + public: + explicit ExportedMetricKeyValueIterable( + absl::Span label_keys, + absl::Span label_values) + : label_keys_(label_keys), label_values_(label_values) { + CHECK_EQ(label_keys_.size(), label_values_.size()); + } + + bool ForEachKeyValue(opentelemetry::nostd::function_ref< + bool(opentelemetry::nostd::string_view, + opentelemetry::common::AttributeValue)> + callback) const noexcept override { + for (size_t i = 0; i < label_keys_.size(); ++i) { + if (!callback(label_keys_[i], + opentelemetry::common::AttributeValue(label_values_[i]))) { + return false; + } + } + return true; + } + + size_t size() const noexcept override { return label_values_.size(); } + + private: + const absl::Span label_keys_; + const absl::Span label_values_; +}; + +class OpenTelemetryPluginImpl::CounterExporter final { + public: + explicit CounterExporter(OpenTelemetryPluginImpl* impl, + const grpc_core::InstrumentMetadata::Description* md) + : impl_(impl), md_(md) {} + + void Export(opentelemetry::metrics::ObserverResult result) { + Sink sink(std::get>>(result), + md_->shape); + impl_->QueryMetrics({md_->name}, sink); + } + + private: + class Sink final : public grpc_core::MetricsSink { + public: + explicit Sink(opentelemetry::nostd::shared_ptr< + opentelemetry::metrics::ObserverResultT> + observer, + grpc_core::InstrumentMetadata::Shape shape) + : observer_(std::move(observer)), shape_(shape) {} + void Counter(absl::Span label_keys, + absl::Span label_values, absl::string_view, + uint64_t value) override { + GRPC_DCHECK( + std::holds_alternative( + shape_)); + LOG(ERROR) << "Counter: " << value + << " label_keys: " << absl::StrJoin(label_keys, ",") + << " label_values: " << absl::StrJoin(label_values, ","); + ExportedMetricKeyValueIterable labels_iterable(label_keys, label_values); + observer_->Observe(value, labels_iterable); + } + void UpDownCounter(absl::Span label_keys, + absl::Span label_values, + absl::string_view, uint64_t value) override { + GRPC_DCHECK(std::holds_alternative< + grpc_core::InstrumentMetadata::UpDownCounterShape>(shape_)); + LOG(ERROR) << "UpDownCounter: " << value + << " label_keys: " << absl::StrJoin(label_keys, ",") + << " label_values: " << absl::StrJoin(label_values, ","); + ExportedMetricKeyValueIterable labels_iterable(label_keys, label_values); + observer_->Observe(value, labels_iterable); + } + void Histogram(absl::Span, absl::Span, + absl::string_view, grpc_core::HistogramBuckets, + absl::Span) override { + LOG(FATAL) << "Expected a counter, got a histogram"; + } + void DoubleGauge(absl::Span, + absl::Span, absl::string_view, + double) override { + LOG(FATAL) << "Expected a counter, got a double gauge"; + } + void IntGauge(absl::Span, absl::Span, + absl::string_view, int64_t) override { + LOG(FATAL) << "Expected a counter, got an int gauge"; + } + void UintGauge(absl::Span, absl::Span, + absl::string_view, uint64_t) override { + LOG(FATAL) << "Expected a counter, got a uint gauge"; + } + + private: + const opentelemetry::nostd::shared_ptr< + opentelemetry::metrics::ObserverResultT> + observer_; + const grpc_core::InstrumentMetadata::Shape shape_; + }; + + OpenTelemetryPluginImpl* const impl_; + const grpc_core::InstrumentMetadata::Description* const md_; +}; + +void OpenTelemetryPluginImpl::QueryMetrics( + absl::Span metrics, grpc_core::MetricsSink& sink) { + grpc_core::MetricsQuery() + .OnlyMetrics(std::vector(metrics.begin(), metrics.end())) + .CollapseLabels(collapse_labels_) + .Run(collection_scope_, sink); +} + namespace { opentelemetry::nostd::shared_ptr MaybeMakeTracer( opentelemetry::trace::TracerProvider* tracer_provider) { @@ -541,6 +709,55 @@ OpenTelemetryPluginImpl::OpenTelemetryPluginImpl( static_cast(optional_key.value())); } } + if (grpc_core::IsOtelExportTelemetryDomainsEnabled()) { + // gRPC metrics. + absl::flat_hash_set labels; + grpc_core::InstrumentMetadata::ForEachInstrument( + [&](const grpc_core::InstrumentMetadata::Description* description) { + if (!metrics.contains(description->name)) return; + for (const auto& label : description->domain->label_names()) { + if (!internal::IsOpenTelemetryLabelOptional(label) || + optional_label_keys.find(label) != + optional_label_keys.end()) { + labels.insert(label); + } + } + grpc_core::Match( + description->shape, + [&](grpc_core::InstrumentMetadata::CounterShape) { + auto instrument = meter->CreateInt64ObservableCounter( + std::string(description->name), + std::string(description->description), + std::string(description->unit)); + exporter_callbacks_.push_back( + std::make_unique>( + instrument, this, description)); + }, + [&](grpc_core::InstrumentMetadata::UpDownCounterShape) { + auto instrument = meter->CreateInt64ObservableUpDownCounter( + std::string(description->name), + std::string(description->description), + std::string(description->unit)); + exporter_callbacks_.push_back( + std::make_unique>( + instrument, this, description)); + }, + [&](grpc_core::InstrumentMetadata::DoubleGaugeShape) { + LOG(FATAL) << "Double gauge shape is not supported yet"; + }, + [&](grpc_core::InstrumentMetadata::IntGaugeShape) { + LOG(FATAL) << "Int gauge shape is not supported yet"; + }, + [&](grpc_core::InstrumentMetadata::UintGaugeShape) { + LOG(FATAL) << "Uint gauge shape is not supported yet"; + }, + [&](grpc_core::InstrumentMetadata::HistogramShape) { + LOG(FATAL) << "Histogram shape is not supported yet"; + }); + }); + std::vector labels_vec(labels.begin(), labels.end()); + collection_scope_ = grpc_core::CreateCollectionScope({}, labels_vec); + } // Non-per-call metrics. grpc_core::GlobalInstrumentsRegistry::ForEach( [&, this](const grpc_core::GlobalInstrumentsRegistry:: diff --git a/deps/grpc/src/cpp/ext/otel/otel_plugin.h b/deps/grpc/src/cpp/ext/otel/otel_plugin.h index 3c53aafb309..cd3ae635c59 100644 --- a/deps/grpc/src/cpp/ext/otel/otel_plugin.h +++ b/deps/grpc/src/cpp/ext/otel/otel_plugin.h @@ -31,10 +31,6 @@ #include #include -#include "absl/container/flat_hash_map.h" -#include "absl/container/flat_hash_set.h" -#include "absl/functional/any_invocable.h" -#include "absl/strings/string_view.h" #include "opentelemetry/metrics/async_instruments.h" #include "opentelemetry/metrics/meter_provider.h" #include "opentelemetry/metrics/observer_result.h" @@ -43,12 +39,19 @@ #include "opentelemetry/trace/tracer.h" #include "src/core/call/metadata_batch.h" #include "src/core/lib/channel/channel_args.h" +#include "src/core/telemetry/instrument.h" #include "src/core/telemetry/metrics.h" #include "src/core/util/down_cast.h" +#include "absl/container/flat_hash_map.h" +#include "absl/container/flat_hash_set.h" +#include "absl/functional/any_invocable.h" +#include "absl/strings/string_view.h" namespace grpc { namespace internal { +bool IsOpenTelemetryLabelOptional(absl::string_view label_key); + // An iterable container interface that can be used as a return type for the // OpenTelemetry plugin's label injector. class LabelsIterable { @@ -240,11 +243,21 @@ class OpenTelemetryPluginImpl channel_scope_filter); ~OpenTelemetryPluginImpl() override; + grpc_core::RefCountedPtr GetCollectionScope() + const override { + return collection_scope_; + } + private: class ClientCallTracerInterface; class KeyValueIterable; class NPCMetricsKeyValueIterable; class ServerCallTracerInterface; + class ExporterCallback; + template + class ExporterCallbackImpl; + class CounterExporter; + class ExportedMetricKeyValueIterable; // Creates a convenience wrapper to help iterate over only those plugin // options that are active over a given channel/server. @@ -478,6 +491,9 @@ class OpenTelemetryPluginImpl grpc_core::GlobalInstrumentsRegistry::GlobalInstrumentHandle handle) const override; + void QueryMetrics(absl::Span metrics, + grpc_core::MetricsSink& sink); + const absl::AnyInvocable& server_selector() const { return server_selector_; @@ -565,6 +581,9 @@ class OpenTelemetryPluginImpl absl::AnyInvocable channel_scope_filter_; + std::vector collapse_labels_; // const after init + std::vector> exporter_callbacks_; + grpc_core::RefCountedPtr collection_scope_; }; class GrpcTextMapCarrier diff --git a/deps/grpc/src/cpp/ext/otel/otel_server_call_tracer.cc b/deps/grpc/src/cpp/ext/otel/otel_server_call_tracer.cc index c41526d54b5..b8bf0d259f9 100644 --- a/deps/grpc/src/cpp/ext/otel/otel_server_call_tracer.cc +++ b/deps/grpc/src/cpp/ext/otel/otel_server_call_tracer.cc @@ -27,12 +27,6 @@ #include #include -#include "absl/functional/any_invocable.h" -#include "absl/strings/str_format.h" -#include "absl/strings/string_view.h" -#include "absl/time/clock.h" -#include "absl/time/time.h" -#include "absl/types/span.h" #include "opentelemetry/context/context.h" #include "opentelemetry/metrics/sync_instruments.h" #include "src/core/call/metadata_batch.h" @@ -49,6 +43,12 @@ #include "src/core/telemetry/tcp_tracer.h" #include "src/cpp/ext/otel/key_value_iterable.h" #include "src/cpp/ext/otel/otel_plugin.h" +#include "absl/functional/any_invocable.h" +#include "absl/strings/str_format.h" +#include "absl/strings/string_view.h" +#include "absl/time/clock.h" +#include "absl/time/time.h" +#include "absl/types/span.h" namespace grpc { namespace internal { diff --git a/deps/grpc/src/cpp/ext/otel/otel_server_call_tracer.h b/deps/grpc/src/cpp/ext/otel/otel_server_call_tracer.h index d80945920ad..32179bcfb26 100644 --- a/deps/grpc/src/cpp/ext/otel/otel_server_call_tracer.h +++ b/deps/grpc/src/cpp/ext/otel/otel_server_call_tracer.h @@ -21,10 +21,10 @@ #include -#include "absl/strings/strip.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/telemetry/call_tracer.h" #include "src/cpp/ext/otel/otel_plugin.h" +#include "absl/strings/strip.h" namespace grpc { namespace internal { diff --git a/deps/grpc/src/cpp/latent_see/latent_see_client.cc b/deps/grpc/src/cpp/latent_see/latent_see_client.cc index a2e85d3e1f1..014515aaf49 100644 --- a/deps/grpc/src/cpp/latent_see/latent_see_client.cc +++ b/deps/grpc/src/cpp/latent_see/latent_see_client.cc @@ -18,8 +18,104 @@ #include +#include "src/core/channelz/property_list.h" +#include "src/core/util/time.h" +#include "absl/log/log.h" + namespace grpc { +using grpc_core::channelz::PropertyList; + +namespace { +PropertyList ToPropertyList(const channelz::v2::PropertyList& proto) { + PropertyList property_list; + for (const auto& element : proto.properties()) { + switch (element.value().kind_case()) { + case channelz::v2::PropertyValue::kStringValue: + property_list.Set(element.key(), element.value().string_value()); + break; + case channelz::v2::PropertyValue::kInt64Value: + property_list.Set(element.key(), element.value().int64_value()); + break; + case channelz::v2::PropertyValue::kDoubleValue: + property_list.Set(element.key(), element.value().double_value()); + break; + case channelz::v2::PropertyValue::kBoolValue: + property_list.Set(element.key(), element.value().bool_value()); + break; + case channelz::v2::PropertyValue::kUint64Value: + property_list.Set(element.key(), element.value().uint64_value()); + break; + case channelz::v2::PropertyValue::kTimestampValue: + gpr_timespec t; + t.tv_sec = element.value().timestamp_value().seconds(); + t.tv_nsec = element.value().timestamp_value().nanos(); + property_list.Set(element.key(), + grpc_core::Timestamp::FromTimespecRoundUp(t)); + break; + case channelz::v2::PropertyValue::kDurationValue: + property_list.Set(element.key(), + grpc_core::Duration::FromSecondsAndNanoseconds( + element.value().duration_value().seconds(), + element.value().duration_value().nanos())); + break; + case channelz::v2::PropertyValue::kAnyValue: { + const auto& any_value = element.value().any_value(); + if (any_value.Is()) { + channelz::v2::PropertyList property_list_proto; + any_value.UnpackTo(&property_list_proto); + // Create a new property list from the new proto and add the new + // property list into the existing one. + property_list.Set(element.key(), ToPropertyList(property_list_proto)); + } else { + // Latent-see emits only a subset of types here, and this + // implementation handles only those types. + // If leveraging this code elsewhere, we'll need to ensure the set of + // types handled is expanded appropriately. + LOG(WARNING) << "Unsupported any value type: " + << any_value.type_url(); + } + } break; + case channelz::v2::PropertyValue::KIND_NOT_SET: + case grpc::channelz::v2::PropertyValue::kEmptyValue: + break; + default: + break; + } + } + return property_list; +} +} // namespace + +void ProcessLatentSeeTrace(const channelz::v2::LatentSeeTrace& trace, + grpc_core::latent_see::Output* output) { + switch (trace.kind_case()) { + case channelz::v2::LatentSeeTrace::KIND_NOT_SET: + return; + case channelz::v2::LatentSeeTrace::kMark: + if (trace.has_mark()) { + output->Mark(trace.name(), trace.tid(), trace.timestamp_ns(), + ToPropertyList(trace.mark().properties())); + } else { + output->Mark(trace.name(), trace.tid(), trace.timestamp_ns(), + PropertyList()); + } + break; + case channelz::v2::LatentSeeTrace::kFlowBegin: + output->FlowBegin(trace.name(), trace.tid(), trace.timestamp_ns(), + trace.flow_begin().id()); + break; + case channelz::v2::LatentSeeTrace::kFlowEnd: + output->FlowEnd(trace.name(), trace.tid(), trace.timestamp_ns(), + trace.flow_end().id()); + break; + case channelz::v2::LatentSeeTrace::kSpan: + output->Span(trace.name(), trace.tid(), trace.timestamp_ns(), + trace.span().duration_ns()); + break; + } +} + Status FetchLatentSee(channelz::v2::LatentSee::Stub* stub, double sample_time, grpc_core::latent_see::Output* output) { channelz::v2::GetTraceRequest request; @@ -32,25 +128,7 @@ Status FetchLatentSee(channelz::v2::LatentSee::Stub* stub, double sample_time, auto reader = stub->GetTrace(&context, request); channelz::v2::LatentSeeTrace trace; while (reader->Read(&trace)) { - switch (trace.kind_case()) { - case channelz::v2::LatentSeeTrace::KIND_NOT_SET: - continue; - case channelz::v2::LatentSeeTrace::kMark: - output->Mark(trace.name(), trace.tid(), trace.timestamp_ns()); - break; - case channelz::v2::LatentSeeTrace::kFlowBegin: - output->FlowBegin(trace.name(), trace.tid(), trace.timestamp_ns(), - trace.flow_begin().id()); - break; - case channelz::v2::LatentSeeTrace::kFlowEnd: - output->FlowEnd(trace.name(), trace.tid(), trace.timestamp_ns(), - trace.flow_end().id()); - break; - case channelz::v2::LatentSeeTrace::kSpan: - output->Span(trace.name(), trace.tid(), trace.timestamp_ns(), - trace.span().duration_ns()); - break; - } + ProcessLatentSeeTrace(trace, output); } output->Finish(); return reader->Finish(); diff --git a/deps/grpc/src/cpp/latent_see/latent_see_client.h b/deps/grpc/src/cpp/latent_see/latent_see_client.h index 301bd38106e..aded3f989d6 100644 --- a/deps/grpc/src/cpp/latent_see/latent_see_client.h +++ b/deps/grpc/src/cpp/latent_see/latent_see_client.h @@ -20,8 +20,11 @@ namespace grpc { +void ProcessLatentSeeTrace(const channelz::v2::LatentSeeTrace& trace, + grpc_core::latent_see::Output* output); + Status FetchLatentSee(channelz::v2::LatentSee::Stub* stub, double sample_time, grpc_core::latent_see::Output* output); -} +} // namespace grpc #endif // GRPC_SRC_CPP_LATENT_SEE_LATENT_SEE_CLIENT_H diff --git a/deps/grpc/src/cpp/latent_see/latent_see_service.cc b/deps/grpc/src/cpp/latent_see/latent_see_service.cc index 1584f9ed77d..fc8468031ea 100644 --- a/deps/grpc/src/cpp/latent_see/latent_see_service.cc +++ b/deps/grpc/src/cpp/latent_see/latent_see_service.cc @@ -14,23 +14,41 @@ #include "src/cpp/latent_see/latent_see_service.h" +#include + +#include "src/core/channelz/property_list.h" #include "src/core/util/latent_see.h" +#include "src/proto/grpc/channelz/v2/property_list.upb.h" +#include "upb/mem/arena.hpp" +#include "absl/strings/string_view.h" namespace grpc { namespace { +using grpc_core::channelz::PropertyList; + class StreamingOutput final : public grpc_core::latent_see::Output { public: explicit StreamingOutput(ServerWriter* response) : response_(response) {} - void Mark(absl::string_view name, int64_t tid, int64_t timestamp) override { + void Mark(absl::string_view name, int64_t tid, int64_t timestamp, + PropertyList property_list) override { channelz::v2::LatentSeeTrace trace; trace.set_name(name); trace.set_tid(tid); trace.set_timestamp_ns(timestamp); - trace.mutable_mark(); + if (!property_list.empty()) { + upb::Arena arena; + auto* upb_proto = grpc_channelz_v2_PropertyList_new(arena.ptr()); + property_list.FillUpbProto(upb_proto, arena.ptr()); + size_t length; + auto* bytes = grpc_channelz_v2_PropertyList_serialize( + upb_proto, arena.ptr(), &length); + trace.mutable_mark()->mutable_properties()->ParseFromString( + absl::string_view(bytes, length)); + } response_->Write(trace); } void FlowBegin(absl::string_view name, int64_t tid, int64_t timestamp, diff --git a/deps/grpc/src/cpp/server/admin/admin_services.cc b/deps/grpc/src/cpp/server/admin/admin_services.cc index 8a6b279bd91..30bb7993a02 100644 --- a/deps/grpc/src/cpp/server/admin/admin_services.cc +++ b/deps/grpc/src/cpp/server/admin/admin_services.cc @@ -23,25 +23,25 @@ // TODO(lidiz) build a real registration system that can pull in services // automatically with minimum amount of code. #include "src/cpp/server/channelz/channelz_service.h" -#if !defined(GRPC_NO_XDS) && !defined(DISABLED_XDS_PROTO_IN_CC) +#if !defined(GRPC_NO_XDS) #include "src/cpp/server/csds/csds.h" -#endif // GRPC_NO_XDS or DISABLED_XDS_PROTO_IN_CC +#endif // GRPC_NO_XDS namespace grpc { namespace { auto* g_channelz_service = new ChannelzService(); -#if !defined(GRPC_NO_XDS) && !defined(DISABLED_XDS_PROTO_IN_CC) +#if !defined(GRPC_NO_XDS) auto* g_csds = new xds::experimental::ClientStatusDiscoveryService(); -#endif // GRPC_NO_XDS or DISABLED_XDS_PROTO_IN_CC +#endif // GRPC_NO_XDS } // namespace void AddAdminServices(ServerBuilder* builder) { builder->RegisterService(g_channelz_service); -#if !defined(GRPC_NO_XDS) && !defined(DISABLED_XDS_PROTO_IN_CC) +#if !defined(GRPC_NO_XDS) builder->RegisterService(g_csds); -#endif // GRPC_NO_XDS or DISABLED_XDS_PROTO_IN_CC +#endif // GRPC_NO_XDS } } // namespace grpc diff --git a/deps/grpc/src/cpp/server/backend_metric_recorder.cc b/deps/grpc/src/cpp/server/backend_metric_recorder.cc index 6670878c7c2..35016836be2 100644 --- a/deps/grpc/src/cpp/server/backend_metric_recorder.cc +++ b/deps/grpc/src/cpp/server/backend_metric_recorder.cc @@ -26,9 +26,9 @@ #include #include -#include "absl/log/log.h" #include "src/core/lib/debug/trace.h" #include "src/core/load_balancing/backend_metric_data.h" +#include "absl/log/log.h" using grpc_core::BackendMetricData; diff --git a/deps/grpc/src/cpp/server/backend_metric_recorder.h b/deps/grpc/src/cpp/server/backend_metric_recorder.h index a556cb9b57f..646f6aca99e 100644 --- a/deps/grpc/src/cpp/server/backend_metric_recorder.h +++ b/deps/grpc/src/cpp/server/backend_metric_recorder.h @@ -28,10 +28,10 @@ #include #include -#include "absl/base/thread_annotations.h" -#include "absl/strings/string_view.h" #include "src/core/ext/filters/backend_metrics/backend_metric_provider.h" #include "src/core/load_balancing/backend_metric_data.h" +#include "absl/base/thread_annotations.h" +#include "absl/strings/string_view.h" namespace grpc { namespace experimental { diff --git a/deps/grpc/src/cpp/server/channelz/channelz_service.cc b/deps/grpc/src/cpp/server/channelz/channelz_service.cc index 8558116b3d8..501b045ce93 100644 --- a/deps/grpc/src/cpp/server/channelz/channelz_service.cc +++ b/deps/grpc/src/cpp/server/channelz/channelz_service.cc @@ -25,12 +25,12 @@ #include #include -#include "absl/strings/str_cat.h" #include "src/core/channelz/channelz.h" #include "src/core/channelz/channelz_registry.h" #include "src/core/channelz/v2tov1/convert.h" #include "src/core/lib/experiments/experiments.h" #include "src/core/util/notification.h" +#include "absl/strings/str_cat.h" using grpc_core::channelz::BaseNode; diff --git a/deps/grpc/src/cpp/server/csds/csds.h b/deps/grpc/src/cpp/server/csds/csds.h index 5eb7ac7df96..ca3dbdddd73 100644 --- a/deps/grpc/src/cpp/server/csds/csds.h +++ b/deps/grpc/src/cpp/server/csds/csds.h @@ -24,14 +24,12 @@ #include #include -#include "src/proto/grpc/testing/xds/v3/csds.grpc.pb.h" +#include "envoy/service/status/v3/csds.grpc.pb.h" namespace grpc { namespace xds { namespace experimental { -// The implementation of -// envoy::service::status::v3::ClientStatusDiscoveryService class ClientStatusDiscoveryService final : public envoy::service::status::v3::ClientStatusDiscoveryService::Service { public: diff --git a/deps/grpc/src/cpp/server/external_connection_acceptor_impl.cc b/deps/grpc/src/cpp/server/external_connection_acceptor_impl.cc index d36de31dcd3..a39d8c36f77 100644 --- a/deps/grpc/src/cpp/server/external_connection_acceptor_impl.cc +++ b/deps/grpc/src/cpp/server/external_connection_acceptor_impl.cc @@ -25,8 +25,8 @@ #include #include -#include "absl/log/log.h" #include "src/core/util/grpc_check.h" +#include "absl/log/log.h" namespace grpc { namespace internal { diff --git a/deps/grpc/src/cpp/server/health/default_health_check_service.cc b/deps/grpc/src/cpp/server/health/default_health_check_service.cc index 492ba694c13..174c013c2cf 100644 --- a/deps/grpc/src/cpp/server/health/default_health_check_service.cc +++ b/deps/grpc/src/cpp/server/health/default_health_check_service.cc @@ -28,11 +28,11 @@ #include #include -#include "absl/log/log.h" #include "src/core/util/grpc_check.h" #include "src/proto/grpc/health/v1/health.upb.h" #include "upb/base/string_view.h" #include "upb/mem/arena.hpp" +#include "absl/log/log.h" #define MAX_SERVICE_NAME_LENGTH 200 diff --git a/deps/grpc/src/cpp/server/health/default_health_check_service.h b/deps/grpc/src/cpp/server/health/default_health_check_service.h index 3a12f66f3a6..0f42f15edc5 100644 --- a/deps/grpc/src/cpp/server/health/default_health_check_service.h +++ b/deps/grpc/src/cpp/server/health/default_health_check_service.h @@ -32,9 +32,9 @@ #include #include -#include "absl/base/thread_annotations.h" #include "src/core/util/ref_counted.h" #include "src/core/util/ref_counted_ptr.h" +#include "absl/base/thread_annotations.h" namespace grpc { diff --git a/deps/grpc/src/cpp/server/load_reporter/get_cpu_stats_unsupported.cc b/deps/grpc/src/cpp/server/load_reporter/get_cpu_stats_unsupported.cc index 05790f69fa8..664a3115b88 100644 --- a/deps/grpc/src/cpp/server/load_reporter/get_cpu_stats_unsupported.cc +++ b/deps/grpc/src/cpp/server/load_reporter/get_cpu_stats_unsupported.cc @@ -20,9 +20,9 @@ #if !defined(GPR_LINUX) && !defined(GPR_WINDOWS) && !defined(GPR_APPLE) -#include "absl/log/log.h" #include "src/core/util/crash.h" #include "src/cpp/server/load_reporter/get_cpu_stats.h" +#include "absl/log/log.h" namespace grpc { namespace load_reporter { diff --git a/deps/grpc/src/cpp/server/load_reporter/load_data_store.cc b/deps/grpc/src/cpp/server/load_reporter/load_data_store.cc index bb6f5882172..46d62cd64f6 100644 --- a/deps/grpc/src/cpp/server/load_reporter/load_data_store.cc +++ b/deps/grpc/src/cpp/server/load_reporter/load_data_store.cc @@ -27,10 +27,10 @@ #include #include -#include "absl/log/log.h" #include "src/core/lib/iomgr/socket_utils.h" #include "src/core/util/grpc_check.h" #include "src/cpp/server/load_reporter/constants.h" +#include "absl/log/log.h" namespace grpc { namespace load_reporter { diff --git a/deps/grpc/src/cpp/server/load_reporter/load_reporter.cc b/deps/grpc/src/cpp/server/load_reporter/load_reporter.cc index 8547259d8ea..42b4262da63 100644 --- a/deps/grpc/src/cpp/server/load_reporter/load_reporter.cc +++ b/deps/grpc/src/cpp/server/load_reporter/load_reporter.cc @@ -28,11 +28,11 @@ #include #include -#include "absl/log/log.h" #include "opencensus/tags/tag_key.h" #include "src/core/util/grpc_check.h" #include "src/cpp/server/load_reporter/constants.h" #include "src/cpp/server/load_reporter/get_cpu_stats.h" +#include "absl/log/log.h" // IWYU pragma: no_include "google/protobuf/duration.pb.h" diff --git a/deps/grpc/src/cpp/server/load_reporter/load_reporter_async_service_impl.cc b/deps/grpc/src/cpp/server/load_reporter/load_reporter_async_service_impl.cc index 014f5c0e5c5..e5f74131440 100644 --- a/deps/grpc/src/cpp/server/load_reporter/load_reporter_async_service_impl.cc +++ b/deps/grpc/src/cpp/server/load_reporter/load_reporter_async_service_impl.cc @@ -24,9 +24,9 @@ #include #include -#include "absl/log/log.h" #include "src/core/util/grpc_check.h" #include "src/cpp/server/load_reporter/constants.h" +#include "absl/log/log.h" // IWYU pragma: no_include "google/protobuf/duration.pb.h" diff --git a/deps/grpc/src/cpp/server/orca/orca_service.cc b/deps/grpc/src/cpp/server/orca/orca_service.cc index 66b85a902b5..2e15cd94a4c 100644 --- a/deps/grpc/src/cpp/server/orca/orca_service.cc +++ b/deps/grpc/src/cpp/server/orca/orca_service.cc @@ -35,9 +35,6 @@ #include #include -#include "absl/log/log.h" -#include "absl/strings/string_view.h" -#include "absl/time/time.h" #include "google/protobuf/duration.upb.h" #include "src/core/lib/event_engine/default_event_engine.h" #include "src/core/lib/iomgr/exec_ctx.h" @@ -50,6 +47,9 @@ #include "upb/mem/arena.hpp" #include "xds/data/orca/v3/orca_load_report.upb.h" #include "xds/service/orca/v3/orca.upb.h" +#include "absl/log/log.h" +#include "absl/strings/string_view.h" +#include "absl/time/time.h" namespace grpc { namespace experimental { diff --git a/deps/grpc/src/cpp/server/orca/orca_service.h b/deps/grpc/src/cpp/server/orca/orca_service.h index 193151ca4f5..62aebb147c1 100644 --- a/deps/grpc/src/cpp/server/orca/orca_service.h +++ b/deps/grpc/src/cpp/server/orca/orca_service.h @@ -28,9 +28,9 @@ #include #include +#include "src/core/util/ref_counted.h" #include "absl/base/thread_annotations.h" #include "absl/strings/string_view.h" -#include "src/core/util/ref_counted.h" namespace grpc { namespace experimental { diff --git a/deps/grpc/src/cpp/server/server_builder.cc b/deps/grpc/src/cpp/server/server_builder.cc index 72fce81f324..51f4fa261ab 100644 --- a/deps/grpc/src/cpp/server/server_builder.cc +++ b/deps/grpc/src/cpp/server/server_builder.cc @@ -44,13 +44,13 @@ #include #include -#include "absl/log/log.h" #include "src/core/ext/transport/chttp2/server/chttp2_server.h" #include "src/core/server/server.h" #include "src/core/util/grpc_check.h" #include "src/core/util/string.h" #include "src/core/util/useful.h" #include "src/cpp/server/external_connection_acceptor_impl.h" +#include "absl/log/log.h" namespace grpc { namespace { diff --git a/deps/grpc/src/cpp/server/server_cc.cc b/deps/grpc/src/cpp/server/server_cc.cc index 66f7252d4ce..7af89e2921a 100644 --- a/deps/grpc/src/cpp/server/server_cc.cc +++ b/deps/grpc/src/cpp/server/server_cc.cc @@ -16,6 +16,7 @@ // #include +#include #include #include #include @@ -63,12 +64,12 @@ #include #include -#include "absl/log/log.h" -#include "absl/status/status.h" #include "src/core/ext/transport/inproc/inproc_transport.h" +#include "src/core/lib/experiments/experiments.h" #include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/iomgr/iomgr.h" #include "src/core/lib/resource_quota/api.h" +#include "src/core/lib/resource_quota/resource_quota.h" #include "src/core/lib/surface/completion_queue.h" #include "src/core/server/server.h" #include "src/core/util/grpc_check.h" @@ -77,6 +78,8 @@ #include "src/cpp/server/external_connection_acceptor_impl.h" #include "src/cpp/server/health/default_health_check_service.h" #include "src/cpp/thread_manager/thread_manager.h" +#include "absl/log/log.h" +#include "absl/status/status.h" namespace grpc { namespace { @@ -109,14 +112,8 @@ Server::GlobalCallbacks* g_raw_callbacks = nullptr; gpr_once g_once_init_callbacks = GPR_ONCE_INIT; void InitGlobalCallbacks() { - if (grpc_core::IsServerGlobalCallbacksOwnershipEnabled()) { - if (!g_raw_callbacks) { - g_raw_callbacks = new DefaultGlobalCallbacks; - } - } else { - if (!g_callbacks) { - g_callbacks = std::make_shared(); - } + if (!g_raw_callbacks) { + g_raw_callbacks = new DefaultGlobalCallbacks; } } @@ -181,7 +178,7 @@ bool ServerInterface::BaseAsyncRequest::FinalizeResult(void** tag, return true; } context_->set_call(call_, call_metric_recording_enabled_, - server_metric_recorder_); + server_metric_recorder_, server_->memory_allocator()); context_->cq_ = call_cq_; if (call_wrapper_.call() == nullptr) { // Fill it since it is empty. @@ -423,21 +420,18 @@ class Server::SyncRequest final : public grpc::internal::CompletionQueueTag { return true; } - void Run(const std::shared_ptr& global_callbacks, - bool resources) { + void Run(bool resources) { ctx_.Init(deadline_, &request_metadata_); wrapped_call_.Init( call_, server_, &cq_, server_->max_receive_message_size(), ctx_->ctx.set_server_rpc_info(method_->name(), method_->method_type(), server_->interceptor_creators_)); ctx_->ctx.set_call(call_, server_->call_metric_recording_enabled(), - server_->server_metric_recorder()); + server_->server_metric_recorder(), + server_->memory_allocator()); ctx_->ctx.cq_ = &cq_; request_metadata_.count = 0; - if (!grpc_core::IsServerGlobalCallbacksOwnershipEnabled()) { - global_callbacks_ = global_callbacks; - } resources_ = resources; interceptor_methods_.SetCall(&*wrapped_call_); @@ -473,21 +467,13 @@ class Server::SyncRequest final : public grpc::internal::CompletionQueueTag { void ContinueRunAfterInterception() { ctx_->ctx.BeginCompletionOp(&*wrapped_call_, nullptr, nullptr); - if (grpc_core::IsServerGlobalCallbacksOwnershipEnabled()) { - g_raw_callbacks->PreSynchronousRequest(&ctx_->ctx); - } else { - global_callbacks_->PreSynchronousRequest(&ctx_->ctx); - } + g_raw_callbacks->PreSynchronousRequest(&ctx_->ctx); auto* handler = resources_ ? method_->handler() : server_->resource_exhausted_handler_.get(); handler->RunHandler(grpc::internal::MethodHandler::HandlerParameter( &*wrapped_call_, &ctx_->ctx, deserialized_request_, request_status_, nullptr, nullptr)); - if (grpc_core::IsServerGlobalCallbacksOwnershipEnabled()) { - g_raw_callbacks->PostSynchronousRequest(&ctx_->ctx); - } else { - global_callbacks_->PostSynchronousRequest(&ctx_->ctx); - } + g_raw_callbacks->PostSynchronousRequest(&ctx_->ctx); cq_.Shutdown(); @@ -542,7 +528,6 @@ class Server::SyncRequest final : public grpc::internal::CompletionQueueTag { grpc_byte_buffer* request_payload_ = nullptr; grpc::CompletionQueue cq_; grpc::Status request_status_; - std::shared_ptr global_callbacks_; bool resources_; void* deserialized_request_ = nullptr; grpc::internal::InterceptorBatchMethodsImpl interceptor_methods_; @@ -671,7 +656,8 @@ class Server::CallbackRequest final // Bind the call, deadline, and metadata from what we got req_->ctx_->set_call(req_->call_, req_->server_->call_metric_recording_enabled(), - req_->server_->server_metric_recorder()); + req_->server_->server_metric_recorder(), + req_->server_->memory_allocator()); req_->ctx_->cq_ = req_->cq_; req_->ctx_->BindDeadlineAndMetadata(req_->deadline_, &req_->request_metadata_); @@ -805,14 +791,12 @@ const char* Server::CallbackRequest< class Server::SyncRequestThreadManager : public grpc::ThreadManager { public: SyncRequestThreadManager(Server* server, grpc::CompletionQueue* server_cq, - std::shared_ptr global_callbacks, grpc_resource_quota* rq, int min_pollers, int max_pollers, int cq_timeout_msec) : ThreadManager("SyncServer", rq, min_pollers, max_pollers), server_(server), server_cq_(server_cq), - cq_timeout_msec_(cq_timeout_msec), - global_callbacks_(std::move(global_callbacks)) {} + cq_timeout_msec_(cq_timeout_msec) {} WorkStatus PollForWork(void** tag, bool* ok) override { *tag = nullptr; @@ -843,7 +827,7 @@ class Server::SyncRequestThreadManager : public grpc::ThreadManager { GRPC_DCHECK_NE(sync_req, nullptr); GRPC_DCHECK(ok); - sync_req->Run(global_callbacks_, resources); + sync_req->Run(resources); } void AddSyncMethod(grpc::internal::RpcServiceMethod* method, void* tag) { @@ -899,7 +883,6 @@ class Server::SyncRequestThreadManager : public grpc::ThreadManager { int cq_timeout_msec_; bool has_sync_method_ = false; std::unique_ptr unknown_method_; - std::shared_ptr global_callbacks_; }; Server::Server( @@ -927,12 +910,7 @@ Server::Server( health_check_service_disabled_(false), server_metric_recorder_(server_metric_recorder) { gpr_once_init(&grpc::g_once_init_callbacks, grpc::InitGlobalCallbacks); - if (grpc_core::IsServerGlobalCallbacksOwnershipEnabled()) { - g_raw_callbacks->UpdateArguments(args); - } else { - global_callbacks_ = grpc::g_callbacks; - global_callbacks_->UpdateArguments(args); - } + g_raw_callbacks->UpdateArguments(args); if (sync_server_cqs_ != nullptr) { bool default_rq_created = false; @@ -944,13 +922,14 @@ Server::Server( } for (const auto& it : *sync_server_cqs_) { - sync_req_mgrs_.emplace_back(new SyncRequestThreadManager( - this, it.get(), global_callbacks_, server_rq, min_pollers, - max_pollers, sync_cq_timeout_msec)); + sync_req_mgrs_.emplace_back( + new SyncRequestThreadManager(this, it.get(), server_rq, min_pollers, + max_pollers, sync_cq_timeout_msec)); } if (default_rq_created) { grpc_resource_quota_unref(server_rq); + server_rq = nullptr; } } @@ -983,6 +962,13 @@ Server::Server( } server_ = grpc_server_create(&channel_args, nullptr); grpc_server_set_config_fetcher(server_, server_config_fetcher); + + if (server_rq != nullptr && + grpc_core::IsTrackWritesInResourceQuotaEnabled()) { + memory_allocator_ = grpc_core::ResourceQuota::FromC(server_rq) + ->memory_quota() + ->CreateMemoryAllocator("server writer endpoint"); + } } Server::~Server() { @@ -1017,15 +1003,9 @@ Server::~Server() { } void Server::SetGlobalCallbacks(GlobalCallbacks* callbacks) { - if (grpc_core::IsServerGlobalCallbacksOwnershipEnabled()) { - GRPC_CHECK(!g_raw_callbacks); - GRPC_CHECK(callbacks); - g_raw_callbacks = callbacks; - } else { - GRPC_CHECK(!g_callbacks); - GRPC_CHECK(callbacks); - g_callbacks.reset(callbacks); - } + GRPC_CHECK(!g_raw_callbacks); + GRPC_CHECK(callbacks); + g_raw_callbacks = callbacks; } grpc_server* Server::c_server() { return server_; } @@ -1152,11 +1132,7 @@ int Server::AddListeningPort(const std::string& addr, grpc::ServerCredentials* creds) { GRPC_CHECK(!started_); int port = creds->AddPortToServer(addr, server_); - if (grpc_core::IsServerGlobalCallbacksOwnershipEnabled()) { - g_raw_callbacks->AddPort(this, addr, creds, port); - } else { - global_callbacks_->AddPort(this, addr, creds, port); - } + g_raw_callbacks->AddPort(this, addr, creds, port); return port; } @@ -1189,11 +1165,7 @@ void Server::UnrefAndWaitLocked() { void Server::Start(grpc::ServerCompletionQueue** cqs, size_t num_cqs) { GRPC_CHECK(!started_); - if (grpc_core::IsServerGlobalCallbacksOwnershipEnabled()) { - g_raw_callbacks->PreServerStart(this); - } else { - g_callbacks->PreServerStart(this); - } + g_raw_callbacks->PreServerStart(this); started_ = true; // Only create default health check service when user did not provide an @@ -1426,4 +1398,11 @@ grpc::CompletionQueue* Server::CallbackCQ() { return callback_cq; } +grpc_event_engine::experimental::MemoryAllocator* Server::memory_allocator() { + if (memory_allocator_.IsValid()) { + return &memory_allocator_; + } + return nullptr; +} + } // namespace grpc diff --git a/deps/grpc/src/cpp/server/server_context.cc b/deps/grpc/src/cpp/server/server_context.cc index 780e2152242..ae13b4544de 100644 --- a/deps/grpc/src/cpp/server/server_context.cc +++ b/deps/grpc/src/cpp/server/server_context.cc @@ -50,9 +50,6 @@ #include #include -#include "absl/log/log.h" -#include "absl/strings/str_format.h" -#include "absl/strings/string_view.h" #include "src/core/lib/resource_quota/arena.h" #include "src/core/lib/surface/call.h" #include "src/core/util/crash.h" @@ -60,6 +57,9 @@ #include "src/core/util/ref_counted.h" #include "src/core/util/sync.h" #include "src/cpp/server/backend_metric_recorder.h" +#include "absl/log/log.h" +#include "absl/strings/str_format.h" +#include "absl/strings/string_view.h" namespace grpc { diff --git a/deps/grpc/src/cpp/thread_manager/thread_manager.cc b/deps/grpc/src/cpp/thread_manager/thread_manager.cc index 572837264b2..db086642a91 100644 --- a/deps/grpc/src/cpp/thread_manager/thread_manager.cc +++ b/deps/grpc/src/cpp/thread_manager/thread_manager.cc @@ -20,13 +20,13 @@ #include -#include "absl/log/log.h" -#include "absl/strings/str_format.h" #include "src/core/lib/resource_quota/resource_quota.h" #include "src/core/util/crash.h" #include "src/core/util/grpc_check.h" #include "src/core/util/ref_counted_ptr.h" #include "src/core/util/thd.h" +#include "absl/log/log.h" +#include "absl/strings/str_format.h" namespace grpc { diff --git a/deps/grpc/third_party/rake-compiler-dock/rake_aarch64-linux-gnu.current_version b/deps/grpc/third_party/rake-compiler-dock/rake_aarch64-linux-gnu.current_version index 8e8d9ce2113..c5ea62eaa84 100644 --- a/deps/grpc/third_party/rake-compiler-dock/rake_aarch64-linux-gnu.current_version +++ b/deps/grpc/third_party/rake-compiler-dock/rake_aarch64-linux-gnu.current_version @@ -1 +1 @@ -us-docker.pkg.dev/grpc-testing/testing-images-public/rake_aarch64-linux-gnu:85b6d99f20e78c35182fe2e570f0648866e863ed@sha256:9d81abde3a25e720bfb28c978df8eb793adaa3bb4e145d507967d72fc6510c71 \ No newline at end of file +us-docker.pkg.dev/grpc-testing/testing-images-public/rake_aarch64-linux-gnu:b2e4f88d9ab2306817161e5b842bb83b85a4640b@sha256:630e8ee14181ad896a67bfba59168781a4081707762ad3b22fd424b0599a1099 \ No newline at end of file diff --git a/deps/grpc/third_party/rake-compiler-dock/rake_aarch64-linux-gnu/Dockerfile b/deps/grpc/third_party/rake-compiler-dock/rake_aarch64-linux-gnu/Dockerfile index 33b52f1d937..c450a280358 100644 --- a/deps/grpc/third_party/rake-compiler-dock/rake_aarch64-linux-gnu/Dockerfile +++ b/deps/grpc/third_party/rake-compiler-dock/rake_aarch64-linux-gnu/Dockerfile @@ -1,4 +1,4 @@ -FROM ghcr.io/rake-compiler/rake-compiler-dock-image:1.9.1-mri-aarch64-linux-gnu +FROM ghcr.io/rake-compiler/rake-compiler-dock-image:1.11.1-mri-aarch64-linux-gnu #================= # Install ccache diff --git a/deps/grpc/third_party/rake-compiler-dock/rake_aarch64-linux-musl.current_version b/deps/grpc/third_party/rake-compiler-dock/rake_aarch64-linux-musl.current_version index 2bb968fc5fa..fb3116c865d 100644 --- a/deps/grpc/third_party/rake-compiler-dock/rake_aarch64-linux-musl.current_version +++ b/deps/grpc/third_party/rake-compiler-dock/rake_aarch64-linux-musl.current_version @@ -1 +1 @@ -us-docker.pkg.dev/grpc-testing/testing-images-public/rake_aarch64-linux-musl:3bb4b1f8021d02ca0bd0739f8c5ec8b7ea57a93a@sha256:c01823e4e1323fe7a32547292a448f32ec5b90c286775a8c063dcefee8503d31 \ No newline at end of file +us-docker.pkg.dev/grpc-testing/testing-images-public/rake_aarch64-linux-musl:167201b4a3f448f7be7ff75ae45c88736d3b461c@sha256:a35685d4087732d3deecdc0f3214598deef6a8c94a44e15ed8b39851e6bd5241 \ No newline at end of file diff --git a/deps/grpc/third_party/rake-compiler-dock/rake_aarch64-linux-musl/Dockerfile b/deps/grpc/third_party/rake-compiler-dock/rake_aarch64-linux-musl/Dockerfile index c64a2649a4b..ae26e077527 100644 --- a/deps/grpc/third_party/rake-compiler-dock/rake_aarch64-linux-musl/Dockerfile +++ b/deps/grpc/third_party/rake-compiler-dock/rake_aarch64-linux-musl/Dockerfile @@ -1,4 +1,4 @@ -FROM ghcr.io/rake-compiler/rake-compiler-dock-image:1.9.1-mri-aarch64-linux-musl +FROM ghcr.io/rake-compiler/rake-compiler-dock-image:1.11.1-mri-aarch64-linux-musl #================= # Install ccache diff --git a/deps/grpc/third_party/rake-compiler-dock/rake_arm64-darwin.current_version b/deps/grpc/third_party/rake-compiler-dock/rake_arm64-darwin.current_version index adf0592183a..e594ddd317b 100644 --- a/deps/grpc/third_party/rake-compiler-dock/rake_arm64-darwin.current_version +++ b/deps/grpc/third_party/rake-compiler-dock/rake_arm64-darwin.current_version @@ -1 +1 @@ -us-docker.pkg.dev/grpc-testing/testing-images-public/rake_arm64-darwin:fe49e7354767e5a07d23724f9d7f7587ffb5a163@sha256:28a88cb72472608f716aa60e7f1f22182c60809cc4e96c035c0e38e708e4e9be \ No newline at end of file +us-docker.pkg.dev/grpc-testing/testing-images-public/rake_arm64-darwin:18a4fe844d2bca92db18b9ecd55a9101f82c5f07@sha256:cf957c32dd8817d45d3ebb02e4b3c66fcbe4c38db812d2cdbba2d2cd642241a5 \ No newline at end of file diff --git a/deps/grpc/third_party/rake-compiler-dock/rake_arm64-darwin/Dockerfile b/deps/grpc/third_party/rake-compiler-dock/rake_arm64-darwin/Dockerfile index 71de5036465..2c0a572be75 100644 --- a/deps/grpc/third_party/rake-compiler-dock/rake_arm64-darwin/Dockerfile +++ b/deps/grpc/third_party/rake-compiler-dock/rake_arm64-darwin/Dockerfile @@ -1 +1 @@ -FROM ghcr.io/rake-compiler/rake-compiler-dock-image:1.9.1-mri-arm64-darwin +FROM ghcr.io/rake-compiler/rake-compiler-dock-image:1.11.1-mri-arm64-darwin diff --git a/deps/grpc/third_party/rake-compiler-dock/rake_x64-mingw-ucrt.current_version b/deps/grpc/third_party/rake-compiler-dock/rake_x64-mingw-ucrt.current_version index 1865478894b..774477772fb 100644 --- a/deps/grpc/third_party/rake-compiler-dock/rake_x64-mingw-ucrt.current_version +++ b/deps/grpc/third_party/rake-compiler-dock/rake_x64-mingw-ucrt.current_version @@ -1 +1 @@ -us-docker.pkg.dev/grpc-testing/testing-images-public/rake_x64-mingw-ucrt:89f6aec960912399eab13578503cdf6fcf3bc05b@sha256:d6d34c393a66a3b36bb62364b149bd6e84f342258b586bfd0301972d9bdda34c \ No newline at end of file +us-docker.pkg.dev/grpc-testing/testing-images-public/rake_x64-mingw-ucrt:5d6524738ce863bf0a8535630ef101dc40cc84b8@sha256:307bb7983dc3acebd1a7dde7433955d67863b675f6240d7f7729003d55765061 \ No newline at end of file diff --git a/deps/grpc/third_party/rake-compiler-dock/rake_x64-mingw-ucrt/Dockerfile b/deps/grpc/third_party/rake-compiler-dock/rake_x64-mingw-ucrt/Dockerfile index 8e43afafb18..716aeb2c35e 100644 --- a/deps/grpc/third_party/rake-compiler-dock/rake_x64-mingw-ucrt/Dockerfile +++ b/deps/grpc/third_party/rake-compiler-dock/rake_x64-mingw-ucrt/Dockerfile @@ -1,4 +1,4 @@ -FROM ghcr.io/rake-compiler/rake-compiler-dock-image:1.9.1-mri-x64-mingw-ucrt +FROM ghcr.io/rake-compiler/rake-compiler-dock-image:1.11.1-mri-x64-mingw-ucrt RUN find / -name win32.h | while read f ; do sed -i 's/gettimeofday/rb_gettimeofday/' $f ; done diff --git a/deps/grpc/third_party/rake-compiler-dock/rake_x86-linux-gnu.current_version b/deps/grpc/third_party/rake-compiler-dock/rake_x86-linux-gnu.current_version index 41258a8c8cf..b42b618ec53 100644 --- a/deps/grpc/third_party/rake-compiler-dock/rake_x86-linux-gnu.current_version +++ b/deps/grpc/third_party/rake-compiler-dock/rake_x86-linux-gnu.current_version @@ -1 +1 @@ -us-docker.pkg.dev/grpc-testing/testing-images-public/rake_x86-linux-gnu:e0fa6d6a4267cc484fbbfba6f2ad64f13594a5d5@sha256:3c39ea31f79c07c78aa691d859ffd1b72496835a95db7c1b8ce8c8028c6e5418 \ No newline at end of file +us-docker.pkg.dev/grpc-testing/testing-images-public/rake_x86-linux-gnu:dcf81aebad1b54d0890e050ee1f117249f74424b@sha256:42a74d7b9413a217a5ac94dd42c6b9e8748df9901a445c5fce677c9d513f2add \ No newline at end of file diff --git a/deps/grpc/third_party/rake-compiler-dock/rake_x86-linux-gnu/Dockerfile b/deps/grpc/third_party/rake-compiler-dock/rake_x86-linux-gnu/Dockerfile index 2314fabdb97..7cdfcb76707 100644 --- a/deps/grpc/third_party/rake-compiler-dock/rake_x86-linux-gnu/Dockerfile +++ b/deps/grpc/third_party/rake-compiler-dock/rake_x86-linux-gnu/Dockerfile @@ -1,4 +1,4 @@ -FROM ghcr.io/rake-compiler/rake-compiler-dock-image:1.9.1-mri-x86-linux-gnu +FROM ghcr.io/rake-compiler/rake-compiler-dock-image:1.11.1-mri-x86-linux-gnu #================= # Install ccache diff --git a/deps/grpc/third_party/rake-compiler-dock/rake_x86-linux-musl.current_version b/deps/grpc/third_party/rake-compiler-dock/rake_x86-linux-musl.current_version index e6b3e1c98c1..7f61b885f84 100644 --- a/deps/grpc/third_party/rake-compiler-dock/rake_x86-linux-musl.current_version +++ b/deps/grpc/third_party/rake-compiler-dock/rake_x86-linux-musl.current_version @@ -1 +1 @@ -us-docker.pkg.dev/grpc-testing/testing-images-public/rake_x86-linux-musl:c1ffe4dd31db4268168860052f0bdbea50bc517a@sha256:3f67eac1e1da927bfe066fe2558389da49bf02b497192ebd061d53b15e9484ac \ No newline at end of file +us-docker.pkg.dev/grpc-testing/testing-images-public/rake_x86-linux-musl:a2ae20d3067ebc429d74f039c96c62334d8f928b@sha256:c9f5d24cd75e1eb2d0f159c7a51dec05b7c13f07fa9a0b26618d842e9c6a01e1 \ No newline at end of file diff --git a/deps/grpc/third_party/rake-compiler-dock/rake_x86-linux-musl/Dockerfile b/deps/grpc/third_party/rake-compiler-dock/rake_x86-linux-musl/Dockerfile index 49d20a2ab75..f8be4013a59 100644 --- a/deps/grpc/third_party/rake-compiler-dock/rake_x86-linux-musl/Dockerfile +++ b/deps/grpc/third_party/rake-compiler-dock/rake_x86-linux-musl/Dockerfile @@ -1,4 +1,4 @@ -FROM ghcr.io/rake-compiler/rake-compiler-dock-image:1.9.1-mri-x86-linux-musl +FROM ghcr.io/rake-compiler/rake-compiler-dock-image:1.11.1-mri-x86-linux-musl #================= # Install ccache diff --git a/deps/grpc/third_party/rake-compiler-dock/rake_x86-mingw32.current_version b/deps/grpc/third_party/rake-compiler-dock/rake_x86-mingw32.current_version index 743c5cfa117..8d6f5c94d19 100644 --- a/deps/grpc/third_party/rake-compiler-dock/rake_x86-mingw32.current_version +++ b/deps/grpc/third_party/rake-compiler-dock/rake_x86-mingw32.current_version @@ -1 +1 @@ -us-docker.pkg.dev/grpc-testing/testing-images-public/rake_x86-mingw32:88bb3d26852f435cb50cb4e5c52d6bf39b6bd785@sha256:2be5e0decccc23f8b7ac1b2d5edd21ea814868dcfe08b955749167fd22f99a20 \ No newline at end of file +us-docker.pkg.dev/grpc-testing/testing-images-public/rake_x86-mingw32:7d66d2ffd68e4f00e45f9149a4d9022f20e5c221@sha256:fa427e2ed1b3997f88b2cf04685f4311aa8eedd31457405fdd9ac1efa285f539 \ No newline at end of file diff --git a/deps/grpc/third_party/rake-compiler-dock/rake_x86-mingw32/Dockerfile b/deps/grpc/third_party/rake-compiler-dock/rake_x86-mingw32/Dockerfile index 44690d51d36..dbbaf1336c2 100644 --- a/deps/grpc/third_party/rake-compiler-dock/rake_x86-mingw32/Dockerfile +++ b/deps/grpc/third_party/rake-compiler-dock/rake_x86-mingw32/Dockerfile @@ -1,4 +1,4 @@ -FROM ghcr.io/rake-compiler/rake-compiler-dock-image:1.9.1-mri-x86-mingw32 +FROM ghcr.io/rake-compiler/rake-compiler-dock-image:1.11.1-mri-x86-mingw32 RUN find / -name win32.h | while read f ; do sed -i 's/gettimeofday/rb_gettimeofday/' $f ; done diff --git a/deps/grpc/third_party/rake-compiler-dock/rake_x86_64-darwin.current_version b/deps/grpc/third_party/rake-compiler-dock/rake_x86_64-darwin.current_version index 558d0aefe27..4455cc6cb33 100644 --- a/deps/grpc/third_party/rake-compiler-dock/rake_x86_64-darwin.current_version +++ b/deps/grpc/third_party/rake-compiler-dock/rake_x86_64-darwin.current_version @@ -1 +1 @@ -us-docker.pkg.dev/grpc-testing/testing-images-public/rake_x86_64-darwin:0b778c0a0ead88ef791333ccbf14fed34d98145d@sha256:e01c02a18130b9669da57bb28b3f6c30458511e20eae5821b3899a41e09f394a \ No newline at end of file +us-docker.pkg.dev/grpc-testing/testing-images-public/rake_x86_64-darwin:8638abf6cedca794a28fa05dc80c4fa9373f796c@sha256:cbfa7625b6656941765827324141e6a06c3c3c30d2a15ff8d466e1f1bd2bde77 \ No newline at end of file diff --git a/deps/grpc/third_party/rake-compiler-dock/rake_x86_64-darwin/Dockerfile b/deps/grpc/third_party/rake-compiler-dock/rake_x86_64-darwin/Dockerfile index 373d068e125..0e5f980d5d6 100644 --- a/deps/grpc/third_party/rake-compiler-dock/rake_x86_64-darwin/Dockerfile +++ b/deps/grpc/third_party/rake-compiler-dock/rake_x86_64-darwin/Dockerfile @@ -1 +1 @@ -FROM ghcr.io/rake-compiler/rake-compiler-dock-image:1.9.1-mri-x86_64-darwin +FROM ghcr.io/rake-compiler/rake-compiler-dock-image:1.11.1-mri-x86_64-darwin diff --git a/deps/grpc/third_party/rake-compiler-dock/rake_x86_64-linux-gnu.current_version b/deps/grpc/third_party/rake-compiler-dock/rake_x86_64-linux-gnu.current_version index e351aaa1ab8..7ba3b0027c2 100644 --- a/deps/grpc/third_party/rake-compiler-dock/rake_x86_64-linux-gnu.current_version +++ b/deps/grpc/third_party/rake-compiler-dock/rake_x86_64-linux-gnu.current_version @@ -1 +1 @@ -us-docker.pkg.dev/grpc-testing/testing-images-public/rake_x86_64-linux-gnu:02508a83bb899323c340597caade247046bec728@sha256:3687dc591d8b92d3e0c3066d1e93b1e82ced3f5f0d92b5859eb9bca283dcf4bf \ No newline at end of file +us-docker.pkg.dev/grpc-testing/testing-images-public/rake_x86_64-linux-gnu:ec51eb4d1aa9479042438270adc1de14111ce1d1@sha256:b2b12feff4dd05afd57de30d995316a3080d48e58b26e0dbfbebc5c3dcd14014 \ No newline at end of file diff --git a/deps/grpc/third_party/rake-compiler-dock/rake_x86_64-linux-gnu/Dockerfile b/deps/grpc/third_party/rake-compiler-dock/rake_x86_64-linux-gnu/Dockerfile index 8ff63875415..2f283b2c903 100644 --- a/deps/grpc/third_party/rake-compiler-dock/rake_x86_64-linux-gnu/Dockerfile +++ b/deps/grpc/third_party/rake-compiler-dock/rake_x86_64-linux-gnu/Dockerfile @@ -1,4 +1,4 @@ -FROM ghcr.io/rake-compiler/rake-compiler-dock-image:1.9.1-mri-x86_64-linux-gnu +FROM ghcr.io/rake-compiler/rake-compiler-dock-image:1.11.1-mri-x86_64-linux-gnu #================= # Install ccache diff --git a/deps/grpc/third_party/rake-compiler-dock/rake_x86_64-linux-musl.current_version b/deps/grpc/third_party/rake-compiler-dock/rake_x86_64-linux-musl.current_version index a402acb2421..796e454482e 100644 --- a/deps/grpc/third_party/rake-compiler-dock/rake_x86_64-linux-musl.current_version +++ b/deps/grpc/third_party/rake-compiler-dock/rake_x86_64-linux-musl.current_version @@ -1 +1 @@ -us-docker.pkg.dev/grpc-testing/testing-images-public/rake_x86_64-linux-musl:616153c6dd69073762ad6a2022aab3f47d91a648@sha256:435aa8daea38c6608e533c1c7b202fe35d4327e5293ed840f644cfb21b2e61ed \ No newline at end of file +us-docker.pkg.dev/grpc-testing/testing-images-public/rake_x86_64-linux-musl:166dd283bac2323e5757f30eea6d4d86df404cc9@sha256:22bdfac59e753047aa17d4ef7b4ca720df75f66cab0248f92b2044be5b9b4c97 \ No newline at end of file diff --git a/deps/grpc/third_party/rake-compiler-dock/rake_x86_64-linux-musl/Dockerfile b/deps/grpc/third_party/rake-compiler-dock/rake_x86_64-linux-musl/Dockerfile index 6f2d0e2dc20..ead7c0bed87 100644 --- a/deps/grpc/third_party/rake-compiler-dock/rake_x86_64-linux-musl/Dockerfile +++ b/deps/grpc/third_party/rake-compiler-dock/rake_x86_64-linux-musl/Dockerfile @@ -1,4 +1,4 @@ -FROM ghcr.io/rake-compiler/rake-compiler-dock-image:1.9.1-mri-x86_64-linux-musl +FROM ghcr.io/rake-compiler/rake-compiler-dock-image:1.11.1-mri-x86_64-linux-musl #================= # Install ccache diff --git a/deps/grpc/third_party/typing_extensions.BUILD b/deps/grpc/third_party/typing_extensions.BUILD index 9d8c77f0cb7..f2e15247526 100644 --- a/deps/grpc/third_party/typing_extensions.BUILD +++ b/deps/grpc/third_party/typing_extensions.BUILD @@ -1,3 +1,5 @@ +load("@rules_python//python:defs.bzl", "py_library") + genrule( name = "copy_typing_extensions", srcs = ["src/typing_extensions.py"],