-
Notifications
You must be signed in to change notification settings - Fork 3.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
kvserver: sustained constraint non-conformance for MR schemas #108127
Comments
Hi @irfansharif, I've guessed the C-ategory of your issue and suitably labeled it. Please re-label if inaccurate. While you're here, please consider adding an A- label to help keep our repository tidy. 🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf. |
cc @cockroachdb/replication |
It looks likely that this is an instance of #106559. The violated voter constraint: root@localhost:26257/defaultdb> select full_config_yaml from crdb_internal.zones INNER JOIN system.replication_constraint_stats on crdb_internal.zones.zone_id = system.replication_constraint_stats.zone_id where system.replication_constraint_stats.violating_ranges > 0;
full_config_yaml
------------------------------------------------------------------------------------------------------------------------------------------------------------------
range_min_bytes: 134217728
range_max_bytes: 536870912
gc:
ttlseconds: 14400
global_reads: null
num_replicas: 7
num_voters: 5
constraints: {+region=europe-central2: 1, +region=europe-north1: 1, +region=europe-west1: 1, +region=us-central1: 1, +region=us-east4: 1, +region=us-west1: 1}
voter_constraints: {+region=us-east4: 2}
lease_preferences: [[+region=us-east4]]
(1 row)
Time: 1.270s total (execution 1.270s / network 0.000s) |
@kvoli can you clarify the following statement? "The number of |
There is no such thing as There used to be a loose invariant (which sometime ago stopped being true) that: cockroach/pkg/kv/kvserver/allocator/allocatorimpl/allocator_scorer.go Lines 1785 to 1788 in 7008173
|
Ah ok - that makes sense. Does it still make sense to strongly recommend (or force) the num_voters in a region <= constraints for that region? I'm not sure I fully understand the use case for why the constraints are set up as they are, so there may be a use case I'm missing. |
It does make sense. I think we need to take a stroll through the SQL code which validates and generates these configs, and look for some low-hanging fruit like this (if possible). |
I was speaking to @otan who mentioned that the code for generating the zone config from high level abstractions is located here: I also realized that this particular issue only happens when using Super Regions + Regional By Row Tables. With Super Regions + Regional tables, I was unable to reproduce. |
I saw above that this issue was linked to #106559, which was initially discovered through a test that only uses secondary regions (no super regions or RBR). I don't understand yet how the issues relate; could someone explain? |
They both have configs which require a non-voter in a specific region, and voter constraints which aren't also present in the all replica constraints. They both end up with a voter somewhere there should be a non-voter, which needs to be swapped with a non-voter (in the voter locality) to satisfy the voter constraint. So they are related because they both have configs which are vulnerable to the bug described in #106559. This issue zcfg
Other issue zcfg
|
Previously, it was possible for a satisfiable voter constraint to never be satisfied when: 1. There were a correct number of `VOTER` and `NON_VOTER` replicas. 2. All existing replicas were necessary to satisfy a replica constraint, or voter constraint. The allocator relies on the `RebalanceVoter` path to resolve voter constraint violations when there are a correct number of each replica type. Candidates which are `necessary` to satisfy a constraint are ranked higher as rebalance targets than those which are not. Under most circumstances this leads to constraint conformance. However, when every existing replica is necessary to satisfy a replica constraint, and a voter constraint is unsatisfied -- `RebalanceVoter` would not consider swapping a `VOTER` and `NON_VOTER` to satisfy the constraint. For example, consider a setup where there are two stores, one in locality `a` and the other `b`, where some range has the following config and initial placement: ``` replicas = a(non-voter) b(voter) constraints = a:1 b:1 voter_constraints = a:1 ``` In this example, the only satisfiable placement is `a(voter)` `b(non-voter)`, which would require promoting `a(non-voter) -> a(voter)`, and demoting `b(voter)->b(non-voter)`. However, both are necessary to satisfy `constraints` leading to no rebalance occurring. Add an additional field to the allocator candidate struct, which is used to sort rebalance candidates. The new field, `voterNecessary` is sorted strictly after `necessary`, but before `diversityScore`. The `voterNecessary` field can be true only when rebalancing voters, and when the rebalance candidate is necessary to satisfy a voter constraint, the rebalance candidate already has a non-voter, and the existing voter is not necessary to satisfy *any* voter constraint. Note these rebalances are turned into swaps (promotion and demotion) in `plan.ReplicationChangesForRebalance`, so incur no snapshots. Fixes: cockroachdb#98020 Fixes: cockroachdb#106559 Fixes: cockroachdb#108127 Release note (bug fix): Voter constraints which were never satisfied due to all existing replicas being considered necessary to satisfy a replica constraint, will now be satisfied by promoting existing non-voters.
111609: allocator: prioritize non-voter promotion to satisfy voter constraints r=sumeerbhola a=kvoli Previously, it was possible for a satisfiable voter constraint to never be satisfied when: 1. There were a correct number of `VOTER` and `NON_VOTER` replicas. 2. All existing replicas were necessary to satisfy a replica constraint, or voter constraint. The allocator relies on the `RebalanceVoter` path to resolve voter constraint violations when there are a correct number of each replica type. Candidates which are `necessary` to satisfy a constraint are ranked higher as rebalance targets than those which are not. Under most circumstances this leads to constraint conformance. However, when every existing replica is necessary to satisfy a replica constraint, and a voter constraint is unsatisfied -- `RebalanceVoter` would not consider swapping a `VOTER` and `NON_VOTER` to satisfy the constraint. For example, consider a setup where there are two stores, one in locality `a` and the other `b`, where some range has the following config and initial placement: ``` replicas = a(non-voter) b(voter) constraints = a:1 b:1 voter_constraints = a:1 ``` In this example, the only satisfiable placement is `a(voter)` `b(non-voter)`, which would require promoting `a(non-voter) -> a(voter)`, and demoting `b(voter)->b(non-voter)`. However, both are necessary to satisfy `constraints` leading to no rebalance occurring. Add an additional field to the allocator candidate struct, which is used to sort rebalance candidates. The new field, `voterNecessary` is sorted strictly after `necessary`, but before `diversityScore`. The `voterNecessary` field can be true only when rebalancing voters, and when the rebalance candidate is necessary to satisfy a voter constraint, the rebalance candidate already has a non-voter, and the existing voter is not necessary to satisfy *any* voter constraint. Note these rebalances are turned into swaps (promotion and demotion) in `plan.ReplicationChangesForRebalance`, so incur no snapshots. Fixes: #98020 Fixes: #106559 Fixes: #108127 Release note (bug fix): Voter constraints which were never satisfied due to all existing replicas being considered necessary to satisfy a replica constraint, will now be satisfied by promoting existing non-voters. Co-authored-by: Austen McClernon <[email protected]>
Re-opening based on conversation with @dikshant. |
Add a manual simulator reproduction for cockroachdb#108127. Note the reproduction doesn't fail on this commit, but may not be meeting the conditions for the failure when setting up the initial replcia placement. Epic: none Release note: None
I couldn't reproduce this following the original steps. The violated constraints get resolved within a few minutes of setting the cfg. The same config as listed above is applied. Note to setup the cluster you'll need to use n1's, since some zones don't support ice lake.
I also tried reproducing with the allocation simulator, similar to a test added in the patch. This was using EDIT: The patch isn't in an alpha yet (v23.2.0-alpha.3 was cut 2 days before it merged.) I would try again when the next alpha comes out, that (hopefully) explains the behavior in testing. |
Closing again, this doesn't reproduce. |
Originally posted by @dikshant in #106128 (comment)
Here is a debug zip, see below for repro steps.
https://drive.google.com/file/d/1Ilkl1vWS8CpyuNDku93dC9XLs0U9aI4k/view?usp=sharing
I tried this on a 23.1.7 on a 18 node multi region cluster in roachprod.
So this is interesting. Mapping replicas to replica_localities using @j82w 's fixed query shows the correct mappings:
However, the violating range is still present and this is after waiting 10+ minutes:
Reproduction steps:
Create a MR cluster. I used:
Apply the following DDL and DML:
https://gist.github.com/dikshant/d4d170d70e493119b7cb6306aedb7551
Check for violating ranges after waiting for ~10 minutes:
It seems the violating range always has the primary region on the config. I don't know if this is expected behavior.
For example I ran an ALTER to change the primary region:
And got:
Whereas running:
Gives us (after waiting a bit):
Jira issue: CRDB-30324
The text was updated successfully, but these errors were encountered: