Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[improve] PIP-307: Use assigned broker URL hints during broker reconnection #1208

Merged
merged 71 commits into from
Apr 23, 2024

Conversation

dragosvictor
Copy link
Contributor

@dragosvictor dragosvictor commented Apr 18, 2024

Motivation

PIP-307 describes a faster process to reconnect a client to the broker when a topic is unloaded from one broker to another. The server-side implementation is out in 3.2. Client-side support is already checked-in for Java and CPP. This PR adds the respective support to the Golang client. It features improvements to both the producer and consumer, while handling direct and proxied connections alike.

Reference Java and CPP implementations:

Modifications

  • Add optional fields assignedBrokerUrl and assignedBrokerUrlTls to the Protobuf spec of CommandCloseProducer and CommandCloseConsumer
  • Forward this information through the client from the source in connection.handleCloseConsumer and connection.handleCloseProducer all the way through to partitionProducer.reconnectToBroker and partitionConsumer.reconnectToBroker, by adding the URLs to the connectionClosed struct
  • If the URLs are present, perform exactly one attempt to reconnect via this "assigned" URL (if the connection fails revert to issuing lookup calls on the broker to locate the topic). Leverages the exiting parsing and name resolution mechanism in the Lookup Service. Method lookupService.getBrokerAddress had to be exposed as public method lookupService.GetBrokerAddress for this purpose. Furthermore, had to add method Connection.IsProxied to allow the reconnection to work properly in the context of proxied connections.

Verifying this change

  • Make sure that the change passes the CI checks.

Added integration test ExtensibleLoadManagerTestSuite.TestTopicUnload, with subtests for both direct connections and proxied connections. The test requires a different configuration than what we currently have elsewhere, so it runs with its own Docker Compose setup. It launches two brokers having the Extensible Load Manager enabled. The test concurrently:
- Produces messages to a topic
- Consumes messages from the topic
- Unloads the topic to the other broker
At the end, it verifies that messages have been successfully delivered both before and after the unloading, while issuing no further topic lookup calls. On that last point, it relies on the topic lookup metrics to perform the verification, as the test framework doesn't have a straightforward way to mock and intercept calls otherwise. This can be a point for further improvement of the test codebase.

Does this pull request potentially affect one of the following parts:

If yes was chosen, please highlight the changes

  • Dependencies (does it add or upgrade a dependency): No
  • The public API: No
  • The schema: No
  • The default values of configurations: No
  • The wire protocol: Yes: Added assigned broker URL(s) fields to the producer and consumer close commands.

Documentation

  • Does this pull request introduce a new feature? Yes
  • If yes, how is the feature documented? Not applicable
  • If a feature is not applicable for documentation, explain why? The feature is an internal performance improvement
  • If a feature is not documented yet in this PR, please create a followup issue for adding the documentation Not applicable

Add docker-compose instructions for ELM

Add ELM test target

Parameterize pulsar version in docker script

Update broker health checks in test

Allow test method httpDo to return the raw bytes

Update test

Update test code

Update test

Cosmetic fixes

Add mock counters

Rename test

Add CI script

Minor fix

Switch to uber atomic package

Test fix

Test fix

Test fix
@dragosvictor dragosvictor marked this pull request as ready for review April 18, 2024 17:01
pulsar/consumer_partition.go Show resolved Hide resolved
pulsar/producer_partition.go Outdated Show resolved Hide resolved
pulsar/internal/lookup_service.go Outdated Show resolved Hide resolved
pulsar/internal/lookup_service.go Outdated Show resolved Hide resolved
pulsar/producer_partition.go Show resolved Hide resolved
@BewareMyPower BewareMyPower merged commit 86054c5 into apache:master Apr 23, 2024
8 checks passed
@RobertIndie RobertIndie added this to the v0.13.0 milestone Jun 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants