Skip to content

[v26.1.x] c/scheduling: fix allocation underflow on no-op reallocate#31116

Open
vbotbuildovich wants to merge 5 commits into
redpanda-data:v26.1.xfrom
vbotbuildovich:ai-backport-pr-31071-v26.1.x-1784135681
Open

[v26.1.x] c/scheduling: fix allocation underflow on no-op reallocate#31116
vbotbuildovich wants to merge 5 commits into
redpanda-data:v26.1.xfrom
vbotbuildovich:ai-backport-pr-31071-v26.1.x-1784135681

Conversation

@vbotbuildovich

Copy link
Copy Markdown
Collaborator

Backport of PR #31071

  • Command: git cherry-pick -x f2694e9 939fb1b 4024162 3b8d9c0 7d32db4
  • Commits backported: 5
  • Conflicts resolved: 1
  • Commits skipped (already on target): 0
  • Backport branch: ai-backport-pr-31071-v26.1.x-1784135681

Conflict details

  • 939fb1b (src/v/cluster/scheduling/types.cc): the include block diverged — the target branch has #include "cluster/logger.h" where dev had #include "base/format_to.h". Resolved by keeping the target's cluster/logger.h and adding the commit's new #include "base/vassert.h" (required by the new original_node2shard methods), ordered alphabetically to satisfy clang-format.

Adds unit tests for allocated partition.
Why?
We found a bug in it that could reasonably have been caught with unit
test coverage.

(cherry picked from commit f2694e9)
Adds a convenience wrapper on allocated partition's _original_node2shard
map.

There is a nuance in the logic where nullopt is not the same as empty
which is not terribly apparent to a code reader.

This change allows for the mistake to be self evident.

(cherry picked from commit 939fb1b)
Regression test which simulates what happens when a reallocate is called
with the same replication factor that the partition had prior.

The long and short: allocated partition would mistakenly consider all
replicas on the partition to be new replicas, and delete all of the
allocations.

This would eventually bubble up as a node crash on double freed
allocations.

(cherry picked from commit 4024162)
Fixes the logic for yielding new replicas, if there were no changes,
there are very clearly no new replicas.

(cherry picked from commit 3b8d9c0)
Use is_original() + one pass instead of find/erase scratch; get() is now
only used for full iteration.

(cherry picked from commit 7d32db4)
@vbotbuildovich vbotbuildovich added this to the v26.1.x-next milestone Jul 15, 2026
@vbotbuildovich vbotbuildovich added the kind/backport PRs targeting a stable branch label Jul 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/build area/redpanda kind/backport PRs targeting a stable branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants