Skip to content

chore(deps): upgrade pebble to v2.1.4#541

Merged
bootjp merged 2 commits into
mainfrom
chore/pebble-v2-bump
Apr 19, 2026
Merged

chore(deps): upgrade pebble to v2.1.4#541
bootjp merged 2 commits into
mainfrom
chore/pebble-v2-bump

Conversation

@bootjp

@bootjp bootjp commented Apr 19, 2026

Copy link
Copy Markdown
Owner

Summary

Upgrades github.com/cockroachdb/pebble from v1.1.5 to v2.1.4.

Supersedes the stale Renovate PR #289, which:

What changed

  • go.mod / go.sum: pin github.com/cockroachdb/pebble/v2 v2.1.4; drop v1 indirect deps that v2 no longer pulls in; add v2-era indirects.
  • All Go source + test imports updated to github.com/cockroachdb/pebble/v2 and github.com/cockroachdb/pebble/v2/vfs.
  • internal/raftstore/pebble_test.go:
    • Dropped TestPebbleStore_RatchetsExistingDB and TestPebbleStore_PreservesLogsAcrossRatchet — both opened a DB at FormatMostCompatible to simulate pre-migration state, but v2 unexports that constant and refuses to open below FormatFlushableIngest. The behavior they guarded (the ratchet) was the job of chore(pebble): pin FormatMajorVersion to ratchet DBs for pebble v2 #538 and has already been validated and deployed.
    • Renamed the remaining test to TestPebbleStore_OpensAtPinnedFormat and tightened it to assert equality with FormatVirtualSSTables, so an unintended downgrade of the pinned version is caught.

Migration safety

Rollout prerequisite already satisfied: #538 is merged and deployed cluster-wide. Every node has opened its raft.db at least once under the prep binary, so on-disk format is ≥ FormatVirtualSSTables — comfortably above v2 FormatMinSupported (FormatFlushableIngest). v2 will open existing DBs without needing any further ratchet.

Test plan

  • go build ./...
  • go vet ./...
  • go test ./... (all packages pass locally, including store/... MVCC + snapshot tests and internal/raftstore/...)
  • golangci-lint run ./... --timeout=5m — 0 issues
  • go mod tidy — no further changes

Follow-up

PR #289 should be closed with a pointer to this PR.

Supersedes the stale Renovate PR #289. That branch only bumped go.mod
and predates the format-ratchet prep (#538), so it could not be merged
as-is:

  - It kept imports under github.com/cockroachdb/pebble, but pebble v2
    moved the module to github.com/cockroachdb/pebble/v2 and go get
    refuses the old path.
  - It reverted the FormatMajorVersion pinning added in #538, which is
    the entire reason the migration was two-stepped.

Changes here:

  - go.mod / go.sum bumped to cockroachdb/pebble/v2 v2.1.4.
  - All source + test imports updated to the /v2 module path.
  - internal/raftstore/pebble_test.go: dropped the two tests that
    simulated a pre-migration DB by opening at FormatMostCompatible,
    since v2 unexports that constant and rejects opens below
    FormatFlushableIngest anyway; kept a single assertion that a fresh
    NewPebbleStore opens at the pinned FormatVirtualSSTables.

Rollout prerequisite satisfied: #538 has been merged and deployed to
every node, so on-disk DBs are already ratcheted above
FormatMinSupported (FormatFlushableIngest) and open cleanly under v2.
@coderabbitai

coderabbitai Bot commented Apr 19, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@bootjp has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 44 minutes and 55 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 44 minutes and 55 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: df8c5ce4-242b-4f1e-848b-be96fbaa1cc4

📥 Commits

Reviewing files that changed from the base of the PR and between cb0c086 and 270c433.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (6)
  • go.mod
  • internal/raftstore/pebble.go
  • internal/raftstore/pebble_test.go
  • store/lsm_store.go
  • store/lsm_store_test.go
  • store/snapshot_pebble.go
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/pebble-v2-bump

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request upgrades the cockroachdb/pebble dependency to v2 across the codebase and updates the associated tests. Feedback includes a suggestion to remove a redundant assertion in the tests and a recommendation to re-add a persistence test to ensure StoreLog and GetLog functionality remains intact after the migration.

Comment on lines +6 to 21
"github.com/cockroachdb/pebble/v2"
"github.com/stretchr/testify/require"
)

