-
Notifications
You must be signed in to change notification settings - Fork 89
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
mysql_db module does not detect mysqldump
failure
#256
Comments
@jsefferon hi, thank you for reporting and investigating this! Looks like a bug. I'll put the "help_wanted" label on the issue. |
I encountered this issue using v3.2.0. If a view reference en missing table, the dump will contain only a single line: Even if the output of mysqldump was very clear: mysqldump: Couldn't execute 'SHOW FIELDS FROM `v1`': View 'someview.v1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them (1356) This is a serious bug! It's even worse than a backup that doesn't works. It produce a SQL that can wipe your data. |
hm, |
I've a fork with an integration test to reproduce the issue: https://github.com/laurent-indermuehle/community.mysql/blob/fix_mysqldump_ignore_errors/tests/integration/targets/test_mysql_db/tasks/issue_256_mysqldump_errors.yml I'm ready to explore solutions. I should have time for this in few hours. If I'm right, the issue is here: https://github.com/ansible-collections/community.mysql/blob/main/plugins/modules/mysql_db.py#L425-L431 |
@laurent-indermuehle cool, please go ahead:) |
@jsefferon thank you for reporting the issue! Thank you folks for your contribution! |
Is this issue really fixed? I'm seeing this issue in 3.6.0 |
@matiasbarrosinvgate do you see it on backup or restore? |
SUMMARY
mysql_db
module does not detectmysqldump
failure when output is set to be a compressed file.ISSUE TYPE
COMPONENT NAME
mysql_db
ANSIBLE VERSION
COLLECTION VERSION
OS / ENVIRONMENT
Encountered on
Debian GNU/Linux 9.13 (stretch)
.STEPS TO REPRODUCE
You need to be able to get mysqldump to fail, in our case it was failing because records dumped exceeded
max_allowed_packet
default of 16MB which we verified by runningmysqldump
from CLI instead of viamysql_db
. Perhaps setting invalid credentials may break it too.E.g.:
EXPECTED RESULTS
Task fails as the value of
max_allowed_packet
doesn't permit it to successfully completemysqldump
when dumping an object bigger than 1MB.ACTUAL RESULTS
Task completes successfully with
/tmp/backup.gz
file created which contains valid SQL file. However the backup is incomplete - i.e. missing data and/or structure as themysqldump
process exited early with an error.I believe this is because the output is set to be gzip and ansible pipes the output from
mysqldump
intogzip
, however unlessset -o pipefail
is set for that shell's environment, failure ofmysqldump
won't be noticed and a partial mysql dump file will be gzipped.I regard this as a bug since it's expected that if the module provides automatic packaging, it should handle the dump failure regarding of what the default shell settings may be.
See https://github.com/ansible-collections/community.mysql/blob/main/plugins/modules/mysql_db.py#L420 for the relevant code.
The text was updated successfully, but these errors were encountered: