[MDEV-24830] Write a warning to error log if Galera replicates InnoDB table with no primary key Created: 2020-06-12 Updated: 2021-02-23 Resolved: 2021-02-23 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Galera, Storage Engine - InnoDB |
| Fix Version/s: | 10.6.0 |
| Type: | Task | Priority: | Minor |
| Reporter: | Geoff Montee (Inactive) | Assignee: | Jan Lindström (Inactive) |
| Resolution: | Fixed | Votes: | 2 |
| Labels: | galera | ||
| Issue Links: |
|
||||||||||||||||
| Description |
|
If wsrep_certify_nonPK is enabled, then Galera will certify transactions for InnoDB tables with no primary key. wsrep_certify_nonPK is enabled by default, so this is actually the default behavior: With Galera, it is not necessarily safe to define tables that have no primary key. Perhaps if wsrep_certify_nonPK is enabled and if log_warnings is set to >=2, then MariaDB should write a warning to the error log if it certifies a transactions for an InnoDB table that has no primary key. e.g. maybe it could look like this:
If we add a warning like this, then we should probably limit the number of times that it gets printed, so that it doesn't flood the log. |
| Comments |
| Comment by Jan Lindström (Inactive) [ 2020-11-12 ] | ||||||||||||||||||||
|
GeoffMontee Default value for log_warnings is 2 so this could have too big effect on normal cluster. Can I use value >2 instead ? | ||||||||||||||||||||
| Comment by Geoff Montee (Inactive) [ 2020-11-12 ] | ||||||||||||||||||||
|
Hi jplindst. In my opinion, not having a PK on a table does deserve a warning by default with Galera, so I think it makes the most sense to log a warning when log_warnings=2. Are you concerned that the log could be flooded with the message? If so, then you could probably avoid flooding the log by doing a check similar to the check for ER_BINLOG_UNSAFE_STATEMENT. e.g.:
https://github.com/MariaDB/server/blob/mariadb-10.5.8/sql/sql_class.cc#L7170 | ||||||||||||||||||||
| Comment by Jan Lindström (Inactive) [ 2020-11-13 ] | ||||||||||||||||||||
|
GeoffMontee Thanks for the feedback. I have another question. Should I print warning to error log only or should every DML that causes unsafe Galera operation also print warning? At the moment it seems based on mtr-tests we have: Completed: Failed 181/1243 tests, 85.44% were successful. I should somehow modify that many tests using current implementation and above will not help on that. Here is example of current output:
| ||||||||||||||||||||
| Comment by Geoff Montee (Inactive) [ 2020-11-13 ] | ||||||||||||||||||||
|
Hi jplindst,
Good point. It would probably make sense to log a warning for all unsafe operations. I believe that some other unsafe operations might be:
What do you think about those? Thanks! | ||||||||||||||||||||
| Comment by Jan Lindström (Inactive) [ 2020-11-19 ] | ||||||||||||||||||||
|
GeoffMontee In this ticket I will handle only primary key issue. Rest of the ideas will be considered on | ||||||||||||||||||||
| Comment by Jan Lindström (Inactive) [ 2021-02-10 ] | ||||||||||||||||||||
|
https://github.com/MariaDB/server/commit/22fe31fec7648ac340690aefbab6053bbf5d02f6 |