Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Potential bug in rds-binlog-to-s3.sh as the last binary log might still be updated by the master #84

Open
vinodpandey opened this issue May 18, 2023 · 0 comments

Comments

@vinodpandey
Copy link

In https://github.com/awslabs/rds-support-tools/blob/main/mysql/rds-binlog-to-s3/rds-binlog-to-s3.sh, we are using "show master logs" to get the master log file names.

mysql_binlog_filename=$(mysql -u $dbuser -h $RDS -e "show master logs"|grep "mysql-bin"|awk '{print $1}')

The master might be updating the last binary log file based on the MySQL server configuration. In that case, when we download the last binary log file from the list, we will get incomplete data.

One possible solution can be to download all binary logs except the last one.

# converting to array by wrapping with ()
# we will remove the last element of the array later

mysql_binlog_filename=($(mysql -u $dbuser -h $RDS -e "show master logs"|grep "mysql-bin"|awk '{print $1}'))

# we are excluding the last element from mysql_binlog_filename as the master
# may still be updating the binary log
for file in ${mysql_binlog_filename[@]::${#mysql_binlog_filename[@]}-1}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant