Merge pull request #297 from aybabtme/firestorm-dont-gc-if-no-documents
Firestorm: dont gc if no documents
This commit is contained in:
commit
8ae2aee0bc
|
@ -76,6 +76,9 @@ func (gc *GarbageCollector) run() {
|
|||
logger.Printf("garbage collector error getting doc count: %v", err)
|
||||
continue
|
||||
}
|
||||
if docSize == 0 {
|
||||
continue
|
||||
}
|
||||
garbageRatio := int(uint64(garbageSize) / docSize)
|
||||
if garbageRatio > gc.garbageThreshold {
|
||||
gc.cleanup()
|
||||
|
|
|
@ -11,6 +11,7 @@ package firestorm
|
|||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/blevesearch/bleve/index"
|
||||
"github.com/blevesearch/bleve/index/store/gtreap"
|
||||
|
@ -115,3 +116,17 @@ func TestGarbageCleanup(t *testing.T) {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
func TestGarbageDontPanicOnEmptyDocs(t *testing.T) {
|
||||
idx, err := NewFirestorm("", nil, index.NewAnalysisQueue(1))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
f := idx.(*Firestorm)
|
||||
gc := NewGarbageCollector(f)
|
||||
gc.garbageSleep = 30 * time.Millisecond
|
||||
|
||||
gc.Start()
|
||||
time.Sleep(40 * time.Millisecond)
|
||||
gc.Stop()
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user