services/mounttable/btmtd: Fix bug with concurrent createChild

When createChild() is called concurrently, it is possible to leave an
incorrect reference in the parent, e.g.

createChild1 --> insert child with ts1 in parent
 createChild2 --> insert child with ts2 in parent

createChild1 --> Create child row with ts1
 createChild2 --> Create child row wth ts2 (Fails, already exists)

OR,

createChild1 --> insert child with ts1 in parent
 createChild2 --> insert child with ts2 in parent

 createChild2 --> Create child row wth ts2
createChild1 --> Create child row with ts1 (Fails, already exists)

When createChild1 or createChild2 fails, the reference in the parent
for ts1 or ts2 was left behind. The fix is to delete that reference when
the row creation fails.

https://github.com/vanadium/build/issues/88

Change-Id: I9947ef2459550636ce0bc7ec3f8c1766f789bbec
diff --git a/services/mounttable/btmtd/internal/node.go b/services/mounttable/btmtd/internal/node.go
index ffb96c1..b83da7b 100644
--- a/services/mounttable/btmtd/internal/node.go
+++ b/services/mounttable/btmtd/internal/node.go
@@ -149,6 +149,11 @@
 	longCtx, cancel := longTimeout(ctx)
 	defer cancel()
 	if err := n.bt.createRow(longCtx, childName, perms, creator, ts, limit); err != nil {
+		mut = bigtable.NewMutation()
+		mut.DeleteTimestampRange(childrenFamily, child, ts, n.bt.timeNext(ts))
+		if err := n.bt.apply(ctx, rowKey(n.name), mut); err != nil {
+			ctx.Errorf("Failed to delete child reference. Parent=%q Child=%q Err=%v", n.name, child, err)
+		}
 		return nil, err
 	}
 	n, err := getNode(ctx, n.bt, childName)