[MDEV-26618] OPTIMIZE table not replicating Created: 2021-09-16 Updated: 2023-04-27 |
|
| Status: | Confirmed |
| Project: | MariaDB Server |
| Component/s: | Data Definition - Alter Table, Replication |
| Affects Version/s: | 10.4.19, 10.4.21 |
| Fix Version/s: | 10.4, 10.5, 10.6 |
| Type: | Bug | Priority: | Major |
| Reporter: | Manuel Arostegui | Assignee: | Sergei Golubchik |
| Resolution: | Unresolved | Votes: | 1 |
| Labels: | None | ||
| Environment: |
debian buster |
||
| Issue Links: |
|
||||||||
| Description |
|
We are trying to optimize a table which is around 50GB and that after the optimization should reduce to around 14GB. We have noticed that running the optimize on the master (10.4.19+STATEMENT or 10.4.21) it doesn't get written on the binlog and hence it doesn't get replicated to any of the slaves.
Using alter table engine=InnoDB does get replicated. This is a different host (runs ROW based):
We have seen this on 10.4.19 and 10.4.21 Table definition (happens with both compressed and non compressed version of this table):
Server variables: https://phabricator.wikimedia.org/P17279 All this made me doubt if OPTIMIZE (or even ANALYZE) gets replicated by default and I double checked it does: |
| Comments |
| Comment by Manuel Arostegui [ 2021-09-16 ] | |||||||||||||||||||||||||||||||||||||
|
Just tried the same thing on a 10.1 intermediate master we still have and there it does show up on binlogs:
| |||||||||||||||||||||||||||||||||||||
| Comment by Alice Sherepa [ 2021-09-16 ] | |||||||||||||||||||||||||||||||||||||
|
Could you please describe the situation more or demonstrate the way to reproduce it? So, you have 1->2->3, server 2 and 3 have semi-sync rpl, and then you're doing | |||||||||||||||||||||||||||||||||||||
| Comment by Alice Sherepa [ 2021-09-16 ] | |||||||||||||||||||||||||||||||||||||
|
Could you please describe the situation more or demonstrate the way to reproduce it? So, you have 1->2->3, server 2 and 3 have semi-sync rpl, and then you're doing | |||||||||||||||||||||||||||||||||||||
| Comment by Manuel Arostegui [ 2021-09-16 ] | |||||||||||||||||||||||||||||||||||||
|
Thanks for the answer.
This has been tried on different hosts, different databases and even different tables with the same result on 10.4 hosts. | |||||||||||||||||||||||||||||||||||||
| Comment by Manuel Arostegui [ 2021-09-16 ] | |||||||||||||||||||||||||||||||||||||
|
Worth mentioning that there are no errors at all on logs or on the prompt. It simply runs fine but then it sort of vanishes from binlog and replication. | |||||||||||||||||||||||||||||||||||||
| Comment by Manuel Arostegui [ 2021-09-16 ] | |||||||||||||||||||||||||||||||||||||
|
Providing more insights:
| |||||||||||||||||||||||||||||||||||||
| Comment by Alice Sherepa [ 2021-09-16 ] | |||||||||||||||||||||||||||||||||||||
|
Thanks for the clarification! KB says: Starting with MariaDB 10.3.20 we have fixed some issues related to read only replicas: Maybe it should be improved so, that if admin statements are executed by the user with the super privilege - they should be written in the binlog (unless NO_WRITE_TO_BINLOG flag was used). Otherwise - it is allowed to execute optimize/analyze, but they are not written to the binlog. | |||||||||||||||||||||||||||||||||||||
| Comment by Manuel Arostegui [ 2021-09-16 ] | |||||||||||||||||||||||||||||||||||||
|
Good catch Alice. These two: Thanks a lot | |||||||||||||||||||||||||||||||||||||
| Comment by Sergei Golubchik [ 2021-09-16 ] | |||||||||||||||||||||||||||||||||||||
|
This was first changed in the commit b62101f84be4. I don't see any explanation for why it was changed or any reference to a MDEV number, so perhaps monty could explain why it was done. There could've been reasons for that, but until I know them, I'd say that OPTIMIZE and ANALYZE should respect read_only. And if executed — read_only or not — they should be written into binlog. This is the most logical behavior, no exception. If somebody wants to run OPTIMIZE despite read_only and not write it to binlog, one can always login as SUPER and do OPTIMIZE ... NO_WRITE_TO_BINLOG. | |||||||||||||||||||||||||||||||||||||
| Comment by Manuel Arostegui [ 2021-10-25 ] | |||||||||||||||||||||||||||||||||||||
|
Any rough estimation on when this could be fixed? | |||||||||||||||||||||||||||||||||||||
| Comment by Jaime Crespo [ 2021-11-18 ] | |||||||||||||||||||||||||||||||||||||
|
I understand whether OPTIMIZE should respect read_only or not can be changed and discussed. MySQL does not apply it, but mariadb can reasonable choose to keep the same behaviour or change it. A different issue is that a user with SUPER should be able to run it (typical case- optimization of a read only replica by an administrator). And if it has been executed and log was enabled, has to be logged. I consider this a regression (either fail or complete, but not something in between!). However, may I ask, until a decision is taken, that the change in behavior is documented on the release notes: https://mariadb.com/kb/en/mariadb-10320-release-notes/ , changelog: https://mariadb.com/kb/en/mariadb-10320-changelog/ (there is no mention of binlog behaviour and SQL semantics change) and possible, the wiki, given that binlog/replication changes are a huge deal for upgrades and compatibility?! | |||||||||||||||||||||||||||||||||||||
| Comment by Sergei Golubchik [ 2021-11-18 ] | |||||||||||||||||||||||||||||||||||||
|
greenman, could you please document the status quo and then reassign back to me? | |||||||||||||||||||||||||||||||||||||
| Comment by Ian Gilfillan [ 2021-11-29 ] | |||||||||||||||||||||||||||||||||||||
|
Changes documented. This was actually in the pulled MariaDB 10.3.19 release, and already present in the changelog. I've added to the release notes, and to the OPTIMIZE, ANALYZE and CHECK pages. |