mdbx_to_mdbx: clean table before load

This commit is contained in:
alex.sharov 2022-12-24 21:55:35 +07:00
parent bf8c916afe
commit 82b8455635

View File

@ -413,7 +413,7 @@ func mdbxToMdbx(ctx context.Context, logger log.Logger, from, to string) error {
src := mdbx2.NewMDBX(logger).Path(from).Flags(func(flags uint) uint { return mdbx.Readonly | mdbx.Accede }).MustOpen()
dst := mdbx2.NewMDBX(logger).Path(to).
WriteMap().
Flags(func(flags uint) uint { return flags | mdbx.NoMemInit | mdbx.WriteMap }).
Flags(func(flags uint) uint { return flags | mdbx.NoMemInit | mdbx.WriteMap | mdbx.Accede }).
MustOpen()
return kv2kv(ctx, src, dst)
}
@ -430,7 +430,7 @@ func kv2kv(ctx context.Context, src, dst kv.RwDB) error {
}
defer dstTx.Rollback()
commitEvery := time.NewTicker(30 * time.Second)
commitEvery := time.NewTicker(5 * time.Minute)
defer commitEvery.Stop()
var total uint64
@ -440,6 +440,7 @@ func kv2kv(ctx context.Context, src, dst kv.RwDB) error {
}
rawdbreset.WarmupTable(ctx, src, name)
_ = dstTx.ClearBucket(name)
c, err := dstTx.RwCursor(name)
if err != nil {
return err