31 Commits
Author SHA1 Message Date
zeekay 7ded8d34a0 chore: sync working tree
Commits 2 outstanding change(s) that were sitting uncommitted.
No build artifacts and no secrets in the changeset (both checked).
2026-07-26 10:07:01 -07:00
zeekay 197200fd11 corona→corona: academic Corona now only in lp-220-p3q-corona 2026-06-11 10:28:47 -07:00
Hanzo Dev d5ea72f886 fix: Go 1.26 vet compliance, grpc build tag in proto gen
- Fix format string vet errors in db2_test.go and key_registry.go
  for Go 1.26 stricter printf checks
- Update pb/gen.sh to add //go:build grpc tag after protoc generation
  so protobuf types only compile with grpc tag (default uses ZAP
  native binary encoding from types_zap.go)
2026-03-11 22:45:10 -07:00
Zach Kelling 97021454b5 fix: use native binary encoding for wire-format compatibility with luxfi/badger
Replace proto.Marshal/Unmarshal with native pb.Marshal/pb.Unmarshal to
match the wire format used by luxfi/badger/v4. This ensures databases
written by nodes using the badger fork (v1.23.4) can be read by nodes
using zapdb (v1.23.5), preventing "proto: cannot parse invalid
wire-format data" errors during rolling upgrades.

Added types_zap.go and marshal_zap.go from luxfi/badger fork, which
provide custom LittleEndian binary encoding for ManifestChangeSet,
KV, Checksum, and other internal types. The standard protobuf
generated code (badgerpb4.pb.go) is now behind a grpc build tag.
2026-02-08 18:33:39 -08:00
Matthew McNeelyandGitHub 56b2d31d75 chore: update README.md with correct links and badges (#2239)
**Description**

Updated links

Closes #2238
2025-12-10 22:11:18 +00:00
Aman MangalandGitHub f0176aab66 Revert "Update badgerpb4.pb.go" (#2172)
This reverts commit a9c14388a1.
2025-02-14 09:05:38 -05:00
Ryan Fox-Tyler a9c14388a1 Update badgerpb4.pb.go 2025-02-05 17:16:36 -05:00
Ryan Fox-TylerandGitHub 94498ea84c chore: align repo conventions (#2158) 2025-02-05 17:00:32 -05:00
Shivaji KharseandGitHub 8fe64016c9 upgrade protobuf library to google's protobuf (#2131) 2024-11-29 05:01:57 +05:30
Joshua GoldsteinandGitHub 10ae1a262c fix(pb): fix generated protos (#1888)
We update protobuf files and generation script to version v4.
2023-02-27 23:55:23 +00:00
Joshua GoldsteinandGitHub ad428b8122 chore(ci): update changelog + import paths for v4 (#1886)
Changelog should reflect that we are switching to SemVer. This requires
moving to a new major version. We also update all import paths in
Badger.
2023-02-27 22:21:42 +00:00
Joshua GoldsteinandGitHub 3758356d91 chore: cherry-pick changes from main to release (#1857)
Cherry picks: #1692 , #1790, #1701, #1724, #1702 , #1766 ,
part of #1808, #1853 , update ChangeLog
2023-02-11 17:04:54 +05:30
Manish R JainandGitHub 0fcf3553a4 feat(Trie): Working prefix match with holes (#1654)
This PR adds a way to match a prefix, while ignoring certain portions of the key (aka holes).

This is useful to implement multi-tenancy in Dgraph, where namespace is stored on the byte index 3-11 in the prefix key, and those bytes need to be ignored to subscribe to updates across all the namespaces.
2021-01-27 20:43:18 -08:00
Naman JainandGitHub 1d9161103c chore: use gogofaster instead of gofast (#1639)
Switch to gogofaster as it does not produce the extra XXX_ fields that increase up the space of protobuf.
2021-01-25 14:58:49 +05:30
aman bansalandGitHub dbca3723b3 changing badger module path to v3 (#1636)
* changing badger module path to v3

* running go mod tidy

* updating metric keys + proto package
2021-01-13 10:55:37 +05:30
Manish R JainandGitHub be00cbf76f opt(memory): Use z.Calloc for allocating KVList (#1563)
KVs can take up a lot of memory in the stream framework. With this change, we allocate them using z.Allocator, and allow callers to KeyToList to use the allocator to generate KVs as well. After we call Send, we release them.

Also change Stream Framework to spit out StreamDone markers.
2020-10-13 14:31:31 -07:00
Ibrahim JarifandGitHub ce11ae2977 [BREAKING] feat(index): Use flatbuffers instead of protobuf (#1546)
This PR 
- Uses flatbuffers instead of protobufs for table index and directly stores byte slices in the cache.
- Uses MaxVersion to pick the oldest tables for compaction first.
- Uses leveldb/bloom so that we can test it without unmarshal
- Adds uncompressed size and key count in table index.
- Updates write bench tool to use managed mode.
2020-10-03 22:04:58 +05:30
Daniel MartíandGitHub a1850a40ff pb: avoid protobuf warning due to common filename (#1519)
If a Go program imports both badger (v1) and badger/v2, a warning will
be produced at init time:

	WARNING: proto: file "pb.proto" is already registered
	A future release will panic on registration conflicts. See:
	https://developers.google.com/protocol-buffers/docs/reference/go/faq#namespace-conflict

The problem is the "pb.proto" filename; it's registered globally, which
makes it very likely to cause conflicts with other protobuf-generated
packages in a Go binary.

Coincidentally, this is a problem with badger's pb package in the v1 module,
since that too uses the name "pb.proto". Instead, call the file
"badgerpb2.proto", which should be unique enough, and it's also the name
we use for the Protobuf package.

Finally, update gen.sh to work out of the box via just "bash gen.sh"
without needing extra tweaks, thanks to the "paths=source_relative"
option. It forces output files to be produced next to the input files,
which is what we want.
2020-09-27 15:43:19 +05:30
Ibrahim JarifandGitHub 46c1b32972 Proto: Rename dgraph.badger.v2.pb to badgerpb2 (#1314)
This PR renames badger protobuf package from `dgraph.badger.v2.pb`
to `badgerpb2`. 
The `pb.pb.go` file has been regenerated using the `pb/gen.sh` script.
2020-04-21 11:56:06 +05:30
Daniel MartíandGitHub 060c97f7ee Proto: make badger/v2 compatible with v1 (#1293)
There were two instances of init-time work being incompatible with v1.
That is, if one imported both v1 and v2 as part of a Go build, the
resulting binary would end up panicking before main could run. The
examples below are done with the latest versions of v1 and v2, and a
main.go as follows:

	package main

	import (
		_ "github.com/dgraph-io/badger"
		_ "github.com/dgraph-io/badger/v2"
	)

	func main() {}

First, the protobuf package used "pb" as its proto package name. This is
a problem, because types are registered globally with their fully
qualified names, like "pb.Foo". Since both badger/pb and badger/v2/pb
tried to globally register types with the same qualified names, we'd get
a panic:

	$ go run .
	panic: proto: duplicate enum registered: pb.ManifestChange_Operation

	goroutine 1 [running]:
	github.com/golang/protobuf/proto.RegisterEnum(...)
		.../go/pkg/mod/github.com/golang/protobuf@v1.3.1/proto/properties.go:459
	github.com/dgraph-io/badger/v2/pb.init.0()
		.../badger/pb/pb.pb.go:638 +0x459

To fix this, make v2's proto package fully qualified. Since the
namespace is global, just "v2.pb" wouldn't suffice; it's not unique
enough. "dgraph.badger.v2.pb" seems good, since it follows the Go module
path pretty closely.

The second issue was with expvar, which too uses globally registered
names:

	$ go run .
	2020/04/08 22:59:20 Reuse of exported var name: badger_disk_reads_total
	panic: Reuse of exported var name: badger_disk_reads_total

	goroutine 1 [running]:
	log.Panicln(0xc00010de48, 0x2, 0x2)
		.../src/log/log.go:365 +0xac
	expvar.Publish(0x906fcc, 0x17, 0x9946a0, 0xc0000b0318)
		.../src/expvar/expvar.go:278 +0x267
	expvar.NewInt(...)
		.../src/expvar/expvar.go:298
	github.com/dgraph-io/badger/v2/y.init.1()
		.../badger/y/metrics.go:55 +0x65
	exit status 2

This time, replacing the "badger_" var prefix with "badger_v2_" seems
like it's simple enough as a fix.

Fixes #1208.
2020-04-09 15:11:09 +05:30
michele meloniandGitHub 891e947240 Add go_package in .proto (#1282) 2020-04-08 15:22:23 +05:30
Ibrahim JarifandGitHub 5524762927 Store total key-value size in table footer (#1137)
This PR stores the total key-value size in a table in the table
footer. The key-value size can be accessed via db.Tables(..) call.
It returns the list of all tables along with the total size of key-values.
2019-12-10 20:07:16 +05:30
Ibrahim JarifandGitHub 7738c9150c Regenerate proto files (#1092)
The proto files in the current master are not compatible with the ones in dgraph.
See build for PR https://github.com/dgraph-io/dgraph/pull/4200
```
	[Step 3/5] # github.com/dgraph-io/dgraph/protos/pb
[11:02:11]	[Step 3/5] ../protos/pb/pb.pb.go:7146:29: m.Kv[iNdEx].MarshalToSizedBuffer undefined (type *pb.KV has no field or method MarshalToSizedBuffer)
[11:02:11]	[Step 3/5] ../protos/pb/pb.pb.go:7209:29: m.Kv[iNdEx].MarshalToSizedBuffer undefined (type *pb.KV has no field or method MarshalToSizedBuffer)
[11:02:40]	[Step 3/5] Makefile:66: recipe for target 'install' failed
[11:02:40]	[Step 3/5] make[1]: *** [install] Error 2
[11:02:40]	[Step 3/5] make[1]: Leaving directory '/home/pawan0201/go/src/github.com/dgraph-io/dgraph/dgraph'
[11:02:40]	[Step 3/5] make: *** [install] Error 2
[11:02:40]	[Step 3/5] Makefile:43: recipe for target 'install' failed
[11:02:40]	[Step 3/5] Process exited with code 2
```

https://teamcity.dgraph.io/viewLog.html?buildId=29232&buildTypeId=Dgraph_Blockade&tab=buildLog

This PR updates the proto files in badger. I've run `./gen.sh` script to regenerate these.
2019-10-21 19:34:16 +05:30
Ashish GoswamiandGitHub 700e8124ff Introduce StreamDone in Stream Writer (#1061)
This PR introduces, a way to tell StreamWriter to close a stream. Previously Streams were always open until Flush is called on StreamWriter. This resulted in memory utilisation, because of underlying TableBuilder to a sortedWriter. Also closing all sorted writer in single call resulted in 
more memory allocation(during Flush()). This can be useful in some case such as bulk loader in
Dgraph, where only one stream is active at a time.
2019-10-18 19:05:08 +05:30
Ibrahim JarifandGitHub 978228d6a4 Support compression in Badger (#1013)
This commit adds support for compression in badger. Two compression
algorithms - Snappy and ZSTD are supported for now. The compression algorithm information
is stored in the manifest file. We compress blocks (typically of size 4KB) stored in the SST.

The compression algorithm can be specified via the CompressionType option to badger.
2019-09-30 17:00:22 +05:30
balajiandGitHub f7920a6bdd Support encryption at rest (#1042)
This PR will add support for encrypting data which going to be on disk.
Two components are being encrypted, one is sst and another one is
vlog. In sst, each block is encrypted with seperate IV using AES CTR
mode. In vlog, each entry is being encrypted. Each vlog will have base
IV of 12 bytes. IV for the each entry is generated by merging base IV 
with entry offset. Data are encrypted using datakey, which is generated by
the badger. The datakey is further encrypted using user provided key 
and stored in disk. So that user can change key. In order to change
key user has to provide old key and new key. we'll decrypt using old
key and store the datakey back to disk by encrypting using the new
key. By this mechanism, it'll simplfy the key change.
2019-09-24 19:36:36 +05:30
Aman MangalandGitHub 2b307b8c73 Regenerate proto files (#954) 2019-08-01 09:20:20 -07:00
Ibrahim JarifandGitHub 96de591d47 [breaking/format] Add key-offset index to the end of SST table (#881)
* Add key-offset index to the end of SST table

This commit adds the key-offset index used for searching the blocks in
a table to the end the SST file. The length of the index is stored in
the last 4 bytes of the file.
2019-07-05 17:13:19 +05:30
Ashish GoswamiandManish R Jain 649987829c Add StreamWriter for fast sorted stream writes (#802)
Changes:

* Start work on a sorted stream writer which can avoid paying the cost of compactions.
* Logic for sorted stream writer is all written.
* Add a stream id to each key in the output from Stream framework.
* Make StreamWriter work. Performance is incredible, able to write at 100MBps.
* Add Tests for Stream Writer
* Update Oracle after Stream Writer is done
* Mods in stream framework so we can decrease the number of key ranges
* Add awareness of stream id in sortedWriter.
* Sync the directories when StreamWriter is done.
* Add licenses
* Moving builder.Finish within the goroutine improves throughput by 15%. Getting 112MBps write speed.
* Change Stream Writer Tests to have managed modes also
* Rename files to stream_writer.go and the corresponding test file.
* Fix a bug caused by marking an index done below current done until, causing a panic. Now we just recreate the oracle.
* Update protos
2019-05-16 16:35:11 -07:00
Manish R JainandGitHub 24eb776fb3 Introduce SSTable sha256 checksums (#689)
Add SHA256 checksums for SSTables in MANIFEST. If a table no longer matches this checksum, that table would be skipped over with an error.

Tested that it works with previous badger directories. As new tables get created, Badger would store their checksums in MANIFEST.

Modified `badger info` to show the checksums stored in MANIFEST, so user can manually compare the output from `sha256sum <filename>` if needed.

Fixes #680 .
2019-01-19 21:02:31 -08:00
Manish R JainandGitHub b5ec83c05a Renaming and Refactoring (#655)
- Flatten function can now be called from live code path, i.e. while Badger is running.
- Refactor stop and start compactions code, so it can be used in Flatten, DropAll, and other places.
- Rename protos package to pb. Consolidate both the proto files into one pb.proto.
- Rename KeyToKVList to just KeyToList in Stream.
- Rename KVPair to just KV.

Changes:
* Rename protos to pb.
* Rename KeyToKVList to KeyToList.
* Refactor stop and start compactions, so we can use it in various places.
* Rename KVPair to KV
* Defer startCompactions right next to stopCompactions.
* Catch all usages of KVPair. Rename to KV.
2018-12-28 16:51:05 -08:00