--- mysql-8.0.31/sql/binlog_ostream.cc 2022-11-17 19:28:38.972797713 +0800 +++ mysql-8.0.31/sql/binlog_ostream.cc 2022-11-17 19:29:32.096066949 +0800 @@ -182,7 +182,7 @@ bool IO_CACHE_binlog_cache_storage::next(unsigned char **buffer, my_off_t *length) { - my_b_fill(&m_io_cache); + if (my_b_bytes_in_cache(&m_io_cache) == 0) my_b_fill(&m_io_cache); *buffer = m_io_cache.read_pos; *length = my_b_bytes_in_cache(&m_io_cache);