Attempt to fix list_rels & list_nonrels for dropped segments

This commit is contained in:
anastasia
2021-09-01 18:03:42 +03:00
parent 2a4d405f96
commit 8c46178256
4 changed files with 19 additions and 8 deletions

View File

@@ -251,6 +251,8 @@ impl Layer for DeltaLayer {
/// Does this segment exist at given LSN?
fn get_seg_exists(&self, lsn: Lsn) -> Result<bool> {
assert!(lsn >= self.start_lsn);
// Is the requested LSN after the rel was dropped?
if self.dropped && lsn >= self.end_lsn {
return Ok(false);

View File

@@ -157,7 +157,9 @@ impl Layer for ImageLayer {
}
/// Get size of the segment
fn get_seg_size(&self, _lsn: Lsn) -> Result<u32> {
fn get_seg_size(&self, lsn: Lsn) -> Result<u32> {
assert!(lsn >= self.lsn);
let inner = self.load()?;
match inner.image_type {
ImageType::Blocky { num_blocks } => Ok(num_blocks),
@@ -166,7 +168,8 @@ impl Layer for ImageLayer {
}
/// Does this segment exist at given LSN?
fn get_seg_exists(&self, _lsn: Lsn) -> Result<bool> {
fn get_seg_exists(&self, lsn: Lsn) -> Result<bool> {
assert!(lsn >= self.lsn);
Ok(true)
}

View File

@@ -198,6 +198,8 @@ impl Layer for InMemoryLayer {
/// Does this segment exist at given LSN?
fn get_seg_exists(&self, lsn: Lsn) -> Result<bool> {
assert!(lsn >= self.start_lsn);
let inner = self.inner.lock().unwrap();
// Is the requested LSN after the segment was dropped?

View File

@@ -227,15 +227,17 @@ impl LayerMap {
{
// Add only if it exists at the requested LSN.
if let Some(open) = &segentry.open {
if open.get_end_lsn() > lsn {
if open.get_end_lsn() > lsn && open.get_start_lsn() <= lsn {
rels.insert(reltag);
}
} else if let Some((_k, _v)) = segentry
} else if let Some((l_start_lsn, layer)) = segentry
.historic
.range((Included(Lsn(0)), Included(lsn)))
.next_back()
{
rels.insert(reltag);
if !layer.is_dropped() && l_start_lsn <= &lsn {
rels.insert(reltag);
}
}
}
}
@@ -253,15 +255,17 @@ impl LayerMap {
} else {
// Add only if it exists at the requested LSN.
if let Some(open) = &segentry.open {
if open.get_end_lsn() > lsn {
if open.get_end_lsn() > lsn && open.get_start_lsn() <= lsn {
rels.insert(seg.rel);
}
} else if let Some((_k, _v)) = segentry
} else if let Some((l_start_lsn, layer)) = segentry
.historic
.range((Included(Lsn(0)), Included(lsn)))
.next_back()
{
rels.insert(seg.rel);
if !layer.is_dropped() && l_start_lsn <= &lsn {
rels.insert(seg.rel);
}
}
}
}