apache / apache/fluss

[fluss-server] Fix replicasOnOffline deadlock in addFetcherForReplicas

Open Beginner friendly
#3,011 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
2.1k
Forks
625
Avg merge
3d 14h
Merged PRs (30d)
97

Description

### Search before asking

- [x] I searched in the [issues](https://github.com/apache/fluss/issues) and found nothing similar.

### Fluss version

0.9.0 (latest release)

### Please describe the bug 🐞

When a tablet server receives a `NotifyLeaderAndIsr` request for a bucket with no elected leader (`leaderId == null`), the original code threw a `STORAGE_EXCEPTION`. The coordinator then marked that replica as offline via `replicasOnOffline`. Since `isReplicaOnline()` excludes replicas in the offline set, subsequent elections could never select these replicas as leader — causing a permanent no-leader state.

### Solution

Replace the error branch with a guard condition (`leaderId != null && leaderId >= 0`). When no valid leader exists, skip fetcher setup silently and let the next `LeaderAndIsr` notification recover naturally.

### Are you willing to submit a PR?

- [x] I'm willing to submit a PR!

Contributor guide

No contributing guide indexed for this repository

Research direction

Start at the addFetcherForReplicas entry point in the Fluss server code and trace how NotifyLeaderAndIsr handles a bucket with no elected leader. Replace the error path with the stated validity guard so replicas are not marked offline and fetcher setup is skipped for an invalid leader. Confirm that a later LeaderAndIsr notification can recover the replica without a permanent no-leader state.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.