• debing.sun's avatar
    Prevent LSET command from causing quicklist plain node size to exceed 4GB (#12955) · 1f00c951
    debing.sun authored
    Fix #12864
    
    The main reason for this crash is that when replacing a element of a
    quicklist packed node with lpReplace() method,
    if the final size is larger than 4GB, lpReplace() will fail and returns
    NULL, causing `node->entry` to be incorrectly set to NULL.
    
    Since the inserted data is not a large element, we can't just replace it
    like a large element, first quicklistInsertAfter()
    and then quicklistDelIndex(), because the current node may be merged and
    invalidated in quicklistInsertAfter().
    
    The solution of this PR:
    When replacing a node fails (listpack exceeds 4GB), split the current
    node, create a new node to put in the middle, and try to merge them.
    This is the same as inserting a large element.
    In the worst case, its size will not exceed 4GB.
    1f00c951
quicklist.c 124 KB