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

Method meta

db.go:1141–1162  ·  view source on GitHub ↗

meta retrieves the current meta page reference.

()

Source from the content-addressed store, hash-verified

1139
1140// meta retrieves the current meta page reference.
1141func (db *DB) meta() *common.Meta {
1142 // We have to return the meta with the highest txid which doesn't fail
1143 // validation. Otherwise, we can cause errors when in fact the database is
1144 // in a consistent state. metaA is the one with the higher txid.
1145 metaA := db.meta0
1146 metaB := db.meta1
1147 if db.meta1.Txid() > db.meta0.Txid() {
1148 metaA = db.meta1
1149 metaB = db.meta0
1150 }
1151
1152 // Use higher meta page if valid. Otherwise, fallback to previous, if valid.
1153 if err := metaA.Validate(); err == nil {
1154 return metaA
1155 } else if err := metaB.Validate(); err == nil {
1156 return metaB
1157 }
1158
1159 // This should never be reached, because both meta1 and meta0 were validated
1160 // on mmap() and we do fsync() on every write.
1161 panic("bolt.DB.meta(): invalid meta pages")
1162}
1163
1164// allocate returns a contiguous block of memory starting at a given page.
1165func (db *DB) allocate(txid common.Txid, count int) (*common.Page, error) {

Callers 5

loadFreelistMethod · 0.95
hasSyncedFreelistMethod · 0.95
freepagesMethod · 0.95
initMethod · 0.80
rollbackMethod · 0.80

Calls 2

TxidMethod · 0.80
ValidateMethod · 0.45

Tested by

no test coverage detected