Skip to content

Commit 2fa005c

Browse files
Francesc Campoydanielmai
authored andcommitted
Explaining new version naming schema. (#906)
* Explaining new Serialization Versioning schema used in Badger.
1 parent 50ccc86 commit 2fa005c

File tree

3 files changed

+170
-9
lines changed

3 files changed

+170
-9
lines changed

CHANGELOG.md

Lines changed: 92 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,98 @@
22
All notable changes to this project will be documented in this file.
33

44
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
5-
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
5+
and this project adheres to [Serialization Versioning](VERSIONING.md).
66

77
## [Unreleased]
88

9+
## [1.6.0] - 2019-07-01
10+
11+
This is a release including almost 200 commits, so expect many changes - some of them
12+
not backward compatible.
13+
14+
Regarding backward compatibility in Badger versions, you might be interested on reading
15+
[VERSIONING.md](VERSIONING.md).
16+
17+
_Note_: The hashes in parentheses correspond to the commits that impacted the given feature.
18+
19+
### New APIs
20+
21+
- badger.DB
22+
- DropPrefix (291295e)
23+
- Flatten (7e41bba)
24+
- KeySplits (4751ef1)
25+
- MaxBatchCount (b65e2a3)
26+
- MaxBatchSize (b65e2a3)
27+
- PrintKeyValueHistogram (fd59907)
28+
- Subscribe (26128a7)
29+
- Sync (851e462)
30+
31+
- badger.DefaultOptions() and badger.LSMOnlyOptions() (91ce687)
32+
- badger.Options.WithX methods
33+
34+
- badger.Entry (e9447c9)
35+
- NewEntry
36+
- WithMeta
37+
- WithDiscard
38+
- WithTTL
39+
40+
- badger.Item
41+
- KeySize (fd59907)
42+
- ValueSize (5242a99)
43+
44+
- badger.IteratorOptions
45+
- PickTable (7d46029, 49a49e3)
46+
- Prefix (7d46029)
47+
48+
- badger.Logger (fbb2778)
49+
50+
- badger.Options
51+
- CompactL0OnClose (7e41bba)
52+
- Logger (3f66663)
53+
- LogRotatesToFlush (2237832)
54+
55+
- badger.Stream (14cbd89, 3258067)
56+
- badger.StreamWriter (7116e16)
57+
- badger.TableInfo.KeyCount (fd59907)
58+
- badger.TableManifest (2017987)
59+
- badger.Tx.NewKeyIterator (49a49e3)
60+
- badger.WriteBatch (6daccf9, 7e78e80)
61+
62+
### Modified APIs
63+
64+
#### Breaking changes:
65+
66+
- badger.DefaultOptions and badger.LSMOnlyOptions are now functions rather than variables (91ce687)
67+
- badger.Item.Value now receives a function that returns an error (439fd46)
68+
- badger.Txn.Commit doesn't receive any params now (6daccf9)
69+
- badger.DB.Tables now receives a boolean (76b5341)
70+
71+
#### Not breaking changes:
72+
73+
- badger.LSMOptions changed values (799c33f)
74+
- badger.DB.NewIterator now allows multiple iterators per RO txn (41d9656)
75+
- badger.Options.TableLoadingMode's new default is options.MemoryMap (6b97bac)
76+
77+
### Removed APIs
78+
79+
- badger.ManagedDB (d22c0e8)
80+
- badger.Options.DoNotCompact (7e41bba)
81+
- badger.Txn.SetWithX (e9447c9)
82+
83+
### Tools:
84+
85+
- badger bank disect (13db058)
86+
- badger bank test (13db058) --mmap (03870e3)
87+
- badger fill (7e41bba)
88+
- badger flatten (7e41bba)
89+
- badger info --histogram (fd59907) --history --lookup --show-keys --show-meta --with-prefix (09e9b63) --show-internal (fb2eed9)
90+
- badger benchmark read (239041e)
91+
- badger benchmark write (6d3b67d)
92+
93+
## [1.5.5] - 2019-06-20
94+
95+
* Introduce support for Go Modules
96+
997
## [1.5.3] - 2018-07-11
1098
Bug Fixes:
1199
* Fix a panic caused due to item.vptr not copying over vs.Value, when looking
@@ -87,7 +175,9 @@ Bug fix:
87175
## [1.0.1] - 2017-11-06
88176
* Fix an uint16 overflow when resizing key slice
89177

90-
[Unreleased]: https://github.com/dgraph-io/badger/compare/v1.5.3...HEAD
178+
[Unreleased]: https://github.com/dgraph-io/badger/compare/v1.6.0...HEAD
179+
[1.6.0]: https://github.com/dgraph-io/badger/compare/v1.5.5...v1.6.0
180+
[1.5.5]: https://github.com/dgraph-io/badger/compare/v1.5.3...v1.5.5
91181
[1.5.3]: https://github.com/dgraph-io/badger/compare/v1.5.2...v1.5.3
92182
[1.5.2]: https://github.com/dgraph-io/badger/compare/v1.5.1...v1.5.2
93183
[1.5.1]: https://github.com/dgraph-io/badger/compare/v1.5.0...v1.5.1

README.md

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ BadgerDB is an embeddable, persistent and fast key-value (KV) database
66
written in pure Go. It's meant to be a performant alternative to non-Go-based
77
key-value stores like [RocksDB](https://github.com/facebook/rocksdb).
88

9-
## Project Status [Oct 27, 2018]
9+
## Project Status [Jun 26, 2019]
1010

1111
Badger is stable and is being used to serve data sets worth hundreds of
1212
terabytes. Badger supports concurrent ACID transactions with serializable
@@ -15,14 +15,20 @@ snapshot isolation (SSI) guarantees. A Jepsen-style bank test runs nightly for
1515
Badger has also been tested to work with filesystem level anomalies, to ensure
1616
persistence and consistency.
1717

18-
Badger v1.0 was released in Nov 2017, with a Badger v2.0 release coming up in a
19-
few months. The [Changelog] is kept fairly up-to-date.
18+
Badger v1.0 was released in Nov 2017, and the latest version that is data-compatible
19+
with v1.0 is v1.6.0.
20+
21+
Badger v2.0, a new release coming up very soon will use a new storage format which won't
22+
be compatible with all of the v1.x. The [Changelog] is kept fairly up-to-date.
23+
24+
For more details on our version naming schema please read [Choosing a version](#choosing-a-version).
2025

2126
[Changelog]:https://github.com/dgraph-io/badger/blob/master/CHANGELOG.md
2227

2328
## Table of Contents
2429
* [Getting Started](#getting-started)
2530
+ [Installing](#installing)
31+
- [Choosing a version](#choosing-a-version)
2632
+ [Opening a database](#opening-a-database)
2733
+ [Transactions](#transactions)
2834
- [Read-only transactions](#read-only-transactions)
@@ -61,6 +67,27 @@ $ go get github.com/dgraph-io/badger/...
6167
This will retrieve the library and install the `badger` command line
6268
utility into your `$GOBIN` path.
6369

70+
#### Choosing a version
71+
72+
BadgerDB is a pretty special package from the point of view that the most important change we can
73+
make to it is not on its API but rather on how data is stored on disk.
74+
75+
This is why we follow a version naming schema that differs from Semantic Versioning.
76+
77+
- New major versions are released when the data format on disk changes in an incompatible way.
78+
- New minor versions are released whenever the API changes but data compatibility is maintained.
79+
Note that the changes on the API could be backward-incompatible - unlike Semantic Versioning.
80+
- New patch versions are released when there's no changes to the data format nor the API.
81+
82+
Following these rules:
83+
84+
- v1.5.0 and v1.6.0 can be used on top of the same files without any concerns, as their major
85+
version is the same, therefore the data format on disk is compatible.
86+
- v1.6.0 and v2.0.0 are data incompatible as their major version implies, so files created with
87+
v1.6.0 will need to be converted into the new format before they can be used by v2.0.0.
88+
89+
For a longer explanation on the reasons behind using a new versioning naming schema, you can read
90+
[VERSIONING.md](VERSIONING.md).
6491

6592
### Opening a database
6693
The top-level object in Badger is a `DB`. It represents multiple files on disk
@@ -82,10 +109,7 @@ import (
82109
func main() {
83110
// Open the Badger database located in the /tmp/badger directory.
84111
// It will be created if it doesn't exist.
85-
opts := badger.DefaultOptions
86-
opts.Dir = "/tmp/badger"
87-
opts.ValueDir = "/tmp/badger"
88-
db, err := badger.Open(opts)
112+
db, err := badger.Open(badger.DefaultOptions("tmp/badger"))
89113
if err != nil {
90114
log.Fatal(err)
91115
}

VERSIONING.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Serialization Versioning: Semantic Versioning for databases
2+
3+
Semantic Versioning, commonly known as SemVer, is a great idea that has been very widely adopted as
4+
a way to decide how to name software versions. The whole concept is very well summarized on
5+
semver.org with the following lines:
6+
7+
> Given a version number MAJOR.MINOR.PATCH, increment the:
8+
>
9+
> 1. MAJOR version when you make incompatible API changes,
10+
> 2. MINOR version when you add functionality in a backwards-compatible manner, and
11+
> 3. PATCH version when you make backwards-compatible bug fixes.
12+
>
13+
> Additional labels for pre-release and build metadata are available as extensions to the
14+
> MAJOR.MINOR.PATCH format.
15+
16+
Unfortunately, API changes are not the most important changes for libraries that serialize data for
17+
later consumption. For these libraries, such as BadgerDB, changes to the API are much easier to
18+
handle than change to the data format used to store data on disk.
19+
20+
## Serialization Version specification
21+
22+
Serialization Versioning, like Semantic Versioning, uses 3 numbers and also calls them
23+
MAJOR.MINOR.PATCH, but the semantics of the numbers are slightly modified:
24+
25+
Given a version number MAJOR.MINOR.PATCH, increment the:
26+
27+
- MAJOR version when you make changes that require a transformation of the dataset before it can be
28+
used again.
29+
- MINOR version when old datasets are still readable but the API might have changed in
30+
backwards-compatible or incompatible ways.
31+
- PATCH version when you make backwards-compatible bug fixes.
32+
33+
Additional labels for pre-release and build metadata are available as extensions to the
34+
MAJOR.MINOR.PATCH format.
35+
36+
Following this naming strategy, migration from v1.x to v2.x requires a migration strategy for your
37+
existing dataset, and as such has to be carefully planned. Migrations in between different minor
38+
versions (e.g. v1.5.x and v1.6.x) might break your build, as the API *might* have changed, but once
39+
your code compiles there's no need for any data migration. Lastly, changes in between two different
40+
patch versions should never break your build or dataset.
41+
42+
For more background on our decision to adopt Serialization Versioning, read the blog post
43+
[Semantic Versioning, Go Modules, and Databases][blog] and the original proposal on
44+
[this comment on Dgraph's Discuss forum][discuss].
45+
46+
[blog]: https://blog.dgraph.io/post/serialization-versioning/
47+
[discuss]: https://discuss.dgraph.io/t/go-modules-on-badger-and-dgraph/4662/7

0 commit comments

Comments
 (0)