[MDEV-14608] mysqlbinlog lastest backupfile size is 0 Created: 2017-12-08  Updated: 2022-03-29  Resolved: 2022-03-29

Status: Closed
Project: MariaDB Server
Component/s: Scripts & Clients
Affects Version/s: 10.1, 10.2.11
Fix Version/s: 10.2.44, 10.3.35, 10.4.25, 10.5.16, 10.6.8, 10.7.4, 10.8.3

Type: Bug Priority: Critical
Reporter: tanqingru Assignee: Brandon Nesterenko
Resolution: Fixed Votes: 0
Labels: None
Environment:

CentOS7.3, CentOS7.4



 Description   

In centos7.3,7.4 , mariadb (10.1.28,10.1.29,10.2.11,)has the following problem:

comand like this:
/usr/bin/mysqlbinlog --raw --read-from-remote-server --stop-never --host=localhost --port=3306 --user=root --password=root --result-file=/backup/binlog/ mysql-bin.000001

lastest backupfile size is 0:

  1. ll

rw-rw-r- 1 mysql mysql 441 Dec 7 09:22 mysql-bin.000076
rw-rw-r- 1 mysql mysql 3230 Dec 8 03:20 mysql-bin.000077
rw-rw-r- 1 mysql mysql 0 Dec 8 03:20 mysql-bin.000078

OTHER:
mariadb10.1.29 In Cent6.8, percona5.7,mysql5.7 in centos7.3,cent7.4 , There is no such problem



 Comments   
Comment by Elena Stepanova [ 2017-12-12 ]

Thanks for the report.

I'm not sure about the difference on different versions of CentOS, but the problem is reproducible on my machine (Debian Jessie) with 10.1 and 10.2, and not reproducible on the same machine with MySQL 5.7.

Comment by Sachin Setiya (Inactive) [ 2018-10-21 ]

I think this is is not a bug , Actually culprit is fwrite , which buffers the data
So cli_safe_read(mysqlbinlog) reads the actual data from server binlog file
And handle_event_raw_mode calls the fwrite which should have written data but it writes into its buffer
(for proof ) I have changed the my_fwrite function to add fflush in end , with this modification tha latest binlog file(created by myysqlbinlog) was no longer of zero size (edited)
drwxr-xr-x 2 sachin users 4.0K Oct 21 21:10 .
drwxr-xr-x 28 sachin users 4.0K Oct 21 21:05 ..
rw-rr- 1 sachin users 314 Oct 21 21:10 master-bin.000001

Comment by Andrei Elkin [ 2020-12-15 ]

sachin.setiya.007 You mention fflush is not done. Probably it's not done too when there's nothing to retrieve from
the server in which case I believe we should take care of doing that.

Comment by Brandon Nesterenko [ 2021-09-22 ]

Hi Andrei,

This is ready for review.

Commit: ff5a568
Buildbot: bb-10.2-MDEV-14608

Comment by Andrei Elkin [ 2022-03-24 ]

Analyzed, reviewed.

Comment by Andrei Elkin [ 2022-03-24 ]

bnestere, the patch looks good. Thanks for taking the time on it. I also spent a little time figuring out if fflush could be executed
not per event but rather when the source file is found empty (that is before sink to waiting).
However there seems to be no straightforward way and a non-blocking attempt read would be required
inside a low-level ma_net_safe_read.

Comment by Brandon Nesterenko [ 2022-03-29 ]

Manual cherry picking resulted in no merge conflicts in later versions.

Generated at Thu Feb 08 08:14:54 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.