fix(core): the behavior of some dump policies is wrong
Description
The behavior of some dump policies is wrong:
- Always Dump policy doesn't dump when a buffer is reallocated. (It might be because BufferManager::restoreBuffer is called after AlwaysDump::apply).
- Barrier Dump policy crashes with a failed assertion when a buffer is reallocated. (It might be because the reallocation is counted twice: the first in BarrierDump::reallocateSuccess and the second in BarrierDump::restoreSuccess, because to reallocate a buffer implies to restore it).
- When using ValveDump with min_free_mem = 2 bytes and hysteresis_offset = 1 byte, when allocating three buffers of 1 byte and the free system memory is 2 bytes, then only one buffer is evicted, though two buffers should be evicted (one for minimum memory and another one for the hysteresis offset). (As a side note, if hysteresis_offset is 0, the no buffer is dumped. It might be because ValveDump::needDump returns true, but ValveDump::dump is effectively called with 0 byte).
- When using ValveDump with the same parameter as above, when reallocating a buffer and crossing the minimal free memory, no buffer is dumped, though at least one should. (It might be related to the problem above).
Steps to reproduce
Check the BufferManagerTest::dumpPolicyTest test added in !695 (merged).
Proposal
Optional section to give some functional or technical hints
Functional specifications
If there is any change to the workflow, UX/UI design, screenshots, etc..., please describe it here
Technical specifications
Details of the implementation of the fix
Test plan
Describe how you will verify that the implementation fulfils the specifications