mirror of https://github.com/status-im/op-geth.git
vendor, ethdb: print warning log if leveldb is performing compaction (#16766)
* vendor: update leveldb package * ethdb: print warning log if db is performing compaction * ethdb: update annotation and log
This commit is contained in:
parent
9af364e42b
commit
6ce21a4744
|
@ -207,6 +207,7 @@ func (db *LDBDatabase) meter(refresh time.Duration) {
|
|||
delaystats [2]int64
|
||||
lastWriteDelay time.Time
|
||||
lastWriteDelayN time.Time
|
||||
lastWritePaused time.Time
|
||||
)
|
||||
|
||||
// Iterate ad infinitum and collect the stats
|
||||
|
@ -267,8 +268,9 @@ func (db *LDBDatabase) meter(refresh time.Duration) {
|
|||
delayN int64
|
||||
delayDuration string
|
||||
duration time.Duration
|
||||
paused bool
|
||||
)
|
||||
if n, err := fmt.Sscanf(writedelay, "DelayN:%d Delay:%s", &delayN, &delayDuration); n != 2 || err != nil {
|
||||
if n, err := fmt.Sscanf(writedelay, "DelayN:%d Delay:%s Paused:%t", &delayN, &delayDuration, &paused); n != 3 || err != nil {
|
||||
db.log.Error("Write delay statistic not found")
|
||||
return
|
||||
}
|
||||
|
@ -301,6 +303,14 @@ func (db *LDBDatabase) meter(refresh time.Duration) {
|
|||
lastWriteDelay = time.Now()
|
||||
}
|
||||
}
|
||||
// If a warning that db is performing compaction has been displayed, any subsequent
|
||||
// warnings will be withheld for one minute not to overwhelm the user.
|
||||
if paused && delayN-delaystats[0] == 0 && duration.Nanoseconds()-delaystats[1] == 0 &&
|
||||
time.Now().After(lastWritePaused.Add(writeDelayWarningThrottler)) {
|
||||
db.log.Warn("Database compacting, degraded performance")
|
||||
lastWritePaused = time.Now()
|
||||
}
|
||||
|
||||
delaystats[0], delaystats[1] = delayN, duration.Nanoseconds()
|
||||
|
||||
// Retrieve the database iostats.
|
||||
|
|
|
@ -35,6 +35,7 @@ type DB struct {
|
|||
// Stats. Need 64-bit alignment.
|
||||
cWriteDelay int64 // The cumulative duration of write delays
|
||||
cWriteDelayN int32 // The cumulative number of write delays
|
||||
inWritePaused int32 // The indicator whether write operation is paused by compaction
|
||||
aliveSnaps, aliveIters int32
|
||||
|
||||
// Session.
|
||||
|
@ -967,7 +968,8 @@ func (db *DB) GetProperty(name string) (value string, err error) {
|
|||
float64(db.s.stor.writes())/1048576.0)
|
||||
case p == "writedelay":
|
||||
writeDelayN, writeDelay := atomic.LoadInt32(&db.cWriteDelayN), time.Duration(atomic.LoadInt64(&db.cWriteDelay))
|
||||
value = fmt.Sprintf("DelayN:%d Delay:%s", writeDelayN, writeDelay)
|
||||
paused := atomic.LoadInt32(&db.inWritePaused) == 1
|
||||
value = fmt.Sprintf("DelayN:%d Delay:%s Paused:%t", writeDelayN, writeDelay, paused)
|
||||
case p == "sstables":
|
||||
for level, tables := range v.levels {
|
||||
value += fmt.Sprintf("--- level %d ---\n", level)
|
||||
|
@ -996,6 +998,75 @@ func (db *DB) GetProperty(name string) (value string, err error) {
|
|||
return
|
||||
}
|
||||
|
||||
// DBStats is database statistics.
|
||||
type DBStats struct {
|
||||
WriteDelayCount int32
|
||||
WriteDelayDuration time.Duration
|
||||
WritePaused bool
|
||||
|
||||
AliveSnapshots int32
|
||||
AliveIterators int32
|
||||
|
||||
IOWrite uint64
|
||||
IORead uint64
|
||||
|
||||
BlockCacheSize int
|
||||
OpenedTablesCount int
|
||||
|
||||
LevelSizes []int64
|
||||
LevelTablesCounts []int
|
||||
LevelRead []int64
|
||||
LevelWrite []int64
|
||||
LevelDurations []time.Duration
|
||||
}
|
||||
|
||||
// Stats populates s with database statistics.
|
||||
func (db *DB) Stats(s *DBStats) error {
|
||||
err := db.ok()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
s.IORead = db.s.stor.reads()
|
||||
s.IOWrite = db.s.stor.writes()
|
||||
s.WriteDelayCount = atomic.LoadInt32(&db.cWriteDelayN)
|
||||
s.WriteDelayDuration = time.Duration(atomic.LoadInt64(&db.cWriteDelay))
|
||||
s.WritePaused = atomic.LoadInt32(&db.inWritePaused) == 1
|
||||
|
||||
s.OpenedTablesCount = db.s.tops.cache.Size()
|
||||
if db.s.tops.bcache != nil {
|
||||
s.BlockCacheSize = db.s.tops.bcache.Size()
|
||||
} else {
|
||||
s.BlockCacheSize = 0
|
||||
}
|
||||
|
||||
s.AliveIterators = atomic.LoadInt32(&db.aliveIters)
|
||||
s.AliveSnapshots = atomic.LoadInt32(&db.aliveSnaps)
|
||||
|
||||
s.LevelDurations = s.LevelDurations[:0]
|
||||
s.LevelRead = s.LevelRead[:0]
|
||||
s.LevelWrite = s.LevelWrite[:0]
|
||||
s.LevelSizes = s.LevelSizes[:0]
|
||||
s.LevelTablesCounts = s.LevelTablesCounts[:0]
|
||||
|
||||
v := db.s.version()
|
||||
defer v.release()
|
||||
|
||||
for level, tables := range v.levels {
|
||||
duration, read, write := db.compStats.getStat(level)
|
||||
if len(tables) == 0 && duration == 0 {
|
||||
continue
|
||||
}
|
||||
s.LevelDurations = append(s.LevelDurations, duration)
|
||||
s.LevelRead = append(s.LevelRead, read)
|
||||
s.LevelWrite = append(s.LevelWrite, write)
|
||||
s.LevelSizes = append(s.LevelSizes, tables.size())
|
||||
s.LevelTablesCounts = append(s.LevelTablesCounts, len(tables))
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// SizeOf calculates approximate sizes of the given key ranges.
|
||||
// The length of the returned sizes are equal with the length of the given
|
||||
// ranges. The returned sizes measure storage space usage, so if the user
|
||||
|
|
|
@ -89,7 +89,11 @@ func (db *DB) flush(n int) (mdb *memDB, mdbFree int, err error) {
|
|||
return false
|
||||
case tLen >= pauseTrigger:
|
||||
delayed = true
|
||||
// Set the write paused flag explicitly.
|
||||
atomic.StoreInt32(&db.inWritePaused, 1)
|
||||
err = db.compTriggerWait(db.tcompCmdC)
|
||||
// Unset the write paused flag.
|
||||
atomic.StoreInt32(&db.inWritePaused, 0)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
|
|
|
@ -418,10 +418,10 @@
|
|||
"revisionTime": "2017-07-05T02:17:15Z"
|
||||
},
|
||||
{
|
||||
"checksumSHA1": "k13cCuMJO7+KhR8ZXx5oUqDKGQA=",
|
||||
"checksumSHA1": "TJV50D0q8E3vtc90ibC+qOYdjrw=",
|
||||
"path": "github.com/syndtr/goleveldb/leveldb",
|
||||
"revision": "ae970a0732be3a1f5311da86118d37b9f4bd2a5a",
|
||||
"revisionTime": "2018-05-02T07:23:49Z"
|
||||
"revision": "59047f74db0d042c8d8dd8e30bb030bc774a7d7a",
|
||||
"revisionTime": "2018-05-21T04:45:49Z"
|
||||
},
|
||||
{
|
||||
"checksumSHA1": "EKIow7XkgNdWvR/982ffIZxKG8Y=",
|
||||
|
|
Loading…
Reference in New Issue