From ed2b36ff045da97a654ef39de62c5abbdcbc5f47 Mon Sep 17 00:00:00 2001 From: Alex Sharov Date: Mon, 30 Nov 2020 15:58:06 +0700 Subject: [PATCH] log db size if stage took longer than 1Minute (#1378) * log db size * log db size --- ethdb/kv_lmdb.go | 6 +++--- ethdb/kv_mdbx.go | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/ethdb/kv_lmdb.go b/ethdb/kv_lmdb.go index d0038e964..3eb11c17d 100644 --- a/ethdb/kv_lmdb.go +++ b/ethdb/kv_lmdb.go @@ -309,11 +309,11 @@ func (db *LmdbKV) Close() { } func (db *LmdbKV) DiskSize(_ context.Context) (uint64, error) { - stats, err := db.env.Stat() + fileInfo, err := os.Stat(path.Join(db.opts.path, "data.mdb")) if err != nil { - return 0, fmt.Errorf("could not read database size: %w", err) + return 0, err } - return uint64(stats.PSize) * (stats.LeafPages + stats.BranchPages + stats.OverflowPages), nil + return uint64(fileInfo.Size()), nil } func (db *LmdbKV) Begin(_ context.Context, parent Tx, flags TxFlags) (Tx, error) { diff --git a/ethdb/kv_mdbx.go b/ethdb/kv_mdbx.go index 6e5f211f2..973666a85 100644 --- a/ethdb/kv_mdbx.go +++ b/ethdb/kv_mdbx.go @@ -269,11 +269,11 @@ func (db *MdbxKV) NewDbWithTheSameParameters() *ObjectDatabase { } func (db *MdbxKV) DiskSize(_ context.Context) (uint64, error) { - stats, err := db.env.Stat() + fileInfo, err := os.Stat(path.Join(db.opts.path, "mdbx.dat")) if err != nil { - return 0, fmt.Errorf("could not read database size: %w", err) + return 0, err } - return uint64(stats.PSize) * (stats.LeafPages + stats.BranchPages + stats.OverflowPages), nil + return uint64(fileInfo.Size()), nil } func (db *MdbxKV) Begin(_ context.Context, parent Tx, flags TxFlags) (Tx, error) {