[v26.1.x] c/scheduling: fix allocation underflow on no-op reallocate#31116
Open
vbotbuildovich wants to merge 5 commits into
Open
[v26.1.x] c/scheduling: fix allocation underflow on no-op reallocate#31116vbotbuildovich wants to merge 5 commits into
vbotbuildovich wants to merge 5 commits into
Conversation
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)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Backport of PR #31071
Conflict details
#include "cluster/logger.h"where dev had#include "base/format_to.h". Resolved by keeping the target'scluster/logger.hand adding the commit's new#include "base/vassert.h"(required by the neworiginal_node2shardmethods), ordered alphabetically to satisfy clang-format.