-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
feat:chain:splitstore chain prune #9056
Conversation
638f2f6
to
699f315
Compare
itests/kit/blockminer.go
Outdated
@@ -255,6 +258,15 @@ func (bm *BlockMiner) MineBlocks(ctx context.Context, blocktime time.Duration) { | |||
defer bm.wg.Done() | |||
|
|||
for { | |||
if paused := atomic.LoadInt64(&bm.pause); paused == 1 { |
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.
I'm an atomic n00b so I might be getting the usage quite wrong
@@ -283,6 +295,18 @@ func (bm *BlockMiner) InjectNulls(rounds abi.ChainEpoch) { | |||
atomic.AddInt64(&bm.nextNulls, int64(rounds)) | |||
} | |||
|
|||
// Pause compels the miner to wait for a signal to restart | |||
func (bm *BlockMiner) Pause() { |
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.
These helped me avoid races in test and seem generally useful. Worth checking carefully to make sure I'm not opening up deadlocks.
@@ -102,6 +102,14 @@ func (b *idstore) Put(ctx context.Context, blk blocks.Block) error { | |||
return b.bs.Put(ctx, blk) | |||
} | |||
|
|||
func (b *idstore) ForEachKey(f func(cid.Cid) error) error { |
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.
Needed so that badger backed cold store satisfies the interface needed for pruning
@@ -14,35 +14,36 @@ func NewMemory() MemBlockstore { | |||
} | |||
|
|||
// MemBlockstore is a terminal blockstore that keeps blocks in memory. | |||
type MemBlockstore map[cid.Cid]blocks.Block | |||
// To match behavior of badger blockstore we index by multihash only. | |||
type MemBlockstore map[string]blocks.Block |
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.
Something I learned during this work is that the badger backed blockstores store mh only as keys to blocks. Until now the MemBlockstore has had different behavior, only matching when codec also matches. When using a coldstore backed by this MemBlockstore this led to a byzantine failure case. I think this is more correct across the board.
I'll add a |
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.
First pass, couple of (mostly nitpicky) comments. I feel like I have a decent idea of what's going on here, and the core logic makes sense.
Would be nice to setup some chaos-style tests for both this and hotstore compaction, crashing the process in the middle of compacting, and seeing if we resume correctly (not as a part of this PR, but before we call splitstore stable)
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.
Nothing serious to complain about.
Definitely needs lots of testing, and maybe measuring perf in a bunch of scenarios, but that seems to be planned already.
Well, other than a bunch of itests hanging for whatever reason |
aed3aea
to
231135b
Compare
71343b9
to
94a348f
Compare
Related Issues
#6577
Proposed Changes
Because many changes from the existing coldstore GC PR (#6728) have made it into lotus master and have been heavily modified with the last year of changes this PR is meant to replace #6728.
The scope of this PR is adding correct splitstore coldstore GC, integration tests of the splitstore, and the
chain prune
command to trigger this manually. Auto cold GC will happen in another PRAdditional Info
There are a few tricky changes to the splitstore itself
Testing also has some nuanced challenges. The splitstore / itest combined complex relies on the coldstore being the universal blockstore for genesis or any other setup state to be loaded. Coldstore can only be gced if it is backed by a badger blockstore as map blockstores don't implement the BlockstoreGC interface. This means that we need to add an option to itest setup to instantiate a fs repo to get a universal badger blockstore. We don't actually need this if we don't test coldstore gc.
Testing
Checklist
Before you mark the PR ready for review, please make sure that:
<PR type>: <area>: <change being made>
fix: mempool: Introduce a cache for valid signatures
PR type
: fix, feat, INTERFACE BREAKING CHANGE, CONSENSUS BREAKING, build, chore, ci, docs,perf, refactor, revert, style, testarea
: api, chain, state, vm, data transfer, market, mempool, message, block production, multisig, networking, paychan, proving, sealing, wallet, deps