Skip to content

Load balance bug#48121

Open
mrm9084 wants to merge 7 commits intoAzure:mainfrom
mrm9084:LoadBalanceBug
Open

Load balance bug#48121
mrm9084 wants to merge 7 commits intoAzure:mainfrom
mrm9084:LoadBalanceBug

Conversation

@mrm9084
Copy link
Member

@mrm9084 mrm9084 commented Feb 25, 2026

Description

  • Fixes a bug where the configuration and feature flag refresh used different clients. Caused an issue if load balancing was enabled in a store that used feature flags could not refresh with feature flags.
  • Fixes an issue where load balancing relplicas were removed from the active list after use.
  • Removes the unused currentReplica variable. From the previous change to activeClient.

Note: A second PR will be created to randomize the active replica list for load balancing.

All SDK Contribution checklist:

  • The pull request does not introduce [breaking changes]
  • CHANGELOG is updated for new features, bug fixes or other significant changes.
  • I have read the contribution guidelines.

General Guidelines and Best Practices

  • Title of the pull request is clear and informative.
  • There are a small number of commits, each of which have an informative message. This means that previously merged commits do not appear in the history of the PR. For more information on cleaning up the commits in your PR, see this page.

Testing Guidelines

  • Pull request includes test coverage for the included changes.

Copilot AI review requested due to automatic review settings February 25, 2026 20:54
@github-actions github-actions bot added the azure-spring All azure-spring related issues label Feb 25, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR addresses load-balancing behavior in Spring Cloud Azure App Configuration refresh flows to ensure configuration and feature-flag refresh use consistent client selection and to avoid dropping replicas from the active rotation.

Changes:

  • Adjusts ConnectionManager#getNextActiveClient to rotate clients for round-robin load balancing instead of removing them from the active list.
  • Updates refresh logic to select clients consistently between configuration refresh checks and feature-flag refresh checks.
  • Removes now-unused “current replica” tracking and updates tests and changelog accordingly.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
sdk/spring/spring-cloud-azure-appconfiguration-config/src/main/java/com/azure/spring/cloud/appconfiguration/config/implementation/ConnectionManager.java Changes load-balancing selection to round-robin rotation; removes unused replica tracking.
sdk/spring/spring-cloud-azure-appconfiguration-config/src/main/java/com/azure/spring/cloud/appconfiguration/config/implementation/AppConfigurationReplicaClientFactory.java Removes API used for tracking “current” replica client.
sdk/spring/spring-cloud-azure-appconfiguration-config/src/main/java/com/azure/spring/cloud/appconfiguration/config/implementation/AppConfigurationRefreshUtil.java Aligns refresh retry/client selection behavior for configuration vs feature-flag checks.
sdk/spring/spring-cloud-azure-appconfiguration-config/src/test/java/com/azure/spring/cloud/appconfiguration/config/implementation/ConnectionManagerTest.java Updates expectations for new round-robin behavior.
sdk/spring/spring-cloud-azure-appconfiguration-config/src/test/java/com/azure/spring/cloud/appconfiguration/config/implementation/AppConfigurationRefreshUtilTest.java Removes obsolete verification tied to removed “current client” API.
sdk/spring/spring-cloud-azure-appconfiguration-config/CHANGELOG.md Adds a bug-fix entry describing the load-balancing/feature-flag refresh fix.

mrm9084 and others added 3 commits February 25, 2026 13:35
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

…/java/com/azure/spring/cloud/appconfiguration/config/implementation/ConnectionManager.java

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@rujche rujche requested a review from Copilot February 26, 2026 07:38
@rujche rujche added the azure-spring-app-configuration Spring app configuration related issues. label Feb 26, 2026
@rujche rujche moved this from Todo to In Progress in Spring Cloud Azure Feb 26, 2026
@rujche rujche added this to the 2026-03 milestone Feb 26, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

…/java/com/azure/spring/cloud/appconfiguration/config/implementation/ConnectionManagerTest.java

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (1)

sdk/spring/spring-cloud-azure-appconfiguration-config/src/main/java/com/azure/spring/cloud/appconfiguration/config/implementation/ConnectionManager.java:102

  • In getNextActiveClient, the local variable name clients shadows the instance field clients, which makes the control flow harder to follow and easy to misread (especially since this method also mutates activeClients). Rename the local variable to something like availableClients (or similar) to avoid shadowing and improve readability.
        if (useLastActive) {
            List<AppConfigurationReplicaClient> clients = getAvailableClients();
            for (AppConfigurationReplicaClient client: clients) {
                if (client.getEndpoint().equals(lastActiveClient)) {
                    return client;

Comment on lines 246 to 253
// Monitor is disabled
RefreshEventData eventData = new AppConfigurationRefreshUtil().refreshStoresCheck(clientFactoryMock,
Duration.ofMinutes(10),
(long) 60, replicaLookUpMock);
assertFalse(eventData.getDoRefresh());
verify(clientFactoryMock, times(1)).setCurrentConfigStoreClient(Mockito.eq(endpoint), Mockito.eq(endpoint));
verify(clientOriginMock, times(0)).getWatchKey(Mockito.anyString(), Mockito.anyString(),
Mockito.any(Context.class));
}
Copy link

Copilot AI Feb 28, 2026

Choose a reason for hiding this comment

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

The tests no longer assert the key behavior this PR is fixing: configuration refresh should select a client with useLastActive=false, and feature-flag refresh should reuse the same client with useLastActive=true (especially in the single-client load-balancing case where activeClients is emptied by the config check). Please strengthen/add a regression test that verifies getNextActiveClient(endpoint, false) is used for configuration and getNextActiveClient(endpoint, true) for feature flags, and that both checks operate on the same client in the single-store scenario.

Copilot generated this review using guidance from repository custom instructions.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

azure-spring All azure-spring related issues azure-spring-app-configuration Spring app configuration related issues.

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

4 participants