[MDEV-12162] binlog_row_image minimal Not Working Created: 2017-03-01 Updated: 2020-09-08 Resolved: 2020-09-08 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Replication |
| Affects Version/s: | 10.1.17, 10.1, 10.2 |
| Fix Version/s: | N/A |
| Type: | Bug | Priority: | Minor |
| Reporter: | Brad Jorgensen | Assignee: | Andrei Elkin |
| Resolution: | Duplicate | Votes: | 1 |
| Labels: | binlog, replication | ||
| Environment: |
3 10.1.17 servers in galera cluster |
||
| Attachments: |
|
||||||||
| Issue Links: |
|
||||||||
| Description |
|
I'm removing about 200GB of blobs from my servers in a galera cluster (don't get me started on them being in the database to begin). I have had `binlog_row_image` set to `MINIMAL` for at least several months. The rows I'm updating to remove the blobs are in a table with an `INT` PK called `id` and a `MEDIUMTEXT` column called `message`. For consistency for now, instead of deleting the rows, I am updating the `messsage` to `'s3'` (we are storing the data on S3 now). I assumed that with `binlog_row_image` set to `MINIMAL` the binlog would only store the old PK (`id`) and the new blob (`message`), but the size of the newly written binlogs is consistent with the amount of data that is being removed and `mysqlbinlog` shows the full old blob. I also tried using `NOBLOB` for testing, but the binlogs looked the same. I thought it might be that galera caused the full image to be written but our async slaves with basically the same config are also writing the full image. I have attached the config for one of the servers in the galera cluster, the others are basically the same. I have moved to updating a similar table as part of the same migration. The table structure is different, but I'm still performing basically the same operation. Here is the create statement for it:
This is a sample of the update query I'm running. `contacts_messages_upload_status` is a table I was using to track which blobs were uploaded to S3.
I added `SELECT @@binlog_row_image` to the top of the script I'm running to do these updates and it does return `MINIMAL`. |
| Comments |
| Comment by Elena Stepanova [ 2017-03-03 ] | |||||||||||||||||||||||||||
|
Yes, please provide the table structure (SHOW CREATE TABLE ...), an example of the UPDATE statement that you are using, SELECT @@binlog_row_image from the same session where UPDATE was executed, and an example of the resulting binlog from the same server. Just in case – when you are saying that you've had binlog_row_image=MINIMAL for months, I assume you restarted the server after you set it, right? | |||||||||||||||||||||||||||
| Comment by Brad Jorgensen [ 2017-03-06 ] | |||||||||||||||||||||||||||
|
I updated the original description. And, yes, I did restart the servers since adding `binlog_row_image=MINIMAL` to the config file and they have been running with that setting. I will attach an excerpt of the binlog showing for one of the update statements. | |||||||||||||||||||||||||||
| Comment by Brad Jorgensen [ 2017-03-06 ] | |||||||||||||||||||||||||||
|
I attached an example binlog entry for one of the updates. It has the row event decoded so I could redact the original blob data. Without it decoding the row data, the same event has a consistently large `BINLOG '...'` block. | |||||||||||||||||||||||||||
| Comment by Brad Jorgensen [ 2017-03-06 ] | |||||||||||||||||||||||||||
|
After looking at the example UPDATE query I added here outside of the code context I normally see it in, I tried removing the message != 's3' condition from the query and it appears that is doesn't log the old blob data anymore. It looks like since I select the old body so it skips already updated rows, that column is marked as needing to be read when writing the binlog row data. It seems odd, though, that since it has the primary key it still writes the other column's data. Unless I'm thinking about this wrong and the binlog writes the full possibly updated row data for the entire query even if not all of the rows would be updated by the query. | |||||||||||||||||||||||||||
| Comment by Elena Stepanova [ 2017-03-13 ] | |||||||||||||||||||||||||||
|
Indeed, it appears to depend on using blob in the WHERE clause, and I agree that it shouldn't. As a workaround, I suppose you can remove the condition, it doesn't do anything useful in your case anyway. Nor reproducible with MySQL 5.6, 5.7. MTR-like test-case (only to reproduce, not to be put into the regression suite as is!)
| |||||||||||||||||||||||||||
| Comment by Claudio Nanni [ 2017-07-18 ] | |||||||||||||||||||||||||||
|
Hi, I have found out that what makes the difference (at least in my case) is having a column defined as: timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP In particular it must be present 'ON UPDATE CURRENT_TIMESTAMP' This even with a Primary Key on the table. I attach a simple test case. | |||||||||||||||||||||||||||
| Comment by Alice Sherepa [ 2020-09-08 ] | |||||||||||||||||||||||||||
|
Fixed by commit f9ac7032cbc4b7 ) (I checked 2 cases- in the 2 above comments )
|