• Andrei Elkin's avatar
    MDEV-16372 ER_BASE64_DECODE_ERROR upon replaying binary log via mysqlbinlog --verbose · feac078f
    Andrei Elkin authored
    (This commit is exclusively for 10.1 branch, do not merge it to upper ones)
    
    In case of a pattern of non-STMT_END-marked Rows-log-event (A) followed by
    a STMT_END marked one (B) mysqlbinlog mixes up the base64 encoded rows events
    with their pseudo sql representation produced by the verbose option:
          BINLOG '
            base64 encoded data for A
            ### verbose section for A
            base64 encoded data for B
            ### verbose section for B
          '/*!*/;
    In effect the produced BINLOG '...' query is not valid and is rejected with the error.
    Examples of this way malformed BINLOG could have been found in binlog_row_annotate.result
    that gets corrected with the patch.
    
    The issue is fixed with introduction an auxiliary IO_CACHE to hold on the verbose
    comments until the terminal STMT_END event is found. The new cache is emptied
    out after two pre-existing ones are done at that time.
    The correctly produced output now for the above case is as the following:
          BINLOG '
            base64 encoded data for A
            base64 encoded data for B
          '/*!*/;
            ### verbose section for A
            ### verbose section for B
    
    Thanks to Alexey Midenkov for the problem recognition and attempt to tackle,
    Venkatesh Duggirala who produced a patch for the upstream whose
    idea is exploited here, as well as to MDEV-23077 reporter LukeXwang who
    also contributed a piece of a patch aiming at this issue.
    
    Extra: mysqlbinlog_row_minimal refined to not produce mutable numeric values into the result file.
    feac078f
mysqlbinlog_row_minimal.result 13.7 KB