Skip to content

Commit

Permalink
rules: suppress a dep-rule in special case
Browse files Browse the repository at this point in the history
Release justification: fixed a release blocker bug.

Previously, in a mixed version state (v22.1 and v22.2), if a old node
drops a rowLevelTTL table and the new shcema changer job was adopted
by a new node, then there is a dep rule that cannot satisfied and hence
causes forward incompatibility. This PR fixes this by suppressing this
dep rule if this particular case happens (namely, it suppress the rule
if `from` is Table element, `to` is a RowLevelTTL element, and there is
no `PUBLIC` status of the table element anywhere in the graph).

Fixes: cockroachdb#86672

Release note: None
  • Loading branch information
Xiang-Gu committed Aug 31, 2022
1 parent 195f161 commit 938878c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pkg/sql/schemachanger/rel/schema_rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@ func (sc *Schema) Def3(name string, a, b, c Var, def func(a, b, c Var) Clauses)
return sc.rule(name, regular, def, a, b, c).(Rule3)
}

// DefNotJoin3 defines a not-join rule with three bound variable arguments.
func (sc *Schema) DefNotJoin3(name string, a, b, c Var, def func(a, b, c Var) Clauses) Rule3 {
return sc.rule(name, notJoin, def, a, b, c).(Rule3)
}

// Def4 defines a Rule4.
func (sc *Schema) Def4(name string, a, b, c, d Var, def func(a, b, c, d Var) Clauses) Rule4 {
return sc.rule(name, regular, def, a, b, c, d).(Rule4)
Expand Down
20 changes: 20 additions & 0 deletions pkg/sql/schemachanger/scplan/internal/rules/dep_drop_object.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,26 @@ func init() {
to.typeFilter(isSimpleDependent),
joinOnDescID(from, to, "desc-id"),
statusesToAbsent(from, scpb.Status_DROPPED, to, scpb.Status_ABSENT),
// The following clause is added to suppress this rule for the special
// case where we drop a rowLevelTTL table in mixed version state for
// forward compatibility (issue #86672).
screl.Schema.DefNotJoin3("suppress rule if dropping rowLevelTTL tables in mixed version state",
"fromTarget", "fromEl", "toEl", func(fromTarget, fromEl, toEl rel.Var) rel.Clauses {
n := rel.Var("n")
return rel.Clauses{
fromEl.Type((*scpb.Table)(nil)),
toEl.Type((*scpb.RowLevelTTL)(nil)),
n.Type((*screl.Node)(nil)),
n.AttrEqVar(screl.Target, fromTarget),
screl.Schema.DefNotJoin1("node does not have a PUBLIC status", "n", func(n rel.Var) rel.Clauses {
public := rel.Var("public")
return rel.Clauses{
public.Eq(scpb.Status_PUBLIC),
n.AttrEqVar(screl.CurrentStatus, public),
}
})(n),
}
})(from.target, from.el, to.el),
}
})

Expand Down

0 comments on commit 938878c

Please sign in to comment.