0

Mysql row-based binary logging seems to have a different behaviour when grouping rows changes in some versions of mysql.

Let's assume the following statement update three rows:

UPDATE table_name SET a=1 WHERE id IN (1, 2, 3);

In mysql 5.7.21: The binary log receive only one log containing the 3 rows changes. (Which is my desired behaviour)

However, when tested in mysql 5.7.11 and mysql 5.7.26, the same statement produces three separated logs. Each one of them containing each changed row.

I have checked the system variables and, at least, the ones who are related to the binary log, seem to be exactly the same on 5.7.21 and 5.7.26.

We have checked the startup variable --binlog-row-event-max-size, which could be causing the problem. Since the rows in our tables could be bigger than the default 8KB. But, we are not able to set this variable. Since we are working in Amazon RDS. (How can we do it?)

I need that the rows that are changed on the same statement are always batched in the binary log. Is there some variable which could be causing this behaviour?

Notes: There is no replication involved in our setup.

  • Can you illustrate the differing behavior you are seeing with mysqlbinlog output? – Michael - sqlbot Sep 5 at 20:17
0

The setting is a "soft" max. If a row exceeds the given value, the entry will be bigger than the max. That is, "no problem".

If your desire is to avoid them ever being batched, you probably need the value to be less than 8K.

From the 8.0.14 Changelog:

The startup option --binlog-row-event-max-size now has a corresponding system variable binlog_row_event_max_size. The startup option and system variable set a soft limit on the maximum size of a row-based binary log event, with a default setting of 8192 bytes. Where possible, rows stored in the binary log are grouped into events with a size not exceeding the value of this setting. If an event cannot be split, the maximum size can be exceeded.

The binlog_row_event_max_size global system variable is read-only and can be set only at server startup.

As for whether, or when, Amazon will provide a way to set it, I don't know. File a bug report with them.

I would suggest that the value of the variable is only a minor optimization.

----- 2017-04-10 8.0.1 Development Milestone & 2017-04-10 5.7.18 General Availability -- Bugs Fixed -- Replication -----

Binlog_sender, which writes events from the binary log to a packet buffer and then sends the packet to the slave, did not reduce the size of the send buffer as expected. (Bug #24643036)

  • My desire is that the rows that are changed on the same statement are always batched in the binary log. That is what I am trying to achieve. As I said, on 5.7.21 this seems like a default behaviour. But I don't know what variable is causing that in other mysql versions entries in the binary log only contain 1 changed row each. Always. – Leonardo Kuffo Sep 5 at 15:18
  • I found another note (see Answer); something changed in 5.7.18, but perhaps does not really explain things. You could file a bug with bugs.mysql.com . – Rick James Sep 5 at 16:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.