Rebrand to Tutus - update license, workflows, and dependencies

This commit is contained in:
Tutus Development 2025-12-27 15:45:20 +00:00
parent fb3828d4f2
commit 783d4c35cf
29 changed files with 1348 additions and 1348 deletions

8
.gitattributes vendored
View File

@ -1,4 +1,4 @@
# ensure that line endings for Windows builds are properly formatted # ensure that line endings for Windows builds are properly formatted
# see https://github.com/golangci/golangci-lint-action?tab=readme-ov-file#how-to-use # see https://github.com/golangci/golangci-lint-action?tab=readme-ov-file#how-to-use
# at "Multiple OS Example" section # at "Multiple OS Example" section
*.go text eol=lf *.go text eol=lf

View File

@ -1,11 +1,11 @@
version: 2 version: 2
updates: updates:
- package-ecosystem: github-actions - package-ecosystem: github-actions
directory: / directory: /
schedule: schedule:
interval: weekly interval: weekly
- package-ecosystem: gomod - package-ecosystem: gomod
directory: / directory: /
schedule: schedule:
interval: weekly interval: weekly

View File

@ -1,9 +1,9 @@
--- ---
name: Benchmarks on PRs (AMD64) name: Benchmarks on PRs (AMD64)
permissions: read-all permissions: read-all
on: [pull_request] on: [pull_request]
jobs: jobs:
amd64: amd64:
uses: ./.github/workflows/benchmark-template.yaml uses: ./.github/workflows/benchmark-template.yaml
with: with:
benchGitRef: ${{ github.event.pull_request.base.sha }} benchGitRef: ${{ github.event.pull_request.base.sha }}

View File

@ -1,13 +1,13 @@
--- ---
name: Nightly Benchmarks against last release (AMD64) name: Nightly Benchmarks against last release (AMD64)
permissions: read-all permissions: read-all
on: on:
schedule: schedule:
- cron: '10 5 * * *' # runs every day at 05:10 UTC - cron: '10 5 * * *' # runs every day at 05:10 UTC
# workflow_dispatch enables manual testing of this job by maintainers # workflow_dispatch enables manual testing of this job by maintainers
workflow_dispatch: workflow_dispatch:
jobs: jobs:
amd64: amd64:
uses: ./.github/workflows/benchmark-template.yaml uses: ./.github/workflows/benchmark-template.yaml
with: with:
benchGitRef: release-1.3 benchGitRef: release-1.3

View File

@ -1,57 +1,57 @@
--- ---
name: Reusable Benchmark Template name: Reusable Benchmark Template
on: on:
workflow_call: workflow_call:
inputs: inputs:
# which git reference to benchmark against # which git reference to benchmark against
benchGitRef: benchGitRef:
required: true required: true
type: string type: string
maxAcceptableDifferencePercent: maxAcceptableDifferencePercent:
required: false required: false
type: number type: number
default: 5 default: 5
runs-on: runs-on:
required: false required: false
type: string type: string
default: "['ubuntu-latest']" default: "['ubuntu-latest']"
permissions: read-all permissions: read-all
jobs: jobs:
benchmark: benchmark:
runs-on: ${{ fromJson(inputs.runs-on) }} runs-on: ${{ fromJson(inputs.runs-on) }}
steps: steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with: with:
fetch-depth: 0 fetch-depth: 0
- id: goversion - id: goversion
run: echo "goversion=$(cat .go-version)" >> "$GITHUB_OUTPUT" run: echo "goversion=$(cat .go-version)" >> "$GITHUB_OUTPUT"
- uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0 - uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0
with: with:
go-version: ${{ steps.goversion.outputs.goversion }} go-version: ${{ steps.goversion.outputs.goversion }}
- name: Run Benchmarks - name: Run Benchmarks
run: | run: |
BENCHSTAT_OUTPUT_FILE=result.txt make test-benchmark-compare REF=${{ inputs.benchGitRef }} BENCHSTAT_OUTPUT_FILE=result.txt make test-benchmark-compare REF=${{ inputs.benchGitRef }}
- run: | - run: |
echo "\`\`\`" >> "$GITHUB_STEP_SUMMARY" echo "\`\`\`" >> "$GITHUB_STEP_SUMMARY"
cat result.txt >> "$GITHUB_STEP_SUMMARY" cat result.txt >> "$GITHUB_STEP_SUMMARY"
echo "\`\`\`" >> "$GITHUB_STEP_SUMMARY" echo "\`\`\`" >> "$GITHUB_STEP_SUMMARY"
cat <<EOL >> "$GITHUB_STEP_SUMMARY" cat <<EOL >> "$GITHUB_STEP_SUMMARY"
<hr /> <hr />
The table shows the median and 90% confidence interval (CI) summaries for each benchmark comparing the HEAD and the BASE, and an A/B comparison under "vs base". The last column shows the statistical p-value with ten runs (n=10). The table shows the median and 90% confidence interval (CI) summaries for each benchmark comparing the HEAD and the BASE, and an A/B comparison under "vs base". The last column shows the statistical p-value with ten runs (n=10).
The last row has the Geometric Mean (geomean) for the given rows in the table. The last row has the Geometric Mean (geomean) for the given rows in the table.
Refer to [benchstat's documentation](https://pkg.go.dev/golang.org/x/perf/cmd/benchstat) for more help. Refer to [benchstat's documentation](https://pkg.go.dev/golang.org/x/perf/cmd/benchstat) for more help.
EOL EOL
- name: Validate results under acceptable limit - name: Validate results under acceptable limit
run: | run: |
export MAX_ACCEPTABLE_DIFFERENCE=${{ inputs.maxAcceptableDifferencePercent }} export MAX_ACCEPTABLE_DIFFERENCE=${{ inputs.maxAcceptableDifferencePercent }}
while IFS= read -r line; do while IFS= read -r line; do
# Get fourth value, which is the comparison with the base. # Get fourth value, which is the comparison with the base.
value="$(echo "$line" | awk '{print $4}')" value="$(echo "$line" | awk '{print $4}')"
if [[ "$value" = +* ]] || [[ "$value" = -* ]]; then if [[ "$value" = +* ]] || [[ "$value" = -* ]]; then
if (( $(echo "${value//[^0-9.]/}"'>'"$MAX_ACCEPTABLE_DIFFERENCE" | bc -l) )); then if (( $(echo "${value//[^0-9.]/}"'>'"$MAX_ACCEPTABLE_DIFFERENCE" | bc -l) )); then
echo "::error::$value is above the maximum acceptable difference ($MAX_ACCEPTABLE_DIFFERENCE)" echo "::error::$value is above the maximum acceptable difference ($MAX_ACCEPTABLE_DIFFERENCE)"
exit 1 exit 1
fi fi
fi fi
done < <(grep geomean result.txt) done < <(grep geomean result.txt)

View File

@ -1,20 +1,20 @@
--- ---
name: Failpoint test name: Failpoint test
on: [push, pull_request] on: [push, pull_request]
permissions: read-all permissions: read-all
jobs: jobs:
test: test:
strategy: strategy:
matrix: matrix:
os: [ubuntu-latest] os: [ubuntu-latest]
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
steps: steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- id: goversion - id: goversion
run: echo "goversion=$(cat .go-version)" >> "$GITHUB_OUTPUT" run: echo "goversion=$(cat .go-version)" >> "$GITHUB_OUTPUT"
- uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0 - uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0
with: with:
go-version: ${{ steps.goversion.outputs.goversion }} go-version: ${{ steps.goversion.outputs.goversion }}
- run: | - run: |
make gofail-enable make gofail-enable
make test-failpoint make test-failpoint

View File

@ -1,42 +1,42 @@
--- ---
name: Approve GitHub Workflows name: Approve GitHub Workflows
permissions: read-all permissions: read-all
on: on:
pull_request_target: pull_request_target:
types: types:
- labeled - labeled
- synchronize - synchronize
branches: branches:
- main - main
- release-1.3 - release-1.3
jobs: jobs:
approve: approve:
name: Approve ok-to-test name: Approve ok-to-test
if: contains(github.event.pull_request.labels.*.name, 'ok-to-test') if: contains(github.event.pull_request.labels.*.name, 'ok-to-test')
runs-on: ubuntu-latest runs-on: ubuntu-latest
permissions: permissions:
actions: write actions: write
steps: steps:
- name: Update PR - name: Update PR
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
continue-on-error: true continue-on-error: true
with: with:
github-token: ${{ secrets.GITHUB_TOKEN }} github-token: ${{ secrets.GITHUB_TOKEN }}
debug: ${{ secrets.ACTIONS_RUNNER_DEBUG == 'true' }} debug: ${{ secrets.ACTIONS_RUNNER_DEBUG == 'true' }}
script: | script: |
const result = await github.rest.actions.listWorkflowRunsForRepo({ const result = await github.rest.actions.listWorkflowRunsForRepo({
owner: context.repo.owner, owner: context.repo.owner,
repo: context.repo.repo, repo: context.repo.repo,
event: "pull_request", event: "pull_request",
status: "action_required", status: "action_required",
head_sha: context.payload.pull_request.head.sha, head_sha: context.payload.pull_request.head.sha,
per_page: 100 per_page: 100
}); });
for (var run of result.data.workflow_runs) { for (var run of result.data.workflow_runs) {
await github.rest.actions.approveWorkflowRun({ await github.rest.actions.approveWorkflowRun({
owner: context.repo.owner, owner: context.repo.owner,
repo: context.repo.repo, repo: context.repo.repo,
run_id: run.id run_id: run.id
}); });
} }

View File

@ -1,17 +1,17 @@
--- ---
name: Robustness Nightly name: Robustness Nightly
permissions: read-all permissions: read-all
on: on:
schedule: schedule:
- cron: '25 9 * * *' # runs every day at 09:25 UTC - cron: '25 9 * * *' # runs every day at 09:25 UTC
# workflow_dispatch enables manual testing of this job by maintainers # workflow_dispatch enables manual testing of this job by maintainers
workflow_dispatch: workflow_dispatch:
jobs: jobs:
amd64: amd64:
# GHA has a maximum amount of 6h execution time, we try to get done within 3h # GHA has a maximum amount of 6h execution time, we try to get done within 3h
uses: ./.github/workflows/robustness_template.yaml uses: ./.github/workflows/robustness_template.yaml
with: with:
count: 100 count: 100
testTimeout: 200m testTimeout: 200m
runs-on: "['ubuntu-latest']" runs-on: "['ubuntu-latest']"

View File

@ -1,50 +1,50 @@
--- ---
name: Reusable Robustness Workflow name: Reusable Robustness Workflow
on: on:
workflow_call: workflow_call:
inputs: inputs:
count: count:
required: true required: true
type: number type: number
testTimeout: testTimeout:
required: false required: false
type: string type: string
default: '30m' default: '30m'
runs-on: runs-on:
required: false required: false
type: string type: string
default: "['ubuntu-latest']" default: "['ubuntu-latest']"
permissions: read-all permissions: read-all
jobs: jobs:
test: test:
# this is to prevent the job to run at forked projects # this is to prevent the job to run at forked projects
if: github.repository == 'etcd-io/bbolt' if: github.repository == 'etcd-io/bbolt'
timeout-minutes: 210 timeout-minutes: 210
runs-on: ${{ fromJson(inputs.runs-on) }} runs-on: ${{ fromJson(inputs.runs-on) }}
steps: steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- id: goversion - id: goversion
run: echo "goversion=$(cat .go-version)" >> "$GITHUB_OUTPUT" run: echo "goversion=$(cat .go-version)" >> "$GITHUB_OUTPUT"
- uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0 - uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0
with: with:
go-version: ${{ steps.goversion.outputs.goversion }} go-version: ${{ steps.goversion.outputs.goversion }}
- name: test-robustness - name: test-robustness
run: | run: |
set -euo pipefail set -euo pipefail
sudo apt-get install -y dmsetup xfsprogs sudo apt-get install -y dmsetup xfsprogs
ROBUSTNESS_TESTFLAGS="--count ${{ inputs.count }} --timeout ${{ inputs.testTimeout }} -failfast" make test-robustness ROBUSTNESS_TESTFLAGS="--count ${{ inputs.count }} --timeout ${{ inputs.testTimeout }} -failfast" make test-robustness
- name: Host Status - name: Host Status
if: always() if: always()
run: | run: |
set -x set -x
mount mount
df df
losetup -l losetup -l
- name: Kernel Message - name: Kernel Message
if: failure() if: failure()
run: | run: |
sudo lsmod sudo lsmod
sudo dmesg -T -f kern sudo dmesg -T -f kern

View File

@ -1,16 +1,16 @@
name: Robustness Test name: Robustness Test
on: [push, pull_request] on: [push, pull_request]
permissions: read-all permissions: read-all
jobs: jobs:
amd64: amd64:
uses: ./.github/workflows/robustness_template.yaml uses: ./.github/workflows/robustness_template.yaml
with: with:
count: 10 count: 10
testTimeout: 30m testTimeout: 30m
runs-on: "['ubuntu-latest']" runs-on: "['ubuntu-latest']"
arm64: arm64:
uses: ./.github/workflows/robustness_template.yaml uses: ./.github/workflows/robustness_template.yaml
with: with:
count: 10 count: 10
testTimeout: 30m testTimeout: 30m
runs-on: "['ubuntu-24.04-arm']" runs-on: "['ubuntu-24.04-arm']"

View File

@ -1,19 +1,19 @@
name: 'Close stale issues and PRs' name: 'Close stale issues and PRs'
on: on:
schedule: schedule:
- cron: '0 0 * * *' # every day at 00:00 UTC - cron: '0 0 * * *' # every day at 00:00 UTC
permissions: permissions:
issues: write issues: write
pull-requests: write pull-requests: write
jobs: jobs:
stale: stale:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/stale@5bef64f19d7facfb25b37b414482c7164d639639 # v9.1.0 - uses: actions/stale@5bef64f19d7facfb25b37b414482c7164d639639 # v9.1.0
with: with:
days-before-stale: 90 days-before-stale: 90
days-before-close: 21 days-before-close: 21
stale-issue-label: stale stale-issue-label: stale
stale-pr-label: stale stale-pr-label: stale

View File

@ -1,55 +1,55 @@
--- ---
name: Reusable unit test Workflow name: Reusable unit test Workflow
on: on:
workflow_call: workflow_call:
inputs: inputs:
runs-on: runs-on:
required: false required: false
type: string type: string
default: ubuntu-latest default: ubuntu-latest
targets: targets:
required: false required: false
type: string type: string
default: "['linux-unit-test-1-cpu','linux-unit-test-2-cpu','linux-unit-test-4-cpu']" default: "['linux-unit-test-1-cpu','linux-unit-test-2-cpu','linux-unit-test-4-cpu']"
permissions: read-all permissions: read-all
jobs: jobs:
test-linux: test-linux:
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
target: ${{ fromJSON(inputs.targets) }} target: ${{ fromJSON(inputs.targets) }}
runs-on: ${{ inputs.runs-on }} runs-on: ${{ inputs.runs-on }}
steps: steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- id: goversion - id: goversion
run: echo "goversion=$(cat .go-version)" >> "$GITHUB_OUTPUT" run: echo "goversion=$(cat .go-version)" >> "$GITHUB_OUTPUT"
- uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0 - uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0
with: with:
go-version: ${{ steps.goversion.outputs.goversion }} go-version: ${{ steps.goversion.outputs.goversion }}
- run: make fmt - run: make fmt
- env: - env:
TARGET: ${{ matrix.target }} TARGET: ${{ matrix.target }}
run: | run: |
case "${TARGET}" in case "${TARGET}" in
linux-unit-test-1-cpu) linux-unit-test-1-cpu)
CPU=1 make test CPU=1 make test
;; ;;
linux-unit-test-2-cpu) linux-unit-test-2-cpu)
CPU=2 make test CPU=2 make test
;; ;;
linux-unit-test-4-cpu) linux-unit-test-4-cpu)
CPU=4 make test CPU=4 make test
;; ;;
linux-unit-test-4-cpu-race) linux-unit-test-4-cpu-race)
CPU=4 ENABLE_RACE=true make test CPU=4 ENABLE_RACE=true make test
;; ;;
*) *)
echo "Failed to find target" echo "Failed to find target"
exit 1 exit 1
;; ;;
esac esac
- name: golangci-lint - name: golangci-lint
uses: golangci/golangci-lint-action@4afd733a84b1f43292c63897423277bb7f4313a9 # v8.0.0 uses: golangci/golangci-lint-action@4afd733a84b1f43292c63897423277bb7f4313a9 # v8.0.0
with: with:
version: v2.1.6 version: v2.1.6

