apache / apache/shenyu

[BUG] Consul instance watch task can stop after one polling error

Open Beginner friendly
#6,499 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
8.8k
Forks
3.1k
Avg merge
7d 1h
Merged PRs (30d)
85

Description

### Current Behavior

Consul instance watch tasks can stop after a transient Consul error.

`ConsulInstanceRegisterRepository.watcherStart()` schedules `watchConfigKeyValues(selectKey)` with `scheduleWithFixedDelay(...)`:

```java
watchFutures.add(this.executor.scheduleWithFixedDelay(
() -> this.watchConfigKeyValues(selectKey), 5, Integer.parseInt(watchDelay), TimeUnit.SECONDS));
```

`watchConfigKeyValues()` calls `getHealthServices(...)`, which performs the Consul blocking query. Neither the scheduled lambda nor `watchConfigKeyValues()` catches exceptions. If the Consul request fails, the exception escapes the fixed-delay task and later executions are suppressed by the scheduler.

### Expected Behavior

A failed Consul watch poll should be logged and retried on the next delay interval.

### Impact

After one transient Consul watch failure, the local `watcherInstanceRegisterMap` may stop receiving instance updates for that select key until the process restarts or the watch is re-created.

### Code Location

- `shenyu-registry/shenyu-registry-consul/src/main/java/org/apache/shenyu/registry/consul/ConsulInstanceRegisterRepository.java`
- `watcherStart()` schedules the fixed-delay watch task.
- `watchConfigKeyValues()` and `getHealthServices()` allow exceptions from Consul calls to escape.

Contributor guide

No contributing guide indexed for this repository

Research direction

Read shenyu-registry/shenyu-registry-consul/src/main/java/org/apache/shenyu/registry/consul/ConsulInstanceRegisterRepository.java, starting with watcherStart(), watchConfigKeyValues(), and getHealthServices(). Confirm how scheduleWithFixedDelay handles an escaping exception, then verify that a failed Consul poll is logged and the same watch runs again after the next delay interval.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
76/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.