In general, a BuddyLocker can be used whenever the primary (API) locker is in use, and we need to lock a node and release that lock before the primary locker transaction ends. In other words, for this particular lock we don't want to use two-phase locking. To accomplish that we use a separate BuddyLocker instance to hold the lock, while sharing locks with the primary locker. The BuddyLocker can be closed to release this particular lock, without releasing the other locks held by the primary locker.
In particular, a BuddyLocker is used when acquiring a RANGE_INSERT lock. RANGE_INSERT only needs to be held until the point we have inserted the new node into the BIN. A separate locker is therefore used so we can release that lock separately when the insertion into the BIN is complete. But the RANGE_INSERT lock must not conflict with locks held by the primary locker. So a BuddyLocker is used that shares locks with the primary locker.
|
|
|
|