mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2025-01-18 08:38:46 +00:00
mdbx: add trace info to open error (#2305)
* add stack info to open error * add stack info to open error
This commit is contained in:
parent
a68b5ba361
commit
ea5abbe0b5
@ -169,7 +169,7 @@ func (opts MdbxOpts) Open() (ethdb.RwKV, error) {
|
||||
|
||||
err = env.Open(opts.path, opts.flags, 0664)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("%w, path: %s", err, opts.path)
|
||||
return nil, fmt.Errorf("%w, label: %s, trace: %s", err, opts.label.String(), debug.Callers(10))
|
||||
}
|
||||
|
||||
defaultDirtyPagesLimit, err := env.GetOption(mdbx.OptTxnDpLimit)
|
||||
@ -327,7 +327,7 @@ func (db *MdbxKV) Close() {
|
||||
db.log.Warn("failed to remove in-mem db file", "err", err)
|
||||
}
|
||||
} else {
|
||||
db.log.Info("database closed (MDBX)")
|
||||
db.log.Info("database closed (MDBX)", "label", db.opts.label.String(), "exclusive", db.opts.flags&mdbx.Exclusive != 0)
|
||||
}
|
||||
}
|
||||
|
||||
@ -343,7 +343,7 @@ func (db *MdbxKV) BeginRo(_ context.Context) (txn ethdb.Tx, err error) {
|
||||
|
||||
tx, err := db.env.BeginTxn(nil, mdbx.Readonly)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("%w, trace: %s", err, debug.Callers(10))
|
||||
return nil, fmt.Errorf("%w, label: %s, trace: %s", err, db.opts.label.String(), debug.Callers(10))
|
||||
}
|
||||
tx.RawRead = true
|
||||
return &MdbxTx{
|
||||
@ -367,7 +367,7 @@ func (db *MdbxKV) BeginRw(_ context.Context) (txn ethdb.RwTx, err error) {
|
||||
tx, err := db.env.BeginTxn(nil, 0)
|
||||
if err != nil {
|
||||
runtime.UnlockOSThread() // unlock only in case of error. normal flow is "defer .Rollback()"
|
||||
return nil, fmt.Errorf("%w, trace: %s", err, debug.Callers(10))
|
||||
return nil, fmt.Errorf("%w, lable: %s, trace: %s", err, db.opts.label.String(), debug.Callers(10))
|
||||
}
|
||||
tx.RawRead = true
|
||||
return &MdbxTx{
|
||||
|
@ -72,6 +72,19 @@ const (
|
||||
Sentry Label = 2
|
||||
)
|
||||
|
||||
func (l Label) String() string {
|
||||
switch l {
|
||||
case Chain:
|
||||
return "chaindata"
|
||||
case TxPool:
|
||||
return "txpool"
|
||||
case Sentry:
|
||||
return "sentry"
|
||||
default:
|
||||
return "unknown"
|
||||
}
|
||||
}
|
||||
|
||||
type Has interface {
|
||||
// Has indicates whether a key exists in the database.
|
||||
Has(bucket string, key []byte) (bool, error)
|
||||
|
Loading…
Reference in New Issue
Block a user