hickey-ai opened a new issue, #16509: URL: https://github.com/apache/dubbo/issues/16509
### Pre-check - [x] I am sure that all the content I provide is in English. ### Search before asking - [x] I had searched in the [issues](https://github.com/apache/dubbo/issues?q=is%3Aissue) and found no similar issues. ### Apache Dubbo Component Java SDK (apache/dubbo) ### Dubbo Version Apache Dubbo source: 3.3.7-SNAPSHOT, branch `3.3`, commit `ae809de2fc81b408194240965eb20bf27e6971df`. Windows 11, OpenJDK 21, Maven 3.6.3. Reproduced by adding one focused regression to the existing dubbo-cluster MergeableClusterInvokerTest. The upstream source was not changed. ### Steps to reproduce this issue ## Component Java SDK (`apache/dubbo`), cluster merge invocation. ## Summary When a method uses a merger and the directory returns multiple providers from the same group, `MergeableClusterInvoker` stores results in a `Map<String, Result>` keyed by `invoker.getUrl().getServiceKey()`. Providers in the same group normally have the same service key, so the later result replaces the earlier one before the merge is performed. The consumer receives an incomplete business result without an exception. In the reproduction, the first provider returns menu entries `1` and `2`, the second returns entries `2` and `3`, but the merged result contains only the second provider's entries. ## Version and verification scope - Apache Dubbo `3.3.7-SNAPSHOT`, branch `3.3`, commit `ae809de2fc81b408194240965eb20bf27e6971df`. - Windows 11, OpenJDK 21, Maven 3.6.3. - Reproduced by adding one focused regression to the existing `dubbo-cluster` `MergeableClusterInvokerTest` and running the module test with Maven. The upstream clone was used only in an isolated worktree; the official source was not changed. - The test uses two local proxy invokers and no registry, network, or deployed provider. It verifies the business merge result, not only the internal map size. ## Minimal reproduction The full regression was added to the existing `MergeableClusterInvokerTest` fixture. The essential setup is: ```java url = url.addParameter(MERGER_KEY, ".merge"); // Both providers use the same service interface, group, and service key. firstInvoker returns firstMenu = { "1": ["10", "11", "12"], "2": ["20", "21", "22"] }; secondInvoker returns secondMenu = { "2": ["23", "24", "25"], "3": ["30", "31", "32"] }; // Their URL parameters differ only by provider address/port; getServiceKey() is equal. given(directory.list(invocation)).willReturn(List.of(firstInvoker, secondInvoker)); Menu actual = (Menu) new MergeableClusterInvoker<MenuService>(directory) .invoke(invocation).getValue(); assertThat(actual.getMenus()).containsExactlyInAnyOrderEntriesOf(Map.of( "1", List.of("10", "11", "12"), "2", List.of("20", "21", "22", "23", "24", "25"), "3", List.of("30", "31", "32"))); // fails: entries 1 and its values are missing ``` The executed test used the repository's existing `Menu`, `MenuService`, proxy invokers, merger configuration, and assertions; the snippet above is shortened to show the business case. ## Actual result Maven test output: ```text Tests run: 9, Failures: 1, Errors: 0, Skipped: 0 MergeableClusterInvokerTest.testMergeMustNotDropProvidersWithTheSameServiceKey expected: {1=[10, 11, 12], 2=[20, 21, 22, 23, 24, 25], 3=[30, 31, 32]} but was: {2=[23, 24, 25], 3=[30, 31, 32]} ``` The normal existing merge tests pass. The failure is silent data loss: the call succeeds but the first provider's result is absent. ## Expected behavior All successful provider results selected for a merge operation should be retained and passed to the configured merger, even when providers share the same service key. A provider address, invoker identity, or an ordered result list can be used as the collection identity; the result map must not collapse same-service-key providers. ## Root-cause observation [`MergeableClusterInvoker.doInvoke`](https://github.com/apache/dubbo/blob/ae809de2fc81b408194240965eb20bf27e6971df/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/support/MergeableClusterInvoker.java) creates `Map<String, Result> results` and executes `results.put(invoker.getUrl().getServiceKey(), ...)`. `serviceKey` identifies the service/group/version, not an individual provider instance. Multiple providers in the same group therefore overwrite each other before `resultList` is built. A minimal fix is to retain results in a list, or key them by a provider-unique identity while preserving the existing group logging separately. The regression should cover two providers with the same service key and different addresses. ## Deduplication Searched open issues for `MergeableClusterInvoker`, `merge group`, `serviceKey merge`, and current merge-related reports. I did not find this same-provider-key result-loss case. Existing merge tests use different groups, so they do not exercise the collision. ### What you expected to happen All successful provider results selected for a merge operation must be retained and passed to the configured merger, even when providers share the same service key. Actual result: the first provider result is silently overwritten and business data is missing. The focused regression ran 9 tests: 8 existing tests passed and the new same-service-key test failed with the expected missing result. ### Anything else Root cause: MergeableClusterInvoker stores results in Map<String, Result> using invoker.getUrl().getServiceKey() as the key. That identifies service/group/version, not a provider instance. Two providers in the same group therefore overwrite one another before merge. Searched open issues for MergeableClusterInvoker, merge group, serviceKey merge and current merge reports; no matching same-provider-key data-loss report was found. This report is separate from the previously submitted utility issues #16500, #16501 and #16502. ### Do you have a (mini) reproduction demo? - [x] Yes, I have a minimal reproduction demo to help resolve this issue more effectively! ### Are you willing to submit a pull request to fix on your own? - [ ] Yes I am willing to submit a pull request on my own! ### Code of Conduct - [x] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
