Skip to content
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

release-19.1: sql: at least one replica is required when using num_replicas = COPY FROM PARENT #44231

Closed
nvanbenschoten opened this issue Jan 22, 2020 · 3 comments
Assignees
Labels
A-zone-configs C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. regression Regression from a release.

Comments

@nvanbenschoten
Copy link
Member

There appears to have been a regression in v19.1.6 where subzones do not interact properly in all cases with COPY FROM PARENT, which can result in an unexpected error.

Reproduction Steps

roachprod create local -n 4
roachprod stage local release v19.1.6
roachprod start local:1-3 --racks=3
roachprod run local:4 -- ./cockroach workload fixtures import tpcc {pgurl:1}
roachprod sql local:1
# run the following in the SQL shell 3 or more times (yes, three times or more!)
# ALTER INDEX tpcc.customer@customer_idx CONFIGURE ZONE USING num_replicas = COPY FROM PARENT, constraints = '{"+rack=1":1}', lease_preferences = '[[+rack=1]]';

pq: could not validate zone config: at least one replica is required

This is not present in v19.1.5 or below. It is also not present in v19.2.0 or above.

I tracked this down to only occurring with subzones because the same issue does not occur when you run:

ALTER TABLE tpcc.customer CONFIGURE ZONE USING num_replicas = COPY FROM PARENT, constraints = '{"+rack=1":1}', lease_preferences = '[[+rack=1]]';

So based on the timing and the behavior, I think it's likely that this was a result of #41699.

@rohany can I get you to take this over? I suspect you'll have additional insight into what's going wrong here. You might also know just by looking at it why this was caused by #41699. Did that change simply reveal a different bug?

@nvanbenschoten nvanbenschoten added C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. regression Regression from a release. A-zone-configs labels Jan 22, 2020
@nvanbenschoten nvanbenschoten mentioned this issue Jan 22, 2020
19 tasks
@rohany
Copy link
Contributor

rohany commented Jan 22, 2020

It's pretty strange that this doesn't show up in v19.2.0 and above because the PR that was backported onto 19.1 (#41506) was also backported onto 19.2. Maybe there's something different about how this is done in the 19.1 branch. I can investigate this further.

@rohany
Copy link
Contributor

rohany commented Jan 22, 2020

Alright, this is reproduceable in a sql shell with:

create table t (x int, index i (x));
alter index t@i configure zone using num_replicas=copy from parent;
alter index t@i configure zone using num_replicas=copy from parent;
alter index t@i configure zone using num_replicas=copy from parent

@rohany
Copy link
Contributor

rohany commented Jan 23, 2020

Whats weird is that after the second alter index, the index has a zone configuration with num_replicas = 0, but this isn't caught by the validator.

rohany added a commit to rohany/cockroach that referenced this issue Jan 23, 2020
Fixes cockroachdb#44231.
Fixes cockroachdb#41553.

This PR fixes a bug caused by backports.

In short, the backport of cockroachdb#41506 to 19.1 did not include some code
in cockroachdb#40493 which allowed a subzone placeholder to inherit fields
from its parents. This caused a problem the second time a index's
zone was altered, because its parent (now a subzone placeholder)
would no longer be able to inherit values from its parent.
We couldn't backport cockroachdb#40493 because it contained features that
were only released in 19.2, and since there was not a test checking
this specific behavior, we didn't catch the regression on 19.1

Release note (bug fix): Fix a bug where repeated use of COPY FROM PARENT
on an index or partition could cause an unexpected validation error.
rohany added a commit to rohany/cockroach that referenced this issue Jan 23, 2020
Fixes cockroachdb#44231.
Fixes cockroachdb#41553.

This PR fixes a bug caused by backports.

In short, the backport of cockroachdb#41506 to 19.1 did not include some code
in cockroachdb#40493 which allowed a subzone placeholder to inherit fields
from its parents. This caused a problem the second time a index's
zone was altered, because its parent (now a subzone placeholder)
would no longer be able to inherit values from its parent.
We couldn't backport cockroachdb#40493 because it contained features that
were only released in 19.2, and since there was not a test checking
this specific behavior, we didn't catch the regression on 19.1.
Therefore, this PR contains a partial backport of cockroachdb#40493.

Release note (bug fix): Fix a bug where repeated use of COPY FROM PARENT
on an index or partition could cause an unexpected validation error.
@rohany rohany closed this as completed Jan 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-zone-configs C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. regression Regression from a release.
Projects
None yet
Development

No branches or pull requests

2 participants