feat: isolate dual-registration failure handling per mode
What is the purpose of the change?
Close https://github.com/apache/dubbo/issues/16247.
Problem
In dual registration mode (register-mode=all) Dubbo emits a single provider URL through two registries:
- interface-level -> registry:// (ZooKeeper, Nacos, ...) - instance-level -> service-discovery-registry://
RegistryProtocol#export calls register() once; the registry wrapper
fans out to both arms. Any RuntimeException from the first arm aborts
the second, so a transient failure on the metadata center silently
takes down the interface-level registration that was otherwise healthy
(or vice versa). The pre-existing FrameworkStatusReportService only
reports a coarse "instance/interface" status and cannot tell observers
which arm failed, which swallowed the error, or why.
Fix
-
FrameworkStatusReportService
- add reportRegistrationOutcome(mode, registryAddress, serviceKey, success, errorMessage) + createRegistrationOutcomeReport() so each registration attempt emits an independently tagged payload {application, mode, registry, service, status, error?}.
-
RegistryProtocol
- new registerWithModeTag(registry, registryUrl, providerUrl) wraps
the existing register() call with per-arm failure isolation:
- success -> report SUCCESS tagged with the resolved mode
- RuntimeException:
- report FAILED with the cause message
- honor registryUrl check= parameter: rethrow iff check=true, otherwise log a warn under CONFIG_REGISTER_INSTANCE_ERROR (5-11) and return false so the sibling arm keeps going
- resolveRegisterModeTag() centralizes the INTERFACE_REGISTER vs INSTANCE_REGISTER label (previously hardcoded in one log line).
- route export() and ExporterChangeableWrapper.register() through the new wrapper; replace the hardcoded "[INSTANCE_REGISTER]" log prefix with the resolved tag.
- reporting failures never leak into the registration flow (wrapped in try/catch(Throwable)).
- new registerWithModeTag(registry, registryUrl, providerUrl) wraps
the existing register() call with per-arm failure isolation:
Tests
- dubbo-common: FrameworkStatusReportServiceTest gains testReportRegistrationOutcomeSuccess / Failure covering the new payload shape.
- dubbo-registry-api: new RegistryProtocolDualRegisterTest with 4 reflection-driven cases over registerWithModeTag — success paths for both protocols, check=true rethrow path, check=false swallow path. A local CapturingFrameworkStatusReporter + SPI registration under src/test/resources provides the capture sink (MockFrameworkStatus- Reporter is scoped to dubbo-common tests and not reachable here).
Behavior change
| Scenario | Before | After |
|---|---|---|
| Both arms succeed | 1 coarse registration report |
2 outcome reports, one per mode, status=SUCCESS |
One arm fails, check=false on that registry URL |
exception bubbles out, sibling arm may be skipped | failure is tagged + reported FAILED, returns false, |
| sibling arm continues | ||
One arm fails, check=true |
exception bubbles out (no outcome report) | outcome still reported FAILED then the original exception is rethrown |
| Reporter itself throws | would leak into registration flow | swallowed — reporting never affects registration |
Checklist
- [x] Make sure there is a GitHub_issue field for the change.
- [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
- [x] Write necessary unit-test to verify your logic correction. If the new feature or significant change is committed, please remember to add sample in dubbo samples project.
- [x] Make sure gitHub actions can pass. Why the workflow is failing and how to fix it?
Codecov Report
:x: Patch coverage is 91.04478% with 6 lines in your changes missing coverage. Please review.
:white_check_mark: Project coverage is 60.91%. Comparing base (3a30432) to head (3e8e2f7).
Additional details and impacted files
@@ Coverage Diff @@
## 3.3 #16248 +/- ##
============================================
+ Coverage 60.87% 60.91% +0.04%
- Complexity 11766 11772 +6
============================================
Files 1953 1953
Lines 89273 89334 +61
Branches 13473 13483 +10
============================================
+ Hits 54346 54421 +75
+ Misses 29333 29318 -15
- Partials 5594 5595 +1
| Flag | Coverage Δ | |
|---|---|---|
| integration-tests-java21 | 32.15% <51.51%> (+<0.01%) |
:arrow_up: |
| integration-tests-java8 | 32.22% <51.51%> (+<0.01%) |
:arrow_up: |
| samples-tests-java21 | 32.10% <50.00%> (-0.10%) |
:arrow_down: |
| samples-tests-java8 | 29.77% <50.00%> (-0.03%) |
:arrow_down: |
| unit-tests-java11 | 59.14% <90.90%> (+0.02%) |
:arrow_up: |
| unit-tests-java17 | 58.63% <90.90%> (-0.01%) |
:arrow_down: |
| unit-tests-java21 | 58.63% <90.90%> (+0.02%) |
:arrow_up: |
| unit-tests-java25 | 58.60% <90.90%> (+0.03%) |
:arrow_up: |
| unit-tests-java8 | 59.18% <92.30%> (+0.03%) |
:arrow_up: |
Flags with carried forward coverage won't be shown. Click here to find out more.
:umbrella: View full report in Codecov by Harness.
:loudspeaker: Have feedback on the report? Share it here.
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
- :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
Thanks for working on this. I noticed a couple of edge cases around how registration failures are reported and recorded.
The first case is mainly related to standard FailbackRegistry implementations. In FailbackRegistry.register(), a failed doRegister() does not always propagate to the caller. When check=false, the failure is converted into a retry task and register() returns normally:
try {
doRegister(url);
} catch (Exception e) {
boolean check = getUrl().getParameter(Constants.CHECK_KEY, true)
&& url.getParameter(Constants.CHECK_KEY, true)
&& (url.getPort() != 0);
if (check || skipFailback) {
throw new IllegalStateException(...);
} else {
logger.error(... "waiting for retry" ...);
}
addFailedRegistered(url);
}
addFailedRegistered(url) then schedules a retry:
FailedRegisteredTask newTask = new FailedRegisteredTask(url, this);
oldOne = failedRegistered.putIfAbsent(url, newTask);
if (oldOne == null) {
retryTimer.newTimeout(newTask, retryPeriod, TimeUnit.MILLISECONDS);
}
So for failback registries such as ZookeeperRegistry, NacosRegistry, or ServiceDiscoveryRegistry, register() may return normally even though the immediate registration attempt failed and is only waiting for retry. In that case, reporting SUCCESS based only on the absence of an exception would be misleading.
The second case is about the caller-side recorded state. registerWithModeTag() may return false when registration fails with check=false, but export() appears to ignore that result and record the stated URL/exporter as registered based on the configured register flag:
boolean register = providerUrl.getParameter(REGISTER_KEY, true)
&& registryUrl.getParameter(REGISTER_KEY, true);
if (register) {
registerWithModeTag(registry, registryUrl, registeredProviderUrl);
}
registerStatedUrl(registryUrl, registeredProviderUrl, register);
exporter.setRegistered(register);
Similarly, ExporterChangeableWrapper.register() should probably avoid keeping its atomic registered flag set when registration returns false or throws. Otherwise, later manual register/re-register logic may incorrectly believe registration has already succeeded.
Could we propagate the actual registration outcome into these recorded states and add regression coverage for these paths? In particular, it would be helpful to cover a realistic FailbackRegistry path where doRegister() fails under check=false but Registry.register() returns normally, since the current failure coverage appears to focus on the direct-throwing Registry.register() path.
@SavitarC PTAL