RepoPilotOpen in app →

boltdb/bolt

An embedded key/value database for Go.

Mixed

Stale — last commit 8y ago

worst of 4 axes
Use as dependencyMixed

last commit was 8y ago; no tests detected…

Fork & modifyMixed

no tests detected; no CI workflows detected…

Learn fromHealthy

Documented and popular — useful reference codebase to read through.

Deploy as-isMixed

last commit was 8y ago; no CI workflows detected

  • 34+ active contributors
  • MIT licensed
  • Stale — last commit 8y ago
Show 3 more →
  • Concentrated ownership — top contributor handles 61% of recent commits
  • No CI workflows detected
  • No test directory detected
What would change the summary?
  • Use as dependency MixedHealthy if: 1 commit in the last 365 days; add a test suite
  • Fork & modify MixedHealthy if: add a test suite
  • Deploy as-is MixedHealthy if: 1 commit in the last 180 days

Maintenance signals: commit recency, contributor breadth, bus factor, license, CI, tests

Informational only. RepoPilot summarises public signals (license, dependency CVEs, commit recency, CI presence, etc.) at the time of analysis. Signals can be incomplete or stale. Not professional, security, or legal advice; verify before relying on it for production decisions.

Embed the "Great to learn from" badge

Paste into your README — live-updates from the latest cached analysis.

