Skip to content

Commit

Permalink
kvserver: allow term and generation increments
Browse files Browse the repository at this point in the history
Previously delegated snapshots had a check where it would not allow
delegation if the term or generation were different between the sender
and the recipient. This was incorrect as on the coordinator it was
possible that the term and generation could increment. This change
allows the sending of changes as long as the sender (leaseholder or
delegate) has an equal or greater term or generation.

Epic: none
Fixes: cockroachdb#104477

Release note: None
  • Loading branch information
andrewbaptist committed Jun 15, 2023
1 parent a02df8e commit d21647b
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pkg/kv/kvserver/replica_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -2914,13 +2914,13 @@ func (r *Replica) validateSnapshotDelegationRequest(
// NB: This is an overly strict check. If other delegates are added to this
// snapshot, we don't necessarily need to reject sending the snapshot, however
// if there are merges or splits, it is safer to reject.
if desc.Generation != req.DescriptorGeneration {
if desc.Generation < req.DescriptorGeneration {
log.VEventf(ctx, 2,
"%s: generation has changed since snapshot was generated %s != %s",
"%s: generation has changed since snapshot was generated %s < %s",
r, req.DescriptorGeneration, desc.Generation,
)
return errors.Errorf(
"%s: generation has changed since snapshot was generated %s != %s",
"%s: generation has changed since snapshot was generated %s < %s",
r, req.DescriptorGeneration, desc.Generation,
)
}
Expand Down Expand Up @@ -2965,7 +2965,7 @@ func (r *Replica) validateSnapshotDelegationRequest(
// and then the term changes before this request is processed. In that
// case this code path will not be checked and the snapshot will still be
// sent.
if replTerm != req.Term {
if replTerm < req.Term {
log.Infof(
ctx,
"sender: %v is not fit to send snapshot for %v; sender term: %v coordinator term: %v",
Expand Down

0 comments on commit d21647b

Please sign in to comment.