Skip to content

Commit

Permalink
Fix Race (#13)
Browse files Browse the repository at this point in the history
* reverse iterator init

* some fixes

* fix reverse iterator seaklowerbound

* fix tests

* fix track channels

* longest prefix on txn

* some fixes

* revisit

* todo revisit

* major code refactor

* some minor fixes

* add lru

* fix bugs

* added walk func

* add more tests

* some prog

* some progress track mutate

* some progress

* fix tests

* some optimizations

* some memory optimizations

* fix tests

* minor fixes

* some minor fixes

* some fixes

* fix delete prefix

* some fixes

* init stack

* fix seek lower bound

* clone

* fix watch

* fix clone bug

* some fixes for go mem db

* merge absl

* Fix race

* fix go mod

* fix race in add child

* fix last memdb test

* clone

* fix memdb last tests

* fix race
  • Loading branch information
absolutelightning authored May 23, 2024
1 parent fcb7feb commit 7472862
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions txn.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,11 +151,12 @@ func (t *Txn[T]) recursiveInsert(node Node[T], key []byte, value T, depth int, o
if child != nil {
newChildChClone := t.writeNode(child)
newChild, val := t.recursiveInsert(newChildChClone, key, value, depth+1, old)
node.setChild(idx, newChild)
nodeClone := t.writeNode(node)
nodeClone.setChild(idx, newChild)
if t.trackMutate {
t.trackChannel(node.getMutateCh())
}
return node, val
return nodeClone, val
}

// No child, node goes within us
Expand Down Expand Up @@ -202,11 +203,12 @@ func (t *Txn[T]) recursiveInsert(node Node[T], key []byte, value T, depth int, o
child, idx := t.findChild(node, key[depth])
if child != nil {
newChild, val := t.recursiveInsert(child, key, value, depth+1, old)
node.setChild(idx, newChild)
nodeClone := t.writeNode(node)
nodeClone.setChild(idx, newChild)
if t.trackMutate {
t.trackChannel(node.getMutateCh())
}
return node, val
return nodeClone, val
}
}

Expand Down

0 comments on commit 7472862

Please sign in to comment.