Repository navigation
refactor(ucore): use a single grpc channel with a name resolver instead of replacing channels - #3920
Merged
Merged
Conversation
…ad of replacing channels Replacing the shared channel on every failed rpc made other threads, which had already read the old stub, fail with "UNAVAILABLE: Channel shutdownNow invoked" (seen in unlockKey right after a reload). Follow the grpc-java examples instead (nameresolve, retrying, waitforready): - UcoreNameResolverProvider feeds the ucore ip list to one long-lived channel; ip list changes are pushed through the channel's SynchronizationContext - the default pick_first policy selects the node and reconnects with backoff, so the per-method "try every ip with a new channel" loops are replaced by one call() helper - the stub is derived per call, so the deadline is computed at call time - a service config enables retries (UNAVAILABLE, 3 attempts) only for the idempotent calls; LockOnSession, Alert/AlertResolve and the long polls rely on transparent retry only - wait-for-ready queues an rpc while the channel connects, bounded by its deadline - only connection level failures are reported as IOException, other statuses are rethrown unchanged lock()'s renew thread handling is intentionally left as it was. Not compiled and not tested: the build environment had no JDK.
The build failed at the validate phase with 6 violations: - SeparatorWrap: the '.' of the chained ManagedChannelBuilder calls has to stay at the end of the line - OperatorWrap: the '+' joining the error message has to stay at the end of the line No behaviour change.
UcoreNameResolverProviderTest (offline, 6 cases): - the provider binds to the ucore scheme and can be registered the way UcoreSender.initChannel does it - every ucore ip becomes its own EquivalentAddressGroup, with the authority staying ip:port as the channel used to send it - a node list change reaches every started resolver, an empty list is reported as UNAVAILABLE, a shut-down resolver stops receiving updates UcoreChannelIntegrationTest (real cluster on 5700, 5 cases): - read-only rpcs over the channel built from the resolver: health check, leader lookup and usage all answer - the channel reaches READY, and pick_first skips an unreachable address - skipped automatically when no ucore node is reachable, so the suite stays green without the cluster Verified against 10.186.63.94, 10.186.63.93 and 10.186.57.108: 11 tests pass.
maxAttempts 3 produces exactly two backoffs (0.2s then 0.4s), so the 2s ceiling copied from the grpc example was never reached and only suggested a cap the policy does not have. 0.5s states the same thing without implying behaviour that does not happen. No runtime change: neither ceiling is reached by this policy.
Two cases around a fake ucore node on 127.0.0.1 (accepts and hangs up at once, which grpc sees as a failed transport): - deadAddressIsDialledOnceThenTheNextNodeAnswers: with a dead address first and three live nodes behind it, the dead one is dialled once and the next address is started right away; the rpc still succeeds. Pins down that pick_first has no per-address retry and no delay between addresses - retryingTheWholeListIsThrottledByBackoff: with the dead node as the only address, the rpc ends with DEADLINE_EXCEEDED after roughly three rounds, which is the exponential backoff (1s, multiplier 1.6, jitter 20%) and not an unbounded retry loop Both are skipped when 127.0.0.1:5700 is taken. 13 tests pass against the real cluster (10.186.63.94, 10.186.63.93, 10.186.57.108).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Replacing the shared channel on every failed rpc made other threads, which had already read the old stub, fail with "UNAVAILABLE: Channel shutdownNow invoked" (seen in unlockKey right after a reload).
Follow the grpc-java examples instead (nameresolve, retrying, waitforready):
lock()'s renew thread handling is intentionally left as it was.
Not compiled and not tested: the build environment had no JDK.
Reason:
BUG #. or Improve #.
Type:
BUG/Improve
Influences:
fix xx