[1/3] Bump grpc to 1.32.x to fix a too_many_pings regression
Part 1: add v1.32.x version to third_party/grpc
Note: partly switches to v1.32.x too as not all bits are versioned and
some of unversioned bits are used from other third_party targets
Composed PR: https://github.com/bazelbuild/bazel/pull/12273
grpc-java transition from v1.26.0 to v1.31.1 enabled auto flow control
which started failing in RBE with
io.grpc.StatusRuntimeException: RESOURCE_EXHAUSTED: Bandwidth exhausted
HTTP/2 error code: ENHANCE_YOUR_CALM
Received Goaway
too_many_pings
grpc-java v1.32.2 has a bugfix attempt on that
grpc v1.32.0 also has something new around keepalive pings
Hopefully version bump to those helps
https://github.com/bazelbuild/bazel/issues/12264
Note: also an attempt and disabling auto flow by default is made in
https://github.com/bazelbuild/bazel/pull/12266
Closes https://github.com/bazelbuild/bazel/pull/12279
diff --git a/third_party/grpc/BUILD b/third_party/grpc/BUILD
index bfd16b6..e4748b9 100644
--- a/third_party/grpc/BUILD
+++ b/third_party/grpc/BUILD
@@ -18,7 +18,7 @@
licenses(["notice"]) # Apache v2
-exports_files(["grpc_1.31.1.patch"])
+exports_files(["grpc_1.31.1.patch", "grpc_1.32.0.patch"])
package(default_visibility = ["//visibility:public"])
@@ -32,14 +32,14 @@
distrib_jar_filegroup(
name = "bootstrap-grpc-jars",
srcs = [
- "grpc-api-1.31.1.jar",
- "grpc-auth-1.31.1.jar",
- "grpc-context-1.31.1.jar",
- "grpc-core-1.31.1.jar",
- "grpc-netty-1.31.1.jar",
- "grpc-protobuf-1.31.1.jar",
- "grpc-protobuf-lite-1.31.1.jar",
- "grpc-stub-1.31.1.jar",
+ "grpc-api-1.32.2.jar",
+ "grpc-auth-1.32.2.jar",
+ "grpc-context-1.32.2.jar",
+ "grpc-core-1.32.2.jar",
+ "grpc-netty-1.32.2.jar",
+ "grpc-protobuf-1.32.2.jar",
+ "grpc-protobuf-lite-1.32.2.jar",
+ "grpc-stub-1.32.2.jar",
],
enable_distributions = ["debian"],
)
diff --git a/third_party/grpc/README.bazel.md b/third_party/grpc/README.bazel.md
index faff935..c7a3ac2 100644
--- a/third_party/grpc/README.bazel.md
+++ b/third_party/grpc/README.bazel.md
@@ -1,24 +1,30 @@
# How to update the C++ sources of gRPC:
1. Update the gRPC definitions in WORKSPACE file, currently we use
- https://github.com/grpc/grpc/archive/v1.31.1.tar.gz
+ https://github.com/grpc/grpc/archive/v1.32.2.tar.gz
2. Update the gRPC patch file if necessary, it mostly helps avoid unnecessary dependencies.
3. Update third_party/grpc/BUILD to redirect targets to @com_github_grpc_grpc if necessary.
# How to update the BUILD/bzl sources of gRPC:
1. `git clone http://github.com/grpc/grpc.git` in a convenient directory
-2. `git checkout <tag>` (current is `v1.31.1`, commithash `7d7e456762`)
+2. `git checkout <tag>` (current is `v1.32.0`, commithash `414bb8322d`)
3. `mkdir -p third_party/grpc/bazel`
4. `cp <gRPC git tree>/bazel/{BUILD,cc_grpc_library.bzl,generate_cc.bzl,protobuf.bzl} third_party/grpc/bazel`
5. In the `third_party/grpc` directory, apply local patches:
- `patch -p3 < bazel_1.31.1.patch`
+ `patch -p3 < bazel_1.32.0.patch`
# How to update the Java plugin:
-1. Checkout tag `v1.31.1` from https://github.com/grpc/grpc-java
+1. Checkout tag `v1.32.2` from https://github.com/grpc/grpc-java
2. `cp -R <grpc-java git tree>/compiler/src/java_plugin third_party/grpc/compiler/src`
# How to update the Java code:
-Download the necessary jars at version `1.31.1` from maven central.
+Download the necessary jars at version `1.32.2` from maven central.
+
+# Submitting the change needs 3 pull requests
+
+1. Update third_party/grpc to include files from new version
+2. Switch WORKSPACE, scripts/bootstrap/compile.sh and any other references to new version
+3. Remove older version from third_party/grpc
diff --git a/third_party/grpc/bazel/protobuf.bzl b/third_party/grpc/bazel/protobuf.bzl
index dd2b5d3..c0abfb3 100644
--- a/third_party/grpc/bazel/protobuf.bzl
+++ b/third_party/grpc/bazel/protobuf.bzl
@@ -214,7 +214,12 @@
path = out_dir,
import_path = out_dir[out_dir.find(_VIRTUAL_IMPORTS) + 1:],
)
- return struct(path = context.genfiles_dir.path, import_path = None)
+
+ out_dir = context.genfiles_dir.path
+ ws_root = context.label.workspace_root
+ if ws_root:
+ out_dir = out_dir + "/" + ws_root
+ return struct(path = out_dir, import_path = None)
def is_in_virtual_imports(source_file, virtual_folder = _VIRTUAL_IMPORTS):
"""Determines if source_file is virtual (is placed in _virtual_imports
diff --git a/third_party/grpc/bazel_1.31.1.patch b/third_party/grpc/bazel_1.32.0.patch
similarity index 100%
rename from third_party/grpc/bazel_1.31.1.patch
rename to third_party/grpc/bazel_1.32.0.patch
diff --git a/third_party/grpc/compiler/src/java_plugin/cpp/java_generator.cpp b/third_party/grpc/compiler/src/java_plugin/cpp/java_generator.cpp
index 695ef85..facb95d 100644
--- a/third_party/grpc/compiler/src/java_plugin/cpp/java_generator.cpp
+++ b/third_party/grpc/compiler/src/java_plugin/cpp/java_generator.cpp
@@ -37,18 +37,22 @@
#define XSTR(s) STR(s)
#endif
-#ifndef FALLTHROUGH_INTENDED
-#define FALLTHROUGH_INTENDED
+#ifdef ABSL_FALLTHROUGH_INTENDED
+#define FALLTHROUGH ABSL_FALLTHROUGH_INTENDED
+#else
+#define FALLTHROUGH
#endif
namespace java_grpc_generator {
-using google::protobuf::FileDescriptor;
-using google::protobuf::ServiceDescriptor;
-using google::protobuf::MethodDescriptor;
-using google::protobuf::Descriptor;
-using google::protobuf::io::Printer;
-using google::protobuf::SourceLocation;
+namespace protobuf = google::protobuf;
+
+using protobuf::Descriptor;
+using protobuf::FileDescriptor;
+using protobuf::MethodDescriptor;
+using protobuf::ServiceDescriptor;
+using protobuf::SourceLocation;
+using protobuf::io::Printer;
using std::to_string;
// java keywords from: https://docs.oracle.com/javase/specs/jls/se8/html/jls-3.html#jls-3.9
@@ -162,7 +166,7 @@
}
static inline std::string MessageFullJavaName(const Descriptor* desc) {
- return google::protobuf::compiler::java::ClassName(desc);
+ return protobuf::compiler::java::ClassName(desc);
}
// TODO(nmittler): Remove once protobuf includes javadoc methods in distribution.
@@ -425,12 +429,12 @@
" .setFullMethodName(generateFullMethodName(SERVICE_NAME, \"$method_name$\"))\n");
bool safe = method->options().idempotency_level()
- == google::protobuf::MethodOptions_IdempotencyLevel_NO_SIDE_EFFECTS;
+ == protobuf::MethodOptions_IdempotencyLevel_NO_SIDE_EFFECTS;
if (safe) {
p->Print(*vars, " .setSafe(true)\n");
} else {
bool idempotent = method->options().idempotency_level()
- == google::protobuf::MethodOptions_IdempotencyLevel_IDEMPOTENT;
+ == protobuf::MethodOptions_IdempotencyLevel_IDEMPOTENT;
if (idempotent) {
p->Print(*vars, " .setIdempotent(true)\n");
}
@@ -542,7 +546,7 @@
break;
case BLOCKING_CLIENT_INTERFACE:
interface = true;
- FALLTHROUGH_INTENDED;
+ FALLTHROUGH;
case BLOCKING_CLIENT_IMPL:
call_type = BLOCKING_CALL;
stub_name += "BlockingStub";
@@ -551,7 +555,7 @@
break;
case FUTURE_CLIENT_INTERFACE:
interface = true;
- FALLTHROUGH_INTENDED;
+ FALLTHROUGH;
case FUTURE_CLIENT_IMPL:
call_type = FUTURE_CALL;
stub_name += "FutureStub";
@@ -916,7 +920,7 @@
(*vars)["proto_base_descriptor_supplier"] = service->name() + "BaseDescriptorSupplier";
(*vars)["proto_file_descriptor_supplier"] = service->name() + "FileDescriptorSupplier";
(*vars)["proto_method_descriptor_supplier"] = service->name() + "MethodDescriptorSupplier";
- (*vars)["proto_class_name"] = google::protobuf::compiler::java::ClassName(service->file());
+ (*vars)["proto_class_name"] = protobuf::compiler::java::ClassName(service->file());
p->Print(
*vars,
"private static abstract class $proto_base_descriptor_supplier$\n"
@@ -1186,7 +1190,7 @@
}
void GenerateService(const ServiceDescriptor* service,
- google::protobuf::io::ZeroCopyOutputStream* out,
+ protobuf::io::ZeroCopyOutputStream* out,
ProtoFlavor flavor,
bool disable_version) {
// All non-generated classes must be referred by fully qualified names to
@@ -1242,7 +1246,7 @@
}
std::string ServiceJavaPackage(const FileDescriptor* file) {
- std::string result = google::protobuf::compiler::java::ClassName(file);
+ std::string result = protobuf::compiler::java::ClassName(file);
size_t last_dot_pos = result.find_last_of('.');
if (last_dot_pos != std::string::npos) {
result.resize(last_dot_pos);
@@ -1252,7 +1256,7 @@
return result;
}
-std::string ServiceClassName(const google::protobuf::ServiceDescriptor* service) {
+std::string ServiceClassName(const ServiceDescriptor* service) {
return service->name() + "Grpc";
}
diff --git a/third_party/grpc/compiler/src/java_plugin/cpp/java_generator.h b/third_party/grpc/compiler/src/java_plugin/cpp/java_generator.h
index 66a4e9c..2ecc884 100644
--- a/third_party/grpc/compiler/src/java_plugin/cpp/java_generator.h
+++ b/third_party/grpc/compiler/src/java_plugin/cpp/java_generator.h
@@ -47,24 +47,26 @@
// Abort the program after logging the mesage.
#define GRPC_CODEGEN_FAIL GRPC_CODEGEN_CHECK(false)
-using namespace std;
-
namespace java_grpc_generator {
+namespace impl {
+namespace protobuf = google::protobuf;
+} // namespace impl
+
enum ProtoFlavor {
NORMAL, LITE
};
// Returns the package name of the gRPC services defined in the given file.
-std::string ServiceJavaPackage(const google::protobuf::FileDescriptor* file);
+std::string ServiceJavaPackage(const impl::protobuf::FileDescriptor* file);
// Returns the name of the outer class that wraps in all the generated code for
// the given service.
-std::string ServiceClassName(const google::protobuf::ServiceDescriptor* service);
+std::string ServiceClassName(const impl::protobuf::ServiceDescriptor* service);
// Writes the generated service interface into the given ZeroCopyOutputStream
-void GenerateService(const google::protobuf::ServiceDescriptor* service,
- google::protobuf::io::ZeroCopyOutputStream* out,
+void GenerateService(const impl::protobuf::ServiceDescriptor* service,
+ impl::protobuf::io::ZeroCopyOutputStream* out,
ProtoFlavor flavor,
bool disable_version);
diff --git a/third_party/grpc/compiler/src/java_plugin/cpp/java_plugin.cpp b/third_party/grpc/compiler/src/java_plugin/cpp/java_plugin.cpp
index d8b10c5..2eed9d2 100644
--- a/third_party/grpc/compiler/src/java_plugin/cpp/java_plugin.cpp
+++ b/third_party/grpc/compiler/src/java_plugin/cpp/java_plugin.cpp
@@ -27,6 +27,8 @@
#include <google/protobuf/descriptor.h>
#include <google/protobuf/io/zero_copy_stream.h>
+namespace protobuf = google::protobuf;
+
static std::string JavaPackageToDir(const std::string& package_name) {
std::string package_dir = package_name;
for (size_t i = 0; i < package_dir.size(); ++i) {
@@ -38,7 +40,7 @@
return package_dir;
}
-class JavaGrpcGenerator : public google::protobuf::compiler::CodeGenerator {
+class JavaGrpcGenerator : public protobuf::compiler::CodeGenerator {
public:
JavaGrpcGenerator() {}
virtual ~JavaGrpcGenerator() {}
@@ -47,12 +49,12 @@
return FEATURE_PROTO3_OPTIONAL;
}
- virtual bool Generate(const google::protobuf::FileDescriptor* file,
+ virtual bool Generate(const protobuf::FileDescriptor* file,
const std::string& parameter,
- google::protobuf::compiler::GeneratorContext* context,
+ protobuf::compiler::GeneratorContext* context,
std::string* error) const override {
std::vector<std::pair<std::string, std::string> > options;
- google::protobuf::compiler::ParseGeneratorParameter(parameter, &options);
+ protobuf::compiler::ParseGeneratorParameter(parameter, &options);
java_grpc_generator::ProtoFlavor flavor =
java_grpc_generator::ProtoFlavor::NORMAL;
@@ -69,10 +71,10 @@
std::string package_name = java_grpc_generator::ServiceJavaPackage(file);
std::string package_filename = JavaPackageToDir(package_name);
for (int i = 0; i < file->service_count(); ++i) {
- const google::protobuf::ServiceDescriptor* service = file->service(i);
+ const protobuf::ServiceDescriptor* service = file->service(i);
std::string filename = package_filename
+ java_grpc_generator::ServiceClassName(service) + ".java";
- std::unique_ptr<google::protobuf::io::ZeroCopyOutputStream> output(
+ std::unique_ptr<protobuf::io::ZeroCopyOutputStream> output(
context->Open(filename));
java_grpc_generator::GenerateService(
service, output.get(), flavor, disable_version);
@@ -83,5 +85,5 @@
int main(int argc, char* argv[]) {
JavaGrpcGenerator generator;
- return google::protobuf::compiler::PluginMain(argc, argv, &generator);
+ return protobuf::compiler::PluginMain(argc, argv, &generator);
}
diff --git a/third_party/grpc/grpc-api-1.32.2.jar b/third_party/grpc/grpc-api-1.32.2.jar
new file mode 100644
index 0000000..26b0ae4
--- /dev/null
+++ b/third_party/grpc/grpc-api-1.32.2.jar
Binary files differ
diff --git a/third_party/grpc/grpc-auth-1.32.2.jar b/third_party/grpc/grpc-auth-1.32.2.jar
new file mode 100644
index 0000000..9470c72
--- /dev/null
+++ b/third_party/grpc/grpc-auth-1.32.2.jar
Binary files differ
diff --git a/third_party/grpc/grpc-context-1.32.2.jar b/third_party/grpc/grpc-context-1.32.2.jar
new file mode 100644
index 0000000..91e94b6
--- /dev/null
+++ b/third_party/grpc/grpc-context-1.32.2.jar
Binary files differ
diff --git a/third_party/grpc/grpc-core-1.32.2.jar b/third_party/grpc/grpc-core-1.32.2.jar
new file mode 100644
index 0000000..60ec907
--- /dev/null
+++ b/third_party/grpc/grpc-core-1.32.2.jar
Binary files differ
diff --git a/third_party/grpc/grpc-netty-1.32.2.jar b/third_party/grpc/grpc-netty-1.32.2.jar
new file mode 100644
index 0000000..a08935f
--- /dev/null
+++ b/third_party/grpc/grpc-netty-1.32.2.jar
Binary files differ
diff --git a/third_party/grpc/grpc-protobuf-1.32.2.jar b/third_party/grpc/grpc-protobuf-1.32.2.jar
new file mode 100644
index 0000000..5f8e87f
--- /dev/null
+++ b/third_party/grpc/grpc-protobuf-1.32.2.jar
Binary files differ
diff --git a/third_party/grpc/grpc-protobuf-lite-1.32.2.jar b/third_party/grpc/grpc-protobuf-lite-1.32.2.jar
new file mode 100644
index 0000000..1ec3587
--- /dev/null
+++ b/third_party/grpc/grpc-protobuf-lite-1.32.2.jar
Binary files differ
diff --git a/third_party/grpc/grpc-stub-1.32.2.jar b/third_party/grpc/grpc-stub-1.32.2.jar
new file mode 100644
index 0000000..1b0b6a9
--- /dev/null
+++ b/third_party/grpc/grpc-stub-1.32.2.jar
Binary files differ
diff --git a/third_party/grpc/grpc_1.32.0.patch b/third_party/grpc/grpc_1.32.0.patch
new file mode 100644
index 0000000..60f4d00
--- /dev/null
+++ b/third_party/grpc/grpc_1.32.0.patch
@@ -0,0 +1,90 @@
+commit bb0d04663c7dc6c0096f8717cb4ec26330a5ae40
+Author: Yun Peng <pcloudy@google.com>
+Date: Wed Jun 3 15:35:31 2020 +0200
+
+ Patch grpc v1.26.0 for Bazel build
+
+ - Avoid loading dependencies that're not needed for the gRPC C++
+ libraries
+ - Add bazel mirror URL for upb and cares
+ - Redirect zlib to @//third_party/zlib
+
+diff --git a/bazel/grpc_build_system.bzl b/bazel/grpc_build_system.bzl
+index 7bb6b8bdb9..7644107b70 100644
+--- a/bazel/grpc_build_system.bzl
++++ b/bazel/grpc_build_system.bzl
+@@ -25,7 +25,7 @@
+
+ load("//bazel:cc_grpc_library.bzl", "cc_grpc_library")
+ load("@upb//bazel:upb_proto_library.bzl", "upb_proto_library")
+-load("@build_bazel_rules_apple//apple:ios.bzl", "ios_unit_test")
++# load("@build_bazel_rules_apple//apple:ios.bzl", "ios_unit_test")
+
+ # The set of pollers to test against if a test exercises polling
+ POLLERS = ["epollex", "epoll1", "poll"]
+@@ -181,13 +181,13 @@ def ios_cc_test(
+ testonly = 1,
+ )
+ ios_test_deps = [ios_test_adapter, ":" + test_lib_ios]
+- ios_unit_test(
+- name = name + "_on_ios",
+- size = kwargs.get("size"),
+- tags = ios_tags,
+- minimum_os_version = "9.0",
+- deps = ios_test_deps,
+- )
++ # ios_unit_test(
++ # name = name + "_on_ios",
++ # size = kwargs.get("size"),
++ # tags = ios_tags,
++ # minimum_os_version = "9.0",
++ # deps = ios_test_deps,
++ # )
+
+ def grpc_cc_test(name, srcs = [], deps = [], external_deps = [], args = [], data = [], uses_polling = True, language = "C++", size = "medium", timeout = None, tags = [], exec_compatible_with = [], exec_properties = {}, shard_count = None, flaky = None):
+ copts = if_mac(["-DGRPC_CFSTREAM"])
+diff --git a/bazel/grpc_deps.bzl b/bazel/grpc_deps.bzl
+index 09fcad95a2..9b737e5deb 100644
+--- a/bazel/grpc_deps.bzl
++++ b/bazel/grpc_deps.bzl
+@@ -33,7 +33,7 @@ def grpc_deps():
+
+ native.bind(
+ name = "madler_zlib",
+- actual = "@zlib//:zlib",
++ actual = "@//third_party/zlib",
+ )
+
+ native.bind(
+diff --git a/bazel/grpc_extra_deps.bzl b/bazel/grpc_extra_deps.bzl
+index 4c1dfad2e8..f63c54ddef 100644
+--- a/bazel/grpc_extra_deps.bzl
++++ b/bazel/grpc_extra_deps.bzl
+@@ -1,11 +1,6 @@
+ """Loads the dependencies necessary for the external repositories defined in grpc_deps.bzl."""
+
+-load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")
+ load("@upb//bazel:workspace_deps.bzl", "upb_deps")
+-load("@envoy_api//bazel:repositories.bzl", "api_dependencies")
+-load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
+-load("@build_bazel_rules_apple//apple:repositories.bzl", "apple_rules_dependencies")
+-load("@build_bazel_apple_support//lib:repositories.bzl", "apple_support_dependencies")
+
+ def grpc_extra_deps():
+ """Loads the extra dependencies.
+@@ -26,15 +21,5 @@ def grpc_extra_deps():
+ grpc_extra_deps()
+ ```
+ """
+- protobuf_deps()
+-
+ upb_deps()
+
+- api_dependencies()
+-
+- go_rules_dependencies()
+- go_register_toolchains()
+-
+- apple_rules_dependencies()
+-
+- apple_support_dependencies()