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

Fix discovery flow for PartitionedHttpClient #3001

Merged
merged 1 commit into from
Jul 11, 2024

Conversation

idelpivnitskiy
Copy link
Member

Motivation:

Our load balancers have an ability to cancel and re-subscribe to the ServiceDiscovery publisher as an attempt to trigger re-discovery when LB turns into unhealthy state for all addresses. However, for PartitionedHttpClient it will result in DuplicateSubscribeException because groupToMany operator does not support re-subscribes.

Modifications:

  • Apply multicast operator with cancelUpstream=false flag to allow LB of a single-address client to re-subscribe to the same group publisher;
  • Disable a retry strategy for ServiceDiscovery at single-address client level for partitioned client;
  • Implement NoRetriesStrategy.toString() for better logging;
  • Reproduce described scenario in PublisherGroupToManyTest;

Result:

Single-address clients under partitioned client won't fail with DuplicateSubscribeException if LB decides to re-subscribe to the group's stream.

Motivation:

Our load balancers have an ability to cancel and re-subscribe to the
`ServiceDiscovery` publisher as an attempt to trigger re-discovery when
LB turns into unhealthy state for all addresses. However, for
`PartitionedHttpClient` it will result in `DuplicateSubscribeException`
because `groupToMany` operator does not support re-subscribes.

Modifications:

- Apply `multicast` operator with `cancelUpstream=false` flag to allow
LB of a single-address client to re-subscribe to the same group
publisher;
- Disable a retry strategy for `ServiceDiscovery` at single-address
client level for partitioned client;
- Implement `NoRetriesStrategy.toString()` for better logging;
- Reproduce described scenario in `PublisherGroupToManyTest`;

Result:

Single-address clients under partitioned client won't fail with
`DuplicateSubscribeException` if LB decides to re-subscribe to the
group's stream.
subscription1New.request(1);
assertThat(group1SubNew.takeOnNext(), is(3));
} else {
assertThat(group1SubNew.awaitOnError(), is(instanceOf(DuplicateSubscribeException.class)));
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was hard to implement a full reproducer for the partitioned client, so I decided to show the problem in PublisherGroupToManyTest

Copy link
Contributor

@bryce-anderson bryce-anderson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not an expert in the partitioned code so maybe get a second opinion before proceeding, but it seems good to me.

@idelpivnitskiy
Copy link
Member Author

Discussed with Scott offline, we agreed on the approach

@idelpivnitskiy idelpivnitskiy merged commit 821619a into apple:main Jul 11, 2024
11 checks passed
@idelpivnitskiy idelpivnitskiy deleted the partitioned branch July 11, 2024 22:00
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.

2 participants