Translog: make sure stats's op count and size are in sync

During translog flush there is a very small window where translog stats reports can be inconsistent.

Closes #10041
This commit is contained in:
Boaz Leskes 2015-03-09 06:21:23 -07:00
parent a8271595dc
commit 3fbd934e30
1 changed files with 6 additions and 1 deletions

View File

@ -439,7 +439,12 @@ public class FsTranslog extends AbstractIndexShardComponent implements Translog
@Override
public TranslogStats stats() {
return new TranslogStats(estimatedNumberOfOperations(), translogSizeInBytes());
FsTranslogFile current = this.current;
if (current == null) {
return new TranslogStats(0, 0);
}
return new TranslogStats(current.estimatedNumberOfOperations(), current.translogSizeInBytes());
}
@Override