git: 9front

Download patch

ref: de6910039a959291afd52305c99d15b836765990
parent: 8078f9f84fcfe433019b900b3defc2248517351f
author: Ori Bernstein <ori@eigenstate.org>
date: Sat Oct 25 15:40:57 EDT 2025

gefs: handle edge case when keys in split change size 

--- a/sys/src/cmd/gefs/tree.c
+++ b/sys/src/cmd/gefs/tree.c
@@ -1103,7 +1103,15 @@
 		p--;
 	}
 	while(p != path){
-		if(!filledpiv(p->b, 1)){
+		/*
+		 * While we will add at most one key to a tree,
+		 * we can mutate the children so that we end up
+		 * replacing small nodes with large ones; as a
+		 * result we need to be a bit more conservative
+		 * here, and split earlier than we may otherwise
+		 * want to do.
+		 */
+		if(!filledpiv(p->b, 2)){
 			trybalance(t, p, pp, p->idx);
 			/* If we merged the root node, break out. */
 			if(up == path && pp != nil && pp->op == POmerge && p->b->nval == 2){
--