Skip to content

Commit

Permalink
GC: Fix behavior of cutoff policy "num commits", 'off by one' (#9096)
Browse files Browse the repository at this point in the history
Fix behavior of cutoff policy "num commits", it was 'off by one' and considered the n-th commit as non-live vs the n-th commit as the last live one

Fixes #9094
  • Loading branch information
snazy committed Jul 15, 2024
1 parent c130af2 commit 849cfba
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ as necessary. Empty sections will not end in the release notes.

### Fixes

- GC: Fix behavior of cutoff policy "num commits", it was 'off by one' and considered the n-th commit as non-live
vs the n-th commit as the last live one.

### Commits

## [0.92.1] Release (2024-07-13)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ final class NumCommitsCutoffPolicy implements CutoffPolicy {

@Override
public boolean isCutoff(@Nonnull Instant commitTime, int numCommits) {
return numCommits >= commits;
return numCommits > commits;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ long liveContentsCount() {

PerRefCutoffPolicySupplier cutOffPolicySupplier() {
Instant cutOff = now.minus(numCommits - numExpired, ChronoUnit.SECONDS);
return atTimestamp ? r -> atTimestamp(cutOff) : r -> numCommits((int) numCommits);
return atTimestamp ? r -> atTimestamp(cutOff) : r -> numCommits((int) numCommits - 1);
}
}

Expand Down

0 comments on commit 849cfba

Please sign in to comment.