remove Lsn::sub in favor of sub_checked

There is only one place doing subtraction, and it had a manually
implemented check.
This commit is contained in:
Eric Seppanen
2021-04-24 14:01:11 -07:00
parent 01e239afa3
commit d760446053
2 changed files with 10 additions and 12 deletions

View File

@@ -831,8 +831,9 @@ impl PageCache {
loop {
thread::sleep(conf.gc_period);
let last_lsn = self.get_last_valid_lsn();
if last_lsn.0 > conf.gc_horizon {
let horizon = last_lsn - conf.gc_horizon;
// checked_sub() returns None on overflow.
if let Some(horizon) = last_lsn.checked_sub(conf.gc_horizon) {
let mut maxkey = CacheKey {
tag: BufferTag {
rel: RelTag {