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

Method rollback

tx.go:323–343  ·  view source on GitHub ↗

rollback needs to reload the free pages from disk in case some system error happens like fsync error.

()

Source from the content-addressed store, hash-verified

321
322// rollback needs to reload the free pages from disk in case some system error happens like fsync error.
323func (tx *Tx) rollback() {
324 if tx.db == nil {
325 return
326 }
327 if tx.writable {
328 tx.db.freelist.Rollback(tx.meta.Txid())
329 // When mmap fails, the `data`, `dataref` and `datasz` may be reset to
330 // zero values, and there is no way to reload free page IDs in this case.
331 if tx.db.data != nil {
332 if !tx.db.hasSyncedFreelist() {
333 // Reconstruct free page list by scanning the DB to get the whole free page list.
334 // Note: scanning the whole db is heavy if your db size is large in NoSyncFreeList mode.
335 tx.db.freelist.NoSyncReload(tx.db.freepages())
336 } else {
337 // Read free page list from freelist page.
338 tx.db.freelist.Reload(tx.db.page(tx.db.meta().Freelist()))
339 }
340 }
341 }
342 tx.close()
343}
344
345func (tx *Tx) close() {
346 if tx.db == nil {

Callers 4

CommitMethod · 0.95
commitFreelistMethod · 0.95
UpdateMethod · 0.80
ViewMethod · 0.80

Calls 10

closeMethod · 0.95
TxidMethod · 0.80
hasSyncedFreelistMethod · 0.80
freepagesMethod · 0.80
FreelistMethod · 0.80
metaMethod · 0.80
RollbackMethod · 0.65
NoSyncReloadMethod · 0.65
ReloadMethod · 0.65
pageMethod · 0.45

Tested by

no test coverage detected