Skip to content

Commit

Permalink
vendor, ethdb: print warning log if leveldb is performing compaction (e…
Browse files Browse the repository at this point in the history
…thereum#16766)

* vendor: update leveldb package

* ethdb: print warning log if db is performing compaction

* ethdb: update annotation and log
  • Loading branch information
rjl493456442 authored and firmianavan committed May 30, 2018
1 parent d58a149 commit 9381fef
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 5 deletions.
12 changes: 11 additions & 1 deletion ethdb/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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.
Expand Down
73 changes: 72 additions & 1 deletion vendor/github.com/syndtr/goleveldb/leveldb/db.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions vendor/github.com/syndtr/goleveldb/leveldb/db_write.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions vendor/vendor.json
Original file line number Diff line number Diff line change
Expand Up @@ -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=",
Expand Down

0 comments on commit 9381fef

Please sign in to comment.