Subject Re: [Firebird-Architect] Bi-directional indexes
Author Geoff Worboys
> A handoff is an atomic move from one page to another. The
> currently fetched page is released only after the next page
> is fetched successfully. Two handoffs 1->2 and 2->1 deadlock,
> because there can be only one lock holder of the given page.

Thanks Dmitry.

So what we get is:
A has 1 and is waiting on 2
B has 2 and is waiting on 1

Neither can give up what they have until they get what they
want - since they do not know what may happen between the
releaes and the acquire. There are inherently only two lock
owners involved here (since there are only two pages with one
lock each to give).

It strikes me that this could be a detectable condition, and
if you can detect it then perhaps the solution could be to
"swap" the lock ownership.

B finds that A has what it wants, and that it has what
A wants, so they do a swap of the lock ownership without
actually releasing the locks.

This assumes that A has totally finished with 1 and that B
has totally finished with 2 and so neither need their locks
on those pages for any other purpose.

It is probably obvious that I am not familiar with the code,
so I do not know if lock ownership can actually be swapped.
Just a thought.

There is also the question of what happens if A has a write
lock and B has a read lock (or vise-versa).

--
Geoff Worboys
Telesis Computing