2021-07-22 09:11:49 +00:00
|
|
|
package splitstore
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
"path/filepath"
|
2022-02-02 12:29:26 +00:00
|
|
|
"runtime"
|
2021-07-22 09:11:49 +00:00
|
|
|
"sync"
|
|
|
|
|
|
|
|
"github.com/dgraph-io/badger/v2"
|
2021-07-22 09:27:59 +00:00
|
|
|
"github.com/dgraph-io/badger/v2/options"
|
2022-06-15 10:06:22 +00:00
|
|
|
"github.com/ipfs/go-cid"
|
2022-06-14 15:00:51 +00:00
|
|
|
"go.uber.org/zap"
|
|
|
|
"golang.org/x/xerrors"
|
2023-02-01 19:04:58 +00:00
|
|
|
|
|
|
|
"github.com/filecoin-project/lotus/system"
|
2021-07-22 09:11:49 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type BadgerMarkSetEnv struct {
|
|
|
|
path string
|
|
|
|
}
|
|
|
|
|
|
|
|
var _ MarkSetEnv = (*BadgerMarkSetEnv)(nil)
|
|
|
|
|
|
|
|
type BadgerMarkSet struct {
|
2021-07-22 10:54:50 +00:00
|
|
|
mx sync.RWMutex
|
|
|
|
cond sync.Cond
|
|
|
|
pend map[string]struct{}
|
2021-07-22 11:43:00 +00:00
|
|
|
writing map[int]map[string]struct{}
|
2021-08-10 07:10:12 +00:00
|
|
|
writers int
|
2021-07-22 11:43:00 +00:00
|
|
|
seqno int
|
2021-07-30 21:13:56 +00:00
|
|
|
version int
|
2022-01-28 13:41:33 +00:00
|
|
|
persist bool
|
2021-07-22 09:11:49 +00:00
|
|
|
|
|
|
|
db *badger.DB
|
|
|
|
path string
|
|
|
|
}
|
|
|
|
|
|
|
|
var _ MarkSet = (*BadgerMarkSet)(nil)
|
2021-07-30 06:42:20 +00:00
|
|
|
|
2021-07-22 12:24:30 +00:00
|
|
|
var badgerMarkSetBatchSize = 16384
|
2021-07-22 09:11:49 +00:00
|
|
|
|
|
|
|
func NewBadgerMarkSetEnv(path string) (MarkSetEnv, error) {
|
|
|
|
msPath := filepath.Join(path, "markset.badger")
|
|
|
|
err := os.MkdirAll(msPath, 0755) //nolint:gosec
|
|
|
|
if err != nil {
|
|
|
|
return nil, xerrors.Errorf("error creating markset directory: %w", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
return &BadgerMarkSetEnv{path: msPath}, nil
|
|
|
|
}
|
|
|
|
|
2022-01-28 13:41:33 +00:00
|
|
|
func (e *BadgerMarkSetEnv) New(name string, sizeHint int64) (MarkSet, error) {
|
2021-07-22 09:11:49 +00:00
|
|
|
path := filepath.Join(e.path, name)
|
|
|
|
|
2022-01-28 13:41:33 +00:00
|
|
|
db, err := openBadgerDB(path, false)
|
2021-07-22 09:11:49 +00:00
|
|
|
if err != nil {
|
2021-07-30 08:17:09 +00:00
|
|
|
return nil, xerrors.Errorf("error creating badger db: %w", err)
|
2021-07-22 09:11:49 +00:00
|
|
|
}
|
|
|
|
|
2021-07-22 10:54:50 +00:00
|
|
|
ms := &BadgerMarkSet{
|
2021-07-22 11:43:00 +00:00
|
|
|
pend: make(map[string]struct{}),
|
|
|
|
writing: make(map[int]map[string]struct{}),
|
|
|
|
db: db,
|
|
|
|
path: path,
|
2021-07-22 10:54:50 +00:00
|
|
|
}
|
|
|
|
ms.cond.L = &ms.mx
|
|
|
|
|
|
|
|
return ms, nil
|
2021-07-22 09:11:49 +00:00
|
|
|
}
|
|
|
|
|
2022-01-28 13:41:33 +00:00
|
|
|
func (e *BadgerMarkSetEnv) Recover(name string) (MarkSet, error) {
|
|
|
|
path := filepath.Join(e.path, name)
|
|
|
|
|
2022-01-30 09:44:27 +00:00
|
|
|
if _, err := os.Stat(path); err != nil {
|
|
|
|
return nil, xerrors.Errorf("error stating badger db path: %w", err)
|
|
|
|
}
|
|
|
|
|
2022-01-28 13:41:33 +00:00
|
|
|
db, err := openBadgerDB(path, true)
|
|
|
|
if err != nil {
|
|
|
|
return nil, xerrors.Errorf("error creating badger db: %w", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
ms := &BadgerMarkSet{
|
|
|
|
pend: make(map[string]struct{}),
|
|
|
|
writing: make(map[int]map[string]struct{}),
|
|
|
|
db: db,
|
|
|
|
path: path,
|
|
|
|
persist: true,
|
|
|
|
}
|
|
|
|
ms.cond.L = &ms.mx
|
|
|
|
|
|
|
|
return ms, nil
|
|
|
|
}
|
|
|
|
|
2021-07-22 09:11:49 +00:00
|
|
|
func (e *BadgerMarkSetEnv) Close() error {
|
2022-01-28 13:41:33 +00:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *BadgerMarkSet) BeginCriticalSection() error {
|
|
|
|
s.mx.Lock()
|
2022-01-28 13:55:10 +00:00
|
|
|
|
|
|
|
if s.persist {
|
|
|
|
s.mx.Unlock()
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
var write bool
|
|
|
|
var seqno int
|
|
|
|
if len(s.pend) > 0 {
|
|
|
|
write = true
|
2022-02-09 16:34:50 +00:00
|
|
|
seqno = s.nextBatch()
|
2022-01-28 13:55:10 +00:00
|
|
|
}
|
2022-01-28 13:41:33 +00:00
|
|
|
|
|
|
|
s.persist = true
|
2022-01-28 13:55:10 +00:00
|
|
|
s.mx.Unlock()
|
|
|
|
|
|
|
|
if write {
|
2022-01-30 10:10:08 +00:00
|
|
|
// all writes sync once perist is true
|
2022-01-28 13:55:10 +00:00
|
|
|
return s.write(seqno)
|
|
|
|
}
|
|
|
|
|
2022-01-30 10:10:08 +00:00
|
|
|
// wait for any pending writes and sync
|
|
|
|
s.mx.Lock()
|
|
|
|
for s.writers > 0 {
|
|
|
|
s.cond.Wait()
|
|
|
|
}
|
|
|
|
s.mx.Unlock()
|
|
|
|
|
|
|
|
return s.db.Sync()
|
2022-01-28 13:41:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (s *BadgerMarkSet) EndCriticalSection() {
|
|
|
|
s.mx.Lock()
|
|
|
|
defer s.mx.Unlock()
|
|
|
|
|
|
|
|
s.persist = false
|
2021-07-22 09:11:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (s *BadgerMarkSet) Mark(c cid.Cid) error {
|
|
|
|
s.mx.Lock()
|
|
|
|
if s.pend == nil {
|
2021-07-22 10:47:40 +00:00
|
|
|
s.mx.Unlock()
|
2021-07-22 09:11:49 +00:00
|
|
|
return errMarkSetClosed
|
|
|
|
}
|
|
|
|
|
2021-08-10 07:10:12 +00:00
|
|
|
write, seqno := s.put(string(c.Hash()))
|
|
|
|
s.mx.Unlock()
|
|
|
|
|
|
|
|
if write {
|
|
|
|
return s.write(seqno)
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
2021-07-22 09:11:49 +00:00
|
|
|
}
|
|
|
|
|
2022-01-30 09:27:24 +00:00
|
|
|
func (s *BadgerMarkSet) MarkMany(batch []cid.Cid) error {
|
|
|
|
s.mx.Lock()
|
|
|
|
if s.pend == nil {
|
|
|
|
s.mx.Unlock()
|
|
|
|
return errMarkSetClosed
|
|
|
|
}
|
|
|
|
|
|
|
|
write, seqno := s.putMany(batch)
|
|
|
|
s.mx.Unlock()
|
|
|
|
|
|
|
|
if write {
|
|
|
|
return s.write(seqno)
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2021-07-22 09:11:49 +00:00
|
|
|
func (s *BadgerMarkSet) Has(c cid.Cid) (bool, error) {
|
|
|
|
s.mx.RLock()
|
|
|
|
defer s.mx.RUnlock()
|
|
|
|
|
|
|
|
key := c.Hash()
|
2021-07-22 11:43:00 +00:00
|
|
|
pendKey := string(key)
|
2021-07-22 09:11:49 +00:00
|
|
|
|
2021-08-03 08:05:43 +00:00
|
|
|
has, err := s.tryPending(pendKey)
|
|
|
|
if has || err != nil {
|
|
|
|
return has, err
|
2021-07-22 11:43:00 +00:00
|
|
|
}
|
|
|
|
|
2021-08-03 08:05:43 +00:00
|
|
|
return s.tryDB(key)
|
2021-07-22 09:11:49 +00:00
|
|
|
}
|
|
|
|
|
2021-07-30 19:07:45 +00:00
|
|
|
func (s *BadgerMarkSet) Visit(c cid.Cid) (bool, error) {
|
2021-07-30 06:42:20 +00:00
|
|
|
key := c.Hash()
|
|
|
|
pendKey := string(key)
|
|
|
|
|
2021-07-30 21:13:56 +00:00
|
|
|
s.mx.RLock()
|
|
|
|
|
2021-08-03 08:05:43 +00:00
|
|
|
has, err := s.tryPending(pendKey)
|
|
|
|
if has || err != nil {
|
2021-07-30 21:13:56 +00:00
|
|
|
s.mx.RUnlock()
|
2021-08-03 08:05:43 +00:00
|
|
|
return false, err
|
2021-07-30 21:13:56 +00:00
|
|
|
}
|
|
|
|
|
2021-08-03 08:05:43 +00:00
|
|
|
has, err = s.tryDB(key)
|
|
|
|
if has || err != nil {
|
2021-07-30 21:13:56 +00:00
|
|
|
s.mx.RUnlock()
|
2021-08-03 08:05:43 +00:00
|
|
|
return false, err
|
|
|
|
}
|
2021-07-30 06:42:20 +00:00
|
|
|
|
2021-08-03 08:05:43 +00:00
|
|
|
// we need to upgrade the lock to exclusive in order to write; take the version count to see
|
|
|
|
// if there was another write while we were upgrading
|
|
|
|
version := s.version
|
|
|
|
s.mx.RUnlock()
|
2021-07-30 21:13:56 +00:00
|
|
|
|
2021-08-03 08:05:43 +00:00
|
|
|
s.mx.Lock()
|
|
|
|
// we have to do the check dance again
|
|
|
|
has, err = s.tryPending(pendKey)
|
|
|
|
if has || err != nil {
|
|
|
|
s.mx.Unlock()
|
|
|
|
return false, err
|
|
|
|
}
|
2021-07-30 21:13:56 +00:00
|
|
|
|
2021-08-03 08:05:43 +00:00
|
|
|
if version != s.version {
|
|
|
|
// something was written to the db, we need to check it
|
|
|
|
has, err = s.tryDB(key)
|
|
|
|
if has || err != nil {
|
2021-07-30 21:13:56 +00:00
|
|
|
s.mx.Unlock()
|
2021-08-03 08:05:43 +00:00
|
|
|
return false, err
|
2021-07-30 21:13:56 +00:00
|
|
|
}
|
2021-08-03 08:05:43 +00:00
|
|
|
}
|
2021-07-30 21:13:56 +00:00
|
|
|
|
2021-08-10 07:10:12 +00:00
|
|
|
write, seqno := s.put(pendKey)
|
|
|
|
s.mx.Unlock()
|
|
|
|
|
|
|
|
if write {
|
|
|
|
err = s.write(seqno)
|
2021-08-03 08:05:43 +00:00
|
|
|
}
|
2021-07-30 21:13:56 +00:00
|
|
|
|
2021-08-10 07:10:12 +00:00
|
|
|
return true, err
|
2021-08-03 08:05:43 +00:00
|
|
|
}
|
2021-07-30 06:42:20 +00:00
|
|
|
|
2021-08-03 08:05:43 +00:00
|
|
|
// reader holds the (r)lock
|
|
|
|
func (s *BadgerMarkSet) tryPending(key string) (has bool, err error) {
|
|
|
|
if s.pend == nil {
|
|
|
|
return false, errMarkSetClosed
|
|
|
|
}
|
2021-07-30 21:13:56 +00:00
|
|
|
|
2021-08-03 08:05:43 +00:00
|
|
|
if _, ok := s.pend[key]; ok {
|
|
|
|
return true, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, wr := range s.writing {
|
|
|
|
if _, ok := wr[key]; ok {
|
2021-07-30 06:42:20 +00:00
|
|
|
return true, nil
|
|
|
|
}
|
2021-08-03 08:05:43 +00:00
|
|
|
}
|
2021-07-30 06:42:20 +00:00
|
|
|
|
2021-08-03 08:05:43 +00:00
|
|
|
return false, nil
|
|
|
|
}
|
2021-07-30 19:07:45 +00:00
|
|
|
|
2021-08-03 08:05:43 +00:00
|
|
|
func (s *BadgerMarkSet) tryDB(key []byte) (has bool, err error) {
|
|
|
|
err = s.db.View(func(txn *badger.Txn) error {
|
|
|
|
_, err := txn.Get(key)
|
|
|
|
return err
|
|
|
|
})
|
|
|
|
|
|
|
|
switch err {
|
|
|
|
case nil:
|
2021-07-30 19:07:45 +00:00
|
|
|
return true, nil
|
2021-07-30 06:42:20 +00:00
|
|
|
|
2021-08-03 08:05:43 +00:00
|
|
|
case badger.ErrKeyNotFound:
|
|
|
|
return false, nil
|
|
|
|
|
2021-07-30 19:07:45 +00:00
|
|
|
default:
|
2021-08-03 08:05:43 +00:00
|
|
|
return false, err
|
2021-07-30 19:07:45 +00:00
|
|
|
}
|
|
|
|
}
|
2021-07-30 06:42:20 +00:00
|
|
|
|
2021-08-10 07:10:12 +00:00
|
|
|
// writer holds the exclusive lock
|
|
|
|
func (s *BadgerMarkSet) put(key string) (write bool, seqno int) {
|
2021-08-03 08:41:49 +00:00
|
|
|
s.pend[key] = struct{}{}
|
2022-01-28 13:41:33 +00:00
|
|
|
if !s.persist && len(s.pend) < badgerMarkSetBatchSize {
|
2021-08-10 07:10:12 +00:00
|
|
|
return false, 0
|
2021-08-03 08:41:49 +00:00
|
|
|
}
|
|
|
|
|
2022-02-09 16:34:50 +00:00
|
|
|
seqno = s.nextBatch()
|
2021-08-10 07:10:12 +00:00
|
|
|
return true, seqno
|
|
|
|
}
|
|
|
|
|
2022-01-30 09:27:24 +00:00
|
|
|
func (s *BadgerMarkSet) putMany(batch []cid.Cid) (write bool, seqno int) {
|
|
|
|
for _, c := range batch {
|
|
|
|
key := string(c.Hash())
|
|
|
|
s.pend[key] = struct{}{}
|
|
|
|
}
|
|
|
|
|
|
|
|
if !s.persist && len(s.pend) < badgerMarkSetBatchSize {
|
|
|
|
return false, 0
|
|
|
|
}
|
|
|
|
|
2022-02-09 16:34:50 +00:00
|
|
|
seqno = s.nextBatch()
|
|
|
|
return true, seqno
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *BadgerMarkSet) nextBatch() int {
|
|
|
|
seqno := s.seqno
|
2022-01-30 09:27:24 +00:00
|
|
|
s.seqno++
|
|
|
|
s.writing[seqno] = s.pend
|
|
|
|
s.pend = make(map[string]struct{})
|
2022-02-09 16:34:50 +00:00
|
|
|
return seqno
|
2022-01-30 09:27:24 +00:00
|
|
|
}
|
|
|
|
|
2021-08-10 07:10:12 +00:00
|
|
|
func (s *BadgerMarkSet) write(seqno int) (err error) {
|
|
|
|
s.mx.Lock()
|
|
|
|
if s.pend == nil {
|
|
|
|
s.mx.Unlock()
|
|
|
|
return errMarkSetClosed
|
|
|
|
}
|
|
|
|
|
|
|
|
pend := s.writing[seqno]
|
|
|
|
s.writers++
|
2021-07-30 19:07:45 +00:00
|
|
|
s.mx.Unlock()
|
2021-07-30 06:42:20 +00:00
|
|
|
|
2021-07-30 19:07:45 +00:00
|
|
|
defer func() {
|
|
|
|
s.mx.Lock()
|
|
|
|
defer s.mx.Unlock()
|
2021-07-30 06:42:20 +00:00
|
|
|
|
2021-08-10 07:10:12 +00:00
|
|
|
if err == nil {
|
|
|
|
delete(s.writing, seqno)
|
|
|
|
s.version++
|
|
|
|
}
|
|
|
|
|
|
|
|
s.writers--
|
|
|
|
if s.writers == 0 {
|
2021-07-30 19:07:45 +00:00
|
|
|
s.cond.Broadcast()
|
2021-07-30 06:42:20 +00:00
|
|
|
}
|
2021-07-30 19:07:45 +00:00
|
|
|
}()
|
2021-07-30 06:42:20 +00:00
|
|
|
|
2021-07-30 19:07:45 +00:00
|
|
|
empty := []byte{} // not nil
|
2021-07-30 06:42:20 +00:00
|
|
|
|
2021-07-30 19:07:45 +00:00
|
|
|
batch := s.db.NewWriteBatch()
|
|
|
|
defer batch.Cancel()
|
|
|
|
|
|
|
|
for k := range pend {
|
2021-08-10 07:10:12 +00:00
|
|
|
if err = batch.Set([]byte(k), empty); err != nil {
|
2021-07-30 19:07:45 +00:00
|
|
|
return xerrors.Errorf("error setting batch: %w", err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-08-10 07:10:12 +00:00
|
|
|
err = batch.Flush()
|
2021-07-30 19:07:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return xerrors.Errorf("error flushing batch to badger markset: %w", err)
|
2021-07-30 06:42:20 +00:00
|
|
|
}
|
2021-07-30 19:07:45 +00:00
|
|
|
|
2022-01-30 10:10:08 +00:00
|
|
|
s.mx.RLock()
|
|
|
|
persist := s.persist
|
|
|
|
s.mx.RUnlock()
|
|
|
|
|
2023-02-23 15:05:18 +00:00
|
|
|
if persist && !system.BadgerFsyncDisable { // WARNING: disabling sync makes recovery from crash during critical section unsound
|
2022-01-30 10:10:08 +00:00
|
|
|
return s.db.Sync()
|
|
|
|
}
|
|
|
|
|
2021-07-30 19:07:45 +00:00
|
|
|
return nil
|
2021-07-30 06:42:20 +00:00
|
|
|
}
|
|
|
|
|
2021-07-30 19:07:45 +00:00
|
|
|
func (s *BadgerMarkSet) Close() error {
|
|
|
|
s.mx.Lock()
|
|
|
|
defer s.mx.Unlock()
|
|
|
|
|
|
|
|
if s.pend == nil {
|
2021-07-30 06:42:20 +00:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2021-08-10 07:10:12 +00:00
|
|
|
for s.writers > 0 {
|
2021-07-30 19:07:45 +00:00
|
|
|
s.cond.Wait()
|
|
|
|
}
|
|
|
|
|
|
|
|
s.pend = nil
|
|
|
|
db := s.db
|
|
|
|
s.db = nil
|
2021-07-30 06:42:20 +00:00
|
|
|
|
2022-01-28 13:41:33 +00:00
|
|
|
return closeBadgerDB(db, s.path, s.persist)
|
2021-07-30 08:17:09 +00:00
|
|
|
}
|
|
|
|
|
2022-01-28 13:41:33 +00:00
|
|
|
func openBadgerDB(path string, recover bool) (*badger.DB, error) {
|
|
|
|
// if it is not a recovery, clean up first
|
|
|
|
if !recover {
|
|
|
|
err := os.RemoveAll(path)
|
|
|
|
if err != nil {
|
|
|
|
return nil, xerrors.Errorf("error clearing markset directory: %w", err)
|
|
|
|
}
|
2021-07-30 08:17:09 +00:00
|
|
|
|
2022-01-28 13:41:33 +00:00
|
|
|
err = os.MkdirAll(path, 0755) //nolint:gosec
|
|
|
|
if err != nil {
|
|
|
|
return nil, xerrors.Errorf("error creating markset directory: %w", err)
|
|
|
|
}
|
2021-07-30 08:17:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
opts := badger.DefaultOptions(path)
|
2022-02-02 12:29:26 +00:00
|
|
|
// we manually sync when we are in critical section
|
2021-07-30 08:17:09 +00:00
|
|
|
opts.SyncWrites = false
|
2022-02-02 12:29:26 +00:00
|
|
|
// no need to do that
|
2021-07-30 08:17:09 +00:00
|
|
|
opts.CompactL0OnClose = false
|
2022-02-02 12:29:26 +00:00
|
|
|
// we store hashes, not much to gain by compression
|
2021-07-30 08:17:09 +00:00
|
|
|
opts.Compression = options.None
|
|
|
|
// Note: We use FileIO for loading modes to avoid memory thrashing and interference
|
|
|
|
// between the system blockstore and the markset.
|
|
|
|
// It was observed that using the default memory mapped option resulted in
|
|
|
|
// significant interference and unacceptably high block validation times once the markset
|
|
|
|
// exceeded 1GB in size.
|
|
|
|
opts.TableLoadingMode = options.FileIO
|
|
|
|
opts.ValueLogLoadingMode = options.FileIO
|
2022-02-02 12:29:26 +00:00
|
|
|
// We increase the number of L0 tables before compaction to make it unlikely to
|
|
|
|
// be necessary.
|
|
|
|
opts.NumLevelZeroTables = 20 // default is 5
|
|
|
|
opts.NumLevelZeroTablesStall = 30 // default is 10
|
|
|
|
// increase the number of compactors from default 2 so that if we ever have to
|
|
|
|
// compact, it is fast
|
|
|
|
if runtime.NumCPU()/2 > opts.NumCompactors {
|
|
|
|
opts.NumCompactors = runtime.NumCPU() / 2
|
|
|
|
}
|
2021-07-30 08:17:09 +00:00
|
|
|
opts.Logger = &badgerLogger{
|
|
|
|
SugaredLogger: log.Desugar().WithOptions(zap.AddCallerSkip(1)).Sugar(),
|
|
|
|
skip2: log.Desugar().WithOptions(zap.AddCallerSkip(2)).Sugar(),
|
|
|
|
}
|
|
|
|
|
|
|
|
return badger.Open(opts)
|
|
|
|
}
|
|
|
|
|
2022-01-28 13:41:33 +00:00
|
|
|
func closeBadgerDB(db *badger.DB, path string, persist bool) error {
|
2021-07-30 06:42:20 +00:00
|
|
|
err := db.Close()
|
|
|
|
if err != nil {
|
|
|
|
return xerrors.Errorf("error closing badger markset: %w", err)
|
|
|
|
}
|
|
|
|
|
2022-01-28 13:41:33 +00:00
|
|
|
if persist {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2021-07-30 08:17:09 +00:00
|
|
|
err = os.RemoveAll(path)
|
2021-07-30 06:42:20 +00:00
|
|
|
if err != nil {
|
|
|
|
return xerrors.Errorf("error deleting badger markset: %w", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2021-07-22 09:11:49 +00:00
|
|
|
// badger logging through go-log
|
|
|
|
type badgerLogger struct {
|
|
|
|
*zap.SugaredLogger
|
|
|
|
skip2 *zap.SugaredLogger
|
|
|
|
}
|
|
|
|
|
2021-07-22 09:27:59 +00:00
|
|
|
func (b *badgerLogger) Warningf(format string, args ...interface{}) {}
|
|
|
|
func (b *badgerLogger) Infof(format string, args ...interface{}) {}
|
|
|
|
func (b *badgerLogger) Debugf(format string, args ...interface{}) {}
|