-
Sujatha Sivakumar authored
TRANSACTION CACHE SIZE IS EXACTLY 32768 Problem: ======== When the binlog's IO_CACHE grows up to exact 32768 bytes it causes binlog events to get corrupt, if this transaction precedes with a transaction whose IO_CACHE size is >32768. Analysis: ======== On the master during the execution of a transaction all the events that are related to that transaction will be written to the IO_CACHE. The size of the IO_CACHE is 32768. The transaction whose events can fit within the IO_CACHE are never flushed to disk. During flush operation they do nothing but simply set the cache->read_end and end_of_file to current size. At the time of writing to the binlog the cache is read back and if CRC is enabled checksum is calculated if not then the content is written to binlog file. If the transaction size exceeds 32768 then it will be written to a temporary file and the cache is reinited so that remaining events can be written to cache. During writing to binary log file this temp file is read back. In the bug scenario the transaction size grows exactly to 32768, and during flush operation it expects current size of cache to be < 32768. Which is incorrect ideally it should have been <= 32768. As the size is still equal to IO_CACHE size. Because of the incorrect check cache is marked for flush but the writing function "my_b_write" doesn't flush the buffer to disk as it expects cache size to be > 32768 and the cache is reinited without writing to temp file. When the cache is read back it finds the buffer to be empty and tries to fill it from temp file which wrong. Hence the buffer is filled with some other transaction related data causing corruption. Fix: === During flush the check for size has been changed from "<" to "<=".
Sujatha Sivakumar authoredTRANSACTION CACHE SIZE IS EXACTLY 32768 Problem: ======== When the binlog's IO_CACHE grows up to exact 32768 bytes it causes binlog events to get corrupt, if this transaction precedes with a transaction whose IO_CACHE size is >32768. Analysis: ======== On the master during the execution of a transaction all the events that are related to that transaction will be written to the IO_CACHE. The size of the IO_CACHE is 32768. The transaction whose events can fit within the IO_CACHE are never flushed to disk. During flush operation they do nothing but simply set the cache->read_end and end_of_file to current size. At the time of writing to the binlog the cache is read back and if CRC is enabled checksum is calculated if not then the content is written to binlog file. If the transaction size exceeds 32768 then it will be written to a temporary file and the cache is reinited so that remaining events can be written to cache. During writing to binary log file this temp file is read back. In the bug scenario the transaction size grows exactly to 32768, and during flush operation it expects current size of cache to be < 32768. Which is incorrect ideally it should have been <= 32768. As the size is still equal to IO_CACHE size. Because of the incorrect check cache is marked for flush but the writing function "my_b_write" doesn't flush the buffer to disk as it expects cache size to be > 32768 and the cache is reinited without writing to temp file. When the cache is read back it finds the buffer to be empty and tries to fill it from temp file which wrong. Hence the buffer is filled with some other transaction related data causing corruption. Fix: === During flush the check for size has been changed from "<" to "<=".
Loading