Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ethdb: print warning log if leveldb is performing compaction #16766

Merged
merged 3 commits into from
May 22, 2018
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 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,15 @@ func (db *LDBDatabase) meter(refresh time.Duration) {
lastWriteDelay = time.Now()
}
}
// If leveldb's compaction has been going on for a long time, print a warning log here.
// If a warning that db is performing compaction has been displayed,
// any subsequent warnings will be withhold for 1 minute to don't overwhelm the user.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor grammar:

// 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 is performing the compaction, all write operations will be paused")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd go with a shorter warning so it looks tidy among the other logs.

db.log.Warn("Database compacting, degraded performance")

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eqzip Hey, when geth receives a CTRL+C signal, it will try to exit.
Unfortunately, your local node is performance a chain insert operation, while the db write operation is stuck by level db compaction. So geth will wait the chain insert operation and then exit gratefully.

So that is the reason why your geth node still prints warning log.

But I got to think that if I use Ctrl-c to exit then it should at least stop printing , it need a signal or context implementation when loop blocked .

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it may like sth in loop:
// to make a signal listen
select {
case <- printSignal:
log.Warn("xxx")
case <- quitSignal:
return
}

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