Comments (8)
Here's a slightly nicer repro case:
https://gist.github.com/cespare/caef571fd9c8d3db72c2
Here I closed and reopened the DB from within my code so you only need to run it once.
- Open the DB
- Write 1000 documents
- Close and reopen
- Call
db.Buckets()
crashes
from bolt.
It looks like when opening a file, it's mmapped at whatever size the file naturally has, and then the Buckets call tries to access a page beyond that point, getting an index out of bounds panic.
Not 100% on what's the best way to fix this. It seems the db size / page count is not stored explicitly in the meta page? Otherwise, could read that to get the right mmap size, when opening. Alternatively, always write to last byte when growing -- but even then, it's not guaranteed to hit the disk immediately.
from bolt.
@cespare @tv42 It was a really dumb bug. While calculating the minimum size I used a wrong intermediate variable. It's fixed with #55.
from bolt.
@cespare by the way, thanks for the reproducible code. It made it really easy to fix the bug.
from bolt.
@benbjohnson Thanks!
from bolt.
@tv42 The meta page doesn't store the last byte written but it does store a high water mark for pages using Meta.pgid
. You can calculate the last byte by multiplying that by the Meta.pageSize
.
from bolt.
I see what's going on with meta.pgid, I confused that with page.id when reading so I was blind to it. I just went through the meta0 vs meta1 and transaction handling code -- really sweet & simple!
from bolt.
@tv42 I really like the simple approach LMDB used with the "double buffering" meta pages. It's hard to get much simpler than that. :)
I should probably document some of the unexported fields (e.g. meta.pgid, etc). Or maybe better names would help like meta.maxpgid. Actually, I need to fix some of the naming. I tried to Go-ify the names as I ported it over but I didn't touch the lower level pieces.
Maybe the following changes in Meta
to start:
type Meta struct {
...
bucketPageID pageID
freelistPageID pageID
maxPageID pageID
maxTransactionID transactionID
}
from bolt.
Related Issues (20)
- C/C++ binding for key/value storage HOT 3
- Security at rest HOT 1
- Can I use the same key for nested bucket and filed in a bucket/ HOT 1
- Document for New Contributors?
- page already freed HOT 5
- How to check if a file is a valid boltdb database without panicing HOT 2
- Check is a database open HOT 1
- what kind fo key can enhance write speed HOT 1
- concurrent writes and deadlocks HOT 2
- [RFE] change sequence number HOT 2
- [RFE] Database Generation ID HOT 7
- Database file size not updating after reaching 1GB HOT 3
- Meta2 make DBFile invalid HOT 1
- how to get the value that the current cursor points to HOT 3
- how to use boltdb for multiple files HOT 2
- page already freed on certain builds
- Not able to create subbucket inside loop
- Tons of compilation errors HOT 1
- permission denied in user home directory when open boltdb path HOT 1
- Cursor.Last() returns nil for non-empty bucket
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bolt.