Skip to content

Fix skipped removal of initial logs for Ubuntu#594

Open
SuperFoo42 wants to merge 5 commits into
geerlingguy:masterfrom
SuperFoo42:master
Open

Fix skipped removal of initial logs for Ubuntu#594
SuperFoo42 wants to merge 5 commits into
geerlingguy:masterfrom
SuperFoo42:master

Conversation

@SuperFoo42
Copy link
Copy Markdown

Currently, the removal of the initial database logfile only works for Debian < 12, as the distribution_version comparison is tailored to Debian.
For reasonably recent Ubuntu versions (e.g., 24), this does not work. However, Ubuntu's apt installation will also create initial log files that have to be removed.

This PR addresses the issue by adding a check for Ubuntu. Furthermore, the apt installation will also create an initial ibdata-file that might interfere with custom user configuration of InnoDB like innodb_page_size. Therefore, this file is deleted as well.

… for debian only without ubuntu.

Also added initial ibdata for removal in case of custom config changing InnoDB settings.
@geerlingguy
Copy link
Copy Markdown
Owner

Looks fine, but please try to fix the lint issues before merge.

@SuperFoo42
Copy link
Copy Markdown
Author

Linter should be satisfied now.
I noticed the molecule tests are failing. Same for me locally, but it seems to be unrelated to the change.

@geerlingguy
Copy link
Copy Markdown
Owner

The last CI run was passing as of March 10:

https://github.com/geerlingguy/ansible-role-mysql/actions/runs/22932344253

The error in CI seems to be:

TASK [geerlingguy.mysql : Ensure MySQL is started and enabled on boot.] ********
  [ERROR]: Task failed: Module failed: Unable to start service mysql: Job for mysql.service failed because the control process exited with error code.
  See "systemctl status mysql.service" and "journalctl -xeu mysql.service" for details.
  
  Origin: /home/runner/work/ansible-role-mysql/ansible-role-mysql/geerlingguy.mysql/tasks/configure.yml:91:3
  
  89   tags: ['skip_ansible_galaxy']
  90
  91 - name: Ensure MySQL is started and enabled on boot.
       ^ column 3
  
  fatal: [instance]: FAILED! => {"changed": false, "msg": "Unable to start service mysql: Job for mysql.service failed because the control process exited with error code.\nSee \"systemctl status mysql.service\" and \"journalctl -xeu mysql.service\" for details.\n"}

Just deleting the ibdata file results in a corrupted tablespace for mysql. Fix by removing the entire data dir and recreate it. Afterwards, reinitialize the data dir.
For the reinitialization, detect mariadb or mysql, as the init command is different, then initialize after config copy.
@SuperFoo42
Copy link
Copy Markdown
Author

SuperFoo42 commented Mar 19, 2026

Sorry it took a bit longer to find time again.

It turned out it is a bit more complicated, because deleting ibdata leaves tablespace metadata still in place, leading to MySQL refusing to start. The main problem, however, was that I could not reproduce this problem first. The molecule test runs against the galaxy role, not against the local repository. @geerlingguy Is that intended? I changed that in b3f8158.

The new behavior is to delete the data directory entirely, recreate it, and later reinitialize. I changed the recreation permissions in accordance with the recommendation from MySQL.
I also removed the OS checks between Debian and Ubuntu entirely, as I could reproduce the problem on Debian 13 as well. This likely affects the entire deb install path.

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

Successfully merging this pull request may close these issues.

2 participants