• Kristian Nielsen's avatar
    Fix a potential lost wakeup for binlog_commit_wait_usec · 09bfaf3a
    Kristian Nielsen authored
    If a transaction T1 needs to wait for a transaction T2, T2's commit will
    skip the normal binlog_commit_wait_usec delay, in order not to needlessly
    stall throughput.
    
    This works by checking if T2 is already ready to commit. If so, it is woken
    up. If not, we set a flag in T2 so that when it gets ready to commit, it
    will do so immediately.
    
    But there was a potential race due to insufficient locking, if T2 gets ready
    to commit just at the point where T1 does the check. If the race hits, the
    wakeup (and early commit) of T2 might be lost.
    
    The race is only theoretical (from code inspection, no known test case), but
    seems best to fix it anyway, by properly locking LOCK_prepare_ordered around
    the check.
    09bfaf3a
log.cc 292 KB