Skip to content

Commit cad66c9

Browse files
joshua-goldsteinmangalaman93
authored andcommitted
chore: cherry-pick changes from main to release (#1857)
Cherry picks: #1692 , #1790, #1701, #1724, #1702 , #1766 , part of #1808, #1853 , update ChangeLog
1 parent 15dc877 commit cad66c9

File tree

11 files changed

+101
-51
lines changed

11 files changed

+101
-51
lines changed

CHANGELOG.md

+12
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,18 @@ 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/).
55

6+
## [3.2103.5] - 2022-12-15
7+
8+
We release Badger CLI tool binaries for amd64 and now arm64. This release does not involve any core code changes to Badger. We add a CD job for building Badger for arm64.
9+
10+
## [3.2103.4] - 2022-11-04
11+
12+
### Fixed
13+
- fix(manifest): fix manifest corruption due to race condition in concurrent compactions (#1756)
14+
15+
### Chores
16+
- We bring the release branch to parity with main by updating the CI/CD jobs, Readme, Codeowners, PR and issue templates, etc.
17+
618
## [3.2103.3] - 2022-10-14
719

820
### Remarks

Makefile

-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ jemalloc:
5050
dependency:
5151
@echo "Installing dependencies..."
5252
@sudo apt-get update
53-
@sudo apt-get -y upgrade
5453
@sudo apt-get -y install \
5554
ca-certificates \
5655
curl \

README.md

+19-14
Original file line numberDiff line numberDiff line change
@@ -42,19 +42,22 @@ For more details on our version naming schema please read [Choosing a version](#
4242
[Changelog]:https://github.com/dgraph-io/badger/blob/master/CHANGELOG.md
4343

4444
## Table of Contents
45-
* [Getting Started](#getting-started)
46-
+ [Installing](#installing)
45+
- [BadgerDB](#badgerdb)
46+
- [Project Status](#project-status)
47+
- [Table of Contents](#table-of-contents)
48+
- [Getting Started](#getting-started)
49+
- [Installing](#installing)
4750
- [Installing Badger Command Line Tool](#installing-badger-command-line-tool)
4851
- [Choosing a version](#choosing-a-version)
49-
* [Badger Documentation](#badger-documentation)
50-
* [Resources](#resources)
51-
+ [Blog Posts](#blog-posts)
52-
* [Design](#design)
53-
+ [Comparisons](#comparisons)
54-
+ [Benchmarks](#benchmarks)
55-
* [Projects Using Badger](#projects-using-badger)
56-
* [Contributing](#contributing)
57-
* [Contact](#contact)
52+
- [Badger Documentation](#badger-documentation)
53+
- [Resources](#resources)
54+
- [Blog Posts](#blog-posts)
55+
- [Design](#design)
56+
- [Comparisons](#comparisons)
57+
- [Benchmarks](#benchmarks)
58+
- [Projects Using Badger](#projects-using-badger)
59+
- [Contributing](#contributing)
60+
- [Contact](#contact)
5861

5962
## Getting Started
6063

@@ -176,7 +179,6 @@ Below is a list of known projects that use Badger:
176179
* [Sandglass](https://github.com/celrenheit/sandglass) - distributed, horizontally scalable, persistent, time sorted message queue.
177180
* [TalariaDB](https://github.com/grab/talaria) - Grab's Distributed, low latency time-series database.
178181
* [Sloop](https://github.com/salesforce/sloop) - Salesforce's Kubernetes History Visualization Project.
179-
* [Immudb](https://github.com/codenotary/immudb) - Lightweight, high-speed immutable database for systems and applications.
180182
* [Usenet Express](https://usenetexpress.com/) - Serving over 300TB of data with Badger.
181183
* [gorush](https://github.com/appleboy/gorush) - A push notification server written in Go.
182184
* [0-stor](https://github.com/zero-os/0-stor) - Single device object store.
@@ -211,6 +213,9 @@ Below is a list of known projects that use Badger:
211213
* [vxdb](https://github.com/vitalvas/vxdb) - Simple schema-less Key-Value NoSQL database with simplest API interface.
212214
* [Opacity](https://github.com/opacity/storage-node) - Backend implementation for the Opacity storage project
213215
* [Vephar](https://github.com/vaccovecrana/vephar) - A minimal key/value store using hashicorp-raft for cluster coordination and Badger for data storage.
216+
* [gowarcserver](https://github.com/nlnwa/gowarcserver) - Open-source server for warc files. Can be used in conjunction with pywb
217+
* [flow-go](https://github.com/onflow/flow-go) - A fast, secure, and developer-friendly blockchain built to support the next generation of games, apps and the digital assets that power them.
218+
* [Wrgl](https://www.wrgl.co) - A data version control system that works like Git but specialized to store and diff CSV.
214219

215220
If you are using Badger in a project please send a pull request to add it to the list.
216221

@@ -219,6 +224,6 @@ If you are using Badger in a project please send a pull request to add it to the
219224
If you're interested in contributing to Badger see [CONTRIBUTING](./CONTRIBUTING.md).
220225

221226
## Contact
222-
- Please use [discuss.dgraph.io](https://discuss.dgraph.io) for questions, feature requests and discussions.
223-
- Please use [discuss.dgraph.io](https://discuss.dgraph.io) for filing bugs or feature requests.
227+
- Please use [Github issues](https://github.com/dgraph-io/badger/issues) for filing bugs.
228+
- Please use [discuss.dgraph.io](https://discuss.dgraph.io) for questions, discussions, and feature requests.
224229
- Follow us on Twitter [@dgraphlabs](https://twitter.com/dgraphlabs).

VERSIONING.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,5 @@ For more background on our decision to adopt Serialization Versioning, read the
4343
[Semantic Versioning, Go Modules, and Databases][blog] and the original proposal on
4444
[this comment on Dgraph's Discuss forum][discuss].
4545

46-
[blog]: https://blog.dgraph.io/post/serialization-versioning/
46+
[blog]: https://open.dgraph.io/post/serialization-versioning/
4747
[discuss]: https://discuss.dgraph.io/t/go-modules-on-badger-and-dgraph/4662/7

docs/content/faq/index.md

+9
Original file line numberDiff line numberDiff line change
@@ -131,3 +131,12 @@ Badger does not directly use CGO but it relies on https://github.com/DataDog/zst
131131
zstd compression and the library requires `gcc/cgo`. You can build badger without cgo by running
132132
`CGO_ENABLED=0 go build`. This will build badger without the support for ZSTD compression algorithm.
133133

134+
As of Badger versions [v2.2007.4](https://github.com/dgraph-io/badger/releases/tag/v2.2007.4) and
135+
[v3.2103.1](https://github.com/dgraph-io/badger/releases/tag/v3.2103.1) the DataDog ZSTD library
136+
was replaced by pure Golang version and CGO is no longer required. The new library is
137+
[backwards compatible in nearly all cases](https://discuss.dgraph.io/t/use-pure-go-zstd-implementation/8670/10):
138+
139+
> Yes they are compatible both ways. The only exception is 0 bytes of input which will give
140+
> 0 bytes output with the Go zstd. But you already have the zstd.WithZeroFrames(true) which
141+
> will wrap 0 bytes in a header so it can be fed to DD zstd. This will of course only be relevant
142+
> when downgrading.

docs/content/get-started/index.md

+39-29
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ To open your database, use the `badger.Open()` function, with the appropriate
5454
options. The `Dir` and `ValueDir` options are mandatory and must be
5555
specified by the client. They can be set to the same value to simplify things.
5656

57-
```
57+
```go
5858
package main
5959

6060
import (
@@ -84,16 +84,30 @@ in-memory mode. When Badger is running in in-memory mode, all the data is stored
8484
Reads and writes are much faster in in-memory mode, but all the data stored in Badger will be lost
8585
in case of a crash or close. To open badger in in-memory mode, set the `InMemory` option.
8686

87-
```
87+
```go
8888
opt := badger.DefaultOptions("").WithInMemory(true)
8989
```
9090

91+
### Encryption Mode
92+
93+
If you enable encryption on Badger, you also need to set the index cache size.
94+
95+
{{% notice "tip" %}}
96+
Having a cache improves the performance. Otherwise, your reads would be very slow while encryption is enabled.
97+
{{% /notice %}}
98+
99+
For example, to set a `100 Mb` cache:
100+
101+
```go
102+
opts.IndexCache = 100 << 20 // 100 mb or some other size based on the amount of data
103+
```
104+
91105
## Transactions
92106

93107
### Read-only transactions
94108
To start a read-only transaction, you can use the `DB.View()` method:
95109

96-
```
110+
```go
97111
err := db.View(func(txn *badger.Txn) error {
98112
// Your code here…
99113
return nil
@@ -108,7 +122,7 @@ seen by calls made within the closure.
108122
### Read-write transactions
109123
To start a read-write transaction, you can use the `DB.Update()` method:
110124

111-
```
125+
```go
112126
err := db.Update(func(txn *badger.Txn) error {
113127
// Your code here…
114128
return nil
@@ -129,7 +143,7 @@ the transaction exceeds a certain limit. In that case, it is best to commit the
129143
transaction and start a new transaction immediately. Here is an example (we are
130144
not checking for errors in some places for simplicity):
131145

132-
```
146+
```go
133147
updates := make(map[string]string)
134148
txn := db.NewTransaction(true)
135149
for k,v := range updates {
@@ -161,7 +175,7 @@ sufficient for read-write transaction. However, if your code doesn’t call
161175
then please make sure you call `Txn.Discard()` in a `defer` block. Refer to the
162176
code below.
163177

164-
```
178+
```go
165179
// Start a writable transaction.
166180
txn := db.NewTransaction(true)
167181
defer txn.Discard()
@@ -193,7 +207,7 @@ durable until the callback has been invoked with a `nil` error value.
193207
## Using key/value pairs
194208
To save a key/value pair, use the `Txn.Set()` method:
195209

196-
```
210+
```go
197211
err := db.Update(func(txn *badger.Txn) error {
198212
err := txn.Set([]byte("answer"), []byte("42"))
199213
return err
@@ -204,7 +218,7 @@ Key/Value pair can also be saved by first creating `Entry`, then setting this
204218
`Entry` using `Txn.SetEntry()`. `Entry` also exposes methods to set properties
205219
on it.
206220

207-
```
221+
```go
208222
err := db.Update(func(txn *badger.Txn) error {
209223
e := badger.NewEntry([]byte("answer"), []byte("42"))
210224
err := txn.SetEntry(e)
@@ -215,7 +229,7 @@ err := db.Update(func(txn *badger.Txn) error {
215229
This will set the value of the `"answer"` key to `"42"`. To retrieve this
216230
value, we can use the `Txn.Get()` method:
217231

218-
```
232+
```go
219233
err := db.View(func(txn *badger.Txn) error {
220234
item, err := txn.Get([]byte("answer"))
221235
handle(err)
@@ -272,7 +286,7 @@ invocations. Setting a bandwidth too low would do more disk writes, setting it
272286
too high would result in wasted integers if Badger is closed or crashes.
273287
To avoid wasted integers, call `Release` before closing Badger.
274288

275-
```
289+
```go
276290
seq, err := db.GetSequence(key, 1000)
277291
defer seq.Release()
278292
for {
@@ -287,7 +301,7 @@ _merged_ with it. It returns a new value which is the result of the _merge_
287301
operation. All values are specified in byte arrays. For e.g., here is a merge
288302
function (`add`) which appends a `[]byte` value to an existing `[]byte` value.
289303

290-
```
304+
```go
291305
// Merge function to append one byte slice to another
292306
func add(originalValue, newValue []byte) []byte {
293307
return append(originalValue, newValue...)
@@ -302,7 +316,7 @@ method.
302316
`MergeOperator.Get()` method can be used to retrieve the cumulative value of the key
303317
associated with the merge operation.
304318

305-
```
319+
```go
306320
key := []byte("merge")
307321

308322
m := db.GetMergeOperator(key, add, 200*time.Millisecond)
@@ -317,7 +331,7 @@ res, _ := m.Get() // res should have value ABC encoded
317331

318332
Example: Merge operator which increments a counter
319333

320-
```
334+
```go
321335
func uint64ToBytes(i uint64) []byte {
322336
var buf [8]byte
323337
binary.BigEndian.PutUint64(buf[:], i)
@@ -353,7 +367,7 @@ elapsed, the key will no longer be retrievable and will be eligible for garbage
353367
collection. A TTL can be set as a `time.Duration` value using the `Entry.WithTTL()`
354368
and `Txn.SetEntry()` API methods.
355369

356-
```
370+
```go
357371
err := db.Update(func(txn *badger.Txn) error {
358372
e := badger.NewEntry([]byte("answer"), []byte("42")).WithTTL(time.Hour)
359373
err := txn.SetEntry(e)
@@ -366,7 +380,7 @@ is represented by a single byte. It can be used to set certain bits along
366380
with the key to aid in interpreting or decoding the key-value pair. User
367381
metadata can be set using `Entry.WithMeta()` and `Txn.SetEntry()` API methods.
368382

369-
```
383+
```go
370384
err := db.Update(func(txn *badger.Txn) error {
371385
e := badger.NewEntry([]byte("answer"), []byte("42")).WithMeta(byte(1))
372386
err := txn.SetEntry(e)
@@ -377,7 +391,7 @@ err := db.Update(func(txn *badger.Txn) error {
377391
`Entry` APIs can be used to add the user metadata and TTL for same key. This `Entry`
378392
then can be set using `Txn.SetEntry()`.
379393

380-
```
394+
```go
381395
err := db.Update(func(txn *badger.Txn) error {
382396
e := badger.NewEntry([]byte("answer"), []byte("42")).WithMeta(byte(1)).WithTTL(time.Hour)
383397
err := txn.SetEntry(e)
@@ -391,7 +405,7 @@ To iterate over keys, we can use an `Iterator`, which can be obtained using the
391405
order.
392406

393407

394-
```
408+
```go
395409
err := db.View(func(txn *badger.Txn) error {
396410
opts := badger.DefaultIteratorOptions
397411
opts.PrefetchSize = 10
@@ -424,7 +438,7 @@ values altogether. See section below on key-only iteration.
424438
### Prefix scans
425439
To iterate over a key prefix, you can combine `Seek()` and `ValidForPrefix()`:
426440

427-
```
441+
```go
428442
db.View(func(txn *badger.Txn) error {
429443
it := txn.NewIterator(badger.DefaultIteratorOptions)
430444
defer it.Close()
@@ -452,7 +466,7 @@ enable key-only iteration, you need to set the `IteratorOptions.PrefetchValues`
452466
field to `false`. This can also be used to do sparse reads for selected keys
453467
during an iteration, by calling `item.Value()` only when required.
454468

455-
```
469+
```go
456470
err := db.View(func(txn *badger.Txn) error {
457471
opts := badger.DefaultIteratorOptions
458472
opts.PrefetchValues = false
@@ -491,7 +505,7 @@ provide full and incremental backups quickly. Dgraph is a heavy user of this
491505
framework. In fact, this framework was developed and used within Dgraph, before
492506
getting ported over to Badger.
493507

494-
```
508+
```go
495509
stream := db.NewStream()
496510
// db.NewStreamAt(readTs) for managed mode.
497511

@@ -546,7 +560,7 @@ the following method, which can be invoked at an appropriate time:
546560
one log file. As an optimization, you could also immediately re-run it whenever
547561
it returns nil error (indicating a successful value log GC), as shown below.
548562

549-
```
563+
```go
550564
ticker := time.NewTicker(5 * time.Minute)
551565
defer ticker.Stop()
552566
for range ticker.C {
@@ -571,13 +585,13 @@ in your PATH to use this tool.
571585
The command below will create a version-agnostic backup of the database, to a
572586
file `badger.bak` in the current working directory
573587

574-
```
588+
```sh
575589
badger backup --dir <path/to/badgerdb>
576590
```
577591

578592
To restore `badger.bak` in the current working directory to a new database:
579593

580-
```
594+
```sh
581595
badger restore --dir <path/to/badgerdb>
582596
```
583597

@@ -587,7 +601,7 @@ If you have a Badger database that was created using v0.8 (or below), you can
587601
use the `badger_backup` tool provided in v0.8.1, and then restore it using the
588602
command above to upgrade your database to work with the latest version.
589603

590-
```
604+
```sh
591605
badger_backup --dir <path/to/badgerdb> --backup-file badger.bak
592606
```
593607

@@ -597,7 +611,7 @@ latest value log which is append-only. So, rsync can be used as rudimentary way
597611
to perform a backup. In the following script, we repeat rsync to ensure that the
598612
LSM tree remains consistent with the MANIFEST file while doing a full backup.
599613

600-
```
614+
```sh
601615
#!/bin/bash
602616
set -o history
603617
set -o histexpand
@@ -612,14 +626,10 @@ Badger's memory usage can be managed by tweaking several options available in
612626
the `Options` struct that is passed in when opening the database using
613627
`DB.Open`.
614628

615-
- `Options.ValueLogLoadingMode` can be set to `options.FileIO` (instead of the
616-
default `options.MemoryMap`) to avoid memory-mapping log files. This can be
617-
useful in environments with low RAM.
618629
- Number of memtables (`Options.NumMemtables`)
619630
- If you modify `Options.NumMemtables`, also adjust `Options.NumLevelZeroTables` and
620631
`Options.NumLevelZeroTablesStall` accordingly.
621632
- Number of concurrent compactions (`Options.NumCompactors`)
622-
- Mode in which LSM tree is loaded (`Options.TableLoadingMode`)
623633
- Size of table (`Options.MaxTableSize`)
624634
- Size of value log file (`Options.ValueLogFileSize`)
625635

docs/content/projects-using-badger/index.md

+15-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ Below is a list of known projects that use Badger:
1515
* [Sandglass](https://github.com/celrenheit/sandglass) - distributed, horizontally scalable, persistent, time sorted message queue.
1616
* [TalariaDB](https://github.com/grab/talaria) - Grab's Distributed, low latency time-series database.
1717
* [Sloop](https://github.com/salesforce/sloop) - Salesforce's Kubernetes History Visualization Project.
18-
* [Immudb](https://github.com/codenotary/immudb) - Lightweight, high-speed immutable database for systems and applications.
1918
* [Usenet Express](https://usenetexpress.com/) - Serving over 300TB of data with Badger.
2019
* [gorush](https://github.com/appleboy/gorush) - A push notification server written in Go.
2120
* [0-stor](https://github.com/zero-os/0-stor) - Single device object store.
@@ -38,5 +37,20 @@ Below is a list of known projects that use Badger:
3837
* [Cete](https://github.com/mosuka/cete) - Simple and highly available distributed key-value store built on Badger. Makes it easy bringing up a cluster of Badger with Raft consensus algorithm by hashicorp/raft.
3938
* [Volument](https://volument.com/) - A new take on website analytics backed by Badger.
4039
* [KVdb](https://kvdb.io/) - Hosted key-value store and serverless platform built on top of Badger.
40+
* [Opacity](https://github.com/opacity/storage-node) - Backend implementation for the Opacity storage project
41+
* [Vephar](https://github.com/vaccovecrana/vephar) - A minimal key/value store using hashicorp-raft for cluster coordination and Badger for data storage.
42+
* [gowarcserver](https://github.com/nlnwa/gowarcserver) - Open-source server for warc files. Can be used in conjunction with pywb
43+
* [flow-go](https://github.com/onflow/flow-go) - A fast, secure, and developer-friendly blockchain built to support the next generation of games, apps and the digital assets that power them.
44+
* [Wrgl](https://www.wrgl.co) - A data version control system that works like Git but specialized to store and diff CSV.
45+
* [chaindb](https://github.com/ChainSafe/chaindb) - A blockchain storage layer used by [Gossamer](https://chainsafe.github.io/gossamer/), a Go client for the [Polkadot Network](https://polkadot.network/).
46+
* [m2](https://github.com/qichengzx/m2) - A simple http key/value store based on the raft protocol.
47+
* [Xuperchain](https://github.com/xuperchain/xupercore) - A highly flexible blockchain architecture with great transaction performance.
48+
* [Pyroscope](https://github.com/pyroscope-io/pyroscope) - Open source confinuous profiling platform built with BadgerDB
49+
* [Souin](https://github.com/darkweak/Souin) - A RFC compliant HTTP cache with lot of other features based on Badger for the storage. Compatible with all existing reverse-proxies.
50+
* [Veri](https://github.com/bgokden/veri) - A distributed feature store optimized for Search and Recommendation tasks.
51+
* [bIter](https://github.com/MikkelHJuul/bIter) - A library and Iterator interface for working with the `badger.Iterator`, simplifying from-to, and prefix mechanics.
52+
* [ld](https://github.com/MikkelHJuul/ld) - (Lean Database) A very simple gRPC-only key-value database, exposing BadgerDB with key-range scanning semantics.
53+
* [smallstep/certificates](https://github.com/smallstep/certificates) - Step-ca is an online certificate authority for secure, automated certificate management.
54+
* [vxdb](https://github.com/vitalvas/vxdb) - Simple schema-less Key-Value NoSQL database with simplest API interface.
4155

4256
If you are using Badger in a project please send a pull request to add it to the list.

0 commit comments

Comments
 (0)