Skip to content
Snippets Groups Projects
  • Dmitry Rodionov's avatar
    a6dc7e99
    refactor: split reenterable_schema_change_request · a6dc7e99
    Dmitry Rodionov authored and Yaroslav Dynnikov's avatar Yaroslav Dynnikov committed
    Previously function was ~700 loc. The patch splits out the logic of
    conversion from ir node to operation. Previously there were two stages,
    initial validation that constructed intermediate structure and then
    intermediate structure was transformed into Op potentially several times
    in case of retries. The patch removes intermediate conversion by
    direct mapping from ir node to op. It makes reading more convenient
    since there is no need to jump back and forth between initial checks and
    actual Op construction. Another benefit is that some checks need to be
    repeated on each retry since retries originate from conflicts and
    conflicts change system state. So in newer state operation may no longer
    make sense. By coupling both operations together there is no way a check
    can be missed in the retry phase.
    
    We still do some cloning here and there. We can probably improve on that
    by constructing Op once and then adjusting it in place for conflicts but
    since retries should be rare in practice it shouldnt be a problem.
    
    Additionally we do a lot of conversion between SmolStr and String. We
    need to use SmolStr in more placese inside picodata so we dont need to
    do that.
    a6dc7e99
    History
    refactor: split reenterable_schema_change_request
    Dmitry Rodionov authored and Yaroslav Dynnikov's avatar Yaroslav Dynnikov committed
    Previously function was ~700 loc. The patch splits out the logic of
    conversion from ir node to operation. Previously there were two stages,
    initial validation that constructed intermediate structure and then
    intermediate structure was transformed into Op potentially several times
    in case of retries. The patch removes intermediate conversion by
    direct mapping from ir node to op. It makes reading more convenient
    since there is no need to jump back and forth between initial checks and
    actual Op construction. Another benefit is that some checks need to be
    repeated on each retry since retries originate from conflicts and
    conflicts change system state. So in newer state operation may no longer
    make sense. By coupling both operations together there is no way a check
    can be missed in the retry phase.
    
    We still do some cloning here and there. We can probably improve on that
    by constructing Op once and then adjusting it in place for conflicts but
    since retries should be rare in practice it shouldnt be a problem.
    
    Additionally we do a lot of conversion between SmolStr and String. We
    need to use SmolStr in more placese inside picodata so we dont need to
    do that.