0
0

moss lowerLevelUpdate didn't handle batches of size 1

This commit is contained in:
Steve Yen 2016-03-11 15:47:09 -08:00
parent e76b1dd8f3
commit c1597842d0
2 changed files with 15 additions and 8 deletions

View File

@ -55,9 +55,11 @@ func initLowerLevelStore(
}
llStore := &llStore{
refs: 0,
kvStore: kvStore,
logf: logf,
refs: 0,
config: config,
llConfig: lowerLevelStoreConfig,
kvStore: kvStore,
logf: logf,
}
llUpdate := func(ssHigher moss.Snapshot) (ssLower moss.Snapshot, err error) {
@ -80,6 +82,9 @@ func initLowerLevelStore(
type llStore struct {
kvStore store.KVStore
config map[string]interface{}
llConfig map[string]interface{}
logf func(format string, a ...interface{})
m sync.Mutex // Protects fields that follow.
@ -219,6 +224,8 @@ func (s *llStore) update(ssHigher moss.Snapshot, maxBatchSize uint64) (
" unexpected operation, ex: %v", ex)
}
i++
err = iter.Next()
if err == moss.ErrIteratorDone {
break
@ -240,19 +247,19 @@ func (s *llStore) update(ssHigher moss.Snapshot, maxBatchSize uint64) (
batch = kvWriter.NewBatch()
}
i++
}
if i > 0 {
s.logf("llStore.update, total: %d, ExecuteBatch: ...", i)
s.logf("llStore.update, ExecuteBatch,"+
" path: %s, total: %d, start", s.llConfig["path"], i)
err = kvWriter.ExecuteBatch(batch)
if err != nil {
return nil, err
}
s.logf("llStore.update, total: %d, ExecuteBatch: done", i)
s.logf("llStore.update, ExecuteBatch,"+
" path: %s: total: %d, done", s.llConfig["path"], i)
}
}

View File

@ -82,7 +82,7 @@ func New(mo store.MergeOperator, config map[string]interface{}) (
// --------------------------------------------------
if options.Log == nil {
if options.Log == nil || options.Debug <= 0 {
options.Log = func(format string, a ...interface{}) {}
}