mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-29 07:07:16 +00:00
Expose Reset (#558)
* exposed Reset() * exposed Reset() * unimplemented commit * complete reset * complete reset * complete reset * better reset * finished Reset * fixed memory mutation Co-authored-by: giuliorebuffo <giuliorebuffo@system76-pc.localdomain>
This commit is contained in:
parent
fadc9b21d1
commit
5d7fb4ddb0
@ -264,6 +264,7 @@ type RwTx interface {
|
|||||||
// CollectMetrics - does collect all DB-related and Tx-related metrics
|
// CollectMetrics - does collect all DB-related and Tx-related metrics
|
||||||
// this method exists only in RwTx to avoid concurrency
|
// this method exists only in RwTx to avoid concurrency
|
||||||
CollectMetrics()
|
CollectMetrics()
|
||||||
|
Reset() error
|
||||||
}
|
}
|
||||||
|
|
||||||
// BucketMigrator used for buckets migration, don't use it in usual app code
|
// BucketMigrator used for buckets migration, don't use it in usual app code
|
||||||
|
@ -1046,6 +1046,28 @@ func (tx *MdbxTx) DBSize() (uint64, error) {
|
|||||||
return info.Geo.Current, err
|
return info.Geo.Current, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (tx *MdbxTx) Reset() (err error) {
|
||||||
|
tx.Rollback()
|
||||||
|
//tx.printDebugInfo()
|
||||||
|
if tx.db.closed.Load() {
|
||||||
|
return fmt.Errorf("db closed")
|
||||||
|
}
|
||||||
|
runtime.LockOSThread()
|
||||||
|
defer func() {
|
||||||
|
if err == nil {
|
||||||
|
tx.db.wg.Add(1)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
tx.tx, err = tx.db.env.BeginTxn(nil, 0)
|
||||||
|
if err != nil {
|
||||||
|
runtime.UnlockOSThread() // unlock only in case of error. normal flow is "defer .Rollback()"
|
||||||
|
return fmt.Errorf("%w, lable: %s, trace: %s", err, tx.db.opts.label.String(), stack2.Trace().String())
|
||||||
|
}
|
||||||
|
tx.tx.RawRead = true
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func (tx *MdbxTx) RwCursor(bucket string) (kv.RwCursor, error) {
|
func (tx *MdbxTx) RwCursor(bucket string) (kv.RwCursor, error) {
|
||||||
b := tx.db.buckets[bucket]
|
b := tx.db.buckets[bucket]
|
||||||
if b.AutoDupSortKeysConversion {
|
if b.AutoDupSortKeysConversion {
|
||||||
|
@ -374,7 +374,10 @@ func (m *MemoryMutation) Cursor(bucket string) (kv.Cursor, error) {
|
|||||||
return m.makeCursor(bucket)
|
return m.makeCursor(bucket)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ViewID creates a new cursor (the real fun begins here)
|
|
||||||
func (m *MemoryMutation) ViewID() uint64 {
|
func (m *MemoryMutation) ViewID() uint64 {
|
||||||
panic("ViewID Not implemented")
|
panic("ViewID Not implemented")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m *MemoryMutation) Reset() error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user