I am new to transaction. When I read the book "Transactional Information Systems", it is mentioned that B-tree uses key-range locking to guarantee serializability. Is that true all accesses to the relation must be conducted via the same B-tree to guarantee serializability?
If I understand correctly, there is no way to guarantee serializability if accesses are via different indexes. See the following example.
Suppose there are two indexes on the same relation, namely, a B-tree and a hash index, and there are two transactions.
First, one transaction reads the relation using the hash index, e.g.,
fetchkey(16) to fetch the (currently absent) record with key
16 and find no match. Since hash does not have key-range locking, it cannot lock the next key. Then, the other transaction inserts a record with key '16' via the B-tree. The insertion will be successful, leading to a phantom.