Skip to content
This repository was archived by the owner on Mar 9, 2019. It is now read-only.
This repository was archived by the owner on Mar 9, 2019. It is now read-only.

frequent "misplaced bucket header" and "page already freed" errors #653

@schollz

Description

@schollz

Hi, I've been using bolt quite successfully for awhile for my project, FIND.

Recent builds have been creating the following errors in one of my tests:

2017/01/30 16:47:32 [Recovery] panic recovered:
POST /track HTTP/1.1
Host: 127.0.0.1:8003
Accept: */*
Content-Length: 1089
Content-Type: application/json
Expect: 100-continue
User-Agent: curl/7.47.0


misplaced bucket header: 7265736f7572636573 -> 73766d44617461
/usr/local/go/src/runtime/panic.go:458 (0x47b6a3)
	gopanic: reflectcall(nil, unsafe.Pointer(d.fn), deferArgs(d), uint32(d.siz), uint32(d.siz))
/home/zns/work/src/github.com/boltdb/bolt/bucket.go:556 (0x5778c8)
	(*Bucket).spill: panic(fmt.Sprintf("misplaced bucket header: %x -> %x", []byte(name), k))
/home/zns/work/src/github.com/boltdb/bolt/tx.go:163 (0x584f55)
	(*Tx).Commit: if err := tx.root.spill(); err != nil {
/home/zns/work/src/github.com/boltdb/bolt/db.go:605 (0x57c96d)
	(*DB).Update: return t.Commit()
/home/zns/Documents/find/svm.go:124 (0x4429c9)
	dumpFingerprintsSVM: })
/home/zns/Documents/find/fingerprint.go:204 (0x4127c5)
	trackFingerprint: dumpFingerprintsSVM(group)
/home/zns/Documents/find/fingerprint.go:138 (0x41088a)
	trackFingerprintPOST: message, success, locationGuess, bayes, svm, rf := trackFingerprint(jsonFingerprint)
/home/zns/work/src/github.com/gin-gonic/gin/context.go:98 (0x58a81a)
	(*Context).Next: c.handlers[c.index](c)
/home/zns/work/src/github.com/gin-gonic/contrib/sessions/sessions.go:65 (0x62dbb9)
	Sessions.func1: c.Next()
/home/zns/work/src/github.com/gin-gonic/gin/context.go:98 (0x58a81a)
	(*Context).Next: c.handlers[c.index](c)
/home/zns/work/src/github.com/gin-gonic/gin/recovery.go:45 (0x59a8fa)
	RecoveryWithWriter.func1: c.Next()
/home/zns/work/src/github.com/gin-gonic/gin/context.go:98 (0x58a81a)
	(*Context).Next: c.handlers[c.index](c)
/home/zns/work/src/github.com/gin-gonic/gin/logger.go:77 (0x5999ef)
	LoggerWithWriter.func1: c.Next()
/home/zns/work/src/github.com/gin-gonic/gin/context.go:98 (0x58a81a)
	(*Context).Next: c.handlers[c.index](c)
/home/zns/work/src/github.com/gin-gonic/gin/gin.go:290 (0x590eae)
	(*Engine).handleHTTPRequest: context.Next()
/home/zns/work/src/github.com/gin-gonic/gin/gin.go:271 (0x590790)
	(*Engine).ServeHTTP: engine.handleHTTPRequest(c)
/usr/local/go/src/net/http/server.go:2202 (0x51b1cd)
	serverHandler.ServeHTTP: handler.ServeHTTP(rw, req)
/usr/local/go/src/net/http/server.go:1579 (0x517b37)
	(*conn).serve: serverHandler{c.server}.ServeHTTP(w, w.req)
/usr/local/go/src/runtime/asm_amd64.s:2086 (0x4ab001)
	goexit: BYTE	$0x90	// NOP

or sometimes it creates this error:

2017/01/30 16:53:14 [Recovery] panic recovered:
GET /calculate?group=testdb HTTP/1.1
Host: 127.0.0.1:8003
Accept: */*
User-Agent: curl/7.47.0


