GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — [fix][client] Fail connection requests on a closed connection pool instead of never completing by merlimat · Pull Request #27514 · apache/pulsar Conversation
Contributor
MotivationProblem. After The pool resolves the broker address with Netty's With an event loop shared with other clients through Example. PulsarClientImpl client = (PulsarClientImpl) PulsarClient.builder() .serviceUrl("pulsar://localhost:6650") .build(); client.close(); // Never completes: TimeoutException client.getSchema("persistent://public/default/t").get(10, TimeUnit.SECONDS); The code path: // PulsarClientImpl.getSchema(): no state check return lookup.getSchema(topicName); // BinaryProtoLookupService.getSchema() client.getCnxPool().getConnection(serviceNameResolver).thenAcceptAsync(clientCnx -> { ... }, lookupPinnedExecutor) // ConnectionPool: a closed pool still creates a connection public CompletableFuture<ClientCnx> getConnection(InetSocketAddress logicalAddress, InetSocketAddress physicalAddress, final int randomKey) { ... CompletableFuture<ClientCnx> completableFuture = pool.computeIfAbsent(key, k -> createConnection(key)); ... } CompletableFuture<List<InetSocketAddress>> resolveName(InetSocketAddress unresolvedAddress) { CompletableFuture<List<InetSocketAddress>> future = new CompletableFuture<>(); // Never notified once the event loop has terminated addressResolver.resolveAll(unresolvedAddress).addListener((Future<List<InetSocketAddress>> resolveFuture) -> { ... }); return future; } Modifications
if (closed) { return FutureUtil.failedFuture( new PulsarClientException.AlreadyClosedException("Connection pool already closed")); }
Not changed here: Verifying this change
This change added tests and can be verified as follows:
Does this pull request potentially affect one of the following parts:If the box was checked, please highlight the changes
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions…stead of never completing After PulsarClient.close() or shutdown(), a lookup that needs a connection from the client's connection pool never completed: getSchema(), the topic lookups behind getConnection(), getConnectionToServiceUrl() and the namespace topic listing all returned futures that stayed pending. The pool resolves the broker address with Netty's address resolver, which completes its future through a task on the client's event loop. That loop has terminated, so Netty logs "Failed to submit a listener notification task. Event loop shut down?" and drops the notification. With an event loop shared with other clients, which keeps running, the closed pool opened a new connection instead, which its channel group closed at once, and the lookup failed with "Missing ClientCnx. This should not happen." ConnectionPool.getConnection() now fails with AlreadyClosedException once the pool is closed, before it looks at the pooled connections or opens a new one. The client closes its pool before it shuts down its event loop.
codelipenghui
approved these changes
codelipenghui
approved these changes
Uh oh!
There was an error while loading. Please reload this page.
poorbarcode
pushed a commit
to poorbarcode/pulsar
that referenced
this pull request
…stead of never completing (apache#27514) (cherry picked from commit 3637479)
poorbarcode
pushed a commit
to poorbarcode/pulsar
that referenced
this pull request
…stead of never completing (apache#27514) (cherry picked from commit 3637479)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ReviewersUh oh!
There was an error while loading. Please reload this page. AssigneesNo one assignedLabelsProjectsMilestoneNo milestoneDevelopmentSuccessfully merging this pull request may close these issues. Uh oh!
There was an error while loading. Please reload this page. 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. |
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |