[Indexes] Buffer Managed Indexes Part 4: Segment Handles for Base Leaf#19303
[Indexes] Buffer Managed Indexes Part 4: Segment Handles for Base Leaf#19303Mytherin merged 2 commits intoduckdb:mainfrom
Conversation
taniabogatsch
left a comment
There was a problem hiding this comment.
Hi @artjomPlaunov, thanks for picking up the work on the buffer-managed indexes! The PR looks good, the only thing I've commented on is the scoping of the node handles. If I saw correctly, most of the Insert-and Delete-functions still need that. Then it should be good to go!
| NodeHandle<Node7Leaf> handle(art, node); | ||
| auto &n7 = handle.Get(); | ||
| if (n7.count == CAPACITY) { | ||
| auto node7 = node; | ||
| Node15Leaf::GrowNode7Leaf(art, node, node7); | ||
| Node15Leaf::InsertByte(art, node, byte); | ||
| return; | ||
| } |
There was a problem hiding this comment.
We likely need to change the logic here slightly, similar to what the BaseNode does (via n7.count != CAPACITY). If we look at BaseNode::InsertChild, the scope of the NodeHandle ends before growing the node. That way, we don't hold on to a node whose memory changes while growing.
{
NodeHandle<Node4> handle(art, node);
auto &n = handle.Get();
if (n.count != CAPACITY) {
InsertChildInternal(n, byte, child);
return;
}
}
// The node is full.
// Grow to Node16.
auto node4 = node;
Node16::GrowNode4(art, node, node4);
Node16::InsertChild(art, node, byte, child);There was a problem hiding this comment.
Thank you for catching that, I will add the changes.
| auto n7_handle = DeleteByteInternal(art, node, byte); | ||
| auto &n7 = n7_handle.Get(); |
There was a problem hiding this comment.
Similarly, we need to scope the NodeHandle here, to avoid holding on to memory that is being compressed as part of the one-way node compression. For reference, see Node4::DeleteChild.
| n7.key[i] = n15.key[i]; | ||
| } | ||
|
|
||
| Node::FreeNode(art, node15_leaf); |
There was a problem hiding this comment.
I think freeing will try to grab the same node handle, so we should also add scope here. I.e., we destroy the handle before we destroy the node memory. See Node4::ShrinkNode16.
faf56e9 to
d88a594
Compare
taniabogatsch
left a comment
There was a problem hiding this comment.
Looks good now, thanks!!
d88a594 to
7d59af0
Compare
7d59af0 to
a44547d
Compare
|
Thanks! |
[Indexes] Buffer Managed Indexes Part 4: Segment Handles for Base Leaf (duckdb/duckdb#19303) Internal duckdb/duckdb#6190: AsOf Threading (duckdb/duckdb#19328)
[Indexes] Buffer Managed Indexes Part 4: Segment Handles for Base Leaf (duckdb/duckdb#19303) Internal duckdb/duckdb#6190: AsOf Threading (duckdb/duckdb#19328)
Follow up PR to: #18567
Related issue: https://github.com/duckdblabs/duckdb-internal/issues/2103