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

Make mysql replicas to work with MySQL 5.7 and 8.0 #82

Merged
merged 1 commit into from
Aug 29, 2022

Conversation

stronk7
Copy link
Member

@stronk7 stronk7 commented Aug 24, 2022

This fixes #80. It has been detected that MySQL main/replica
configurations have stopped working. My personal bet is that
some changes in the MySQL images have leaded to that, or maybe
they were working for MySQL 5.6 and never have worked to 5.7.

NVM, this commit just makes them back to work for both 5.7 and 8.0,
that are the currently "supported" MySQL databases.

Note that, after this PR, we'll be checking the MariaDB main/replica
configurations because they may need similar changes.

Also, while I've tested the solution locally, we are lacking any own
CI for this product, so I've created an issue about that:

#81

Finally, here there are the explanations about the changes performed:

  1. Moved the bin logs from /var/log/mysql to /var/lib/mysql . Reason
    being that the former directory doesn't exist anymore in MySQL 5.7
    and up (and also, that the binary logs are better with data than
    with logs).
  2. Removed the 'multi_admin' user related stuff. Not needed at all.
  3. Minor changes to moodle and root GRANT/IDENTIFIED stuff because
    of changes in MySQL 8 (already deprecated in 5.7). Use ALTER USER
    instead.
  4. Use IDENTIFIED WITH mysql_native_password (the old password schema),
    because MySQL 8, when using the new hashed schema requires
    communications between the hosts to be encrypted. We don't need that
    extra complexity and while it can be disabled as part of the CHANGE MASTER TO
    command... it cannot be disabled for MySQL 5.7. SO the only option
    working in both versions is the used one (force old passwords schema
    for the replication user).
  5. Remove the need of stopping and starting the temp server in the
    replica. All the commands can be executed with the temp server
    running and then the container entrypoint manageing itself will stop
    the temp server and start the final one.
  6. Stop needing gosu completely. Now the replica conf files are made
    available via volume mount (like the standalone or main cases).

And that's all. The changes are small and subtle, but each one is
for a good reason, I think.

This fixes moodlehq#80. It has been detected that MySQL main/replica
configurations have stopped working. My personal bet is that
some changes in the MySQL images have leaded to that, or maybe
they were working for MySQL 5.6 and never have worked to 5.7.

NVM, this commit just makes them back to work for both 5.7 and 8.0,
that are the currently "supported" MySQL databases.

Note that, after this PR, we'll be checking the MariaDB main/replica
configurations because they may need similar changes.

Also, while I've tested the solution locally, we are lacking any own
CI for this product, so I've created an issue about that:

moodlehq#81

Finally, here there are the explanations about the changes performed:

1. Moved the bin logs from /var/log/mysql to /var/lib/mysql . Reason
   being that the former directory doesn't exist anymore in MySQL 5.7
   and up (and also, that the binary logs are better with data than
   with logs).
2. Removed the 'multi_admin' user related stuff. Not needed at all.
3. Minor changes to moodle and root GRANT/IDENTIFIED stuff because
   of changes in MySQL 8 (already deprecated in 5.7). Use ALTER USER
   instead.
4. Use IDENTIFIED WITH mysql_native_password (the old password schema),
   because MySQL 8, when using the new hashed schema requires
   communications between the hosts to be encrypted. We don't need that
   extra complexity and while it can be disabled as part of the CHANGE MASTER TO
   command... it cannot be disabled for MySQL 5.7. SO the only option
   working in both versions is the used one (force old passwords schema
   for the replication user).
5. Remove the need of stopping and starting the temp server in the
   replica. All the commands can be executed with the temp server
   running and then the container entrypoint manageing itself will stop
   the temp server and start the final one.
6. Stop needing gosu completely. Now the replica conf files are made
   available via volume mount (like the standalone or main cases).

And that's all. The changes are small and subtle, but each one is
for a good reason, I think.
@stronk7
Copy link
Member Author

stronk7 commented Aug 24, 2022

Have launched a few PHPUnit jobs @ CI using the testing environment with this branch applied:

  • MySQL 5.7 standalone: Build Status
  • MySQL 5.7 with read-only replica: Build Status
  • MySQL 8.0 standalone: Build Status
  • MySQL 8.0 with read-only replica (MDL-71000): Build Status and Build Status
  • MySQL 8.0 with read-only replica (master): Build Status

Let's see how they end...

Edited: to launch the MDL-71000 one again (it had 2 failures) and also launch a master one, to see if the problem is the issue.

Edited 2: Curiously, they pass when running them alone (--filter audience_test), see Build Status.

I'm going to give them another complete run against master: Build Status

@stronk7
Copy link
Member Author

stronk7 commented Aug 26, 2022

No matter the results above, I think this is acceptable as is. The problem is only happening with MySQL 8.0, not with MySQL 5.7 that is our current default database. We can move the investigations with MySQL 8.0 to another issue.

@stronk7 stronk7 changed the title Make mysql replicas to work with MySQL 5.7 and 5.8 Make mysql replicas to work with MySQL 5.7 and 8.0 Aug 26, 2022
@stronk7
Copy link
Member Author

stronk7 commented Aug 29, 2022

#84 has been created to further investigate the MySQL 8.0 problems.

@stronk7
Copy link
Member Author

stronk7 commented Aug 29, 2022

I'm self merging this, so can continue with #83 and #79 ...

@stronk7 stronk7 merged commit ef96180 into moodlehq:master Aug 29, 2022
@stronk7 stronk7 deleted the mysql_replicas_57_80 branch August 29, 2022 08:04
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.

Runs with MySQL replicas enabled are failing
1 participant