Migration: Use autobatch bs
This commit is contained in:
parent
8190658fe9
commit
66bb149a65
@ -1492,11 +1492,11 @@ func upgradeActorsV9Common(
|
|||||||
root cid.Cid, epoch abi.ChainEpoch, ts *types.TipSet,
|
root cid.Cid, epoch abi.ChainEpoch, ts *types.TipSet,
|
||||||
config nv17.Config,
|
config nv17.Config,
|
||||||
) (cid.Cid, error) {
|
) (cid.Cid, error) {
|
||||||
buf := blockstore.NewTieredBstore(sm.ChainStore().StateBlockstore(), blockstore.NewMemorySync())
|
writeStore := blockstore.NewAutobatch(ctx, sm.ChainStore().StateBlockstore(), units.GiB/4)
|
||||||
store := store.ActorStore(ctx, buf)
|
store := store.ActorStore(ctx, writeStore)
|
||||||
|
|
||||||
// ensure that the manifest is loaded in the blockstore
|
// ensure that the manifest is loaded in the blockstore
|
||||||
if err := bundle.LoadBundles(ctx, buf, actorstypes.Version9); err != nil {
|
if err := bundle.LoadBundles(ctx, sm.ChainStore().StateBlockstore(), actorstypes.Version9); err != nil {
|
||||||
return cid.Undef, xerrors.Errorf("failed to load manifest bundle: %w", err)
|
return cid.Undef, xerrors.Errorf("failed to load manifest bundle: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1535,15 +1535,13 @@ func upgradeActorsV9Common(
|
|||||||
return cid.Undef, xerrors.Errorf("failed to persist new state root: %w", err)
|
return cid.Undef, xerrors.Errorf("failed to persist new state root: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Persist the new tree.
|
// Persists the new tree and shuts down the flush worker
|
||||||
|
if err := writeStore.Flush(ctx); err != nil {
|
||||||
|
return cid.Undef, xerrors.Errorf("writeStore flush failed: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
{
|
if err := writeStore.Shutdown(ctx); err != nil {
|
||||||
from := buf
|
return cid.Undef, xerrors.Errorf("writeStore shutdown failed: %w", err)
|
||||||
to := buf.Read()
|
|
||||||
|
|
||||||
if err := vm.Copy(ctx, from, to, newRoot); err != nil {
|
|
||||||
return cid.Undef, xerrors.Errorf("copying migrated tree: %w", err)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return newRoot, nil
|
return newRoot, nil
|
||||||
|
Loading…
Reference in New Issue
Block a user