You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
BUG#33666652: Server may decompress entire Transaction_payload_log_event in memory
* Background
Binary log compression is implemented by compressing many events into
one. There were decompressing iterators over the file, which yielded
the events of the binary log one at a time, including the decompressed
events.
* Problem
When the iterators reached a Transaction_payload_log_event, they
decompressed the full payload, even if only one event at a time was
yielded to the caller. This is wasteful.
* Solution
- The decompressor was mixing memory management with decompressor
glue. Separated the responsibilities so the decompressor only is
compressor glue, and the new class Growable_buffer manages memory
for a growable buffer.
- The decompressor APIs were implemented as "iterators". However, the
implementation violated a common iterator idiom by holding an error
state. This made it necessary to keep the iterator object after it
had reached the end iteraton in order to check for the error, which
maked it unusable for e.g. range-based for loops. So, changed to
using a "stream" instead, where it is more natural to check for
errors using the typical idioms.
- Made the stream classes decompress only one event at a time.
- Removed the abstract base class common to compressors and
decompressors.
- Changed the Decompressor API to better match what decompressor
libraries provide and what API clients need. Now the use
pattern is:
- Call 'feed' to provide input to decompress
- Call 'decompress' produce a given number of decompressed bytes.
- Repeat the above as many times as needed.
- The above process can be aborted at any time (e.g. after error)
by calling 'reset'.
- The caller doesn't need to track how much is left to compress; it
only needs to check whether the compress operation failed.
- Removed use of ZSTD's "advanced" decompression API. We were not
using the features it provided, and some platforms were using an older
version where this API was unstable.
- Made all instantiations of template class Basic_binlog_file_reader
have a common base class, IBasic_binlog_file_reader. Before, the
old "Iterator" class had to perform a reinterpret_cast (in
binlog.cc:show_binlog_events) in order to reuse the same code for
Relaylog_ifile and Binlog_ifile. This is dangerous and we should
never use such casts; it would lead to crashes if the types are not
binary compatible. Now, the new "stream" class just uses a pointer
to the base class and resolves whether the object is a
Relaylog_ifile or a Binlog_ifile using polymorphism.
Change-Id: I1e4872597fb6b37bda03682eadd058dd59b21a60
0 commit comments