Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add log when file.WriteAt or syscall.Fdatasync fails #616

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion bolt_linux.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
package bbolt

import (
"fmt"
"syscall"
)

// fdatasync flushes written data to a file descriptor.
func fdatasync(db *DB) error {
return syscall.Fdatasync(int(db.file.Fd()))
err := syscall.Fdatasync(int(db.file.Fd()))
if err != nil {
fmt.Printf("linux: fdatasync failed: %v\n", err)
}
return err
}
4 changes: 2 additions & 2 deletions cmd/bbolt/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -1237,7 +1237,7 @@ func (cmd *benchCommand) runWritesWithSource(db *bolt.DB, options *BenchOptions,
b, _ := tx.CreateBucketIfNotExists(benchBucketName)
b.FillPercent = options.FillPercent

fmt.Fprintf(cmd.Stderr, "Starting write iteration %d\n", i)
//fmt.Fprintf(cmd.Stderr, "Starting write iteration %d\n", i)
for j := int64(0); j < options.BatchSize; j++ {
key := make([]byte, options.KeySize)
value := make([]byte, options.ValueSize)
Expand All @@ -1252,7 +1252,7 @@ func (cmd *benchCommand) runWritesWithSource(db *bolt.DB, options *BenchOptions,

results.AddCompletedOps(1)
}
fmt.Fprintf(cmd.Stderr, "Finished write iteration %d\n", i)
//fmt.Fprintf(cmd.Stderr, "Finished write iteration %d\n", i)

return nil
}); err != nil {
Expand Down
2 changes: 2 additions & 0 deletions tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,7 @@ func (tx *Tx) write() error {
buf := common.UnsafeByteSlice(unsafe.Pointer(p), written, 0, int(sz))

if _, err := tx.db.ops.writeAt(buf, offset); err != nil {
fmt.Printf("writeAt (offset: %d) failed: %v\n", offset, err)
return err
}

Expand Down Expand Up @@ -509,6 +510,7 @@ func (tx *Tx) writeMeta() error {

// Write the meta page to file.
if _, err := tx.db.ops.writeAt(buf, int64(p.Id())*int64(tx.db.pageSize)); err != nil {
fmt.Printf("writeMeta: writeAt (p.Id(): %d) failed: %v\n", p.Id(), err)
return err
}
if !tx.db.NoSync || common.IgnoreNoSync {
Expand Down
Loading