Skip to content

Commit

Permalink
sql/catalog/descs: enforce invariant that OriginalVersion does not ch…
Browse files Browse the repository at this point in the history
…ange

It's a bug any time we increment a version more than once in the context
of a single descriptor collection. Let's enforce it.

Release note: None
  • Loading branch information
ajwerner committed Apr 8, 2022
1 parent 7a97bdd commit 1da50fd
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions pkg/sql/catalog/descs/uncommitted_descriptors.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,13 @@ func (ud *uncommittedDescriptors) add(
for _, n := range uNew.immutable.GetDrainingNames() {
ud.descNames.Add(n)
}
if prev, ok := ud.descs.GetByID(mut.GetID()).(*uncommittedDescriptor); ok {
if prev.mutable.OriginalVersion() != mut.OriginalVersion() {
return nil, errors.AssertionFailedf(
"cannot add a version of descriptor with a different original version" +
" than it was previously added with")
}
}
ud.descs.Upsert(uNew)
return uNew.immutable, err
}
Expand Down

0 comments on commit 1da50fd

Please sign in to comment.