log db size if stage took longer than 1Minute (#1378)

* log db size

* log db size
This commit is contained in:
Alex Sharov 2020-11-30 15:58:06 +07:00 committed by GitHub
parent 9a233da93d
commit ed2b36ff04
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 6 deletions

View File

@ -309,11 +309,11 @@ func (db *LmdbKV) Close() {
} }
func (db *LmdbKV) DiskSize(_ context.Context) (uint64, error) { 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 { 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) { func (db *LmdbKV) Begin(_ context.Context, parent Tx, flags TxFlags) (Tx, error) {

View File

@ -269,11 +269,11 @@ func (db *MdbxKV) NewDbWithTheSameParameters() *ObjectDatabase {
} }
func (db *MdbxKV) DiskSize(_ context.Context) (uint64, error) { 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 { 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) { func (db *MdbxKV) Begin(_ context.Context, parent Tx, flags TxFlags) (Tx, error) {