In the current implementation of __curhs_prev_visible(), we keep iterating backwards to find a record that is visible. We continue doing even when we hit an update that has globally visible tombstone. This is problematic for two reasons:
- If we hit an update that has globally visible tombstone, we will not be able to see any update for the key before that. Therefore, we are wasting effort by continuing to iterate (this is evident from BF-20400).
- We can potentially reading updates that are older than oldest timestamp. Any updates that are older than timestamps can be freed and result in cursor iteration to read a record that is not valid anymore (which can explain BF-20391).
The aim of this ticket is to review and fix __curhs_prev_visible() and run MongoDB patch tests to verify the solution.