View File

@ -1,26 +1,26 @@
--- ---
name: Tests AMD64 name: Tests AMD64
permissions: read-all permissions: read-all
on: [push, pull_request] on: [push, pull_request]
jobs: jobs:
test-linux-amd64: test-linux-amd64:
uses: ./.github/workflows/tests-template.yml uses: ./.github/workflows/tests-template.yml
test-linux-amd64-race: test-linux-amd64-race:
uses: ./.github/workflows/tests-template.yml uses: ./.github/workflows/tests-template.yml
with: with:
runs-on: ubuntu-latest runs-on: ubuntu-latest
targets: "['linux-unit-test-4-cpu-race']" targets: "['linux-unit-test-4-cpu-race']"
coverage: coverage:
needs: needs:
- test-linux-amd64 - test-linux-amd64
- test-linux-amd64-race - test-linux-amd64-race
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- id: goversion - id: goversion
run: echo "goversion=$(cat .go-version)" >> "$GITHUB_OUTPUT" run: echo "goversion=$(cat .go-version)" >> "$GITHUB_OUTPUT"
- uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0 - uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0
with: with:
go-version: ${{ steps.goversion.outputs.goversion }} go-version: ${{ steps.goversion.outputs.goversion }}
- run: make coverage - run: make coverage

View File

@ -1,26 +1,26 @@
--- ---
name: Tests ARM64 name: Tests ARM64
permissions: read-all permissions: read-all
on: [push, pull_request] on: [push, pull_request]
jobs: jobs:
test-linux-arm64: test-linux-arm64:
uses: ./.github/workflows/tests-template.yml uses: ./.github/workflows/tests-template.yml
test-linux-arm64-race: test-linux-arm64-race:
uses: ./.github/workflows/tests-template.yml uses: ./.github/workflows/tests-template.yml
with: with:
runs-on: ubuntu-24.04-arm runs-on: ubuntu-24.04-arm
targets: "['linux-unit-test-4-cpu-race']" targets: "['linux-unit-test-4-cpu-race']"
coverage: coverage:
needs: needs:
- test-linux-arm64 - test-linux-arm64
- test-linux-arm64-race - test-linux-arm64-race
runs-on: ubuntu-24.04-arm runs-on: ubuntu-24.04-arm
steps: steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- id: goversion - id: goversion
run: echo "goversion=$(cat .go-version)" >> "$GITHUB_OUTPUT" run: echo "goversion=$(cat .go-version)" >> "$GITHUB_OUTPUT"
- uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0 - uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0
with: with:
go-version: ${{ steps.goversion.outputs.goversion }} go-version: ${{ steps.goversion.outputs.goversion }}
- run: make coverage - run: make coverage

View File

@ -1,57 +1,57 @@
--- ---
name: Tests name: Tests
on: [push, pull_request] on: [push, pull_request]
permissions: read-all permissions: read-all
jobs: jobs:
test-windows: test-windows:
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
target: target:
- windows-amd64-unit-test-4-cpu - windows-amd64-unit-test-4-cpu
# FIXME(fuweid): # FIXME(fuweid):
# #
# The windows will throws the following error when enable race. # The windows will throws the following error when enable race.
# We skip it until we have solution. # We skip it until we have solution.
# #
# ThreadSanitizer failed to allocate 0x000200000000 (8589934592) bytes at 0x0400c0000000 (error code: 1455) # ThreadSanitizer failed to allocate 0x000200000000 (8589934592) bytes at 0x0400c0000000 (error code: 1455)
# #
# - windows-amd64-unit-test-4-cpu-race # - windows-amd64-unit-test-4-cpu-race
runs-on: windows-latest runs-on: windows-latest
steps: steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- id: goversion - id: goversion
run: echo "goversion=$(cat .go-version)" >> "$GITHUB_OUTPUT" run: echo "goversion=$(cat .go-version)" >> "$GITHUB_OUTPUT"
- uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0 - uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0
with: with:
go-version: ${{ steps.goversion.outputs.goversion }} go-version: ${{ steps.goversion.outputs.goversion }}
- run: make fmt - run: make fmt
- env: - env:
TARGET: ${{ matrix.target }} TARGET: ${{ matrix.target }}
run: | run: |
case "${TARGET}" in case "${TARGET}" in
windows-amd64-unit-test-4-cpu) windows-amd64-unit-test-4-cpu)
CPU=4 make test CPU=4 make test
;; ;;
*) *)
echo "Failed to find target" echo "Failed to find target"
exit 1 exit 1
;; ;;
esac esac
shell: bash shell: bash
- name: golangci-lint - name: golangci-lint
uses: golangci/golangci-lint-action@4afd733a84b1f43292c63897423277bb7f4313a9 # v8.0.0 uses: golangci/golangci-lint-action@4afd733a84b1f43292c63897423277bb7f4313a9 # v8.0.0
with: with:
version: v2.1.6 version: v2.1.6
coverage: coverage:
needs: ["test-windows"] needs: ["test-windows"]
runs-on: windows-latest runs-on: windows-latest
steps: steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- id: goversion - id: goversion
run: echo "goversion=$(cat .go-version)" >> "$GITHUB_OUTPUT" run: echo "goversion=$(cat .go-version)" >> "$GITHUB_OUTPUT"
- uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0 - uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0
with: with:
go-version: ${{ steps.goversion.outputs.goversion }} go-version: ${{ steps.goversion.outputs.goversion }}
- run: make coverage - run: make coverage