page 193 already freed
/usr/local/go/src/runtime/panic.go:443 (0x4840c9)
	gopanic: reflectcall(nil, unsafe.Pointer(d.fn), deferArgs(d), uint32(d.siz), uint32(d.siz))
/home/zns/work/src/github.com/boltdb/bolt/freelist.go:121 (0x5817fb)
	(*freelist).free: panic(fmt.Sprintf("page %d already freed", id))
/home/zns/work/src/github.com/boltdb/bolt/node.go:363 (0x58510a)
	(*node).spill: tx.db.freelist.free(tx.meta.txid, tx.page(node.pgid))
/home/zns/work/src/github.com/boltdb/bolt/bucket.go:570 (0x57861f)
	(*Bucket).spill: if err := b.rootNode.spill(); err != nil {
/home/zns/work/src/github.com/boltdb/bolt/bucket.go:537 (0x579012)
	(*Bucket).spill: if err := child.spill(); err != nil {
/home/zns/work/src/github.com/boltdb/bolt/tx.go:163 (0x589084)
	(*Tx).Commit: if err := tx.root.spill(); err != nil {
/home/zns/work/src/github.com/boltdb/bolt/db.go:605 (0x57ea3d)
	(*DB).Update: return t.Commit()
/home/zns/Downloads/find-2.1/svm.go:124 (0x448938)
	dumpFingerprintsSVM: })
/home/zns/Downloads/find-2.1/api.go:97 (0x402666)
	calculate: dumpFingerprintsSVM(strings.ToLower(group))
/home/zns/work/src/github.com/gin-gonic/gin/context.go:98 (0x58f5ba)
	(*Context).Next: c.handlers[c.index](c)
/home/zns/work/src/github.com/gin-gonic/contrib/sessions/sessions.go:65 (0x61d7f3)
	Sessions.func1: c.Next()
/home/zns/work/src/github.com/gin-gonic/gin/context.go:98 (0x58f5ba)
	(*Context).Next: c.handlers[c.index](c)
/home/zns/work/src/github.com/gin-gonic/gin/recovery.go:45 (0x5a25f1)
	RecoveryWithWriter.func1: c.Next()
/home/zns/work/src/github.com/gin-gonic/gin/context.go:98 (0x58f5ba)
	(*Context).Next: c.handlers[c.index](c)
/home/zns/work/src/github.com/gin-gonic/gin/logger.go:77 (0x5a1862)
	LoggerWithWriter.func1: c.Next()
/home/zns/work/src/github.com/gin-gonic/gin/context.go:98 (0x58f5ba)
	(*Context).Next: c.handlers[c.index](c)
/home/zns/work/src/github.com/gin-gonic/gin/gin.go:290 (0x596ae2)
	(*Engine).handleHTTPRequest: context.Next()
/home/zns/work/src/github.com/gin-gonic/gin/gin.go:271 (0x596717)
	(*Engine).ServeHTTP: engine.handleHTTPRequest(c)
/usr/local/go/src/net/http/server.go:2081 (0x51bfbe)
	serverHandler.ServeHTTP: handler.ServeHTTP(rw, req)
/usr/local/go/src/net/http/server.go:1472 (0x51886e)
	(*conn).serve: serverHandler{c.server}.ServeHTTP(w, w.req)
/usr/local/go/src/runtime/asm_amd64.s:1998 (0x4b4911)
	goexit: BYTE	$0x90	// NOP

It can be replicated the following way:

  1. Get latest dependencies with go get -u -v github.com/schollz/find
  2. git clone https://github.com/schollz/find.git && cd find && go build && ./find
  3. In another window, cd into the find/testing directory and run ./testdb.sh. It will insert things into the database, and then (possibly) suddenly fail when it tries to use the items from the database for calculations.
  4. If you want to try again, just do rm data/testdb.db from the find directory.

It doesn't seem to always fail, but it seems to fail about 7/10 times when I try this test on two systems with Linux (Ubuntu 16) + AMD64. It seems to fail 1/10 times on Linux (Ubuntu 14) + AMD64. . It seems to do this with the current master of boltdb (9145e04) with both go 1.6 and 1.7 and 1.8. I did try with earlier versions of Bolt (e.g. v1.2.0) and it works fine every time I run the test that earlier version.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions