0
0

Merge pull request #297 from aybabtme/firestorm-dont-gc-if-no-documents

Firestorm: dont gc if no documents
This commit is contained in:
Marty Schoch 2015-12-25 11:23:49 -08:00
commit 8ae2aee0bc
2 changed files with 18 additions and 0 deletions

View File

@ -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()

View File

@ -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()
}