mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-08-28 10:54:59 +00:00
only set bits after the holder is completely setup
This should help prevent a data race. SetBit can, in some cases, cause an asynchronous task to run which tries to update the stats counter. But if that task runs while we are modifying the stats counter itself, we have a data race.
This commit is contained in:
parent
6b23925bd7
commit
45633e23a5
1 changed files with 6 additions and 5 deletions
|
|
@ -81,11 +81,6 @@ func TestStatsCount_TopN(t *testing.T) {
|
|||
defer c.Close()
|
||||
hldr := test.Holder{Holder: c.GetNode(0).Server.Holder()}
|
||||
|
||||
hldr.SetBit("d", "f", 0, 0)
|
||||
hldr.SetBit("d", "f", 0, 1)
|
||||
hldr.SetBit("d", "f", 0, pilosa.ShardWidth)
|
||||
hldr.SetBit("d", "f", 0, pilosa.ShardWidth+2)
|
||||
|
||||
// Execute query.
|
||||
called := false
|
||||
hldr.Holder.Stats = &MockStats{
|
||||
|
|
@ -101,6 +96,12 @@ func TestStatsCount_TopN(t *testing.T) {
|
|||
called = true
|
||||
},
|
||||
}
|
||||
|
||||
hldr.SetBit("d", "f", 0, 0)
|
||||
hldr.SetBit("d", "f", 0, 1)
|
||||
hldr.SetBit("d", "f", 0, pilosa.ShardWidth)
|
||||
hldr.SetBit("d", "f", 0, pilosa.ShardWidth+2)
|
||||
|
||||
if _, err := c.GetNode(0).API.Query(context.Background(), &pilosa.QueryRequest{Index: "d", Query: `TopN(field=f, n=2)`}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue