Skip to content

Commit

Permalink
Merge branch 'main' of github.com:dgraph-io/badger
Browse files Browse the repository at this point in the history
  • Loading branch information
kokizzu committed Jul 23, 2024
2 parents 259ddf6 + a5db1d4 commit 11ba6e8
Show file tree
Hide file tree
Showing 28 changed files with 108 additions and 132 deletions.
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# CODEOWNERS info: https://help.github.com/en/articles/about-code-owners
# Owners are automatically requested for review for PRs that changes code
# that they own.
* @akon-dey @nosql22 @billprovince @joshua-goldstein @skrdgraph
* @dgraph-io/committers
20 changes: 0 additions & 20 deletions .github/stale.yml

This file was deleted.

12 changes: 6 additions & 6 deletions .github/workflows/cd-badger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ on:
type: string
jobs:
badger-build-amd64:
runs-on: ubuntu-20.04
runs-on: warp-ubuntu-latest-x64-4x
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
ref: '${{ github.event.inputs.releasetag }}'
- name: Get Go Version
Expand All @@ -19,7 +19,7 @@ jobs:
GOVERSION=$({ [ -f .go-version ] && cat .go-version; })
echo "GOVERSION=$GOVERSION" >> $GITHUB_ENV
- name: Set up Go
uses: actions/setup-go@v3
uses: actions/setup-go@v5
with:
go-version: ${{ env.GOVERSION }}
- name: Set Badger Release Version
Expand Down Expand Up @@ -51,9 +51,9 @@ jobs:
badger/badger-checksum-linux-amd64.sha256
badger/badger-linux-amd64.tar.gz
badger-build-arm64:
runs-on: [self-hosted, ARM64]
runs-on: warp-ubuntu-latest-arm64-4x
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
ref: '${{ github.event.inputs.releasetag }}'
- name: Get Go Version
Expand All @@ -62,7 +62,7 @@ jobs:
GOVERSION=$({ [ -f .go-version ] && cat .go-version; })
echo "GOVERSION=$GOVERSION" >> $GITHUB_ENV
- name: Set up Go
uses: actions/setup-go@v3
uses: actions/setup-go@v5
with:
go-version: ${{ env.GOVERSION }}
- name: Set Badger Release Version
Expand Down
11 changes: 3 additions & 8 deletions .github/workflows/ci-aqua-security-trivy-tests.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,20 @@
name: ci-aqua-security-trivy-tests
on:
push:
branches:
- main
pull_request:
types:
- opened
- reopened
- synchronize
- ready_for_review
branches:
- main
schedule:
- cron: "1 0 * * *"
- main
jobs:
build:
name: trivy-tests
runs-on: ubuntu-20.04
runs-on: warp-ubuntu-latest-x64-4x
steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@master
with:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/ci-badger-bank-tests-nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ on:
- cron: "1 3 * * *"
jobs:
badger-bank:
runs-on: ubuntu-20.04
runs-on: warp-ubuntu-latest-x64-4x
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Get Go Version
run: |
#!/bin/bash
GOVERSION=$({ [ -f .go-version ] && cat .go-version; })
echo "GOVERSION=$GOVERSION" >> $GITHUB_ENV
- name: Setup Go
uses: actions/setup-go@v3
uses: actions/setup-go@v5
with:
go-version: ${{ env.GOVERSION }}
- name: Install Dependencies
Expand Down
12 changes: 3 additions & 9 deletions .github/workflows/ci-badger-bank-tests.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,21 @@
name: ci-badger-bank-tests
on:
push:
branches:
- main
- 'release/v*'
pull_request:
branches:
- main
- 'release/v*'
schedule:
- cron: "1 0 * * *"
jobs:
badger-bank:
runs-on: ubuntu-20.04
runs-on: warp-ubuntu-latest-x64-4x
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Get Go Version
run: |
#!/bin/bash
GOVERSION=$({ [ -f .go-version ] && cat .go-version; })
echo "GOVERSION=$GOVERSION" >> $GITHUB_ENV
- name: Setup Go
uses: actions/setup-go@v3
uses: actions/setup-go@v5
with:
go-version: ${{ env.GOVERSION }}
- name: Install Dependencies
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/ci-badger-tests-coverage.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
name: ci-badger-tests-coverage
on:
pull_request_target:
pull_request:
branches:
- main
- 'release/v*'
jobs:
badger-tests-coverage:
runs-on: ubuntu-20.04
runs-on: warp-ubuntu-latest-x64-4x
steps:
- uses: actions/checkout@v3 # checkout merge commit
- uses: actions/checkout@v4 # checkout merge commit
with:
ref: "refs/pull/${{ github.event.number }}/merge"
- name: Get Go Version
Expand All @@ -17,7 +17,7 @@ jobs:
GOVERSION=$({ [ -f .go-version ] && cat .go-version; })
echo "GOVERSION=$GOVERSION" >> $GITHUB_ENV
- name: Setup Go
uses: actions/setup-go@v3
uses: actions/setup-go@v5
with:
go-version: ${{ env.GOVERSION }}
- name: Install Dependencies
Expand Down
12 changes: 3 additions & 9 deletions .github/workflows/ci-badger-tests.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,21 @@
name: ci-badger-tests
on:
push:
branches:
- main
- 'release/v*'
pull_request:
branches:
- main
- 'release/v*'
schedule:
- cron: "1 0 * * *"
jobs:
badger-tests:
runs-on: ubuntu-20.04
runs-on: warp-ubuntu-latest-x64-4x
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Get Go Version
run: |
#!/bin/bash
GOVERSION=$({ [ -f .go-version ] && cat .go-version; })
echo "GOVERSION=$GOVERSION" >> $GITHUB_ENV
- name: Setup Go
uses: actions/setup-go@v3
uses: actions/setup-go@v5
with:
go-version: ${{ env.GOVERSION }}
- name: Install Dependencies
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/ci-dgraph-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ on:
- main
jobs:
dgraph-tests:
runs-on: ubuntu-20.04-32gb
runs-on: warp-ubuntu-latest-x64-16x
steps:
- name: Checkout Dgraph repo
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
repository: dgraph-io/dgraph
ref: main
Expand All @@ -18,14 +18,14 @@ jobs:
GOVERSION=$({ [ -f .go-version ] && cat .go-version; })
echo "GOVERSION=$GOVERSION" >> $GITHUB_ENV
- name: Set up Go
uses: actions/setup-go@v3
uses: actions/setup-go@v5
with:
go-version: ${{ env.GOVERSION }}
- name: Fetch latest Badger version
run: |
go get github.com/dgraph-io/badger/v4@main
- name: Set up Node
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 16
- name: Install protobuf-compiler
Expand Down
21 changes: 7 additions & 14 deletions .github/workflows/ci-golang-lint.yml
Original file line number Diff line number Diff line change
@@ -1,37 +1,30 @@
name: ci-golang-lint
on:
push:
branches:
- main
- 'release/v*'
pull_request:
branches:
- main
- 'release/v*'
schedule:
- cron: "1 0 * * *"
jobs:
go-lint:
name: lint
runs-on: ubuntu-20.04
runs-on: warp-ubuntu-latest-x64-4x
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Get Go Version
run: |
#!/bin/bash
GOVERSION=$({ [ -f .go-version ] && cat .go-version; })
echo "GOVERSION=$GOVERSION" >> $GITHUB_ENV
- name: Setup Go
uses: actions/setup-go@v3
uses: actions/setup-go@v5
with:
go-version: ${{ env.GOVERSION }}
- name: golang-lint
env:
# prevent OOM
GOGC: 10
uses: golangci/golangci-lint-action@v3.2.0
uses: golangci/golangci-lint-action@v4
with:
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
version: v1.48
version: latest
only-new-issues: true
args: --timeout=10m
skip-pkg-cache: true
skip-build-cache: true
18 changes: 18 additions & 0 deletions .github/workflows/stale.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: 'Close stale issues and PRs'
on:
schedule:
- cron: '00 02,14 * * *'

permissions:
issues: write
pull-requests: write

jobs:
stale:
runs-on: ubuntu-latest
steps:
- uses: actions/stale@v9
with:
stale-issue-message: 'This issue has been stale for 60 days and will be closed automatically in 7 days. Comment to keep it open.'
stale-pr-message: 'This PR has been stale for 60 days and will be closed automatically in 7 days. Comment to keep it open.'
operations-per-run: 100
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ Below is a list of known projects that use Badger:
* [raft-badger](https://github.com/rfyiamcool/raft-badger) - raft-badger implements LogStore and StableStore Interface of hashcorp/raft. it is used to store raft log and metadata of hashcorp/raft.
* [DVID](https://github.com/janelia-flyem/dvid) - A dataservice for branched versioning of a variety of data types. Originally created for large-scale brain reconstructions in Connectomics.
* [KVS](https://github.com/tauraamui/kvs) - A library for making it easy to persist, load and query full structs into BadgerDB, using an ownership hierarchy model.
* [LLS](https://github.com/Boc-chi-no/LLS) - LLS is an efficient URL Shortener that can be used to shorten links and track link usage. Support for BadgerDB and MongoDB. Improved performance by more than 30% when using BadgerDB

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

Expand Down
5 changes: 5 additions & 0 deletions batch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,12 @@ func TestEmptyWriteBatch(t *testing.T) {
wb = db.NewWriteBatch()
require.NoError(t, wb.Flush())
wb = db.NewWriteBatch()
// Flush commits inner txn and sets a new one instead.
// Thus we need to save it to check if it was discarded.
txn := wb.txn
require.NoError(t, wb.Flush())
// check that flushed txn was discarded and marked as read.
require.True(t, txn.discarded)
})
})
t.Run("managed mode", func(t *testing.T) {
Expand Down
13 changes: 7 additions & 6 deletions db.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import (
humanize "github.com/dustin/go-humanize"
"github.com/pkg/errors"

"github.com/dgraph-io/badger/v4/fb"
"github.com/dgraph-io/badger/v4/options"
"github.com/dgraph-io/badger/v4/pb"
"github.com/dgraph-io/badger/v4/skl"
Expand Down Expand Up @@ -123,8 +124,8 @@ type DB struct {

pub *publisher
registry *KeyRegistry
blockCache *ristretto.Cache
indexCache *ristretto.Cache
blockCache *ristretto.Cache[[]byte, *table.Block]
indexCache *ristretto.Cache[uint64, *fb.TableIndex]
allocPool *z.AllocatorPool
}

Expand Down Expand Up @@ -162,7 +163,7 @@ func checkAndSetOptions(opt *Options) error {
// the transaction APIs. Transaction batches entries into batches of size opt.maxBatchSize.
if opt.ValueThreshold > opt.maxBatchSize {
return errors.Errorf("Valuethreshold %d greater than max batch size of %d. Either "+
"reduce opt.ValueThreshold or increase opt.MaxTableSize.",
"reduce opt.ValueThreshold or increase opt.BaseTableSize.",
opt.ValueThreshold, opt.maxBatchSize)
}
// ValueLogFileSize should be stricly LESS than 2<<30 otherwise we will
Expand Down Expand Up @@ -274,14 +275,14 @@ func Open(opt Options) (*DB, error) {
numInCache = 1
}

config := ristretto.Config{
config := ristretto.Config[[]byte, *table.Block]{
NumCounters: numInCache * 8,
MaxCost: opt.BlockCacheSize,
BufferItems: 64,
Metrics: true,
OnExit: table.BlockEvictHandler,
}
db.blockCache, err = ristretto.NewCache(&config)
db.blockCache, err = ristretto.NewCache[[]byte, *table.Block](&config)
if err != nil {
return nil, y.Wrap(err, "failed to create data cache")
}
Expand All @@ -297,7 +298,7 @@ func Open(opt Options) (*DB, error) {
numInCache = 1
}

config := ristretto.Config{
config := ristretto.Config[uint64, *fb.TableIndex]{
NumCounters: numInCache * 8,
MaxCost: opt.IndexCacheSize,
BufferItems: 64,
Expand Down
2 changes: 1 addition & 1 deletion db_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1800,7 +1800,7 @@ func TestLSMOnly(t *testing.T) {

// Also test for error, when ValueThresholdSize is greater than maxBatchSize.
dopts.ValueThreshold = LSMOnlyOptions(dir).ValueThreshold
// maxBatchSize is calculated from MaxTableSize.
// maxBatchSize is calculated from BaseTableSize.
dopts.MemTableSize = LSMOnlyOptions(dir).ValueThreshold
_, err = Open(dopts)
require.Error(t, err, "db creation should have been failed")
Expand Down
2 changes: 1 addition & 1 deletion docs/content/faq/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ workloads, you should be using the `Transaction` API.

If you're using Badger with `SyncWrites=false`, then your writes might not be written to value log
and won't get synced to disk immediately. Writes to LSM tree are done inmemory first, before they
get compacted to disk. The compaction would only happen once `MaxTableSize` has been reached. So, if
get compacted to disk. The compaction would only happen once `BaseTableSize` has been reached. So, if
you're doing a few writes and then checking, you might not see anything on disk. Once you `Close`
the database, you'll see these writes on disk.

Expand Down
Loading

0 comments on commit 11ba6e8

Please sign in to comment.