-
Notifications
You must be signed in to change notification settings - Fork 159
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: don't GC manifests #4959
fix: don't GC manifests #4959
Changes from all commits
e75471b
b291b78
51d3e4d
9835839
d58f9f1
83e3757
1969edc
3525185
a406b8f
b48527e
88c86ec
aaaa984
612e41b
480cfd6
f8d964d
fa0dd54
9f7cc5e
b096d1b
6110bac
da0ade0
ab874a2
c692f25
4284d18
64f3d3f
2be3331
6b42faf
9a61222
2927a83
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "forest-filecoin" | ||
version = "0.22.0" | ||
version = "0.22.1" | ||
authors = ["ChainSafe Systems <[email protected]>"] | ||
repository = "https://github.com/ChainSafe/forest" | ||
edition = "2021" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ | |
|
||
use super::{CacheKey, RandomAccessFileReader, ZstdFrameCache}; | ||
use crate::blocks::Tipset; | ||
use crate::db::PersistentStore; | ||
use crate::utils::io::EitherMmapOrRandomAccessFile; | ||
use cid::Cid; | ||
use fvm_ipld_blockstore::Blockstore; | ||
|
@@ -124,6 +125,19 @@ where | |
} | ||
} | ||
|
||
impl<ReaderT> PersistentStore for AnyCar<ReaderT> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I feel it would be less error-prone to make There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can create an issue for that and we’ll address it as prioritized. It’s out of scope for this PR, I have already created an issue to generalize different stores a bit more to be able to rely on tests for different database types better. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I’m also not sure that making Blockstore persistent by default is a good idea as the use-cases for persistent storage are pretty limited at the moment. |
||
where | ||
ReaderT: ReadAt, | ||
{ | ||
fn put_keyed_persistent(&self, k: &Cid, block: &[u8]) -> anyhow::Result<()> { | ||
match self { | ||
AnyCar::Forest(forest) => forest.put_keyed_persistent(k, block), | ||
AnyCar::Plain(plain) => plain.put_keyed_persistent(k, block), | ||
AnyCar::Memory(mem) => mem.put_keyed_persistent(k, block), | ||
} | ||
} | ||
} | ||
|
||
impl<ReaderT> From<super::ForestCar<ReaderT>> for AnyCar<ReaderT> { | ||
fn from(car: super::ForestCar<ReaderT>) -> Self { | ||
Self::Forest(car) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -238,7 +238,7 @@ mod test { | |
use crate::blocks::{CachingBlockHeader, Tipset}; | ||
use crate::chain::{ChainEpochDelta, ChainStore}; | ||
|
||
use crate::db::{GarbageCollectable, MarkAndSweep, MemoryDB}; | ||
use crate::db::{GarbageCollectable, MarkAndSweep, MemoryDB, PersistentStore}; | ||
use crate::message_pool::test_provider::{mock_block, mock_block_with_parents}; | ||
use crate::networks::ChainConfig; | ||
|
||
|
@@ -247,7 +247,11 @@ mod test { | |
use core::time::Duration; | ||
|
||
use crate::shim::clock::ChainEpoch; | ||
use cid::multihash::Code::Identity; | ||
use cid::multihash::MultihashDigest; | ||
use cid::Cid; | ||
use fvm_ipld_blockstore::Blockstore; | ||
use fvm_ipld_encoding::DAG_CBOR; | ||
use std::sync::Arc; | ||
|
||
const ZERO_DURATION: Duration = Duration::from_secs(0); | ||
|
@@ -473,4 +477,43 @@ mod test { | |
current_epoch + 1 + depth * 2 | ||
); | ||
} | ||
|
||
#[tokio::test] | ||
async fn persistent_data_resilient_to_gc() { | ||
let depth = 5 as ChainEpochDelta; | ||
let current_epoch = 0 as ChainEpochDelta; | ||
|
||
let tester = GCTester::new(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shall we test both There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ParityDB is tricky to test, there is an issue for that. Therefore it has been tested manually. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The main issue there is that deletes are not propagating immediately, so unit testing it reliably is not currently possible. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. actually, no issue. creating one |
||
let mut gc = MarkAndSweep::new( | ||
tester.db.clone(), | ||
tester.get_heaviest_tipset_fn(), | ||
depth, | ||
ZERO_DURATION, | ||
); | ||
|
||
let depth = depth as ChainEpochDelta; | ||
let current_epoch = current_epoch as ChainEpochDelta; | ||
|
||
let persistent_data = [1, 55]; | ||
let persistent_cid = Cid::new_v1(DAG_CBOR, Identity.digest(&persistent_data)); | ||
|
||
// Make sure we run enough epochs to initiate GC. | ||
tester.run_epochs(current_epoch); | ||
tester.run_epochs(depth); | ||
tester | ||
.db | ||
.put_keyed_persistent(&persistent_cid, &persistent_data) | ||
.unwrap(); | ||
// Mark. | ||
gc.gc_workflow(ZERO_DURATION).await.unwrap(); | ||
tester.run_epochs(depth); | ||
// Sweep. | ||
gc.gc_workflow(ZERO_DURATION).await.unwrap(); | ||
|
||
// Make sure persistent data stays. | ||
assert_eq!( | ||
tester.db.get(&persistent_cid).unwrap(), | ||
Some(persistent_data.to_vec()) | ||
); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would love to see GC being manually triggered in at least one of the CI tests. Could you create a tracking issue if it cannot land in this PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there is an issue for manual gc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#4461