// Guards the pebble v1 → v2 migration: v2 refuses to open DBs below
// FormatFlushableIngest.
func TestPebbleStore_FormatRatchetedForV2(t *testing.T) {
// Pins the on-open format so unintended downgrades below pebble v2
// FormatMinSupported are caught early.
func TestPebbleStore_OpensAtPinnedFormat(t *testing.T) {
dir := t.TempDir()

s, err := NewPebbleStore(dir)
require.NoError(t, err)
t.Cleanup(func() { require.NoError(t, s.Close()) })

require.GreaterOrEqual(t, s.db.FormatMajorVersion(), pebble.FormatFlushableIngest)
}

// Existing on-disk DBs from pre-migration binaries must be ratcheted up on
// reopen — this is the migration path for clusters that already have raft.db.
func TestPebbleStore_RatchetsExistingDB(t *testing.T) {
dir := t.TempDir()

// Simulate an existing on-disk DB created by a pre-migration binary,
// which left FormatMajorVersion unset (== FormatMostCompatible after
// EnsureDefaults in pebble v1).
old, err := pebble.Open(dir, &pebble.Options{
FormatMajorVersion: pebble.FormatMostCompatible,
})
require.NoError(t, err)
require.Equal(t, pebble.FormatMostCompatible, old.FormatMajorVersion())
require.NoError(t, old.Close())

// Reopen through the production path.
s, err := NewPebbleStore(dir)
require.NoError(t, err)
t.Cleanup(func() { require.NoError(t, s.Close()) })

require.GreaterOrEqual(t, s.db.FormatMajorVersion(), pebble.FormatFlushableIngest)
}

// The format ratchet runs during DB open; committed Raft entries must survive it.
func TestPebbleStore_PreservesLogsAcrossRatchet(t *testing.T) {
dir := t.TempDir()

old, err := pebble.Open(dir, &pebble.Options{
FormatMajorVersion: pebble.FormatMostCompatible,
})
require.NoError(t, err)
pre := &PebbleStore{db: old}
require.NoError(t, pre.StoreLog(&raft.Log{Index: 1, Term: 1, Data: []byte("hello")}))
require.NoError(t, pre.StoreLog(&raft.Log{Index: 2, Term: 1, Data: []byte("world")}))
require.NoError(t, old.Close())

s, err := NewPebbleStore(dir)
require.NoError(t, err)
t.Cleanup(func() { require.NoError(t, s.Close()) })

var got raft.Log
require.NoError(t, s.GetLog(1, &got))
require.Equal(t, []byte("hello"), got.Data)
require.NoError(t, s.GetLog(2, &got))
require.Equal(t, []byte("world"), got.Data)

last, err := s.LastIndex()
require.NoError(t, err)
require.Equal(t, uint64(2), last)
require.Equal(t, pebble.FormatVirtualSSTables, s.db.FormatMajorVersion())
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The removal of TestPebbleStore_PreservesLogsAcrossRatchet results in a loss of functional testing for the PebbleStore implementation's persistence logic. While the specific ratchet scenario from FormatMostCompatible is no longer testable in Pebble v2 (as it refuses to open versions below FormatFlushableIngest), it is still essential to verify that StoreLog and GetLog work correctly across a database close/reopen cycle with the new library version. Consider adding a simplified persistence test that uses the pinned format version to ensure that the integration between the PebbleStore wrapper and the Pebble v2 library remains correct. Additionally, ensure that any Close() calls on the database within the test explicitly handle or log errors to prevent silent resource leaks or cleanup failures.

References
  1. Ensure persistence logic is verified and that resource cleanup, such as Close() calls, handles errors explicitly to avoid silent failures.

Comment thread internal/raftstore/pebble_test.go Outdated
- Drop the redundant GreaterOrEqual assertion; the Equal check on
  FormatVirtualSSTables already covers it (Gemini review).
- Re-add a round-trip persistence test (TestPebbleStore_PersistsLogs
  AcrossReopen) that exercises StoreLog/GetLog across a close/reopen
  against pebble v2, replacing the dropped ratchet variant so the
  StoreLog/GetLog path still has end-to-end coverage (Gemini review).
@bootjp

bootjp commented Apr 19, 2026

Copy link
Copy Markdown
Owner Author

Thanks for the review. Pushed 270c433 addressing both items:

Applied:

  • Dropped the redundant GreaterOrEqual(..., FormatFlushableIngest) assertion in TestPebbleStore_OpensAtPinnedFormat — the Equal(..., FormatVirtualSSTables) check subsumes it.
  • Added TestPebbleStore_PersistsLogsAcrossReopen as a replacement for the dropped ratchet persistence test. It does not try to reproduce the pre-migration DB state (v2 cannot create one), but it still exercises StoreLog / GetLog / LastIndex end-to-end across a close/reopen so the wrapper ↔ pebble v2 integration stays covered.

@bootjp

bootjp commented Apr 19, 2026

Copy link
Copy Markdown
Owner Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request upgrades the cockroachdb/pebble dependency from v1 to v2 across the codebase, updating module requirements and import paths. The test suite in internal/raftstore/pebble_test.go was refactored to verify that the store opens with the FormatVirtualSSTables major version and maintains data integrity across reopens. I have no feedback to provide.

@bootjp bootjp merged commit cc3c63e into main Apr 19, 2026
9 checks passed
@bootjp bootjp deleted the chore/pebble-v2-bump branch April 19, 2026 14:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant