MCPcopy
hub / github.com/etcd-io/bbolt / Sync

Method Sync

db.go:1095–1108  ·  view source on GitHub ↗

Sync executes fdatasync() against the database file handle. This is not necessary under normal operation, however, if you use NoSync then it allows you to force the database file to sync against the disk.

()

Source from the content-addressed store, hash-verified

1093// This is not necessary under normal operation, however, if you use NoSync
1094// then it allows you to force the database file to sync against the disk.
1095func (db *DB) Sync() (err error) {
1096 if lg := db.Logger(); lg != discardLogger {
1097 lg.Debugf("Syncing bbolt db (%s)", db.path)
1098 defer func() {
1099 if err != nil {
1100 lg.Errorf("[GOOS: %s, GOARCH: %s] syncing bbolt db (%s) failed: %v", runtime.GOOS, runtime.GOARCH, db.path, err)
1101 } else {
1102 lg.Debugf("Syncing bbolt db (%s) successfully", db.path)
1103 }
1104 }()
1105 }
1106
1107 return fdatasync(db)
1108}
1109
1110// Stats retrieves ongoing performance stats for the database.
1111// This is only updated when a transaction closes.

Callers 5

fdatasyncFunction · 0.80
fdatasyncFunction · 0.80
growMethod · 0.80
fdatasyncFunction · 0.80
writeFileFunction · 0.80

Calls 4

LoggerMethod · 0.95
fdatasyncFunction · 0.70
DebugfMethod · 0.65
ErrorfMethod · 0.65

Tested by 1

writeFileFunction · 0.64