cockroachdb / cockroachdb/cockroach
allocator: voter constraint not satisfied when constraints are underspecified
- Dominant language
- Go
- Stars
- 32.5k
- Forks
- 4.1k
- PR merge metrics
- PR metrics pending
Description
**Describe the problem**
A voter constraint may not be satisfied when in an configuration where every existing voter is required to satisfy an all replica constraint and there isn't already a non-voter which would satisfy the voter constraint if promoted.
Note that this case is slightly different than https://github.com/cockroachdb/cockroach/issues/106559, where there already exists the correct number of replicas to satisfy every constraint, just the type is incorrect. Here, there are not enough replicas to satisfy the voter constraint regardless so a swap cannot take place. e.g.
Config:
```
num_replicas=4 num_voters=3
constraints={'+region=a':1,'+region=b':1,'+region=c':1}
voter_constraints={'+region=c':2}
```
Topology
```
a
└── [1]
b
└── [2]
c
└── [3 4]
d
└── [5]
```
Existing placement:
```
a,b,c,d(non-voter)
```
**To Reproduce**
See https://github.com/kvoli/cockroach/commit/f92433a835d006a71fe56760887842e18013cbea
**Expected behavior**
Voter constraint is satisfied if possible.
**Environment:**
- CockroachDB version All versions affected.
**Additional context**
Less voting replicas than desired in a locality.
Jira issue: CRDB-37790
Contributor guide
Assessment
This issue has not been assessed yet.