Skip to content

Commit

Permalink
DAOS-17148 common: btree delete may move target out of boundary - b26
Browse files Browse the repository at this point in the history
During btr_node_del_rec(), if the record to be deleted from current
node is the last one, the logic will try to migrate one record from
its sibling node. If current node is at the tail position in parent
node, original logic may migrate an invalid record from a non-exist
sibling node on the right. That may cause kinds of corruption since
the content in such invalid record is undefined.

Signed-off-by: Fan Yong <[email protected]>
  • Loading branch information
Nasf-Fan committed Feb 21, 2025
1 parent 0919f60 commit 5bb8293
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/common/btree.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/**
* (C) Copyright 2016-2024 Intel Corporation.
* (C) Copyright 2025 Hewlett Packard Enterprise Development LP
*
* SPDX-License-Identifier: BSD-2-Clause-Patent
*/
Expand Down Expand Up @@ -3152,12 +3153,13 @@ btr_node_del_rec(struct btr_context *tcx, struct btr_trace *par_tr,
D_DEBUG(DB_TRACE, "Parent trace at=%d, key_nr=%d\n",
par_tr->tr_at, par_nd->tn_keyn);

D_ASSERT(par_tr->tr_at < par_nd->tn_keyn);

if (par_tr->tr_at == 0) {
/* only has sibling on the right side */
sib_off = btr_node_child_at(tcx, par_tr->tr_node, 1);
sib_on_right = true;

} else if (par_tr->tr_at == par_nd->tn_keyn) {
} else if (par_tr->tr_at == par_nd->tn_keyn - 1) {
/* only has sibling on the left side */
sib_off = btr_node_child_at(tcx, par_tr->tr_node,
par_tr->tr_at - 1);
Expand Down

0 comments on commit 5bb8293

Please sign in to comment.