Skip to content

Commit

Permalink
Merge pull request #2 from oocococo/master
Browse files Browse the repository at this point in the history
fix(io): fix tmpfs issue
  • Loading branch information
Connor1996 authored Dec 20, 2021
2 parents 5ff470f + 2682898 commit e856748
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
10 changes: 8 additions & 2 deletions blob.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,10 @@ func newBlobFileBuilder(fid uint32, dir string, writeBufferSize int) (*blobFileB
fileName := newBlobFileName(fid, dir)
file, err := directio.OpenFile(fileName, os.O_CREATE|os.O_RDWR, 0666)
if err != nil {
return nil, err
file, err = os.OpenFile(fileName, os.O_CREATE|os.O_RDWR, 0666)
if err != nil {
return nil, err
}
}
writer := fileutil.NewDirectWriter(file, writeBufferSize, nil)
// Write 4 bytes 0 header.
Expand Down Expand Up @@ -585,7 +588,10 @@ func (h *blobGCHandler) doGCIfNeeded() error {
fileName := newBlobFileName(newFid, h.bm.kv.opt.Dir)
file, err := directio.OpenFile(fileName, os.O_CREATE|os.O_RDWR, 0666)
if err != nil {
return err
file, err = os.OpenFile(fileName, os.O_CREATE|os.O_RDWR, 0666)
if err != nil {
return err
}
}
writer := fileutil.NewDirectWriter(file, 1024*1024, nil)
// 4 bytes addrMapping length
Expand Down
7 changes: 6 additions & 1 deletion db.go
Original file line number Diff line number Diff line change
Expand Up @@ -924,7 +924,12 @@ func (db *DB) runFlushMemTable(c *y.Closer) error {
fileName := table.NewFilename(fileID, db.opt.Dir)
fd, err := directio.OpenFile(fileName, os.O_CREATE|os.O_RDWR, 0666)
if err != nil {
return y.Wrap(err)
// fallback to no directio
fd, err = os.OpenFile(fileName, os.O_CREATE|os.O_RDWR, 0666)
if err != nil {
log.Errorf("ERROR while opening file%s: %v", fileName, err)
return y.Wrap(err)
}
}

// Don't block just to sync the directory entry.
Expand Down
5 changes: 4 additions & 1 deletion levels.go
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,10 @@ func (lc *levelsController) compactBuildTables(level int, cd compactDef,
var fd *os.File
fd, err = directio.OpenFile(fileName, os.O_CREATE|os.O_RDWR, 0666)
if err != nil {
return
fd, err = os.OpenFile(fileName, os.O_CREATE|os.O_RDWR, 0666)
if err != nil {
return
}
}
if builder == nil {
builder = table.NewTableBuilder(fd, limiter, cd.nextLevel.level, lc.opt)
Expand Down

0 comments on commit e856748

Please sign in to comment.