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-21.2: kvserver: allow gc of data at timestamp < lease start #82969

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions pkg/kv/kvserver/replica_protected_timestamp.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,20 @@ func (r *Replica) checkProtectedTimestampsForGC(
// read.earliestRecord is the record with the earliest timestamp which is
// greater than the existing gcThreshold.
read = r.readProtectedTimestampsRLocked(ctx, nil)
if read.readAt.IsEmpty() {
// We don't want to allow GC to proceed if no protected timestamp
// information is available.
log.VEventf(ctx, 1,
"not gc'ing replica %v because protected timestamp information is unavailable", r)
return false, hlc.Timestamp{}, hlc.Timestamp{}, hlc.Timestamp{}, hlc.Timestamp{}
}

if read.readAt.Less(lease.Start.ToTimestamp()) {
log.VEventf(ctx, 1, "not gc'ing replica %v because current lease %v started after record was read %v",
r, lease, read.readAt)
return false, hlc.Timestamp{}, hlc.Timestamp{}, hlc.Timestamp{}, hlc.Timestamp{}
}

gcTimestamp = read.readAt
if read.earliestRecord != nil {
// NB: we want to allow GC up to the timestamp preceding the earliest valid
Expand All @@ -291,12 +305,6 @@ func (r *Replica) checkProtectedTimestampsForGC(
}
}

if gcTimestamp.Less(lease.Start.ToTimestamp()) {
log.VEventf(ctx, 1, "not gc'ing replica %v due to new lease %v started after %v",
r, lease, gcTimestamp)
return false, hlc.Timestamp{}, hlc.Timestamp{}, hlc.Timestamp{}, hlc.Timestamp{}
}

newThreshold = gc.CalculateThreshold(gcTimestamp, gcTTL)

return true, read.readAt, gcTimestamp, oldThreshold, newThreshold
Expand Down