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.
()
| 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. |
| 1095 | func (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. |