cockroachdb / cockroachdb/pebble

Custom key comparer in version 2.1 failing assertion

Open
#5,436 5 comments 0 reactions 0 assignees View on GitHub
A-storage O-community T-storage
Dominant language
Go
Stars
6k
Forks
584
Avg merge
16h 35m
Merged PRs (30d)
5

Description

I'm using a custom comparison function with Pebble (main reason is to have hierarchical friendly sorting, eg. assigning special meaning to `/` and have filesystem like tree structure).

This worked well in Pebble 1.x (apart from the addition of `AbbreviatedKey` which silently broker the ordering.. :) ).

In Pebble 2.1 there is an assertion check the custom compare returns the same order as the default compare:

https://github.com/cockroachdb/pebble/blob/d5392e3c8319009c305d93a9523ede0230bff75b/internal/base/comparer.go#L417-L425

Is there anything I'm missing here? Any configuration function to pass in to make it work? How any non-standard compare implementation can work if it needs to be checked against bytewise compare in the end?

Jira issue: PEBBLE-1217

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with internal/base/comparer.go at lines 417-425 and reproduce the assertion using a custom comparer with hierarchical slash ordering. Trace how Pebble validates comparer ordering and determine the intended behavior for non-bytewise comparers; the issue does not name a test or specify a target change, so completion requires clarifying the expected compatibility with maintainers.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
databases
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.