Skip to content

Commit

Permalink
Funny business
Browse files Browse the repository at this point in the history
  • Loading branch information
jasontedor committed Mar 23, 2017
1 parent 3c78802 commit 192a7ce
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ private int totalOperations(long minGeneration) {
try (ReleasableLock ignored = readLock.acquire()) {
ensureOpen();
return Stream.concat(readers.stream(), Stream.of(current))
.filter(r -> r.getGeneration() >= minGeneration)
.filter(r -> r.getGeneration() > minGeneration)
.mapToInt(BaseTranslogReader::totalOperations)
.sum();
}
Expand All @@ -371,7 +371,7 @@ private long sizeInBytes(long minGeneration) {
try (ReleasableLock ignored = readLock.acquire()) {
ensureOpen();
return Stream.concat(readers.stream(), Stream.of(current))
.filter(r -> r.getGeneration() >= minGeneration)
.filter(r -> r.getGeneration() > minGeneration)
.mapToLong(BaseTranslogReader::sizeInBytes)
.sum();
}
Expand Down Expand Up @@ -519,7 +519,7 @@ private Snapshot createSnapshot(long minGeneration) {
public Translog.View newView() {
try (ReleasableLock lock = readLock.acquire()) {
ensureOpen();
View view = new View(lastCommittedTranslogFileGeneration);
View view = new View(lastCommittedTranslogFileGeneration + 1);
outstandingViews.add(view);
return view;
}
Expand Down Expand Up @@ -1418,9 +1418,9 @@ void trimUnreferencedReaders() {
return;
}
long minReferencedGen = outstandingViews.stream().mapToLong(View::minTranslogGeneration).min().orElse(Long.MAX_VALUE);
minReferencedGen = Math.min(lastCommittedTranslogFileGeneration, minReferencedGen);
minReferencedGen = Math.min(lastCommittedTranslogFileGeneration + 1, minReferencedGen);
final long finalMinReferencedGen = minReferencedGen;
List<TranslogReader> unreferenced = readers.stream().filter(r -> r.getGeneration() <= finalMinReferencedGen).collect(Collectors.toList());
List<TranslogReader> unreferenced = readers.stream().filter(r -> r.getGeneration() < finalMinReferencedGen).collect(Collectors.toList());
for (final TranslogReader unreferencedReader : unreferenced) {
Path translogPath = unreferencedReader.path();
logger.trace("delete translog file - not referenced and not current anymore {}", translogPath);
Expand Down

0 comments on commit 192a7ce

Please sign in to comment.