v1.6 : upon restart after crash 100% cpu is being used
This is related to issue #908
What version of Go are you using (go version)?
$ go version go version go1.12.4 darwin/amd64
What version of Badger are you using?
1.6
Does this issue reproduce with the latest master?
yes
What are the hardware specifications of the machine (RAM, OS, Disk)?
MacBook Pro (13-inch, 2016, Four Thunderbolt 3 Ports) 2.9 GHz Intel Core i5 16 GB 2133 MHz LPDDR3 500 GB Flash Storage
What did you do?
I have a test program in github.com/dwoske/btest which opens a managed db, sets a couple of keys using CommitAt - reads the keys using NewTransactionAt, then starts and http listener.
When looking at CPU usage, I can get the process to peg at over 100% after a few program executions without closing the db.
The first time stopping the program without a database close (via the /stop handler in the program) the cpu pegged for about 30 seconds and dropped to normal, I ran it again without cleaning my badger directory, it pegged for what seemed a little longer - but cpu still dropped down to normal (at this point I was thinking 1.6 was fine), the third time I started the cpu pegged and didn't drop after about 5 minutes, and I stopped the program - this run is the profile currently in my repo (commit 430f0db977e292eac972ba1724f1fab905f9f641)
Issue #908 was in regards to current master, and with the results of this test, I think the problem exists (for me) in 1.6 as well.
What did you expect to see?
cpu usage for the process dropping down to very low level (just the http listener going)
What did you see instead?
cpu usage pegged at over 100% and this in the pprof
This happened on my third cycle of starting the process and hitting the localhost:9999/stop endpoint to write the profile, and stop the process, without closing the db.
(pprof) text
Showing nodes accounting for 432.46s, 99.94% of 432.74s total
Dropped 41 nodes (cum <= 2.16s)
flat flat% sum% cum cum%
201.40s 46.54% 46.54% 432.46s 99.94% github.com/dgraph-io/badger/y.(*WaterMark).process.func1
119.10s 27.52% 74.06% 128.20s 29.63% runtime.mapaccess1_fast64
90.75s 20.97% 95.03% 102.86s 23.77% runtime.mapdelete_fast64
21.21s 4.90% 99.94% 21.21s 4.90% runtime.newstack
0 0% 99.94% 432.46s 99.94% github.com/dgraph-io/badger/y.(*WaterMark).process
(pprof) quit
I will try and test this using a different Mac and comment on the issue again with the results, perhaps something in my current laptop configuration contributes to the problem.
Thanks for the report
Indeed, this looks like a duplicate of #908, so I'll close this one and we'll make sure we fix this ASAP.