Improve error messages, create regular dir for block

pull/5805/head
Fabian Reinartz 8 years ago
parent d2322f6095
commit e006bc6dc6

@ -114,18 +114,20 @@ type mmapFile struct {
}
func openMmapFile(path string) (*mmapFile, error) {
f, err := fileutil.TryLockFile(path, os.O_RDONLY, 0666)
// We have to open the file in RDWR for the lock to work with fileutil.
// TODO(fabxc): use own flock call that supports multi-reader.
f, err := fileutil.TryLockFile(path, os.O_RDWR, 0666)
if err != nil {
return nil, err
return nil, errors.Wrap(err, "try lock file")
}
info, err := f.Stat()
if err != nil {
return nil, err
return nil, errors.Wrap(err, "stat")
}
b, err := mmap(f.File, int(info.Size()))
if err != nil {
return nil, err
return nil, errors.Wrap(err, "mmap")
}
return &mmapFile{f: f, b: b}, nil

@ -134,7 +134,7 @@ func (c *compactor) compact(dir string, blocks ...Block) (err error) {
return err
}
}
if err = fileutil.CreateDirAll(dir); err != nil {
if err = os.MkdirAll(dir, 0755); err != nil {
return err
}

@ -113,8 +113,8 @@ func Open(dir string, logger log.Logger, opts *Options) (db *DB, err error) {
return nil, err
}
}
var r prometheus.Registerer
// r := prometheus.DefaultRegisterer
// var r prometheus.Registerer
r := prometheus.DefaultRegisterer
if opts == nil {
opts = DefaultOptions
@ -393,6 +393,8 @@ func (a *dbAppender) Add(ref uint64, t int64, v float64) error {
if gen != a.gen {
return ErrNotFound
}
a.db.metrics.samplesAppended.Inc()
return a.head.Add(ref, t, v)
}

Loading…
Cancel
Save