Browse Source

Extract appending from goroutine.

pull/84/head
Matt T. Proud 12 years ago
parent
commit
47ce7ad302
  1. 6
      storage/metric/leveldb.go

6
storage/metric/leveldb.go

@ -540,7 +540,6 @@ func (l *LevelDBMetricPersistence) AppendSamples(samples model.Samples) (err err
var (
fingerprintToSamples = groupByFingerprint(samples)
indexErrChan = make(chan error)
doneCommitting sync.WaitGroup
)
go func(groups map[model.Fingerprint]model.Samples) {
@ -555,11 +554,8 @@ func (l *LevelDBMetricPersistence) AppendSamples(samples model.Samples) (err err
indexErrChan <- l.indexMetrics(metrics)
}(fingerprintToSamples)
go func() {
doneCommitting.Add(1)
samplesBatch := leveldb.NewBatch()
defer samplesBatch.Close()
defer doneCommitting.Done()
for fingerprint, group := range fingerprintToSamples {
for {
@ -601,9 +597,7 @@ func (l *LevelDBMetricPersistence) AppendSamples(samples model.Samples) (err err
if err != nil {
panic(err)
}
}()
doneCommitting.Wait()
err = <-indexErrChan
if err != nil {
panic(err)

Loading…
Cancel
Save