SiriusTL666 opened a new pull request, #16542:
URL: https://github.com/apache/dubbo/pull/16542
## What is the purpose of this PR?
Bound the connect timeout of the liveness probe used when expiring multicast
providers.
## Background
`MulticastRegistry.isExpired()` decides whether a provider has gone away by
opening a TCP connection to it:
```java
try (Socket socket = new Socket(url.getHost(), url.getPort())) {
```
`new Socket(host, port)` applies **no connect timeout**, so the call blocks
until the OS-level TCP timeout. `clean()` calls `isExpired()` for **every**
provider in the multicast group, from a single scheduled thread
(`DubboMulticastRegistryCleanTimer`). A provider that crashed without sending
RST, dropped off the network, or sits behind a filtering firewall therefore
stalls expiry handling for every other provider for tens of seconds — and the
probe runs twice per provider with a 100ms sleep between, so the cost
multiplies quickly.
## What is the enhancement?
- Route both probes through `isPortReachable`, which uses `connect(address,
timeout)`.
- The timeout comes from the registry URL (`TIMEOUT_KEY`,
`DEFAULT_TIMEOUT`), so it can be tuned per registry without a code change.
- Restore the interrupt flag if the retry sleep is interrupted, instead of
swallowing `InterruptedException`.
- Make `isExpired` package-private so it can be tested directly.
**Probe semantics are unchanged**: two attempts 100ms apart, and the
provider is treated as expired only if both fail. Only the wait is now bounded.
## Does this PR introduce a breaking change?
No. Default timeout is the existing `DEFAULT_TIMEOUT` from `CommonConstants`.
## Verification
Built and tested with JDK 17:
- `mvn -pl dubbo-registry/dubbo-registry-multicast test` — **16/16 pass**
(15 in `MulticastRegistryTest`, 1 in `MulticastRegistryFactoryTest`).
Three new tests: bounded behaviour for an unreachable provider, no false
positive for a reachable port, and the existing skip rules (non-dynamic,
consumer protocol).
The bounded-timeout test was verified in both directions:
| Code | `isExpired` elapsed |
|---|---|
| `connect(address, 0)` (before) | **42168 ms**, test fails |
| `connect(address, cleanCheckTimeout)` | passes; the whole suite runs in
~30s |
## Additional context
No existing issue covers this; I found it while auditing Apache projects for
unbounded network waits. Happy to file an issue first if the project prefers
that.
Note for anyone building locally: javac's `@argfile` handling fails when the
repository sits under a path containing non-ASCII characters, and the
maven-compiler-plugin reports it only as a bare "Compilation failure" with no
diagnostics. A pure-ASCII checkout path works.
--
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]