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

Function verifyPageReachable

tx_check.go:155–175  ·  view source on GitHub ↗
(p *common.Page, hwm common.Pgid, stack []common.Pgid, reachable map[common.Pgid]*common.Page, freed map[common.Pgid]bool, ch chan error)

Source from the content-addressed store, hash-verified

153}
154
155func verifyPageReachable(p *common.Page, hwm common.Pgid, stack []common.Pgid, reachable map[common.Pgid]*common.Page, freed map[common.Pgid]bool, ch chan error) {
156 if p.Id() > hwm {
157 ch <- fmt.Errorf("page %d: out of bounds: %d (stack: %v)", int(p.Id()), int(hwm), stack)
158 }
159
160 // Ensure each page is only referenced once.
161 for i := common.Pgid(0); i <= common.Pgid(p.Overflow()); i++ {
162 var id = p.Id() + i
163 if _, ok := reachable[id]; ok {
164 ch <- fmt.Errorf("page %d: multiple references (stack: %v)", int(id), stack)
165 }
166 reachable[id] = p
167 }
168
169 // We should only encounter un-freed leaf and branch pages.
170 if freed[p.Id()] {
171 ch <- fmt.Errorf("page %d: reachable freed", int(p.Id()))
172 } else if !p.IsBranchPage() && !p.IsLeafPage() {
173 ch <- fmt.Errorf("page %d: invalid type: %s (stack: %v)", int(p.Id()), p.Typ(), stack)
174 }
175}
176
177// recursivelyCheckPageKeyOrder verifies database consistency with respect to b-tree
178// key order constraints:

Callers 1

Calls 7

PgidTypeAlias · 0.92
IdMethod · 0.80
OverflowMethod · 0.80
IsBranchPageMethod · 0.80
IsLeafPageMethod · 0.80
TypMethod · 0.80
ErrorfMethod · 0.65

Tested by

no test coverage detected