mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-08-28 10:54:59 +00:00
add a test case which breaks the rowcache code
It turns out that frozen containers which have mmapped data are only safe *until the data gets unmapped*. Which it does on a snapshot.
This commit is contained in:
parent
f09c3ebf7c
commit
636f132564
1 changed files with 39 additions and 0 deletions
|
|
@ -26,6 +26,7 @@ import (
|
|||
"os"
|
||||
"reflect"
|
||||
"sort"
|
||||
"sync/atomic"
|
||||
"testing"
|
||||
"testing/quick"
|
||||
|
||||
|
|
@ -104,6 +105,44 @@ func TestFragment_ClearBit(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
// What about rowcache timing.
|
||||
func TestFragment_RowcacheMap(t *testing.T) {
|
||||
var done int64
|
||||
f := mustOpenFragment("i", "f", viewStandard, 0, "")
|
||||
defer f.Clean(t)
|
||||
|
||||
ch := make(chan struct{})
|
||||
|
||||
for i := 0; i < f.MaxOpN; i++ {
|
||||
f.setBit(0, uint64(i*32))
|
||||
}
|
||||
// force snapshot so we get a mmapped row...
|
||||
f.snapshot()
|
||||
row := f.row(0)
|
||||
segment := row.Segments()[0]
|
||||
bitmap := segment.data
|
||||
|
||||
// request information from the frozen bitmap we got back
|
||||
go func() {
|
||||
for atomic.LoadInt64(&done) == 0 {
|
||||
for i := 0; i < f.MaxOpN; i++ {
|
||||
_ = bitmap.Contains(uint64(i * 32))
|
||||
}
|
||||
}
|
||||
close(ch)
|
||||
}()
|
||||
|
||||
// modify the original bitmap, until it causes a snapshot, which
|
||||
// then invalidates the other map...
|
||||
for j := 0; j < 5; j++ {
|
||||
for i := 0; i < f.MaxOpN; i++ {
|
||||
f.setBit(0, uint64(i*32+j+1))
|
||||
}
|
||||
}
|
||||
atomic.StoreInt64(&done, 1)
|
||||
<-ch
|
||||
}
|
||||
|
||||
// Ensure a fragment can clear a row.
|
||||
func TestFragment_ClearRow(t *testing.T) {
|
||||
f := mustOpenFragment("i", "f", viewStandard, 0, "")
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue