Fix race in gc sweep

Removes extra goroutine and calls removal and scan in same thread

Signed-off-by: Derek McGowan <derek@mcgstyle.net>
This commit is contained in:
Derek McGowan
2017-10-27 13:12:58 -07:00
parent e2f9fbfe71
commit 432670237c
4 changed files with 42 additions and 46 deletions

View File

@@ -242,16 +242,11 @@ func TestMetadataCollector(t *testing.T) {
var actual []gc.Node
if err := mdb.View(func(tx *bolt.Tx) error {
nodeC := make(chan gc.Node)
var scanErr error
go func() {
defer close(nodeC)
scanErr = scanAll(ctx, tx, nodeC)
}()
for node := range nodeC {
scanFn := func(ctx context.Context, node gc.Node) error {
actual = append(actual, node)
return nil
}
return scanErr
return scanAll(ctx, tx, scanFn)
}); err != nil {
t.Fatal(err)
}