Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG FIX] FAIR algorithm #4

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Conversation

SeKwonLee
Copy link

@SeKwonLee SeKwonLee commented Mar 1, 2019

Problem)

We found FAIR algorithm proposed in FAST'18 has a problem in correctly handling node splits to be concurrent and crash-recoverable. Original FAIR algorithm proposed blink-tree like scheme to overcome the intermediate states of B+tree's node split by adding additional next sibling pointers to each level. However, only with it, we cannot correctly address every case caused by node split operation.

In case of internal node split, the middle key is not moved to right sibling node, but only added to parent node. Therefore, when write thread A concurrently try to insert its split key to the internal node where write thread B is splitting, write thread A can insert it to an incorrect node. Please refer to below Example 1 for more detail.

Example 1)
Original internal node: (1, 5, 9, 15)
Writer A: inserting 10
Writer B: inserting 20 and handling split
==========================================             =====================
                Writer B                                     Writer A
                                (9)                             (9)
                              /    \                          /     \
(1, 5, 9, 15) ---------> (1, 5)-->(15, 20) --------->  (1, 5, 10)-->(15, 20)

Differently from internal node split, leaf node split moves the middle key not only to parent node, but also to newly allocated right sibling node. However, as this middle key can be deleted by "remove" operation, a concurrent writer thread can insert a new key into wrong node. Please refer to Example 2 for more detail.

Example 2)
Original leaf node: (1, 5, 9, 15)
Writer A: inserting 10 (waiting for writer B to finish split before acquire the lock of original leaf node)
Writer B: inserting 20 and handling split
Remover : deleting 9
==========================================           =================          =====================
                Writer B                                 Remover                        Writer A
                                (9)                         (9)                           (9)
                              /    \                      /    \                        /     \
(1, 5, 9, 15) -------> (1, 5)-->(9, 15, 20) -------> (1, 5)-->(15, 20) -------> (1, 5, 10)-->(15, 20)

Solution)

We have added High key (middle key) to newly allocated right sibling node when internal node split occurs. This idea was originally proposed by Sang Kyun Cha, et al. [1].

[1] Cha, Sang Kyun, Sangyong Hwang, Kihong Kim, and Keunjoo Kwon. "Cache-conscious concurrency control of main-memory indexes on shared-memory multiprocessor systems." In VLDB, vol. 1, pp. 181-190. 2001.

Current additional implementation for fixing FAIR bug is only reflected
to insertion and search operations. Please change other code sections
for other operations, such as remove and scan.
@SeKwonLee SeKwonLee mentioned this pull request Mar 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant