-
Notifications
You must be signed in to change notification settings - Fork 20.2k
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
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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,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. | ||
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") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
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 . There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it may like sth in loop: |
||
lastWritePaused = time.Now() | ||
} | ||
|
||
delaystats[0], delaystats[1] = delayN, duration.Nanoseconds() | ||
|
||
// Retrieve the database iostats. | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor grammar: