Let us take an example: replication of the following statement to a 10.3 server:
ALTER TABLE t ADD COLUMN c INT;
|
GeoffMontee provided the following motivation in the Description:
We may want to add a way for users to avoid putting tables into the non-canonical INSTANT format, if they would like.
serg, you did not cover SET alter_algorithm at all. It was introduced in 10.3 by MDEV-13134. You only mentioned changes to the processing of an explicit ALGORITHM clause, which would override the session variable alter_algorithm.
The user could want to use the INSTANT format only on a specific set of nodes that are being replicated from or to, by setting a configuration parameter, which could be alter_algorithm or something else (such as the repurposed innodb_file_format that I suggested).
Also, I have trouble understanding the following part of the proposal:
"use exactly algorithm XXX, nothing else"
That seems to contradict with the following in MDEV-13134:
With respect to the allowed operations, ALGORITHM=INSTANT is a subset of ALGORITHM=NOCOPY which is a subset of ALGORITHM=INPLACE which is a subset of ALGORITHM=COPY.
ALGORITHM=INPLACE was introduced in MySQL 5.6 and MariaDB 10.0 already. It can indeed cover 3 fundamentally different classes of operations:
- instantaneous (like ALGORITHM=INSTANT): renaming columns, adding/removing FOREIGN KEY constraint (if foreign_key_checks=0), starting with MySQL 5.7 or MariaDB 10.2.2: extending some VARCHAR
- true in-place operation (like ALGORITHM=NOCOPY): DROP INDEX, ADD INDEX of secondary indexes
- table rebuild (copying it; contradicting the INPLACE keyword): add/drop/reorder columns, add/drop PRIMARY KEY
For ALGORITHM=INSTANT or ALGORITHM=COPY, the proposal “use exactly algorithm XXX” is clear, and does not change anything.
But, what does “use exactly algorithm NOCOPY” mean? That the operation must consume some time that is proportional to the size of the table? Should we reject the following (if the column is only being renamed)?
ALTER TABLE t CHANGE c d INT, ALGORITHM=NOCOPY;
|
If yes, that would break replication from older versions.
Note: I do not think that we can redefine ALGORITHM=NOCOPY to only cover those operations that do not require changes to the file format (MDEV-11369, MDEV-15562). The following is currently being accepted by 10.3 and 10.4 GA versions, and if we started to reject that, we would break replication from those versions:
ALTER TABLE t ADD e INT, ALGORITHM=NOCOPY;
|
Also, what does “use exactly algorithm INPLACE” mean? That it should imply the FORCE clause, which was introduced in MariaDB 5.5.42, to ensure that the table will be rebuilt? But, that would again break the replication of the following from older versions:
ALTER TABLE t CHANGE c d INT, ALGORITHM=INPLACE;
|
ALTER TABLE t CHANGE d c INT, FORCE, ALGORITHM=INPLACE;
|
Assuming that the type of the column does not change, the first operation is instantaneous. The second operation will cause the table to be copied. And InnoDB could refuse table-rebuilding ALGORITHM=INPLACE in some cases, most notably, if multiple FULLTEXT INDEX exist in the table. Furthermore, not all cases of table-rebuilding ALGORITHM=INPLACE allow LOCK=NONE.
In summary, the proposal would seem to not only make replication (and binlog roll-forward) considerably slower (by replacing schema-only changes with table rebuild operations), but also cause it to abort because previously valid operations could be rejected.
I would appreciate feedback on my proposal of introducing a configuration parameter that would restrict the storage engine’s choice of file formats.
I don't understand. Why cannot ALGORITHM=INPLACE prevent instant changes?