[MDEV-29048] Table create statement on master does not get replicated on replica Created: 2022-07-06 Updated: 2022-07-25 Resolved: 2022-07-25 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Replication |
| Affects Version/s: | 10.6.7, 10.7.3, 10.7.4, 10.8.3 |
| Fix Version/s: | N/A |
| Type: | Bug | Priority: | Major |
| Reporter: | Erlandas | Assignee: | Unassigned |
| Resolution: | Not a Bug | Votes: | 0 |
| Labels: | replication | ||
| Environment: |
Ubuntu 20.04 |
||
| Description |
|
Simple CREATE TABLE (or a column in the table) statement used to create a new table in the existing database does not get replicated on replica. Sometimes it works from some MySQL DBA clients but usually it is an issue from CLI, DataGrip and other DBA. Replica then issues: Last_Errno: 1146 I have been having this issue since 10.6.7 when I started using Master-> Replica setup In the past I was getting 1054 error which is unknown column name (when I was adding column to the existing table but I see the same problem is with new table addition too), now with 10.8.3 I am getting 1146 error but the cause is always the same - create a table with columns or a new column on master and replication then breaks on replica when master gets writes into newly created column/table. The only solution then is to import the whole database again on replica from master dump and start replication again. Replica config as follows:
|
| Comments |
| Comment by Angelique Sklavounos (Inactive) [ 2022-07-09 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Hi Erland22, thank you for the bug report. Unfortunately I was not able to reproduce this. I tried with 10.6.7 and the mariadb/mysql client, using the following commands:
1) Do these statements (particularly the Alter) match what you tried? | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Erlandas [ 2022-07-13 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Hello Angelique, This is the exact statement I used to create the table (there was no ALTER statement, just create table and it did not get replicated to Replica):
jobs2 database already had other tables and data before creating `queued_tasks_slots` table. I added table with columns (which did not get replicated) not just column to the database (Sorry about the confusion). Master has /etc/mysql/mariadb.conf.d/server.cnf :
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Angelique Sklavounos (Inactive) [ 2022-07-13 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Great, thanks Erland22, I can see the behavior on 10.6.7. The problem appears to be with replicate_do_db (admittedly I left this out the first time, a bad assumption on my part) and if a default database is not set. If I clear the replicate_do_db filter, then the table replicates. However, with the filter set, the table will replicate if it is preceded by USE jobs2. So I would just like to verify with you that the CREATE TABLE statement below was NOT preceded by USE jobs2. From your comment:
In other words, with replicate_do_db=jobs2:
Table replicated
Also, with the following, the table is not replicated, but also the 1146 error does not appear:
I was curious about this, so ran mysqldump on my test server using --all-databases, and can see that after jobs2 is created, it is set as the default with USE. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Erlandas [ 2022-07-13 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
I'm glad to hear that you were able to get the problem repeated on your side. The problem is on 10.6.7 and 10.7.3 and 10.8.3 - I have tried all of those and was getting the same issue. I use replicate_do_db=jobs2 to specify which exact database to replicate (and other databases on other servers as well as I have multiple masters replicating into one replica. And I have multiple databases on each server but i need only specific databases to be replicated) I did not state `USE jobs2;` as the statement was executed via admin panel (where database was already selected). But when I try via CLI - yes, i issue `USE jobs2;` but as you mentioned - the problem comes from `replicate_do_db=jobs2` setting. I was having same issue most of the time in CLI as well (sometimes somehow it miraculously did replicate when executed from CLI but usually not) And what I mean admin panel is - PHP Adminer or Data Grip or some other application which allows working with MariaDB/MySQL without going to Command Line Interface. In the admin panel you just select database which corresponds the `use jobs2;` in CLI. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Angelique Sklavounos (Inactive) [ 2022-07-14 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Hi Erland22, unfortunately then it looks like I am NOT reproducing what you are seeing, but I was testing with only a single master.
As I said:
and Table replicated
I will test with multiple masters, but if you are seeing the issue with a single master, do you have SQL logs, error logs, output from SHOW SLAVE STATUS, output from SHOW VARIABLES in the case when it did not replicate and CLI was being used? | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Angelique Sklavounos (Inactive) [ 2022-07-14 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
This might be useful to consult (and might explain why the issue is seen most of the time but not always): | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Erlandas [ 2022-07-14 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Yes, I see that error logs is there for Replica server and error logs are present for the master. I have not tried with single master as it was setup with multiple masters to replicate to single replica. Where would SQL log be located? I see Binlogs but I cannot see SQL log file. Where can I upload error log and other logs privately? They would be around 10-15 Mb each when Zipped. Yes, I see 'replicate_do_db' limitation on the URL you have shown. So what setup would be best in my scenario when I need to replicate from multiple masters, only specific databases to single replica? And how does it replicate other statements when we do not specify USE XXXX; - replicated just row by row? | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Erlandas [ 2022-07-14 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Yes, I see that error logs is there for Replica server and error logs are present for the master. I have not tried with single master as it was setup with multiple masters to replicate to single replica. Where would SQL log be located? I see Binlogs but I cannot see SQL log file. Where can I upload error log and other logs privately? They would be around 10-15 Mb each when Zipped. Yes, I see 'replicate_do_db' limitation on the URL you have shown. So what setup would be best in my scenario when I need to replicate from multiple masters, only specific databases to single replica? And how does it replicate other statements when we do not specify USE XXXX; - replicated just row by row? | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Erlandas [ 2022-07-14 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
I now fully understood what you meant in previous messages about using `USE` before CREATE TABLE. MariaDB replicate_do_db setting is simply designed to work that way with statement based replication which to me looks error prone requirement which basically is not really necessary. When we look at the currently required usage to avoid error: Table replicated work this way:
But in fact - we already tell which database to use with CREATE statement. `CREATE TABLE jobs2.t1` - already says - we are working with jobs2 database. No other database is involved. So why is `USE jobs2;` is so necessary? I understand it is necessary if I issue such statement: `CREATE TABLE t1;` - then surely - MariaDB does not know on which database to create the table but if I am executing `CREATE TABLE jobs2.t1` - issuing `USE jobs2;` before it - is completely unnecessary. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Elena Stepanova [ 2022-07-25 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
As of now, it is not the question of necessity, historically it was designed and implemented this way. True enough, it is confusing to many users, which is the reason why it is very verbosely documented both in MySQL manual and in MariaDB KB. You are very welcome to create a feature request with suggestions how the behavior could be changed. Meanwhile, you can explore replicate-wild-do-table, it may be more to your liking. |