greptimedb icon indicating copy to clipboard operation
greptimedb copied to clipboard

Manually flush trigger

Open waynexia opened this issue 2 years ago • 2 comments

Current the flush will only be scheduled when memory threshold reached. It's a completely internal operation. This ticket request an external public interface to force flush a table or a region.

The requested API is helpful when

  • Testing behaviors related to flush
  • Scheduling a table (close in one instance and open in another one)

waynexia avatar Nov 07 '22 06:11 waynexia

@waynexia I dig around, found this function: https://github.com/GreptimeTeam/greptimedb/blob/57979c9d3dba13beef5d63b4dc73fa1b3281e7e6/src/storage/src/flush.rs#L37

Should we add a new FlushStrategy like EventBasedStrategy which holding a channel receiver be good? And this strategy also can be composed with SizeBasedStragety.

SSebo avatar Nov 16 '22 02:11 SSebo

Glad you are interested!

found this function

Yes, in the write process we will check should_flush every time before writing. This is an async way to implement (if no write request then the flush event won't be executed neither). And I'm also wondering to exposing an active (sync) interface on RegionWriter to perform flush without depends on write request. Both active and passive manners are useful.

But consider the maybe use-case of the passive way, looks like FlushSwitch is able to cover the unit-test scenario. If we have EventBasedStrategy in the non-test path, a problem is where to put the tx of this strategy? So in my perspective we should implement the active way first.

waynexia avatar Nov 16 '22 06:11 waynexia

Done in #1184

evenyag avatar Apr 25 '23 07:04 evenyag