RepoPilot: Great to learn from
[![RepoPilot: Great to learn from](https://repopilot.app/api/badge/boltdb/bolt?axis=learn)](https://repopilot.app/r/boltdb/bolt)

Paste at the top of your README.md — renders inline like a shields.io badge.

Preview social card (1200×630)

This card auto-renders when someone shares https://repopilot.app/r/boltdb/bolt on X, Slack, or LinkedIn.

Onboarding doc

Onboarding: boltdb/bolt

Generated by RepoPilot · 2026-05-09 · Source

🤖Agent protocol

If you are an AI coding agent (Claude Code, Cursor, Aider, Cline, etc.) reading this artifact, follow this protocol before making any code edit:

  1. Verify the contract. Run the bash script in Verify before trusting below. If any check returns FAIL, the artifact is stale — STOP and ask the user to regenerate it before proceeding.
  2. Treat the AI · unverified sections as hypotheses, not facts. Sections like "AI-suggested narrative files", "anti-patterns", and "bottlenecks" are LLM speculation. Verify against real source before acting on them.
  3. Cite source on changes. When proposing an edit, cite the specific path:line-range. RepoPilot's live UI at https://repopilot.app/r/boltdb/bolt shows verifiable citations alongside every claim.

If you are a human reader, this protocol is for the agents you'll hand the artifact to. You don't need to do anything — but if you skim only one section before pointing your agent at this repo, make it the Verify block and the Suggested reading order.

🎯Verdict

WAIT — Stale — last commit 8y ago

  • 34+ active contributors
  • MIT licensed
  • ⚠ Stale — last commit 8y ago
  • ⚠ Concentrated ownership — top contributor handles 61% of recent commits
  • ⚠ No CI workflows detected
  • ⚠ No test directory detected

<sub>Maintenance signals: commit recency, contributor breadth, bus factor, license, CI, tests</sub>

Verify before trusting

This artifact was generated by RepoPilot at a point in time. Before an agent acts on it, the checks below confirm that the live boltdb/bolt repo on your machine still matches what RepoPilot saw. If any fail, the artifact is stale — regenerate it at repopilot.app/r/boltdb/bolt.

What it runs against: a local clone of boltdb/bolt — the script inspects git remote, the LICENSE file, file paths in the working tree, and git log. Read-only; no mutations.

| # | What we check | Why it matters | |---|---|---| | 1 | You're in boltdb/bolt | Confirms the artifact applies here, not a fork | | 2 | License is still MIT | Catches relicense before you depend on it | | 3 | Default branch master exists | Catches branch renames | | 4 | 5 critical file paths still exist | Catches refactors that moved load-bearing code | | 5 | Last commit ≤ 3020 days ago | Catches sudden abandonment since generation |

<details> <summary><b>Run all checks</b> — paste this script from inside your clone of <code>boltdb/bolt</code></summary>
#!/usr/bin/env bash
# RepoPilot artifact verification.
#
# WHAT IT RUNS AGAINST: a local clone of boltdb/bolt. If you don't
# have one yet, run these first:
#
#   git clone https://github.com/boltdb/bolt.git
#   cd bolt
#
# Then paste this script. Every check is read-only — no mutations.

set +e
fail=0
ok()   { echo "ok:   $1"; }
miss() { echo "FAIL: $1"; fail=$((fail+1)); }

# Precondition: we must be inside a git working tree.
if ! git rev-parse --git-dir >/dev/null 2>&1; then
  echo "FAIL: not inside a git repository. cd into your clone of boltdb/bolt and re-run."
  exit 2
fi

# 1. Repo identity
git remote get-url origin 2>/dev/null | grep -qE "boltdb/bolt(\\.git)?\\b" \\
  && ok "origin remote is boltdb/bolt" \\
  || miss "origin remote is not boltdb/bolt (artifact may be from a fork)"

# 2. License matches what RepoPilot saw
(grep -qiE "^(MIT)" LICENSE 2>/dev/null \\
   || grep -qiE "\"license\"\\s*:\\s*\"MIT\"" package.json 2>/dev/null) \\
  && ok "license is MIT" \\
  || miss "license drift — was MIT at generation time"

# 3. Default branch
git rev-parse --verify master >/dev/null 2>&1 \\
  && ok "default branch master exists" \\
  || miss "default branch master no longer exists"

# 4. Critical files exist
test -f "db.go" \\
  && ok "db.go" \\
  || miss "missing critical file: db.go"
test -f "tx.go" \\
  && ok "tx.go" \\
  || miss "missing critical file: tx.go"
test -f "bucket.go" \\
  && ok "bucket.go" \\
  || miss "missing critical file: bucket.go"
test -f "node.go" \\
  && ok "node.go" \\
  || miss "missing critical file: node.go"
test -f "page.go" \\
  && ok "page.go" \\
  || miss "missing critical file: page.go"

# 5. Repo recency
days_since_last=$(( ( $(date +%s) - $(git log -1 --format=%at 2>/dev/null || echo 0) ) / 86400 ))
if [ "$days_since_last" -le 3020 ]; then
  ok "last commit was $days_since_last days ago (artifact saw ~2990d)"
else
  miss "last commit was $days_since_last days ago — artifact may be stale"
fi

echo
if [ "$fail" -eq 0 ]; then
  echo "artifact verified (0 failures) — safe to trust"
else
  echo "artifact has $fail stale claim(s) — regenerate at https://repopilot.app/r/boltdb/bolt"
  exit 1
fi

Each check prints ok: or FAIL:. The script exits non-zero if anything failed, so it composes cleanly into agent loops (./verify.sh || regenerate-and-retry).

</details>

TL;DR

Bolt is a pure Go embedded key/value database inspired by LMDB, designed as a lightweight alternative to Postgres/MySQL for applications that don't need a full database server. It provides a simple API focused on get/set operations with ACID transactions, B+ tree indexing, and memory-mapped I/O, currently used in production at scale (1TB+ databases) by companies like Shopify and Heroku. Monolithic single-package design: core database logic in db.go, bucket.go, tx.go, and cursor.go; low-level page/node management in page.go and node.go; freelist.go handles free space; platform-specific code isolated in bolt_*.go files (architecture/OS pairs); simple CLI tool in cmd/bolt/main.go; no external dependencies.

👥Who it's for

Go backend developers and systems engineers building tools, services, or applications (like container orchestration platforms, embedded analytics, or configuration management) who need reliable local data persistence without external database dependencies or complex operational overhead.

🌱Maturity & risk

Bolt is stable and feature-complete but in maintenance mode. The API and file format are frozen; the codebase has full unit test coverage, randomized black-box testing (simulation_test.go, quick_test.go), and CI via AppVeyor. However, the original author (Ben Johnson) stepped back in 2017 due to maintenance burden—it's production-ready but not actively developed. The CoreOS fork (bbolt) now receives active maintenance and feature additions.

Bolt carries moderate risk: it's a single-author abandoned project with no recent commit activity or maintenance response, so critical bugs or security issues will not be patched upstream. The codebase has zero external dependencies (pure Go), mitigating supply-chain risk, but platform-specific code across 11 bolt_*.go files (Unix, Windows, Solaris, ARM, PPC, s390x) needs careful testing on your target architecture. Users requiring new features or fixes should migrate to bbolt (the maintained fork).

Active areas of work

Nothing—this is a closed project. The README explicitly states maintenance has ended and recommends users migrate to CoreOS's bbolt fork for active development. The last meaningful activity was stabilization and bug fixes prior to 2017.

🚀Get running

git clone https://github.com/boltdb/bolt.git && cd bolt && make test

Daily commands: make test (runs full test suite via Makefile); go test ./... (standard Go testing); cmd/bolt/main.go provides CLI tools (inspect, dump database files).

🗺️Map of the codebase

  • db.go — Entry point and core database lifecycle management; every feature depends on understanding how DB opens, closes, and manages transactions.
  • tx.go — Transaction abstraction layer that orchestrates read/write isolation and bucket access; critical to understanding ACID guarantees.
  • bucket.go — Key-value storage container and cursor API; the primary interface users interact with for all get/put/delete operations.
  • node.go — In-memory B+tree node representation and manipulation; core to understanding how data structures work in memory before page serialization.
  • page.go — On-disk page serialization and layout; required to understand how bytes map to database structures and page allocation.
  • freelist.go — Page allocation and reuse tracking; essential for understanding garbage collection, fragmentation, and storage efficiency.
  • cursor.go — B+tree traversal and key-value seeking logic; critical for range queries, iteration, and efficient key lookup.

🧩Components & responsibilities

  • DB (Go sync, os package, mmap syscalls) — Manages file handle, mmap region, global read/write locks, freelist, and transaction lifecycle.
    • Failure mode: If mmap fails, database is inaccessible; if lock is lost, concurrent process corruption possible.
  • Transaction (Tx) (Go sync.RWMutex, node tracking) — Provides isolation via CoW snapshots; read txs see a consistent page snapshot; write txs defer changes to a dirty node tree until Commit.
    • Failure mode: If a write tx panics before Commit, changes are lost but database remains consistent.
  • Bucket (Node operations, cursor API) — Container for key-value pairs at a specific page in the B+tree; supports Get, Put, Delete, and nested buckets.
    • Failure mode: If bucket root page is corrupted, all data in bucket is inaccessible.
  • Cursor (Node pointer chasing, page deserialization) — Traverses B+tree nodes to seek and iterate over key-value pairs in sorted order.
    • Failure mode: If a node page is corrupted mid-traversal, Seek may panic or return incorrect results.
  • Node — In-memory representation of a B+tree node (branch or leaf);

🛠️How to make changes

Add a new bucket operation (e.g., increment counter)

  1. Define the operation as a method on the Bucket struct in bucket.go, leveraging existing Get/Put primitives (bucket.go)
  2. Wrap it in a transaction using db.Update() in your application code to ensure ACID isolation (db.go)
  3. Add unit tests in bucket_test.go following the pattern of existing BenchmarkBucketGet tests (bucket_test.go)

Port Bolt to a new architecture or OS

  1. Create a new bolt_<os>.go file (e.g., bolt_freebsd.go) with mmap and file I/O implementations (bolt_unix.go)
  2. Add architecture-specific page size constant in a new bolt_<arch>.go file if needed (bolt_amd64.go)
  3. Implement the required mmap, munmap, and flock syscalls matching the unix.go interface (bolt_unix.go)
  4. Run full test suite (quick_test.go and simulation_test.go) to verify consistency on new platform (quick_test.go)

Optimize cursor range query performance

  1. Review current Seek and Next implementations and benchmark with cursor_test.go patterns (cursor.go)
  2. Optimize node traversal logic, potentially reducing allocations or improving cache locality in node.go (node.go)
  3. Add benchmarks for your optimization in cursor_test.go using Go's built-in testing framework (cursor_test.go)

🔧Why these technologies

  • B+tree data structure — Provides O(log n) lookups with excellent cache locality and natural range query support; inspired by LMDB.
  • Memory-mapped I/O (mmap) — Eliminates intermediate buffering, allows OS page cache to manage memory efficiently, and provides atomic page-level writes.
  • Copy-on-write (CoW) transactions — Enables lock-free reads while maintaining ACID guarantees; readers never block writers.
  • Pure Go implementation — No C dependencies; simplifies deployment and cross-platform compatibility; easy to understand and modify.

⚖️Trade-offs already made

  • Single writer, multiple concurrent readers

    • Why: Simplifies consistency guarantees and avoids complex write coordination.
    • Consequence: Write throughput is limited to one transaction at a time; unsuitable for write-heavy workloads.
  • Entire database held in virtual address space via mmap

    • Why: Achieves zero-copy reads and leverages OS page cache.
    • Consequence: Database size limited by available virtual address space (32-bit systems capped at ~2GB); potential memory pressure on large DBs.
  • No query language; key-value API only

    • Why: Keeps codebase minimal and API surface simple.
    • Consequence: Clients must implement application-level indexing, filtering, and aggregation logic.
  • Synchronous I/O with blocking writes on Commit

    • Why: Ensures durability and simplifies reasoning about transaction state.
    • Consequence: Commit latency driven by disk sync time; not suitable for sub-millisecond latency requirements.

🚫Non-goals (don't propose these)

  • Does not provide a network API; must be embedded in-process.
  • Does not support full-text search or complex queries.
  • Does not support distributed replication or clustering.
  • Does not provide automatic partitioning or sharding.
  • Does not support hot backups without stopping writes.

🪤Traps & gotchas

Bolt uses platform-specific code for mmap and file locking—test on your target architecture (ARM, PPC, s390x variants all have separate files). The database file format is fixed and byte-order sensitive; no schema migrations are provided. Transactions hold mmap views of the file, so file size growth requires careful page allocation. The project is abandoned upstream; never expect bug fixes or security patches from the original repo.

🏗️Architecture

💡Concepts to learn

  • B+ tree — Bolt's entire index structure and range scan performance depend on B+ tree properties (logarithmic lookup, sequential leaf traversal); understanding node splits/merges in node.go is essential
  • Memory-mapped I/O (mmap) — Bolt's core performance trick: pages are accessed as memory pointers rather than read()/write() syscalls; see bolt_unix.go and bolt_windows.go for platform-specific mmap setup
  • Copy-on-write (COW) — Bolt uses COW for transaction isolation: writes create new pages without mutating originals, enabling readers and writers to coexist; see tx.go and node.go for implementation
  • ACID transactions — Bolt guarantees Atomicity, Consistency, Isolation (via COW + locking), and Durability (via fsync); tx.go implements the state machine and commit protocol
  • Freelist management — freelist.go tracks deallocated pages for reuse; understanding how free pages are reclaimed during compaction prevents fragmentation in long-running instances
  • File locking (fcntl) — Bolt uses platform-specific locks (fcntl on Unix, LockFileEx on Windows in bolt_*.go) to prevent concurrent access to the database file; critical for crash safety
  • Bucket (namespace/table abstraction) — Bolt buckets are the user-facing abstraction for key namespacing and nesting; understanding bucket.go's Get/Put/ForEach API and nested bucket lifecycle is required to use Bolt correctly
  • coreos/bbolt — Active fork of Bolt that adds features (e.g., arbitrary bucket options, improved error handling) and receives security/bug fixes; recommended migration target if you need active maintenance
  • etcd-io/etcd — Heavy Bolt/bbolt user—demonstrates production patterns for embedded KV store in a distributed consensus system; good reference for transaction patterns at scale
  • dgraph-io/badger — Alternative Go embedded KV store with LSM tree design instead of B+ tree; faster writes, different trade-offs on read latency and disk overhead
  • lmdb/lmdb — Original C project that inspired Bolt; understanding LMDB's design (especially memory-mapped page management and read-only transactions) clarifies Bolt's architecture
  • golang/go — Bolt's sync/atomic and syscall usage for mmap/locking depends on Go runtime; relevant for understanding platform-specific behavior in bolt_*.go files

🪄PR ideas

To work on one of these in Claude Code or Cursor, paste: Implement the "<title>" PR idea from CLAUDE.md, working through the checklist as the task list.

Add integration tests for Windows-specific bolt_windows.go behavior

The repo has platform-specific implementations (bolt_windows.go, bolt_unix.go, bolt_linux.go, etc.) but db_test.go and other test files don't appear to have Windows-specific test cases. The Windows implementation likely has different locking, memory-mapping, and file handling behavior that needs dedicated testing to prevent regressions.

  • [ ] Review bolt_windows.go for Windows-specific code paths (file locking, memory-mapped I/O differences)
  • [ ] Create db_windows_test.go with Windows-specific test cases (concurrent access, file handle limits, memory mapping behavior)
  • [ ] Add tests for edge cases like network paths, UNC paths, and permission-related failures specific to Windows
  • [ ] Verify tests can run in CI environments (AppVeyor is already configured in appveyor.yml)

Add comprehensive error handling tests in errors.go

The repo has errors.go defined but no corresponding errors_test.go. Given that Bolt is used as low-level database infrastructure, error cases must be thoroughly tested (corruption detection, I/O failures, transaction conflicts, etc.) to ensure reliable error reporting.

  • [ ] Create errors_test.go to test error creation and formatting
  • [ ] Add tests for error conditions in db.go (DB corruption, invalid transaction states)
  • [ ] Add tests for error conditions in tx.go (read-only transaction write attempts, closed transaction operations)
  • [ ] Add tests for freelist.go errors (allocation failures, consistency checks)

Add freelist corruption detection and recovery tests

freelist.go manages the free page allocation, which is critical to database integrity. While freelist_test.go exists, there are likely no tests for corruption scenarios (invalid page IDs, circular references, overflow conditions) that could silently corrupt the database.

  • [ ] Review freelist.go for validation logic and edge cases
  • [ ] Add test cases to freelist_test.go for detecting corrupted freelist state (duplicate page IDs, invalid ranges, orphaned pages)
  • [ ] Add tests for freelist recovery/repair scenarios when opened with an already-corrupted database
  • [ ] Add stress tests in quick_test.go or simulation_test.go that specifically target freelist edge cases under concurrent load

🌿Good first issues

  • Write platform-specific integration tests for bolt_ppc64le.go, bolt_arm64.go, and bolt_s390x.go; currently only common paths are well-tested in CI (appveyor.yml shows Windows + limited Linux). Add a Makefile target or GitHub Actions step to catch arch-specific regressions.
  • Add cursor range scan benchmarks to complement existing tests in cursor_test.go; measure performance of Seek() + Next() loops over keys with various prefix patterns, then document patterns in README that achieve O(log n) lookups.
  • Extend bucket_test.go with deterministic examples for nested bucket edge cases (e.g., deleting a parent bucket that has children, or creating circular bucket references); currently undocumented behavior risks silent data loss.

Top contributors

Click to expand

📝Recent commits

Click to expand
  • fd01fc7 — Merge pull request #748 from Chyroc/add/tx-copy-deprecated (benbjohnson)
  • fa91bb2 — add tx-copy-deprecated (chyroc)
  • 9da3174 — Merge pull request #736 from tv42/silly-if (benbjohnson)
  • 32cc6eb — Remove unnecessary if in batch handling (tv42)
  • fa5367d — README (benbjohnson)
  • 2f1ce7a — Merge pull request #703 from nilslice/patch-1 (benbjohnson)
  • f7f91ab — Add Ponzu CMS to list of projects using Bolt (nilslice)
  • e9cf4fa — Merge pull request #654 from benbjohnson/revert-ca9f208 (benbjohnson)
  • 82ecdfe — Revert "replace unix implementation to be the same as solaris to fix an issue with glusterfs" (benbjohnson)
  • 9145e04 — Merge pull request #651 from zweizeichen/master (benbjohnson)

🔒Security observations

BoltDB is a mature, stable embedded database with a relatively solid security posture for its intended use case. However, as a low-level data store that directly manipulates memory-mapped files, it requires careful handling of untrusted input (malformed database files) and platform-specific implementation details. The main risks are: (1) insufficient validation of database file format and structure, (2) potential memory safety issues in unsafe memory operations, (3) platform-specific implementation inconsistencies, and (4) lack of built-in encryption. No hardcoded secrets, injection vulnerabilities, or obvious misconfigurations were identified in the provided file structure. Security relies heavily on the integrity of the database file and proper file system permissions.

  • Medium · Potential Memory Corruption via Unsafe Memory Operations — page.go, node.go, bolt_*.go. BoltDB is a low-level key/value store that directly manipulates memory-mapped files and raw page structures. The presence of files like page.go, node.go, and architecture-specific bolt_*.go files suggests direct memory operations. Without visible bounds checking and validation, there's potential for buffer overflows or out-of-bounds access when parsing corrupted database files. Fix: Implement comprehensive bounds checking on all page and node parsing operations. Add validation for page sizes, offsets, and element counts before dereferencing memory. Consider fuzzing with malformed database files to identify edge cases.
  • Medium · No Input Validation on Database File Format — db.go, page.go, freelist.go. The codebase appears to read raw page structures directly from disk (db.go, page.go). There's no indication of cryptographic verification or strict format validation of database files. A malicious or corrupted database file could trigger undefined behavior. Fix: Implement strict validation of database file headers and page structures. Add checksums or cryptographic signatures to detect file tampering. Validate magic numbers, versions, and structural invariants before processing pages.
  • Low · Platform-Specific Code Without Clear Security Review — bolt_linux.go, bolt_windows.go, bolt_openbsd.go, bolt_unix.go, bolt_unix_solaris.go, boltsync_unix.go. Multiple platform-specific files (bolt_linux.go, bolt_windows.go, bolt_openbsd.go, etc.) handle file I/O and memory mapping differently across platforms. Inconsistent security implementations across platforms could lead to vulnerabilities on specific OS configurations. Fix: Conduct platform-specific security audits for each OS implementation. Ensure consistent file permission handling, memory mapping protections, and sync operations across all supported platforms. Document platform-specific security assumptions.
  • Low · Missing Concurrency Controls Documentation — tx.go, db.go, boltsync_unix.go. While tx.go suggests transaction support, the security implications of concurrent access patterns are not visible in the provided file structure. Race conditions or improper locking could lead to data corruption or information leaks. Fix: Document concurrency guarantees and thread-safety properties clearly. Use Go's race detector during testing. Implement and verify mutex protections for all shared mutable state.
  • Low · No Visible Encryption or Access Control — db.go, entire codebase. As a file-based embedded database, BoltDB stores data directly on disk without apparent encryption. File-level access control is the only protection for sensitive data. Fix: Document that encryption should be implemented at the application layer if sensitive data is stored. Consider adding optional encryption support. Advise users on proper file permissions (e.g., chmod 600) and disk-level encryption.

LLM-derived; treat as a starting point, not a security audit.


Generated by RepoPilot. Verdict based on maintenance signals — see the live page for receipts. Re-run on a new commit to refresh.

Mixed signals · boltdb/bolt — RepoPilot