Commit Graph

1772 Commits

Author SHA1 Message Date
Eric Anderson 004ee10a73
core: Vastly separate types of clock in FakeClock
There was an attempt to use different epochs for the wall clock and the
monotonic clock. However, 123456789 is actually less than a second.
We want the gap between clocks to be at least a day. This issue was
discovered in #8968.

This separation found a bug in an RLS test where it was mixing epochs.
However, it was only a problem in the test. The code under test is
wrongly using wall clock for calculation durations, but that seems to be
a wide-spread problem and will need to be handled separately.
2022-04-04 11:24:55 -07:00
Kurt Alfred Kluever 31ce764723 Use `try/execute/fail/catch` instead of the strongly discouraged `@Test(expected=...)`
cl/437399696
2022-03-28 14:34:33 -07:00
yifeizhuang 86b74d9ecc
core: delayedClientCall returns drainPendingCalls runnable in setCall (#8978)
`setCall()` returns drainPendingCalls runnable only when there are calls to drain, otherwise return null. Preserved the behaviour of `start()` and `cancel()`, as they are protected by `delayOrExecute()`.
2022-03-15 12:57:24 -07:00
John Cormie abd1642371
New streams before transportReady() are not guaranteed to work (#8955)
Update javadoc to mention this previously-unwritten rule.

Update earlyServerClose_serverFailure_withClientCancelOnListenerClosed to obey it.

Update BinderTransport to fail sooner if this rule is broken.
2022-03-03 08:03:07 -08:00
Eric Anderson 4cf3a2b801
core: Decrease transparent retry limit to 1000
The test for 10,000 took 10s to run and would time out when using other
tools like TSAN. "10000" was just a "very large number less than
infinity" and 1000 serves the same purpose and should similarly never
trigger. Using 1000 has the test run in 1s and TSAN completes in 17s.

The limit was originally added in dc6eaccc.
2022-02-23 09:15:04 -08:00
Terry Wilson ec3db2b454
Start 1.46.0 development cycle (#8939) 2022-02-23 08:23:41 -08:00
ZHANG Dapeng dc6eacccbf
core: limit total number of local-only transparent retries
Limit the total number of local-only transparent retries per RPC for the moment to mitigate any potential bug that would trigger infinite loop of transparent retries. If the limit is exceeded, fail the RPC.
2022-02-09 13:20:07 -08:00
ZHANG Dapeng 431fb0255f
core/netty: infinite local-only transparent retry for netty (#8878)
In core, add a new enum element to `RpcProgress` for the case that the stream is closed even before anything leaves the client. `RetriableStream` will do unlimited transparent retry for this type of `RpcProgress` since they are local-only.

In netty, call `tranportReportStatus()` for pending streams on failure.

Also fixes #8394
2022-02-04 22:12:03 -08:00
Sergii Tkachenko c46d2c276a
core: test JsonUtil.getObject with a map containing a null value (#8881)
Verifies the behavior of JsonUtil.getObject when the map contains a null value for a given key.

Note: this may be incorrect behavior. Issue to track the investigation: #8883.
2022-02-04 09:56:26 -08:00
Zhouyihai Ding 46563b75bf
core: include cause when logging Status in InternalSubchannel (#8846)
It would be good to print Cause when the transport is shutdown and has throwable exception messages.

The current log doesn't have this information for debugging:
`SHUTDOWN with UNAVAILABLE(io exception Channel Pipeline: [HttpProxyHandler$HttpClientCodecWrapper#0, HttpProxyHandler#0, TsiHandshakeHandler#0, WriteBufferingAndExceptionHandler#0, DefaultChannelPipeline$TailContext#0])`
2022-01-27 11:07:14 -08:00
Penn (Dapeng) Zhang cf4cd65707 Revert "all: clean up code related to android api level less than 19"
This reverts commit 3ad4d9bfb7.
2022-01-18 10:14:50 -08:00
Penn (Dapeng) Zhang 3179bc3be0 Revert "use charset from StandardCharsets instead of 'Charset.forName' (#8779)"
This reverts commit a74a3ad834.
2022-01-18 10:14:50 -08:00
yifeizhuang 26f0d611db
Start 1.45.0 development cycle (#8825) 2022-01-12 12:08:22 -08:00
Eric Anderson 58a7ace6ac
Bump ErrorProne to 2.10.0
Previous versions of error prone were incompatible with Java 17 javac.

In grpc-api, errorprone is now api dependency because it is on a public
API.  I was happy to see that Gradle failed the build without the dep
change, although the error message wasn't super clear as to the cause.

It seems that previously -PerrorProne=false did nothing. I'm guessing
this is due to a behavior change of Gradle at some point. Swapping to
using the project does build without errorProne, although the build
fails with Javac complaining certain classes are unavailable. It's
unclear why. It doesn't seem to be caused by the error-prone plugin.
I've left it failing as a pre-existing issue.

ClientCalls/ServerCalls had Deprecated removed from some methods because
they were only deprecated in the internal class, not the API. And with
Deprecated, InlineMeSuggester complained.

I'm finding InlineMeSuggester to be overzealous, complaining about
package-private methods. In time we may figure out how to use it better,
or we may request changes to the checker in error-prone.
2022-01-12 12:06:27 -08:00
Jintao a74a3ad834
use charset from StandardCharsets instead of 'Charset.forName' (#8779)
Co-authored-by: Penn (Dapeng) Zhang <zdapeng@google.com>
2022-01-07 15:03:14 -08:00
Eric Anderson d44de5069d
Bump to Gradle 6.9 and update plugins
These changes make the build compatible with Gradle 7, except for
Android which requires plugin updates.

I removed animalsniffer from binder because it did nothing (as there
were no signatures) and it was failing after setting toolVersion. It
failed because animalsniffer is only compatible with java plugin. After
this change I put the withId(animalsniffer) loading inside the
withId(java) to avoid a plugin ordering failure. That made it safe again
for binder to load animalsniffer, but it is still best to remove the
plugin from binder as it is misleading.

I did not upgrade Android plugin versions as newer versions (even 3.6)
require dealing with androidx (#8421).
2022-01-07 09:54:50 -08:00
ZHANG Dapeng 3ad4d9bfb7
all: clean up code related to android api level less than 19 2022-01-07 08:13:32 -08:00
ZHANG Dapeng 042f9879d4
all: remove deprecated StreamInfo.transportAttrs (#8768)
APIs such as `StreamInfo.getTransportAttrs()` were [deprecated](860e97d12a (diff-aa4049f54d6d5d462700e9221344184a37d2068b3ba7d715abd417b1df5bf883R114)) since 1.41.0. Removing now.
2021-12-20 09:46:25 -08:00
ZHANG Dapeng 63756ec951
core: remove unused method in AutoConfiguredLoadBalancer (#8769)
The method added in #5821 seems not used now.
2021-12-17 07:36:00 -08:00
ZHANG Dapeng 531db504ca
core: fix race condition in idleTimer & ManagedChannel#enterIdle
PR for Spikhalskiy/grpc-java@6d260b8

Hot fix of #8714
2021-12-14 17:55:48 -08:00
ZHANG Dapeng 65c00cf24e
Start 1.44.0 development cycle (#8729) 2021-11-30 11:53:56 -08:00
ZHANG Dapeng a5f1fb51b8
core: have JsonUtil support parsing String value as number (#8711)
As documented in https://developers.google.com/protocol-buffers/docs/proto3#json,
the canonical proto-to-json converter converts int64 (Java long) values to string values in Json rather than Json numbers (Java Double). Conversely, either Json string value or number value are accepted to be converted to int64 proto value.

To better support service configs defined by protobuf messages, support parsing String values as numbers in `JsonUtil`.
2021-11-19 10:12:39 -08:00
markb74 607362a7d2
Add support for anonymous in-process servers. (#8589)
Support anonymous in-process servers, and InProcessChannelBuilder.forTarget.

Anonymous servers aren't registered statically, meaning they can't be looked up by name.
Only the AnonymousInProcessSocketAddress passed to InProcessServerBuilder.forAddress(),
(or subsequently fetched from Server.getListenSockets()) can be used to connect to the server.

Supporting InProcessChannelBuilder.forTarget is particularly useful for production
Android usage of in-process servers, where process startup latency is crucial.
A custom name resolver can be used to create the server instance on demand
without directly impacting the startup latency of in-process gRPC clients.

Together, these features support a more-standard approach to "OnDeviceServer" referenced in gRFC L73.
https://github.com/grpc/proposal/blob/master/L73-java-binderchannel.md#ondeviceserver
2021-10-25 20:59:48 +02:00
Benjamin Peterson 1fe62dd417
Fix sentences with a missing "be". (#8613) 2021-10-20 15:14:10 -07:00
Sergii Tkachenko 6d41b4283a Start 1.43.0 development cycle 2021-10-20 13:47:03 -04:00
ZhenLian d2b9151e7b
core: remove DSA check in CertificateUtils 2021-10-19 19:50:33 -04:00
ZhenLian e9b0c2e851
Make CertificateUtils to use other key algorithms (#8609) 2021-10-15 14:42:14 -07:00
Sergii Tkachenko 0376de15b8
Fix AbstractManagedChannelImplBuilder#maxInboundMessageSize(int) ABI (#8607)
In refactoring described in #7211, the implementation of #maxInboundMessageSize(int)
(and its corresponding field) were pulled down from internal AbstractManagedChannelImplBuilder
to concrete classes that actually enforce this setting. For the same reason, it wasn't ported
to ManagedChannelImplBuilder (the #delegate()).

Then AbstractManagedChannelImplBuilder was brought back to fix ABI backward compatibility,
and temporarily turned into a ForwardingChannelBuilder, ref PR #7564. Eventually it will
be deleted, after a period with "bridge" ABI solution introduced in #7834.

However, restoring AbstractManagedChannelImplBuilder unintentionally made ABI of
pre-refactoring builds expect it to be a method of AbstractManagedChannelImplBuilder,
and not concrete classes, ref #8313.

The end goal is to keep #maxInboundMessageSize(int) only in concrete classes that enforce it.
To fix method's ABI, we temporary reintroduce it to the original layer it was removed from:
AbstractManagedChannelImplBuilder. This class' only intention is to provide short-term
ABI compatibility. Once we move forward with dropping the ABI, both fixes are no longer
necessary, and both will perish with removing AbstractManagedChannelImplBuilder.
2021-10-14 17:25:06 -07:00
Terry Wilson fc57cad4ec
Revert "Revert "core/auth: Remove CallCredentials2 (#8464)"" (#8572)
This reverts commit a91cc85dfd.
2021-10-05 10:34:44 -07:00
ZHANG Dapeng 28f2647aaf
core: move closed check from Stream.isReady() to Call.isReady() (#8566)
This fixes data race described in #8565.

We are doubtful whether checking closed in isReady() is necessary (#3201 might be a requirement), but it was easier to just maintain the existing behavior than think heavily about it.
2021-09-29 09:42:59 -07:00
Zhouyihai Ding e41df60bea
core: change the mapping from ChannelLogLevel to java.util.logging.Level
Instead of `ChannelLogLevel.{DEBUG,INFO}` mapping to the same java level, `ChannelLogLevel.{WARNING,ERROR}` will shame the same java level. This allows us to be able to independently control the visibility of `ChannelLogLevel.DEBUG` logs which are the most verbose.
2021-09-22 09:43:08 -07:00
ZhenLian 838438cedb
AdvancedTls: add functions to load credentials from static files (#8525)
* AdvancedTls: add functions to load credentials from static files
2021-09-17 09:45:41 -07:00
ZHANG Dapeng 3b237339c7
core: discard outbound content-length header (#8522)
Since netty version v4.1.67, content-lenght header validation will be enforced. So once grpc upgrades netty to that version or above, RPCs with invalid content-length header will fail.

Some libraries such as HTTP to gRPC adapters blindly copy all HTTP headers to gRPC metadata, but the content-length header is one of those that shouldn't be forwarded because gRPC uses different encoding. This mistake has already been in existence for a long time.

Discard outbound content-length headers in gRPC, so that users who encounter invalid content-length issue when upgrading grpc-java version on server/client side would be able to workaround by upgrading grpc-java on client/server side as well without fixing the HTTP adapter.
2021-09-13 17:15:45 -07:00
ZHANG Dapeng 7c6f53ab79
all: add internal API to disable retry stats (#8510)
Resolves b/197648853 for internal performance regression. Reporting retry stats caused significant amount of performance overhead internally.
2021-09-13 09:12:04 -07:00
ZhenLian fb00463001
fix a flaky test in advanced TLS (#8474)
* fix a flaky test in advanced tls
2021-09-08 11:43:23 -07:00
Eric Anderson 1f1396f3f0 Start 1.42.0 development cycle 2021-09-08 09:10:20 -07:00
Sergii Tkachenko a91cc85dfd
Revert "core/auth: Remove CallCredentials2 (#8464)"
This reverts commit 7cde473efa.
2021-09-02 17:20:20 -07:00
Brice Jaglin 62fafe7eda core: clarify exception message
Reformulate message to highlight that SizeEnforcingInputStream is
applied on the message size of the message after decompression.
2021-09-02 15:18:00 -07:00
Anuraag Agrawal 522b37bc3b
Fix drift in MessageFramer comment (#8427) 2021-09-02 08:56:56 -07:00
Terry Wilson 7cde473efa
core/auth: Remove CallCredentials2 (#8464)
- Removes CallCredentials2
- Removes CallCredentials2ApplyingTest
- Adds two tests from CallCredentials2ApplyingTest to CallCredentialsApplyingTest
- Updates GoogleAuthLibraryCallCredentials to extend from CallCredentials instead of CallCredentials2
2021-09-01 09:49:20 -07:00
Terry Wilson df4ac5973c
core: Exit idle mode in enterIdle() if there are pending calls or delayed transport.
This change assures that if there are only calls in real transport the
channel will remain in idle mode. Idle mode will be exited if there
are calls in delayed transport to allow them to be processed.
2021-08-26 14:42:27 -07:00
ZhenLian 3cb0696b1f
advancedtls: change enum to use UPPER_SNAKE_CASE (#8446) 2021-08-25 16:13:09 -07:00
Terry Wilson e45aab085c
core: Don't mark calls as cancelled if they are successfully completed. (#8408)
The semantics around cancel vary slightly between ServerCall and CancellableContext - the context should always be cancelled regardless of the outcome of the call while the ServerCall should only be cancelled on a non-OK status.

This fixes a bug where the ServerCall was always marked cancelled regardless of call status.

Fixes #5882
2021-08-20 14:42:01 -07:00
ZhenLian 2c2ebaebd5
advancedtls: adding AdvancedTlsX509TrustManager and AdvancedTlsX509KeyManager (#8175)
* add advanced TLS classes and tests
2021-08-17 16:13:30 -07:00
ZHANG Dapeng bdf9a96476
core: enable retry by default (#8402)
Stabilize `enableRetry()` and `disableRetry()`.

Disable retry in `ManagedChannelImplTest` because each call attempt will fork the headers to a new instance, and add a ClientStreamTracer.Factory for bufferSizeLimit in CallOptions, which makes verification not straightforward.
2021-08-11 14:44:23 -07:00
ZHANG Dapeng 2142902343
core: fix retry flow control issue (#8401)
There has been an issue about flow control when retry is enabled.

Currently we call `masterListener.onReady()` whenever `substreamListener.onReady()` is called.

The user's `onReady()` implementation might do

```
while(observer.isReady()) {
  // send one more message.
}
```

However, currently if the `RetriableStream` is still draining, `isReady()` is false, and user's `onReady()` exits immediately. And because `substreamListener.onReady()` is already called, it may not be called again after drained.

This PR fixes the issue by

- Use a SerializeExecutor to call all `masterListener` callbacks.
- Once `RetriableStream` is drained, check `isReady()` and if so call `onReady()`.
- Once `substreamListener.onReady()` is called, check `isReady()` and only if so we call `masterListener.onReady()`.
2021-08-11 10:25:57 -07:00
ZHANG Dapeng fd2a58a55e
all: implement retry stats (#8362) 2021-08-11 10:24:37 -07:00
ZHANG Dapeng cbda32a3c1
core: fix RetriableStream edge case bug introduced in #8386 (#8393)
While adding regression tests to #8386, I found a bug in an edge case: while retry attempt is draining the last buffered entry, if it is in the mean time committed and then we cancel the call, the stream will never be cancelled. See the regression test case `commitAndCancelWhileDraining()`.
2021-08-06 18:32:55 -07:00
ZHANG Dapeng 3668f2e52c
core: fix bug RetriableStream cancel() racing with start() (#8386)
There is a bug in the scenario of the following sequence of events:

- `call.start()` 
- received retryable status and about to retry
- The retry attempt Substream is created but not yet `drain()` 
- `call.cancel()`

But `stream.cancel()` cannot be called prior to `stream.start()`, otherwise retry will cause a failure with IllegalStateException. The current RetriableStream code must be fixed to not cancel a stream until `start()` is called in `drain()`.
2021-08-05 18:22:37 -07:00
ZHANG Dapeng c77083f013
core: fix old ClientStreamTracer.Factory creating tracers twice (#8381)
Fix a bug introduced in #8355 : old ClientStreamTracer.Factory implementation creates tracers twice.
2021-08-04 14:32:49 -07:00