24
.gitignore vendored
View File

@ -1,12 +1,12 @@
*.prof *.prof
*.test *.test
*.swp *.swp
/bin/ /bin/
cover.out cover.out
cover-*.out cover-*.out
/.idea /.idea
*.iml *.iml
/bbolt /bbolt
/cmd/bbolt/bbolt /cmd/bbolt/bbolt
.DS_Store .DS_Store

View File

@ -1 +1 @@
1.24.3 1.24.3

View File

@ -1,34 +1,34 @@
formatters: formatters:
enable: enable:
- gofmt - gofmt
- goimports - goimports
settings: # please keep this alphabetized settings: # please keep this alphabetized
goimports: goimports:
local-prefixes: local-prefixes:
- go.etcd.io # Put imports beginning with prefix after 3rd-party packages. - go.etcd.io # Put imports beginning with prefix after 3rd-party packages.
issues: issues:
max-same-issues: 0 max-same-issues: 0
linters: linters:
default: none default: none
enable: # please keep this alphabetized enable: # please keep this alphabetized
- errcheck - errcheck
- govet - govet
- ineffassign - ineffassign
- staticcheck - staticcheck
- unused - unused
exclusions: exclusions:
presets: presets:
- comments - comments
- common-false-positives - common-false-positives
- legacy - legacy
- std-error-handling - std-error-handling
settings: # please keep this alphabetized settings: # please keep this alphabetized
staticcheck: staticcheck:
checks: checks:
- all - all
- -QF1003 # Convert if/else-if chain to tagged switch - -QF1003 # Convert if/else-if chain to tagged switch
- -QF1010 # Convert slice of bytes to string when printing it - -QF1010 # Convert slice of bytes to string when printing it
- -ST1003 # Poorly chosen identifier - -ST1003 # Poorly chosen identifier
- -ST1005 # Incorrectly formatted error string - -ST1005 # Incorrectly formatted error string
- -ST1012 # Poorly chosen name for error variable - -ST1012 # Poorly chosen name for error variable
version: "2" version: "2"

View File

