From 6ce21a4744461fc35c05b1c5fcc92136761be747 Mon Sep 17 00:00:00 2001 From: gary rong Date: Tue, 22 May 2018 16:12:52 +0800 Subject: 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 --- ethdb/database.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'ethdb') diff --git a/ethdb/database.go b/ethdb/database.go index 001d8f0bb..86dd21076 100644 --- a/ethdb/database.go +++ b/ethdb/database.go @@ -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. -- cgit