-
Notifications
You must be signed in to change notification settings - Fork 834
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ctrie data race #122
Comments
Thanks, will need to take a closer look, but that probably needs to be an On Thu, Dec 24, 2015, 11:59 AM Matthew Newhook notifications@github.com
|
I made that fix locally, but I'm still getting very occasional crashes in a highly concurrent test case.
|
If you have a test which can reproduce semi reliably that would be great. On Thu, Dec 24, 2015, 3:15 PM Matthew Newhook notifications@github.com
|
The test is part of something much larger. I'll try and reproduce in something small. |
I haven't hit the nil pointer issue, but there definitely appears to be an issue with snapshotting (don't know if it's related to your issue or not). I ran the following program which gives the correct output unless the two goroutines are commented out and the wg is adjusted accordingly. package main
import (
"fmt"
"strconv"
"sync"
"github.com/Workiva/go-datastructures/trie/ctrie"
)
func main() {
trie := ctrie.New(nil)
var wg sync.WaitGroup
wg.Add(2)
go func() {
for i := 0; i < 1000000; i++ {
trie.Insert([]byte(strconv.Itoa(i)), i)
}
wg.Done()
}()
go func() {
for i := 0; i < 1000000; i++ {
trie.Lookup([]byte(strconv.Itoa(i)))
}
wg.Done()
}()
//go func() {
// for i := 0; i < 1000000; i++ {
// trie.Snapshot()
// }
// wg.Done()
//}()
//go func() {
// for i := 0; i < 1000000; i++ {
// trie.ReadOnlySnapshot()
// }
// wg.Done()
//}()
wg.Wait()
i := 1
for _ = range trie.Iterator(nil) {
fmt.Println(i)
i++
}
fmt.Println("size", trie.Size())
} |
I have a branch with a few fixes, but snapshotting is still broken: https://github.com/tylertreat/go-datastructures/tree/fixes Simpler test: package main
import (
"fmt"
"strconv"
"sync"
"github.com/Workiva/go-datastructures/trie/ctrie"
)
func main() {
trie := ctrie.New(nil)
var wg sync.WaitGroup
wg.Add(2)
go func() {
for i := 0; i < 7; i++ {
trie.Insert([]byte(strconv.Itoa(i)), i)
}
wg.Done()
}()
go func() {
for i := 0; i < 7; i++ {
trie.Snapshot()
}
wg.Done()
}()
wg.Wait()
fmt.Println("size", trie.Size())
} Expected size is 7, but if you run it enough times you should see values less than 7 occasionally. |
Issue appears to be with GCAS. I made an incorrect assumption from Java (where |
I believe I have it fixed with this: https://github.com/Workiva/go-datastructures/compare/master...tylertreat:fixes?expand=1. I haven't been able to reproduce after applying those fixes. @newhook can you confirm this branch fixes your problem? |
Awesome! I'll check on Tuesday :) |
I just got a report of data race in the ctrie impl on committed.
The text was updated successfully, but these errors were encountered: