facebook / rocksdb

A library that provides an embeddable, persistent key-value store for fast storage.
http://rocksdb.org
GNU General Public License v2.0
27.85k stars 6.2k forks source link

Fix manual flush hanging on waiting for no stall for UDT in memtable … #12771

Closed jowlyzhang closed 3 weeks ago

jowlyzhang commented 3 weeks ago

This PR fix a possible manual flush hanging scenario because of its expectation that others will clear out excessive memtables was not met. The root cause is the FlushRequest rescheduling logic is using a stricter criteria for what a write stall is about to happen means than WaitUntilFlushWouldNotStallWrites does. Currently, the former thinks a write stall is about to happen when the last memtable is half full, and it will instead reschedule queued FlushRequest and not actually proceed with the flush. While the latter thinks if we already start to use the last memtable, we should wait until some other background flush jobs clear out some memtables before proceed this manual flush.

If we make them use the same criteria, we can guarantee that at any time whenWaitUntilFlushWouldNotStallWrites is waiting, it's not because the rescheduling logic is holding it back.

Test plan: Added unit test

jowlyzhang commented 3 weeks ago

@ajkr Thank you for the quick review!

facebook-github-bot commented 3 weeks ago

@jowlyzhang has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

facebook-github-bot commented 3 weeks ago

@jowlyzhang merged this pull request in facebook/rocksdb@f5e44f34904d78d1f649452dc19ef3b36b94ea9d.