Skip to content

Commit 0542a5e

Browse files
authored
Merge pull request ceph#64714 from chanyoung/fix-rebalancing-assertion
crimson/.../linked_tree_node: fix pivot_idx assertion in balancing Reviewed-by: Xuehan Xu <[email protected]>
2 parents f3dc256 + 5bec6b8 commit 0542a5e

File tree

4 files changed

+27
-1
lines changed

4 files changed

+27
-1
lines changed

src/crimson/os/seastore/btree/fixed_kv_node.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,8 @@ struct FixedKVInternalNode
349349
auto replacement_right = c.cache.template alloc_new_non_data_extent<node_type_t>(
350350
c.trans, node_size, placement_hint_t::HOT, INIT_GENERATION);
351351

352+
// We should do full merge if pivot_idx == right.get_size().
353+
ceph_assert(pivot_idx != right.get_size());
352354
this->balance_child_ptrs(
353355
c.trans,
354356
static_cast<node_type_t&>(*this),

src/crimson/os/seastore/lba/lba_btree_node.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,8 @@ struct LBALeafNode
266266
uint32_t pivot_idx,
267267
LBALeafNode &replacement_left,
268268
LBALeafNode &replacement_right) final {
269+
// We should do full merge if pivot_idx == right.get_size().
270+
ceph_assert(pivot_idx != right.get_size());
269271
this->balance_child_ptrs(
270272
t, left, right, pivot_idx, replacement_left, replacement_right);
271273
}

src/crimson/os/seastore/linked_tree_node.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -655,7 +655,7 @@ class ParentNode {
655655
size_t l_size = left.get_size();
656656
size_t r_size = right.get_size();
657657

658-
ceph_assert(pivot_idx != l_size && pivot_idx != r_size);
658+
ceph_assert(pivot_idx != l_size);
659659
replacement_left.maybe_expand_children(pivot_idx);
660660
replacement_right.maybe_expand_children(r_size + l_size - pivot_idx);
661661

src/test/crimson/seastore/test_omap_manager.cc

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -837,6 +837,28 @@ TEST_P(omap_manager_test_t, full_range_list)
837837
});
838838
}
839839

840+
TEST_P(omap_manager_test_t, increasing_key_size)
841+
{
842+
// reproduces https://tracker.ceph.com/issues/72303
843+
run_async([this] {
844+
omap_root_t omap_root = initialize();
845+
846+
for (int i = 0; i < 1000; i++) {
847+
auto t = create_mutate_transaction();
848+
std::string key(i, 'A');
849+
set_key(omap_root, *t, key, rand_buffer(1024));
850+
submit_transaction(std::move(t));
851+
}
852+
check_mappings(omap_root);
853+
854+
while (test_omap_mappings.size() > 0) {
855+
auto t = create_mutate_transaction();
856+
rm_key(omap_root, *t, test_omap_mappings.begin()->first);
857+
submit_transaction(std::move(t));
858+
}
859+
});
860+
}
861+
840862
INSTANTIATE_TEST_SUITE_P(
841863
omap_manager_test,
842864
omap_manager_test_t,

0 commit comments

Comments
 (0)