@ -1,90 +1,90 @@
Note that we start to track changes starting from v1.3.7. Note that we start to track changes starting from v1.3.7.
<hr> <hr>
## v1.3.11(2024-08-21) ## v1.3.11(2024-08-21)
### BoltDB ### BoltDB
- Fix [the `freelist.allocs` isn't rollbacked when a tx is rollbacked](https://github.com/etcd-io/bbolt/pull/823). - Fix [the `freelist.allocs` isn't rollbacked when a tx is rollbacked](https://github.com/etcd-io/bbolt/pull/823).
### CMD ### CMD
- Add [`-gobench-output` option for bench command to adapt to benchstat](https://github.com/etcd-io/bbolt/pull/802). - Add [`-gobench-output` option for bench command to adapt to benchstat](https://github.com/etcd-io/bbolt/pull/802).
### Other ### Other
- [Bump go version to 1.22.x](https://github.com/etcd-io/bbolt/pull/822). - [Bump go version to 1.22.x](https://github.com/etcd-io/bbolt/pull/822).
- This patch also added `dmflakey` package, which can be reused by other projects. See https://github.com/etcd-io/bbolt/pull/812. - This patch also added `dmflakey` package, which can be reused by other projects. See https://github.com/etcd-io/bbolt/pull/812.
<hr> <hr>
## v1.3.10(2024-05-06) ## v1.3.10(2024-05-06)
### BoltDB ### BoltDB
- [Remove deprecated `UnsafeSlice` and use `unsafe.Slice`](https://github.com/etcd-io/bbolt/pull/717) - [Remove deprecated `UnsafeSlice` and use `unsafe.Slice`](https://github.com/etcd-io/bbolt/pull/717)
- [Stabilize the behaviour of Prev when the cursor already points to the first element](https://github.com/etcd-io/bbolt/pull/744) - [Stabilize the behaviour of Prev when the cursor already points to the first element](https://github.com/etcd-io/bbolt/pull/744)
### Other ### Other
- [Bump go version to 1.21.9](https://github.com/etcd-io/bbolt/pull/713) - [Bump go version to 1.21.9](https://github.com/etcd-io/bbolt/pull/713)
<hr> <hr>
## v1.3.9(2024-02-24) ## v1.3.9(2024-02-24)
### BoltDB ### BoltDB
- [Clone the key before operating data in bucket against the key](https://github.com/etcd-io/bbolt/pull/639) - [Clone the key before operating data in bucket against the key](https://github.com/etcd-io/bbolt/pull/639)
### CMD ### CMD
- [Fix `bbolt keys` and `bbolt get` to prevent them from panicking when no parameter provided](https://github.com/etcd-io/bbolt/pull/683) - [Fix `bbolt keys` and `bbolt get` to prevent them from panicking when no parameter provided](https://github.com/etcd-io/bbolt/pull/683)
<hr> <hr>
## v1.3.8(2023-10-26) ## v1.3.8(2023-10-26)
### BoltDB ### BoltDB
- Fix [db.close() doesn't unlock the db file if db.munnmap() fails](https://github.com/etcd-io/bbolt/pull/439). - Fix [db.close() doesn't unlock the db file if db.munnmap() fails](https://github.com/etcd-io/bbolt/pull/439).
- [Avoid syscall.Syscall use on OpenBSD](https://github.com/etcd-io/bbolt/pull/406). - [Avoid syscall.Syscall use on OpenBSD](https://github.com/etcd-io/bbolt/pull/406).
- Fix [rollback panicking after mlock failed or both meta pages corrupted](https://github.com/etcd-io/bbolt/pull/444). - Fix [rollback panicking after mlock failed or both meta pages corrupted](https://github.com/etcd-io/bbolt/pull/444).
- Fix [bbolt panicking due to 64bit unaligned on arm32](https://github.com/etcd-io/bbolt/pull/584). - Fix [bbolt panicking due to 64bit unaligned on arm32](https://github.com/etcd-io/bbolt/pull/584).
### CMD ### CMD
- [Update the usage of surgery command](https://github.com/etcd-io/bbolt/pull/411). - [Update the usage of surgery command](https://github.com/etcd-io/bbolt/pull/411).
<hr> <hr>
## v1.3.7(2023-01-31) ## v1.3.7(2023-01-31)
### BoltDB ### BoltDB
- Add [recursive checker to confirm database consistency](https://github.com/etcd-io/bbolt/pull/225). - Add [recursive checker to confirm database consistency](https://github.com/etcd-io/bbolt/pull/225).
- Add [support to get the page size from the second meta page if the first one is invalid](https://github.com/etcd-io/bbolt/pull/294). - Add [support to get the page size from the second meta page if the first one is invalid](https://github.com/etcd-io/bbolt/pull/294).
- Add [support for loong64 arch](https://github.com/etcd-io/bbolt/pull/303). - Add [support for loong64 arch](https://github.com/etcd-io/bbolt/pull/303).
- Add [internal iterator to Bucket that goes over buckets](https://github.com/etcd-io/bbolt/pull/356). - Add [internal iterator to Bucket that goes over buckets](https://github.com/etcd-io/bbolt/pull/356).
- Add [validation on page read and write](https://github.com/etcd-io/bbolt/pull/358). - Add [validation on page read and write](https://github.com/etcd-io/bbolt/pull/358).
- Add [PreLoadFreelist option to support loading free pages in readonly mode](https://github.com/etcd-io/bbolt/pull/381). - Add [PreLoadFreelist option to support loading free pages in readonly mode](https://github.com/etcd-io/bbolt/pull/381).
- Add [(*Tx) CheckWithOption to support generating human-readable diagnostic messages](https://github.com/etcd-io/bbolt/pull/395). - Add [(*Tx) CheckWithOption to support generating human-readable diagnostic messages](https://github.com/etcd-io/bbolt/pull/395).
- Fix [Use `golang.org/x/sys/windows` for `FileLockEx`/`UnlockFileEx`](https://github.com/etcd-io/bbolt/pull/283). - Fix [Use `golang.org/x/sys/windows` for `FileLockEx`/`UnlockFileEx`](https://github.com/etcd-io/bbolt/pull/283).
- Fix [readonly file mapping on windows](https://github.com/etcd-io/bbolt/pull/307). - Fix [readonly file mapping on windows](https://github.com/etcd-io/bbolt/pull/307).
- Fix [the "Last" method might return no data due to not skipping the empty pages](https://github.com/etcd-io/bbolt/pull/341). - Fix [the "Last" method might return no data due to not skipping the empty pages](https://github.com/etcd-io/bbolt/pull/341).
- Fix [panic on db.meta when rollback](https://github.com/etcd-io/bbolt/pull/362). - Fix [panic on db.meta when rollback](https://github.com/etcd-io/bbolt/pull/362).
### CMD ### CMD
- Add [support for get keys in sub buckets in `bbolt get` command](https://github.com/etcd-io/bbolt/pull/295). - Add [support for get keys in sub buckets in `bbolt get` command](https://github.com/etcd-io/bbolt/pull/295).
- Add [support for `--format` flag for `bbolt keys` command](https://github.com/etcd-io/bbolt/pull/306). - Add [support for `--format` flag for `bbolt keys` command](https://github.com/etcd-io/bbolt/pull/306).
- Add [safeguards to bbolt CLI commands](https://github.com/etcd-io/bbolt/pull/354). - Add [safeguards to bbolt CLI commands](https://github.com/etcd-io/bbolt/pull/354).
- Add [`bbolt page` supports --all and --value-format=redacted formats](https://github.com/etcd-io/bbolt/pull/359). - Add [`bbolt page` supports --all and --value-format=redacted formats](https://github.com/etcd-io/bbolt/pull/359).
- Add [`bbolt surgery` commands](https://github.com/etcd-io/bbolt/issues/370). - Add [`bbolt surgery` commands](https://github.com/etcd-io/bbolt/issues/370).
- Fix [open db file readonly mode for commands which shouldn't update the db file](https://github.com/etcd-io/bbolt/pull/365), see also [pull/292](https://github.com/etcd-io/bbolt/pull/292). - Fix [open db file readonly mode for commands which shouldn't update the db file](https://github.com/etcd-io/bbolt/pull/365), see also [pull/292](https://github.com/etcd-io/bbolt/pull/292).
### Other ### Other
- [Build bbolt CLI tool, test and format the source code using golang 1.17.13](https://github.com/etcd-io/bbolt/pull/297). - [Build bbolt CLI tool, test and format the source code using golang 1.17.13](https://github.com/etcd-io/bbolt/pull/297).
- [Bump golang.org/x/sys to v0.4.0](https://github.com/etcd-io/bbolt/pull/397). - [Bump golang.org/x/sys to v0.4.0](https://github.com/etcd-io/bbolt/pull/397).
### Summary ### Summary
Release v1.3.7 contains following critical fixes: Release v1.3.7 contains following critical fixes:
- fix to problem that `Last` method might return incorrect value ([#341](https://github.com/etcd-io/bbolt/pull/341)) - fix to problem that `Last` method might return incorrect value ([#341](https://github.com/etcd-io/bbolt/pull/341))
- fix of potential panic when performing transaction's rollback ([#362](https://github.com/etcd-io/bbolt/pull/362)) - fix of potential panic when performing transaction's rollback ([#362](https://github.com/etcd-io/bbolt/pull/362))
Other changes focused on defense-in-depth ([#358](https://github.com/etcd-io/bbolt/pull/358), [#294](https://github.com/etcd-io/bbolt/pull/294), [#225](https://github.com/etcd-io/bbolt/pull/225), [#395](https://github.com/etcd-io/bbolt/pull/395)) Other changes focused on defense-in-depth ([#358](https://github.com/etcd-io/bbolt/pull/358), [#294](https://github.com/etcd-io/bbolt/pull/294), [#225](https://github.com/etcd-io/bbolt/pull/225), [#395](https://github.com/etcd-io/bbolt/pull/395))
`bbolt` command line tool was expanded to: `bbolt` command line tool was expanded to:
- allow fixing simple corruptions by `bbolt surgery` ([#370](https://github.com/etcd-io/bbolt/pull/370)) - allow fixing simple corruptions by `bbolt surgery` ([#370](https://github.com/etcd-io/bbolt/pull/370))
- be flexible about output formatting ([#306](https://github.com/etcd-io/bbolt/pull/306), [#359](https://github.com/etcd-io/bbolt/pull/359)) - be flexible about output formatting ([#306](https://github.com/etcd-io/bbolt/pull/306), [#359](https://github.com/etcd-io/bbolt/pull/359))
- allow accessing data in subbuckets ([#295](https://github.com/etcd-io/bbolt/pull/295)) - allow accessing data in subbuckets ([#295](https://github.com/etcd-io/bbolt/pull/295))

View File

@ -1,76 +1,76 @@
<hr> <hr>
## v1.4.0(2025-02-05) ## v1.4.0(2025-02-05)
There isn't any production code change since v1.4.0-beta.0. Only some dependencies There isn't any production code change since v1.4.0-beta.0. Only some dependencies
are bumped, also updated some typos in comment and readme, and removed the legacy are bumped, also updated some typos in comment and readme, and removed the legacy
build tag `// +build` in https://github.com/etcd-io/bbolt/pull/879. build tag `// +build` in https://github.com/etcd-io/bbolt/pull/879.
<hr> <hr>
## v1.4.0-beta.0(2024-11-04) ## v1.4.0-beta.0(2024-11-04)
### BoltDB ### BoltDB
- Reorganized the directory structure of freelist source code - Reorganized the directory structure of freelist source code
- [Move array related freelist source code into a separate file](https://github.com/etcd-io/bbolt/pull/777) - [Move array related freelist source code into a separate file](https://github.com/etcd-io/bbolt/pull/777)
- [Move method `freePages` into freelist.go](https://github.com/etcd-io/bbolt/pull/783) - [Move method `freePages` into freelist.go](https://github.com/etcd-io/bbolt/pull/783)
- [Add an interface for freelist](https://github.com/etcd-io/bbolt/pull/775) - [Add an interface for freelist](https://github.com/etcd-io/bbolt/pull/775)
- [Rollback alloc map when a transaction is rollbacked](https://github.com/etcd-io/bbolt/pull/819) - [Rollback alloc map when a transaction is rollbacked](https://github.com/etcd-io/bbolt/pull/819)
- [No handling freelist as a special case when freeing a page](https://github.com/etcd-io/bbolt/pull/788) - [No handling freelist as a special case when freeing a page](https://github.com/etcd-io/bbolt/pull/788)
- [Ensure hashmap init method clears the data structures](https://github.com/etcd-io/bbolt/pull/794) - [Ensure hashmap init method clears the data structures](https://github.com/etcd-io/bbolt/pull/794)
- [Panicking when a write transaction tries to free a page allocated by itself](https://github.com/etcd-io/bbolt/pull/792) - [Panicking when a write transaction tries to free a page allocated by itself](https://github.com/etcd-io/bbolt/pull/792)
### CMD ### CMD
- [Add `-gobench-output` flag for `bbolt bench` command](https://github.com/etcd-io/bbolt/pull/765) - [Add `-gobench-output` flag for `bbolt bench` command](https://github.com/etcd-io/bbolt/pull/765)
### Other ### Other
- [Bump go version to 1.23.x](https://github.com/etcd-io/bbolt/pull/821) - [Bump go version to 1.23.x](https://github.com/etcd-io/bbolt/pull/821)
<hr> <hr>
## v1.4.0-alpha.1(2024-05-06) ## v1.4.0-alpha.1(2024-05-06)
### BoltDB ### BoltDB
- [Enhance check functionality to support checking starting from a pageId](https://github.com/etcd-io/bbolt/pull/659) - [Enhance check functionality to support checking starting from a pageId](https://github.com/etcd-io/bbolt/pull/659)
- [Optimize the logger performance for frequent called methods](https://github.com/etcd-io/bbolt/pull/741) - [Optimize the logger performance for frequent called methods](https://github.com/etcd-io/bbolt/pull/741)
- [Stabilize the behaviour of Prev when the cursor already points to the first element](https://github.com/etcd-io/bbolt/pull/734) - [Stabilize the behaviour of Prev when the cursor already points to the first element](https://github.com/etcd-io/bbolt/pull/734)
### CMD ### CMD
- [Fix `bbolt keys` and `bbolt get` to prevent them from panicking when no parameter provided](https://github.com/etcd-io/bbolt/pull/682) - [Fix `bbolt keys` and `bbolt get` to prevent them from panicking when no parameter provided](https://github.com/etcd-io/bbolt/pull/682)
- [Fix surgery freelist command in info logs](https://github.com/etcd-io/bbolt/pull/700) - [Fix surgery freelist command in info logs](https://github.com/etcd-io/bbolt/pull/700)
- [Remove txid references in surgery meta command's comment and description](https://github.com/etcd-io/bbolt/pull/703) - [Remove txid references in surgery meta command's comment and description](https://github.com/etcd-io/bbolt/pull/703)
- [Add rnd read capabilities to bbolt bench](https://github.com/etcd-io/bbolt/pull/711) - [Add rnd read capabilities to bbolt bench](https://github.com/etcd-io/bbolt/pull/711)
- [Use `cobra.ExactArgs` to simplify the argument number check](https://github.com/etcd-io/bbolt/pull/728) - [Use `cobra.ExactArgs` to simplify the argument number check](https://github.com/etcd-io/bbolt/pull/728)
- [Migrate `bbolt check` command to cobra style](https://github.com/etcd-io/bbolt/pull/723) - [Migrate `bbolt check` command to cobra style](https://github.com/etcd-io/bbolt/pull/723)
- [Simplify the naming of cobra commands](https://github.com/etcd-io/bbolt/pull/732) - [Simplify the naming of cobra commands](https://github.com/etcd-io/bbolt/pull/732)
- [Aggregate adding completed ops for read test of the `bbolt bench` command](https://github.com/etcd-io/bbolt/pull/721) - [Aggregate adding completed ops for read test of the `bbolt bench` command](https://github.com/etcd-io/bbolt/pull/721)
- [Add `--from-page` flag to `bbolt check` command](https://github.com/etcd-io/bbolt/pull/737) - [Add `--from-page` flag to `bbolt check` command](https://github.com/etcd-io/bbolt/pull/737)
### Document ### Document
- [Add document for a known issue on the writing a value with a length of 0](https://github.com/etcd-io/bbolt/pull/730) - [Add document for a known issue on the writing a value with a length of 0](https://github.com/etcd-io/bbolt/pull/730)
### Test ### Test
- [Enhance robustness test to cover XFS](https://github.com/etcd-io/bbolt/pull/707) - [Enhance robustness test to cover XFS](https://github.com/etcd-io/bbolt/pull/707)
### Other ### Other
- [Bump go toolchain version to 1.22.2](https://github.com/etcd-io/bbolt/pull/712) - [Bump go toolchain version to 1.22.2](https://github.com/etcd-io/bbolt/pull/712)
<hr> <hr>
## v1.4.0-alpha.0(2024-01-12) ## v1.4.0-alpha.0(2024-01-12)
### BoltDB ### BoltDB
- [Improve the performance of hashmapGetFreePageIDs](https://github.com/etcd-io/bbolt/pull/419) - [Improve the performance of hashmapGetFreePageIDs](https://github.com/etcd-io/bbolt/pull/419)
- [Improve CreateBucketIfNotExists to avoid double searching the same key](https://github.com/etcd-io/bbolt/pull/532) - [Improve CreateBucketIfNotExists to avoid double searching the same key](https://github.com/etcd-io/bbolt/pull/532)
- [Support Android platform](https://github.com/etcd-io/bbolt/pull/571) - [Support Android platform](https://github.com/etcd-io/bbolt/pull/571)
- [Record the count of free page to improve the performance of hashmapFreeCount](https://github.com/etcd-io/bbolt/pull/585) - [Record the count of free page to improve the performance of hashmapFreeCount](https://github.com/etcd-io/bbolt/pull/585)
- [Add logger to bbolt](https://github.com/etcd-io/bbolt/issues/509) - [Add logger to bbolt](https://github.com/etcd-io/bbolt/issues/509)
- [Support moving bucket inside the same db](https://github.com/etcd-io/bbolt/pull/635) - [Support moving bucket inside the same db](https://github.com/etcd-io/bbolt/pull/635)
- [Support inspecting database structure](https://github.com/etcd-io/bbolt/pull/674) - [Support inspecting database structure](https://github.com/etcd-io/bbolt/pull/674)
### CMD ### CMD
- [Add `surgery clear-page-elements` command](https://github.com/etcd-io/bbolt/pull/417) - [Add `surgery clear-page-elements` command](https://github.com/etcd-io/bbolt/pull/417)
- [Add `surgery abandon-freelist` command](https://github.com/etcd-io/bbolt/pull/443) - [Add `surgery abandon-freelist` command](https://github.com/etcd-io/bbolt/pull/443)
- [Add `bbolt version` command](https://github.com/etcd-io/bbolt/pull/552) - [Add `bbolt version` command](https://github.com/etcd-io/bbolt/pull/552)
- [Add `bbolt inspect` command](https://github.com/etcd-io/bbolt/pull/674) - [Add `bbolt inspect` command](https://github.com/etcd-io/bbolt/pull/674)
- [Add `--no-sync` option to `bbolt compact` command](https://github.com/etcd-io/bbolt/pull/290) - [Add `--no-sync` option to `bbolt compact` command](https://github.com/etcd-io/bbolt/pull/290)

40
LICENSE
View File

@ -1,20 +1,20 @@
The MIT License (MIT) The MIT License (MIT)
Copyright (c) 2013 Ben Johnson Copyright (c) 2013 Ben Johnson
Permission is hereby granted, free of charge, to any person obtaining a copy of Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so, the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions: subject to the following conditions:
The above copyright notice and this permission notice shall be included in all The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software. copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

216
Makefile
View File

@ -1,108 +1,108 @@
BRANCH=`git rev-parse --abbrev-ref HEAD` BRANCH=`git rev-parse --abbrev-ref HEAD`
COMMIT=`git rev-parse --short HEAD` COMMIT=`git rev-parse --short HEAD`
GOLDFLAGS="-X main.branch $(BRANCH) -X main.commit $(COMMIT)" GOLDFLAGS="-X main.branch $(BRANCH) -X main.commit $(COMMIT)"
GOFILES = $(shell find . -name \*.go) GOFILES = $(shell find . -name \*.go)
TESTFLAGS_RACE=-race=false TESTFLAGS_RACE=-race=false
ifdef ENABLE_RACE ifdef ENABLE_RACE
TESTFLAGS_RACE=-race=true TESTFLAGS_RACE=-race=true
endif endif
TESTFLAGS_CPU= TESTFLAGS_CPU=
ifdef CPU ifdef CPU
TESTFLAGS_CPU=-cpu=$(CPU) TESTFLAGS_CPU=-cpu=$(CPU)
endif endif
TESTFLAGS = $(TESTFLAGS_RACE) $(TESTFLAGS_CPU) $(EXTRA_TESTFLAGS) TESTFLAGS = $(TESTFLAGS_RACE) $(TESTFLAGS_CPU) $(EXTRA_TESTFLAGS)
TESTFLAGS_TIMEOUT=30m TESTFLAGS_TIMEOUT=30m
ifdef TIMEOUT ifdef TIMEOUT
TESTFLAGS_TIMEOUT=$(TIMEOUT) TESTFLAGS_TIMEOUT=$(TIMEOUT)
endif endif
TESTFLAGS_ENABLE_STRICT_MODE=false TESTFLAGS_ENABLE_STRICT_MODE=false
ifdef ENABLE_STRICT_MODE ifdef ENABLE_STRICT_MODE
TESTFLAGS_ENABLE_STRICT_MODE=$(ENABLE_STRICT_MODE) TESTFLAGS_ENABLE_STRICT_MODE=$(ENABLE_STRICT_MODE)
endif endif
.EXPORT_ALL_VARIABLES: .EXPORT_ALL_VARIABLES:
TEST_ENABLE_STRICT_MODE=${TESTFLAGS_ENABLE_STRICT_MODE} TEST_ENABLE_STRICT_MODE=${TESTFLAGS_ENABLE_STRICT_MODE}
.PHONY: fmt .PHONY: fmt
fmt: fmt:
@echo "Verifying gofmt, failures can be fixed with ./scripts/fix.sh" @echo "Verifying gofmt, failures can be fixed with ./scripts/fix.sh"
@!(gofmt -l -s -d ${GOFILES} | grep '[a-z]') @!(gofmt -l -s -d ${GOFILES} | grep '[a-z]')
@echo "Verifying goimports, failures can be fixed with ./scripts/fix.sh" @echo "Verifying goimports, failures can be fixed with ./scripts/fix.sh"
@!(go run golang.org/x/tools/cmd/goimports@latest -l -d ${GOFILES} | grep '[a-z]') @!(go run golang.org/x/tools/cmd/goimports@latest -l -d ${GOFILES} | grep '[a-z]')
.PHONY: lint .PHONY: lint
lint: lint:
golangci-lint run ./... golangci-lint run ./...
.PHONY: test .PHONY: test
test: test:
@echo "hashmap freelist test" @echo "hashmap freelist test"
BBOLT_VERIFY=all TEST_FREELIST_TYPE=hashmap go test -v ${TESTFLAGS} -timeout ${TESTFLAGS_TIMEOUT} BBOLT_VERIFY=all TEST_FREELIST_TYPE=hashmap go test -v ${TESTFLAGS} -timeout ${TESTFLAGS_TIMEOUT}
BBOLT_VERIFY=all TEST_FREELIST_TYPE=hashmap go test -v ${TESTFLAGS} ./internal/... BBOLT_VERIFY=all TEST_FREELIST_TYPE=hashmap go test -v ${TESTFLAGS} ./internal/...
BBOLT_VERIFY=all TEST_FREELIST_TYPE=hashmap go test -v ${TESTFLAGS} ./cmd/bbolt BBOLT_VERIFY=all TEST_FREELIST_TYPE=hashmap go test -v ${TESTFLAGS} ./cmd/bbolt
@echo "array freelist test" @echo "array freelist test"
BBOLT_VERIFY=all TEST_FREELIST_TYPE=array go test -v ${TESTFLAGS} -timeout ${TESTFLAGS_TIMEOUT} BBOLT_VERIFY=all TEST_FREELIST_TYPE=array go test -v ${TESTFLAGS} -timeout ${TESTFLAGS_TIMEOUT}
BBOLT_VERIFY=all TEST_FREELIST_TYPE=array go test -v ${TESTFLAGS} ./internal/... BBOLT_VERIFY=all TEST_FREELIST_TYPE=array go test -v ${TESTFLAGS} ./internal/...
BBOLT_VERIFY=all TEST_FREELIST_TYPE=array go test -v ${TESTFLAGS} ./cmd/bbolt BBOLT_VERIFY=all TEST_FREELIST_TYPE=array go test -v ${TESTFLAGS} ./cmd/bbolt
.PHONY: coverage .PHONY: coverage
coverage: coverage:
@echo "hashmap freelist test" @echo "hashmap freelist test"
TEST_FREELIST_TYPE=hashmap go test -v -timeout ${TESTFLAGS_TIMEOUT} \ TEST_FREELIST_TYPE=hashmap go test -v -timeout ${TESTFLAGS_TIMEOUT} \
-coverprofile cover-freelist-hashmap.out -covermode atomic -coverprofile cover-freelist-hashmap.out -covermode atomic
@echo "array freelist test" @echo "array freelist test"
TEST_FREELIST_TYPE=array go test -v -timeout ${TESTFLAGS_TIMEOUT} \ TEST_FREELIST_TYPE=array go test -v -timeout ${TESTFLAGS_TIMEOUT} \
-coverprofile cover-freelist-array.out -covermode atomic -coverprofile cover-freelist-array.out -covermode atomic
BOLT_CMD=bbolt BOLT_CMD=bbolt
build: build:
go build -o bin/${BOLT_CMD} ./cmd/${BOLT_CMD} go build -o bin/${BOLT_CMD} ./cmd/${BOLT_CMD}
.PHONY: clean .PHONY: clean
clean: # Clean binaries clean: # Clean binaries
rm -f ./bin/${BOLT_CMD} rm -f ./bin/${BOLT_CMD}
.PHONY: gofail-enable .PHONY: gofail-enable
gofail-enable: install-gofail gofail-enable: install-gofail
gofail enable . gofail enable .
.PHONY: gofail-disable .PHONY: gofail-disable
gofail-disable: install-gofail gofail-disable: install-gofail
gofail disable . gofail disable .
.PHONY: install-gofail .PHONY: install-gofail
install-gofail: install-gofail:
go install go.etcd.io/gofail go install go.etcd.io/gofail
.PHONY: test-failpoint .PHONY: test-failpoint
test-failpoint: test-failpoint:
@echo "[failpoint] hashmap freelist test" @echo "[failpoint] hashmap freelist test"
BBOLT_VERIFY=all TEST_FREELIST_TYPE=hashmap go test -v ${TESTFLAGS} -timeout 30m ./tests/failpoint BBOLT_VERIFY=all TEST_FREELIST_TYPE=hashmap go test -v ${TESTFLAGS} -timeout 30m ./tests/failpoint
@echo "[failpoint] array freelist test" @echo "[failpoint] array freelist test"
BBOLT_VERIFY=all TEST_FREELIST_TYPE=array go test -v ${TESTFLAGS} -timeout 30m ./tests/failpoint BBOLT_VERIFY=all TEST_FREELIST_TYPE=array go test -v ${TESTFLAGS} -timeout 30m ./tests/failpoint
.PHONY: test-robustness # Running robustness tests requires root permission for now .PHONY: test-robustness # Running robustness tests requires root permission for now
# TODO: Remove sudo once we fully migrate to the prow infrastructure # TODO: Remove sudo once we fully migrate to the prow infrastructure
test-robustness: gofail-enable build test-robustness: gofail-enable build
sudo env PATH=$$PATH go test -v ${TESTFLAGS} ./tests/dmflakey -test.root sudo env PATH=$$PATH go test -v ${TESTFLAGS} ./tests/dmflakey -test.root
sudo env PATH=$(PWD)/bin:$$PATH go test -v ${TESTFLAGS} ${ROBUSTNESS_TESTFLAGS} ./tests/robustness -test.root sudo env PATH=$(PWD)/bin:$$PATH go test -v ${TESTFLAGS} ${ROBUSTNESS_TESTFLAGS} ./tests/robustness -test.root
.PHONY: test-benchmark-compare .PHONY: test-benchmark-compare
# Runs benchmark tests on the current git ref and the given REF, and compares # Runs benchmark tests on the current git ref and the given REF, and compares
# the two. # the two.
test-benchmark-compare: install-benchstat test-benchmark-compare: install-benchstat
@git fetch @git fetch
./scripts/compare_benchmarks.sh $(REF) ./scripts/compare_benchmarks.sh $(REF)
.PHONY: install-benchstat .PHONY: install-benchstat
install-benchstat: install-benchstat:
go install golang.org/x/perf/cmd/benchstat@latest go install golang.org/x/perf/cmd/benchstat@latest

20
OWNERS
View File

@ -1,10 +1,10 @@
# See the OWNERS docs at https://go.k8s.io/owners # See the OWNERS docs at https://go.k8s.io/owners
approvers: approvers:
- ahrtr # Benjamin Wang <benjamin.ahrtr@gmail.com> <benjamin.wang@broadcom.com> - ahrtr # Benjamin Wang <benjamin.ahrtr@gmail.com> <benjamin.wang@broadcom.com>
- serathius # Marek Siarkowicz <siarkowicz@google.com> <marek.siarkowicz@gmail.com> - serathius # Marek Siarkowicz <siarkowicz@google.com> <marek.siarkowicz@gmail.com>
- ptabor # Piotr Tabor <piotr.tabor@gmail.com> - ptabor # Piotr Tabor <piotr.tabor@gmail.com>
- spzala # Sahdev Zala <spzala@us.ibm.com> - spzala # Sahdev Zala <spzala@us.ibm.com>
reviewers: reviewers:
- fuweid # Wei Fu <fuweid89@gmail.com> - fuweid # Wei Fu <fuweid89@gmail.com>
- tjungblu # Thomas Jungblut <tjungblu@redhat.com> - tjungblu # Thomas Jungblut <tjungblu@redhat.com>

View File

@ -1,12 +1,12 @@
# See the OWNERS docs at https://go.k8s.io/owners # See the OWNERS docs at https://go.k8s.io/owners
approvers: approvers:
- ahrtr # Benjamin Wang <benjamin.ahrtr@gmail.com> <benjamin.wang@broadcom.com> - ahrtr # Benjamin Wang <benjamin.ahrtr@gmail.com> <benjamin.wang@broadcom.com>
- fuweid # Wei Fu <fuweid89@gmail.com> - fuweid # Wei Fu <fuweid89@gmail.com>
- serathius # Marek Siarkowicz <siarkowicz@google.com> <marek.siarkowicz@gmail.com> - serathius # Marek Siarkowicz <siarkowicz@google.com> <marek.siarkowicz@gmail.com>
- ptabor # Piotr Tabor <piotr.tabor@gmail.com> - ptabor # Piotr Tabor <piotr.tabor@gmail.com>
- spzala # Sahdev Zala <spzala@us.ibm.com> - spzala # Sahdev Zala <spzala@us.ibm.com>
- tjungblu # Thomas Jungblut <tjungblu@redhat.com> - tjungblu # Thomas Jungblut <tjungblu@redhat.com>
reviewers: reviewers:
- elbehery # Mustafa Elbehery <melbeher@redhat.com> - elbehery # Mustafa Elbehery <melbeher@redhat.com>
- ivanvc # Ivan Valdes <ivan@vald.es> - ivanvc # Ivan Valdes <ivan@vald.es>

View File

@ -1,453 +1,453 @@
# Introduction to bbolt command line # Introduction to bbolt command line
`bbolt` provides a command line utility for inspecting and manipulating bbolt database files. To install bbolt command-line please refer [here](https://github.com/etcd-io/bbolt#installing) `bbolt` provides a command line utility for inspecting and manipulating bbolt database files. To install bbolt command-line please refer [here](https://github.com/etcd-io/bbolt#installing)
**Note**: [etcd](https://github.com/etcd-io/etcd) uses bbolt as its backend storage engine. In this document, we take etcd as an example to demonstrate the usage of bbolt commands. Refer to [install etcd](https://etcd.io/docs/v3.5/install/) for installing etcd. **Note**: [etcd](https://github.com/etcd-io/etcd) uses bbolt as its backend storage engine. In this document, we take etcd as an example to demonstrate the usage of bbolt commands. Refer to [install etcd](https://etcd.io/docs/v3.5/install/) for installing etcd.
1. Start a single member etcd cluster with this command below: 1. Start a single member etcd cluster with this command below:
```bash ```bash
$etcd $etcd
``` ```
It will create a directory `default.etcd` by default under current working directory, and the directory structure will look like this: It will create a directory `default.etcd` by default under current working directory, and the directory structure will look like this:
```bash ```bash
$tree default.etcd $tree default.etcd
default.etcd default.etcd
└── member └── member
├── snap ├── snap
│   └── db // this is bbolt database file │   └── db // this is bbolt database file
└── wal └── wal
└── 0000000000000000-0000000000000000.wal └── 0000000000000000-0000000000000000.wal
3 directories, 2 files 3 directories, 2 files
``` ```
2. Put some dummy data using [etcdctl](https://github.com/etcd-io/etcd/tree/main/etcdctl). 2. Put some dummy data using [etcdctl](https://github.com/etcd-io/etcd/tree/main/etcdctl).
3. Stop the etcd instance. Note a bbolt database file can only be opened by one read-write process, because it is exclusively locked when opened. 3. Stop the etcd instance. Note a bbolt database file can only be opened by one read-write process, because it is exclusively locked when opened.
## Usage ## Usage
- `bbolt command [arguments]` - `bbolt command [arguments]`
### help ### help
- help will print information about that command - help will print information about that command
```bash ```bash
$bbolt help $bbolt help
The commands are: The commands are:
version prints the current version of bbolt version prints the current version of bbolt
bench run synthetic benchmark against bbolt bench run synthetic benchmark against bbolt
buckets print a list of buckets buckets print a list of buckets
check verifies integrity of bbolt database check verifies integrity of bbolt database
compact copies a bbolt database, compacting it in the process compact copies a bbolt database, compacting it in the process
dump print a hexadecimal dump of a single page dump print a hexadecimal dump of a single page
get print the value of a key in a bucket get print the value of a key in a bucket
info print basic info info print basic info
keys print a list of keys in a bucket keys print a list of keys in a bucket
help print this screen help print this screen
page print one or more pages in human readable format page print one or more pages in human readable format
pages print list of pages with their types pages print list of pages with their types
page-item print the key and value of a page item. page-item print the key and value of a page item.
stats iterate over all pages and generate usage stats stats iterate over all pages and generate usage stats
surgery perform surgery on bbolt database surgery perform surgery on bbolt database
``` ```
- you can use `help` with any command: `bbolt [command] -h` for more information about command. - you can use `help` with any command: `bbolt [command] -h` for more information about command.
## Analyse bbolt database with bbolt command line ## Analyse bbolt database with bbolt command line
### version ### version
- `version` print the current version information of bbolt command-line. - `version` print the current version information of bbolt command-line.
- usage: - usage:
`bbolt version` `bbolt version`
Example: Example:
```bash ```bash
$bbolt version $bbolt version
bbolt version: 1.3.7 bbolt version: 1.3.7
Go Version: go1.21.6 Go Version: go1.21.6
Go OS/Arch: darwin/arm64 Go OS/Arch: darwin/arm64
``` ```
### info ### info
- `info` print the basic information about the given Bbolt database. - `info` print the basic information about the given Bbolt database.
- usage: - usage:
`bbolt info [path to the bbolt database]` `bbolt info [path to the bbolt database]`
Example: Example:
```bash ```bash
$bbolt info ~/default.etcd/member/snap/db $bbolt info ~/default.etcd/member/snap/db
Page Size: 4096 Page Size: 4096
``` ```
- **note**: page size is given in bytes - **note**: page size is given in bytes
- Bbolt database is using page size of 4KB - Bbolt database is using page size of 4KB
### buckets ### buckets
- `buckets` print a list of buckets of Bbolt database is currently having. Find more information on buckets [here](https://github.com/etcd-io/bbolt#using-buckets) - `buckets` print a list of buckets of Bbolt database is currently having. Find more information on buckets [here](https://github.com/etcd-io/bbolt#using-buckets)
- usage: - usage:
`bbolt buckets [path to the bbolt database]` `bbolt buckets [path to the bbolt database]`
Example: Example:
```bash ```bash
$bbolt buckets ~/default.etcd/member/snap/db $bbolt buckets ~/default.etcd/member/snap/db
alarm alarm
auth auth
authRoles authRoles
authUsers authUsers
cluster cluster
key key
lease lease
members members
members_removed members_removed
meta meta
``` ```
- It means when you start an etcd, it creates these `10` buckets using bbolt database. - It means when you start an etcd, it creates these `10` buckets using bbolt database.
### check ### check
- `check` opens a database at a given `[PATH]` and runs an exhaustive check to verify that all pages are accessible or are marked as freed. It also verifies that no pages are double referenced. - `check` opens a database at a given `[PATH]` and runs an exhaustive check to verify that all pages are accessible or are marked as freed. It also verifies that no pages are double referenced.
- usage: - usage:
`bbolt check [path to the bbolt database]` `bbolt check [path to the bbolt database]`
Example: Example:
```bash ```bash
$bbolt check ~/default.etcd/member/snap/db $bbolt check ~/default.etcd/member/snap/db
ok ok
``` ```
- It returns `ok` as our database file `db` is not corrupted. - It returns `ok` as our database file `db` is not corrupted.
### stats ### stats
- To gather essential statistics about the bbolt database: `stats` performs an extensive search of the database to track every page reference. It starts at the current meta page and recursively iterates through every accessible bucket. - To gather essential statistics about the bbolt database: `stats` performs an extensive search of the database to track every page reference. It starts at the current meta page and recursively iterates through every accessible bucket.
- usage: - usage:
`bbolt stats [path to the bbolt database]` `bbolt stats [path to the bbolt database]`
Example: Example:
```bash ```bash
$bbolt stats ~/default.etcd/member/snap/db $bbolt stats ~/default.etcd/member/snap/db
Aggregate statistics for 10 buckets Aggregate statistics for 10 buckets
Page count statistics Page count statistics
Number of logical branch pages: 0 Number of logical branch pages: 0
Number of physical branch overflow pages: 0 Number of physical branch overflow pages: 0
Number of logical leaf pages: 0 Number of logical leaf pages: 0
Number of physical leaf overflow pages: 0 Number of physical leaf overflow pages: 0
Tree statistics Tree statistics
Number of keys/value pairs: 11 Number of keys/value pairs: 11
Number of levels in B+tree: 1 Number of levels in B+tree: 1
Page size utilization Page size utilization
Bytes allocated for physical branch pages: 0 Bytes allocated for physical branch pages: 0
Bytes actually used for branch data: 0 (0%) Bytes actually used for branch data: 0 (0%)
Bytes allocated for physical leaf pages: 0 Bytes allocated for physical leaf pages: 0
Bytes actually used for leaf data: 0 (0%) Bytes actually used for leaf data: 0 (0%)
Bucket statistics Bucket statistics
Total number of buckets: 10 Total number of buckets: 10
Total number on inlined buckets: 10 (100%) Total number on inlined buckets: 10 (100%)
Bytes used for inlined buckets: 780 (0%) Bytes used for inlined buckets: 780 (0%)
``` ```
### inspect ### inspect
- `inspect` inspect the structure of the database. - `inspect` inspect the structure of the database.
- Usage: `bbolt inspect [path to the bbolt database]` - Usage: `bbolt inspect [path to the bbolt database]`
Example: Example:
```bash ```bash
$ ./bbolt inspect ~/default.etcd/member/snap/db $ ./bbolt inspect ~/default.etcd/member/snap/db
{ {
"name": "root", "name": "root",
"keyN": 0, "keyN": 0,
"buckets": [ "buckets": [
{ {
"name": "alarm", "name": "alarm",
"keyN": 0 "keyN": 0
}, },
{ {
"name": "auth", "name": "auth",
"keyN": 2 "keyN": 2
}, },
{ {
"name": "authRoles", "name": "authRoles",
"keyN": 1 "keyN": 1
}, },
{ {
"name": "authUsers", "name": "authUsers",
"keyN": 1 "keyN": 1
}, },
{ {
"name": "cluster", "name": "cluster",
"keyN": 1 "keyN": 1
}, },
{ {
"name": "key", "name": "key",
"keyN": 1285 "keyN": 1285
}, },
{ {
"name": "lease", "name": "lease",
"keyN": 2 "keyN": 2
}, },
{ {
"name": "members", "name": "members",
"keyN": 1 "keyN": 1
}, },
{ {
"name": "members_removed", "name": "members_removed",
"keyN": 0 "keyN": 0
}, },
{ {
"name": "meta", "name": "meta",
"keyN": 3 "keyN": 3
} }
] ]
} }
``` ```
### pages ### pages
- Pages prints a table of pages with their type (meta, leaf, branch, freelist). - Pages prints a table of pages with their type (meta, leaf, branch, freelist).
- The `meta` will store the metadata information of database. - The `meta` will store the metadata information of database.
- The `leaf` and `branch` pages will show a key count in the `items` column. - The `leaf` and `branch` pages will show a key count in the `items` column.
- The `freelist` will show the number of free pages, which are free for writing again. - The `freelist` will show the number of free pages, which are free for writing again.
- The `overflow` column shows the number of blocks that the page spills over into. - The `overflow` column shows the number of blocks that the page spills over into.
- usage: - usage:
`bbolt pages [path to the bbolt database]` `bbolt pages [path to the bbolt database]`
Example: Example:
```bash ```bash
$bbolt pages ~/default.etcd/member/snap/db $bbolt pages ~/default.etcd/member/snap/db
ID TYPE ITEMS OVRFLW ID TYPE ITEMS OVRFLW
======== ========== ====== ====== ======== ========== ====== ======
0 meta 0 0 meta 0
1 meta 0 1 meta 0
2 free 2 free
3 leaf 10 3 leaf 10
4 freelist 2 4 freelist 2
5 free 5 free
``` ```
### page ### page
- Page prints one or more pages in human readable format. - Page prints one or more pages in human readable format.
- usage: - usage:
```bash ```bash
bolt page [path to the bbolt database] pageid [pageid...] bolt page [path to the bbolt database] pageid [pageid...]
or: bolt page --all [path to the bbolt database] or: bolt page --all [path to the bbolt database]
Additional options include: Additional options include:
--all --all
prints all pages (only skips pages that were considered successful overflow pages) prints all pages (only skips pages that were considered successful overflow pages)
--format-value=auto|ascii-encoded|hex|bytes|redacted (default: auto) --format-value=auto|ascii-encoded|hex|bytes|redacted (default: auto)
prints values (on the leaf page) using the given format prints values (on the leaf page) using the given format
``` ```
Example: Example:
```bash ```bash
$bbolt page ~/default.etcd/member/snap/db 3 $bbolt page ~/default.etcd/member/snap/db 3
Page ID: 3 Page ID: 3
Page Type: leaf Page Type: leaf
Total Size: 4096 bytes Total Size: 4096 bytes
Overflow pages: 0 Overflow pages: 0
Item Count: 10 Item Count: 10
"alarm": <pgid=0,seq=0> "alarm": <pgid=0,seq=0>
"auth": <pgid=0,seq=0> "auth": <pgid=0,seq=0>
"authRoles": <pgid=0,seq=0> "authRoles": <pgid=0,seq=0>
"authUsers": <pgid=0,seq=0> "authUsers": <pgid=0,seq=0>
"cluster": <pgid=0,seq=0> "cluster": <pgid=0,seq=0>
"key": <pgid=0,seq=0> "key": <pgid=0,seq=0>
"lease": <pgid=0,seq=0> "lease": <pgid=0,seq=0>
"members": <pgid=0,seq=0> "members": <pgid=0,seq=0>
"members_removed": <pgid=0,seq=0> "members_removed": <pgid=0,seq=0>
"meta": <pgid=0,seq=0> "meta": <pgid=0,seq=0>
``` ```
- It prints information of page `page ID: 3` - It prints information of page `page ID: 3`
### page-item ### page-item
- page-item prints a page item's key and value. - page-item prints a page item's key and value.
- usage: - usage:
```bash ```bash
bolt page-item [options] [path to the bbolt database] <pageId> <itemId> bolt page-item [options] [path to the bbolt database] <pageId> <itemId>
Additional options include: Additional options include:
--key-only --key-only
Print only the key Print only the key
--value-only --value-only
Print only the value Print only the value
--format --format
Output format. One of: auto|ascii-encoded|hex|bytes|redacted (default=auto) Output format. One of: auto|ascii-encoded|hex|bytes|redacted (default=auto)
``` ```
Example: Example:
```bash ```bash
$bbolt page-item --key-only ~/default.etcd/member/snap/db 3 7 $bbolt page-item --key-only ~/default.etcd/member/snap/db 3 7
"members" "members"
``` ```
- It returns the key as `--key-only` flag is passed of `pageID: 3` and `itemID: 7` - It returns the key as `--key-only` flag is passed of `pageID: 3` and `itemID: 7`
### dump ### dump
- Dump prints a hexadecimal dump of one or more given pages. - Dump prints a hexadecimal dump of one or more given pages.
- usage: - usage:
`bolt dump [path to the bbolt database] [pageid...]` `bolt dump [path to the bbolt database] [pageid...]`
### keys ### keys
- Print a list of keys in the given bucket. - Print a list of keys in the given bucket.
- usage: - usage:
```bash ```bash
bolt keys [path to the bbolt database] [BucketName] bolt keys [path to the bbolt database] [BucketName]
Additional options include: Additional options include:
--format --format
Output format. One of: auto|ascii-encoded|hex|bytes|redacted (default=auto) Output format. One of: auto|ascii-encoded|hex|bytes|redacted (default=auto)
``` ```
Example 1: Example 1:
```bash ```bash
$bbolt keys ~/default.etcd/member/snap/db meta $bbolt keys ~/default.etcd/member/snap/db meta
confState confState
consistent_index consistent_index
term term
``` ```
- It list all the keys in bucket: `meta` - It list all the keys in bucket: `meta`
Example 2: Example 2:
```bash ```bash
$bbolt keys ~/default.etcd/member/snap/db members $bbolt keys ~/default.etcd/member/snap/db members
8e9e05c52164694d 8e9e05c52164694d
``` ```
- It list all the keys in `members` bucket which is a `memberId` of etcd cluster member. - It list all the keys in `members` bucket which is a `memberId` of etcd cluster member.
- In this case we are running a single member etcd cluster, hence only `one memberId` is present. If we would have run a `3` member etcd cluster then it will return a `3 memberId` as `3 cluster members` would have been present in `members` bucket. - In this case we are running a single member etcd cluster, hence only `one memberId` is present. If we would have run a `3` member etcd cluster then it will return a `3 memberId` as `3 cluster members` would have been present in `members` bucket.
### get ### get
- Print the value of the given key in the given bucket. - Print the value of the given key in the given bucket.
- usage: - usage:
```bash ```bash
bolt get [path to the bbolt database] [BucketName] [Key] bolt get [path to the bbolt database] [BucketName] [Key]
Additional options include: Additional options include:
--format --format
Output format. One of: auto|ascii-encoded|hex|bytes|redacted (default=auto) Output format. One of: auto|ascii-encoded|hex|bytes|redacted (default=auto)
--parse-format --parse-format
Input format (of key). One of: ascii-encoded|hex (default=ascii-encoded)" Input format (of key). One of: ascii-encoded|hex (default=ascii-encoded)"
``` ```
Example 1: Example 1:
```bash ```bash
$bbolt get --format=hex ~/default.etcd/member/snap/db meta term $bbolt get --format=hex ~/default.etcd/member/snap/db meta term
0000000000000004 0000000000000004
``` ```
- It returns the value present in bucket: `meta` for key: `term` in hexadecimal format. - It returns the value present in bucket: `meta` for key: `term` in hexadecimal format.
Example 2: Example 2:
```bash ```bash
$bbolt get ~/default.etcd/member/snap/db members 8e9e05c52164694d $bbolt get ~/default.etcd/member/snap/db members 8e9e05c52164694d
{"id":10276657743932975437,"peerURLs":["http://localhost:2380"],"name":"default","clientURLs":["http://localhost:2379"]} {"id":10276657743932975437,"peerURLs":["http://localhost:2380"],"name":"default","clientURLs":["http://localhost:2379"]}
``` ```
- It returns the value present in bucket: `members` for key: `8e9e05c52164694d`. - It returns the value present in bucket: `members` for key: `8e9e05c52164694d`.
### compact ### compact
- Compact opens a database at given `[Source Path]` and walks it recursively, copying keys as they are found from all buckets, to a newly created database at `[Destination Path]`. The original database is left untouched. - Compact opens a database at given `[Source Path]` and walks it recursively, copying keys as they are found from all buckets, to a newly created database at `[Destination Path]`. The original database is left untouched.
- usage: - usage:
```bash ```bash
bbolt compact [options] -o [Destination Path] [Source Path] bbolt compact [options] -o [Destination Path] [Source Path]
Additional options include: Additional options include:
-tx-max-size NUM -tx-max-size NUM
Specifies the maximum size of individual transactions. Specifies the maximum size of individual transactions.
Defaults to 64KB Defaults to 64KB
``` ```
Example: Example:
```bash ```bash
$bbolt compact -o ~/db.compact ~/default.etcd/member/snap/db $bbolt compact -o ~/db.compact ~/default.etcd/member/snap/db
16805888 -> 32768 bytes (gain=512.88x) 16805888 -> 32768 bytes (gain=512.88x)
``` ```
- It will create a compacted database file: `db.compact` at given path. - It will create a compacted database file: `db.compact` at given path.
### bench ### bench
- run synthetic benchmark against bbolt database. - run synthetic benchmark against bbolt database.
- usage: - usage:
```bash ```bash
Usage: Usage:
-batch-size int -batch-size int
-blockprofile string -blockprofile string
-count int -count int
(default 1000) (default 1000)
-cpuprofile string -cpuprofile string
-fill-percent float -fill-percent float
(default 0.5) (default 0.5)
-key-size int -key-size int
(default 8) (default 8)
-memprofile string -memprofile string
-no-sync -no-sync
-path string -path string
-profile-mode string -profile-mode string
(default "rw") (default "rw")
-read-mode string -read-mode string
(default "seq") (default "seq")
-value-size int -value-size int
(default 32) (default 32)
-work -work
-write-mode string -write-mode string
(default "seq") (default "seq")
``` ```
Example: Example:
```bash ```bash
$bbolt bench ~/default.etcd/member/snap/db -batch-size 400 -key-size 16 $bbolt bench ~/default.etcd/member/snap/db -batch-size 400 -key-size 16
# Write 68.523572ms (68.523µs/op) (14593 op/sec) # Write 68.523572ms (68.523µs/op) (14593 op/sec)
# Read 1.000015152s (11ns/op) (90909090 op/sec) # Read 1.000015152s (11ns/op) (90909090 op/sec)
``` ```
- It runs a benchmark with batch size of `400` and with key size of `16` while for others parameters default value is taken. - It runs a benchmark with batch size of `400` and with key size of `16` while for others parameters default value is taken.

View File

@ -1,3 +1,3 @@
# etcd Community Code of Conduct # etcd Community Code of Conduct
Please refer to [etcd Community Code of Conduct](https://github.com/etcd-io/etcd/blob/main/code-of-conduct.md). Please refer to [etcd Community Code of Conduct](https://github.com/etcd-io/etcd/blob/main/code-of-conduct.md).

48
go.sum
View File

@ -1,24 +1,24 @@
github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g= github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/spf13/cobra v1.9.1 h1:CXSaggrXdbHK9CF+8ywj8Amf7PBRmPCOJugH954Nnlo= github.com/spf13/cobra v1.9.1 h1:CXSaggrXdbHK9CF+8ywj8Amf7PBRmPCOJugH954Nnlo=
github.com/spf13/cobra v1.9.1/go.mod h1:nDyEzZ8ogv936Cinf6g1RU9MRY64Ir93oCnqb9wxYW0= github.com/spf13/cobra v1.9.1/go.mod h1:nDyEzZ8ogv936Cinf6g1RU9MRY64Ir93oCnqb9wxYW0=
github.com/spf13/pflag v1.0.6 h1:jFzHGLGAlb3ruxLB8MhbI6A8+AQX/2eW4qeyNZXNp2o= github.com/spf13/pflag v1.0.6 h1:jFzHGLGAlb3ruxLB8MhbI6A8+AQX/2eW4qeyNZXNp2o=
github.com/spf13/pflag v1.0.6/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/spf13/pflag v1.0.6/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
go.etcd.io/gofail v0.2.0 h1:p19drv16FKK345a09a1iubchlw/vmRuksmRzgBIGjcA= go.etcd.io/gofail v0.2.0 h1:p19drv16FKK345a09a1iubchlw/vmRuksmRzgBIGjcA=
go.etcd.io/gofail v0.2.0/go.mod h1:nL3ILMGfkXTekKI3clMBNazKnjUZjYLKmBHzsVAnC1o= go.etcd.io/gofail v0.2.0/go.mod h1:nL3ILMGfkXTekKI3clMBNazKnjUZjYLKmBHzsVAnC1o=
golang.org/x/sync v0.14.0 h1:woo0S4Yywslg6hp4eUFjTVOyKt0RookbpAHG4c1HmhQ= golang.org/x/sync v0.14.0 h1:woo0S4Yywslg6hp4eUFjTVOyKt0RookbpAHG4c1HmhQ=
golang.org/x/sync v0.14.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA= golang.org/x/sync v0.14.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
golang.org/x/sys v0.33.0 h1:q3i8TbbEz+JRD9ywIRlyRAQbM0qF7hu24q3teo2hbuw= golang.org/x/sys v0.33.0 h1:q3i8TbbEz+JRD9ywIRlyRAQbM0qF7hu24q3teo2hbuw=
golang.org/x/sys v0.33.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= golang.org/x/sys v0.33.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

View File

@ -1,70 +1,70 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# https://github.com/kubernetes/kube-state-metrics/blob/main/tests/compare_benchmarks.sh (originally written by mxinden) # https://github.com/kubernetes/kube-state-metrics/blob/main/tests/compare_benchmarks.sh (originally written by mxinden)
# exit immediately when a command fails # exit immediately when a command fails
set -e set -e
# only exit with zero if all commands of the pipeline exit successfully # only exit with zero if all commands of the pipeline exit successfully
set -o pipefail set -o pipefail
# error on unset variables # error on unset variables
set -u set -u
[[ "$#" -eq 1 ]] || echo "One argument required, $# provided." [[ "$#" -eq 1 ]] || echo "One argument required, $# provided."
REF_CURRENT="$(git rev-parse --abbrev-ref HEAD)" REF_CURRENT="$(git rev-parse --abbrev-ref HEAD)"
BASE_TO_COMPARE=$1 BASE_TO_COMPARE=$1
RESULT_CURRENT="$(mktemp)-${REF_CURRENT}" RESULT_CURRENT="$(mktemp)-${REF_CURRENT}"
RESULT_TO_COMPARE="$(mktemp)-${BASE_TO_COMPARE}" RESULT_TO_COMPARE="$(mktemp)-${BASE_TO_COMPARE}"
BENCH_COUNT=${BENCH_COUNT:-10} BENCH_COUNT=${BENCH_COUNT:-10}
BENCHSTAT_CONFIDENCE_LEVEL=${BENCHSTAT_CONFIDENCE_LEVEL:-0.9} BENCHSTAT_CONFIDENCE_LEVEL=${BENCHSTAT_CONFIDENCE_LEVEL:-0.9}
BENCHSTAT_FORMAT=${BENCHSTAT_FORMAT:-"text"} BENCHSTAT_FORMAT=${BENCHSTAT_FORMAT:-"text"}
BENCH_PARAMETERS=${BENCH_PARAMETERS:-"-count 2000000 -batch-size 10000"} BENCH_PARAMETERS=${BENCH_PARAMETERS:-"-count 2000000 -batch-size 10000"}
if [[ "${BENCHSTAT_FORMAT}" == "csv" ]] && [[ -z "${BENCHSTAT_OUTPUT_FILE}" ]]; then if [[ "${BENCHSTAT_FORMAT}" == "csv" ]] && [[ -z "${BENCHSTAT_OUTPUT_FILE}" ]]; then
echo "BENCHSTAT_FORMAT is set to csv, but BENCHSTAT_OUTPUT_FILE is not set." echo "BENCHSTAT_FORMAT is set to csv, but BENCHSTAT_OUTPUT_FILE is not set."
exit 1 exit 1
fi fi
function bench() { function bench() {
local output_file local output_file
output_file="$1" output_file="$1"
make build make build
for _ in $(seq "$BENCH_COUNT"); do for _ in $(seq "$BENCH_COUNT"); do
echo ./bin/bbolt bench -gobench-output -profile-mode n ${BENCH_PARAMETERS} echo ./bin/bbolt bench -gobench-output -profile-mode n ${BENCH_PARAMETERS}
# shellcheck disable=SC2086 # shellcheck disable=SC2086
./bin/bbolt bench -gobench-output -profile-mode n ${BENCH_PARAMETERS} >> "${output_file}" ./bin/bbolt bench -gobench-output -profile-mode n ${BENCH_PARAMETERS} >> "${output_file}"
done done
} }
function main() { function main() {
echo "### Benchmarking PR ${REF_CURRENT}" echo "### Benchmarking PR ${REF_CURRENT}"
bench "${RESULT_CURRENT}" bench "${RESULT_CURRENT}"
echo "" echo ""
echo "### Done benchmarking ${REF_CURRENT}" echo "### Done benchmarking ${REF_CURRENT}"
echo "### Benchmarking base ${BASE_TO_COMPARE}" echo "### Benchmarking base ${BASE_TO_COMPARE}"
git checkout "${BASE_TO_COMPARE}" git checkout "${BASE_TO_COMPARE}"
bench "${RESULT_TO_COMPARE}" bench "${RESULT_TO_COMPARE}"
echo "" echo ""
echo "### Done benchmarking ${BASE_TO_COMPARE}" echo "### Done benchmarking ${BASE_TO_COMPARE}"
git checkout - git checkout -
echo "" echo ""
echo "### Result" echo "### Result"
echo "BASE=${BASE_TO_COMPARE} HEAD=${REF_CURRENT}" echo "BASE=${BASE_TO_COMPARE} HEAD=${REF_CURRENT}"
if [[ "${BENCHSTAT_FORMAT}" == "csv" ]]; then if [[ "${BENCHSTAT_FORMAT}" == "csv" ]]; then
benchstat -format=csv -confidence="${BENCHSTAT_CONFIDENCE_LEVEL}" BASE="${RESULT_TO_COMPARE}" HEAD="${RESULT_CURRENT}" 2>/dev/null 1>"${BENCHSTAT_OUTPUT_FILE}" benchstat -format=csv -confidence="${BENCHSTAT_CONFIDENCE_LEVEL}" BASE="${RESULT_TO_COMPARE}" HEAD="${RESULT_CURRENT}" 2>/dev/null 1>"${BENCHSTAT_OUTPUT_FILE}"
else else
if [[ -z "${BENCHSTAT_OUTPUT_FILE}" ]]; then if [[ -z "${BENCHSTAT_OUTPUT_FILE}" ]]; then
benchstat -confidence="${BENCHSTAT_CONFIDENCE_LEVEL}" BASE="${RESULT_TO_COMPARE}" HEAD="${RESULT_CURRENT}" benchstat -confidence="${BENCHSTAT_CONFIDENCE_LEVEL}" BASE="${RESULT_TO_COMPARE}" HEAD="${RESULT_CURRENT}"
else else
benchstat -confidence="${BENCHSTAT_CONFIDENCE_LEVEL}" BASE="${RESULT_TO_COMPARE}" HEAD="${RESULT_CURRENT}" 1>"${BENCHSTAT_OUTPUT_FILE}" benchstat -confidence="${BENCHSTAT_CONFIDENCE_LEVEL}" BASE="${RESULT_TO_COMPARE}" HEAD="${RESULT_CURRENT}" 1>"${BENCHSTAT_OUTPUT_FILE}"
fi fi
fi fi
} }
main main

View File

@ -1,13 +1,13 @@
GO_CMD="go" GO_CMD="go"
# TODO(ptabor): Expand to cover different architectures (GOOS GOARCH), or just list go files. # TODO(ptabor): Expand to cover different architectures (GOOS GOARCH), or just list go files.
GOFILES=$(${GO_CMD} list --f "{{with \$d:=.}}{{range .GoFiles}}{{\$d.Dir}}/{{.}}{{\"\n\"}}{{end}}{{end}}" ./...) GOFILES=$(${GO_CMD} list --f "{{with \$d:=.}}{{range .GoFiles}}{{\$d.Dir}}/{{.}}{{\"\n\"}}{{end}}{{end}}" ./...)
TESTGOFILES=$(${GO_CMD} list --f "{{with \$d:=.}}{{range .TestGoFiles}}{{\$d.Dir}}/{{.}}{{\"\n\"}}{{end}}{{end}}" ./...) TESTGOFILES=$(${GO_CMD} list --f "{{with \$d:=.}}{{range .TestGoFiles}}{{\$d.Dir}}/{{.}}{{\"\n\"}}{{end}}{{end}}" ./...)
XTESTGOFILES=$(${GO_CMD} list --f "{{with \$d:=.}}{{range .XTestGoFiles}}{{\$d.Dir}}/{{.}}{{\"\n\"}}{{end}}{{end}}" ./...) XTESTGOFILES=$(${GO_CMD} list --f "{{with \$d:=.}}{{range .XTestGoFiles}}{{\$d.Dir}}/{{.}}{{\"\n\"}}{{end}}{{end}}" ./...)
echo "${GOFILES}" "${TESTGOFILES}" "${XTESTGOFILES}"| xargs -n 100 go run golang.org/x/tools/cmd/goimports@latest -w -local go.etcd.io echo "${GOFILES}" "${TESTGOFILES}" "${XTESTGOFILES}"| xargs -n 100 go run golang.org/x/tools/cmd/goimports@latest -w -local go.etcd.io
go fmt ./... go fmt ./...
go mod tidy go mod tidy