Skip to content

branch-3.1: [fix](load) fix quorum success invalid in move-memtable-on-sink load path #60681Fix quorum sucess 3.1#62824

Open
liutang123 wants to merge 1 commit intoapache:branch-3.1from
liutang123:fix_quorum_sucess-3.1
Open

branch-3.1: [fix](load) fix quorum success invalid in move-memtable-on-sink load path #60681Fix quorum sucess 3.1#62824
liutang123 wants to merge 1 commit intoapache:branch-3.1from
liutang123:fix_quorum_sucess-3.1

Conversation

@liutang123
Copy link
Copy Markdown
Contributor

Cherry-picked from #60681

…path (apache#60681)

## Description

In `VTabletWriterV2`, the `_quorum_success()` function always returns
`false` even when
all streams have finished successfully, making the quorum success write
feature effectively
non-functional.

## Root Cause

In both `_build_tablet_node_mapping()` and
`_incremental_open_streams()`,
`_tablets_by_node[node].emplace(tablet_id)` is guarded by the
`known_indexes` check:

```cpp
if (known_indexes.contains(index.index_id)) [[likely]] {
    continue;
}
_indexes_from_node[node].emplace_back(tablet);
_tablets_by_node[node].emplace(tablet_id);
known_indexes.insert(index.index_id);
```

The known_indexes set is shared across all partitions, tablets, and
nodes. Once an
index_id is inserted after processing the first tablet's first node, all
subsequent
tablets (and all other nodes of the same tablet) with the same index_id
skip the
_tablets_by_node update.

For example, with 1 index, 3 tablets [T1, T2, T3], and 3 replicas [N1,
N2, N3]:

Only _tablets_by_node[N1] = {T1} gets populated
T1 on N2/N3, and T2/T3 on all nodes are skipped
This causes _quorum_success() to compute finished_tablets_replica
incorrectly:

finished_tablets_replica[T1] = 1 (only counted from N1)
finished_tablets_replica[T2] = 0, finished_tablets_replica[T3] = 0
With a quorum requirement of 2 (for 3 replicas), the check always fails.

The known_indexes optimization was intended only for _indexes_from_node
(to avoid
sending duplicate schema info per index), but it incorrectly also
blocked the
_tablets_by_node population.

Note: vtablet_writer.cpp does NOT have this issue — its
_tablets_by_channel is
populated without the known_indexes guard.

## Fix
Move _tablets_by_node[node].emplace(tablet_id) before the known_indexes
check in
both _build_tablet_node_mapping() and _incremental_open_streams(), so
that every
tablet on every node is correctly recorded.
@hello-stephen
Copy link
Copy Markdown
Contributor

Thank you for your contribution to Apache Doris.
Don't know what should be done next? See How to process your PR.

Please clearly describe your PR:

  1. What problem was fixed (it's best to include specific error reporting information). How it was fixed.
  2. Which behaviors were modified. What was the previous behavior, what is it now, why was it modified, and what possible impacts might there be.
  3. What features were added. Why was this function added?
  4. Which code was refactored and why was this part of the code refactored?
  5. Which functions were optimized and what is the difference before and after the optimization?

@liutang123 liutang123 changed the base branch from master to branch-3.1 April 24, 2026 11:39
@liutang123 liutang123 requested a review from morrySnow as a code owner April 24, 2026 11:39
@liutang123
Copy link
Copy Markdown
Contributor Author

run buildall

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants