Thanks to putting it outside the bbolt_test package it can be used to test other packages.
The replacement of the bbolt_test variant inlined in db_test.go is to be performed in a follow up PR.
Signed-off-by: Piotr Tabor <ptab@google.com>
--all - prints all pages (only skips pages that were considered successful overflow pages)
--value-format=redacted just prints a length of the value, to reduce length and protect privacy.
The auto & redacted formats are supported in all tools that accept '--format'.
Signed-off-by: Piotr Tabor <ptab@google.com>
So far the code was frequently traversing all the keys (ignoring flag whether key is a bucket)
and trying to open each of the keys as bucket (seeking the same entry from the scratch).
In this proposal, we iterate only through bucket keys.
Signed-off-by: Piotr Tabor <ptab@google.com>
It makes it easy to find which page actually looks to be corrupted.
```
go build ./cmd/bbolt/ && ./bbolt check ~/Downloads/db
panic: freepages: failed to get all reachable pages (page 8314893338927566090: out of bounds: 6258 (stack: [4517 395 821]))
goroutine 18 [running]:
go.etcd.io/bbolt.(*DB).freepages.func2()
/Users/ptab/gits/bbolt/db.go:1056 +0x8c
created by go.etcd.io/bbolt.(*DB).freepages
/Users/ptab/gits/bbolt/db.go:1054 +0x138
```
Signed-off-by: Piotr Tabor <ptab@google.com>
The tests were failing when doing development on M1 mac. This was due to page-size difference (4KB assumed in tests) vs. the
OS defaults.
Signed-off-by: Piotr Tabor <ptab@google.com>
This allows to print keys as 'hex', especially useful in context of etcd revisions:
./bbolt keys --format=hex ./foo/db key
Signed-off-by: Piotr Tabor <ptab@google.com>
`CreateFileMapping` tries to extend the file to the size of mapping
which leads to failure if database was opened in readonly and calculated
mmap size is bigger than the file size.
Providing 0 to `MapViewOfFile` will create a view which has size of
mapping, i.e. file-size in read-only mode and full size if file was
truncated.
Also, swap `sizehi` and `sizelo` names to reflect windows API docs.
This was changed in 1c97a490d for seemingly no reason.
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
We just need to cache a list of freepage ID, and don't dare what's
the value (true or false) at all, so changed the map's value from
bool to struct{}.
Signed-off-by: Benjamin Wang <wachao@vmware.com>
Added a changelog file for 1.3.x, and planning to release
1.3.7 with a detailed changelog for users reference.
Signed-off-by: Benjamin Wang <wachao@vmware.com>