Subject Re: [Firebird-Architect] Bi-directional indexes
Author Ann W. Harrison
Dmitry Yemanov wrote:
> The backward reader keeps a read lock on page 125, then:
> 1) tries a no wait handoff to the left sibling page
> 2) if successful, we're done


> 3) otherwise, refetch the current page (125) for write

Did you really mean refetch? If so, you've got no idea what you'll find
on the page when you refetch it. If you meant to convert the lock
you've maintained on 123, what if the conversion fails?

> 4) mark it with btr_dont_gc and release
> 5) fetch the left sibling page
> 6) handoff right sibling pointers until the remembered page (125) is found

That algorithm fails in the case that the left sibling page has been
combined with the next one to its left. In that case, you can read the
left sibling and find a TIP, data page, or a different part of the same
index. Starting again with a remembered key and record number works better.