cockroachdb / cockroachdb/cockroach

kvserver: lease preferences can be confusing

Open
#106,107 4 comments 0 reactions 0 assignees View on GitHub
A-kv-distribution C-question E-starter T-kv
Dominant language
Go
Stars
32.5k
Forks
4.1k
PR merge metrics
PR metrics pending

Description

I'm not sure if this is a docs issue or a UX issue, but opening here to get some thoughts. Opened a corresponding docs issue in [DOC-8259](https://cockroachlabs.atlassian.net/browse/DOC-8259).

I find lease preferences to be a bit confusing. I got two things immediately wrong:

1. Lease preferences are not ordered by priority. If I specify `[[+rack=0], [+rack=1]]`, I would expect leases to be placed in `rack=0` when possible, and only if `rack=0` can't be satisfied (e.g. because all nodes are unavailable) should they be placed in `rack=1`. However, leases are placed in either of `rack=0` or `rack=1`.

2. It is sufficient for a store to satisfy _any_ preference. If I specify `[[+rack=0], [-rack=2]]` I would expect leases to only be placed in `rack=0`, but I found a bunch of leases also with `rack=1`. This happens because any constraint is sufficient, and `rack=1` satisfies the `-rack=2` constraint. I should have specified `[[+rack=0, -rack=2]]` instead.

In both of these cases, I misinterpreted the meaning of the lease preference list. It's basically an OR of ANDs: if a store satisfies ALL constraints in ANY preference, it may get a lease.

I guess we should document the current policy regardless, but is this the most useful or intuitive policy structure?

Jira issue: CRDB-29406

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.