Commit 9039dc1
Marko Mäkelä
Bug#16216513 INPLACE ALTER DISABLED FOR PARTITIONED TABLES
Due to Bug#14760210, INPLACE ALTER TABLE was disabled for partitioned tables.
But it is possible to support this within InnoDB (our only
transactional engine that can use the partitioning engine,
ha_partition).
The fix is to atomically commit the ALTER TABLE changes to all
partitions of the table, within a single data dictionary
transaction. The groundwork for this was laid out when fixing
Bug#15989081 INNODB ALTER TABLE IS NOT ATOMIC.
This patch modifies the solution so that changes to all partitions
will be committed using the same data dictionary transaction, and (if
needed) piggy-backing the rename of all partition *.ibd files in the
same mini-transaction with the data dictionary transaction commit.
In this way, crash recovery will either replay or roll back the ALTER
TABLE. The worst possible scenario should be that the *.frm file (for
which there is no log-based recovery) gets out of sync with the InnoDB
data dictionary. This problem affects all tables.
handler::commit_inplace_alter_table(): Slightly modify the API. Add
ha_alter_info->group_commit_ctx. When it is NULL, the behaviour is as
usual (commit only the table handle).
When ha_alter_info->group_commit_ctx != NULL, it is assumed to be a
pointer to a NULL-terminated array of ha_alter_info->handler_ctx,
belonging to the partitions of a table. All partitions of the table
will share the TABLE and altered_table objects.
If handler::commit_inplace_alter_table() supports this operation, it
must set ha_alter_info->group_commit_ctx = NULL. In this case,
ha_partition::commit_inplace_alter_table(commit=true) will assume that
the handler::commit_inplace_alter_table(commit=true) for the first
partition committed the changes to all partitions.
The rollback of partitions is unaffected by this. That is,
handler::commit_inplace_alter_table(commit=false) will be invoked on
every partition separately.
The InnoDB changes are described below in detail.
INNOBASE_ALTER_REBUILD: Renamed from INNOBASE_INPLACE_REBUILD.
INNOBASE_ALTER_DATA: Renamed from INNOBASE_INPLACE_CREATE.
INNOBASE_ALTER_NOREBUILD: Replaces INNOBASE_ONLINE_OPERATIONS.
Does not include INNOBASE_INPLACE_IGNORE (no change inside InnoDB).
ha_innobase_inplace_ctx: Replace user_trx with a reference to
prebuilt. ha_innobase::commit_inplace_alter_table() needs to replace
the ha_innobase::prebuilt in every partition. Add old_table and rename
indexed_table to new_table. Add max_autoinc, so that we can preserve
the current auto-increment value for every partition. Add the
predicate ctx->need_rebuild(). Rename add, drop to add_index, drop_index.
ha_innobase::prepare_inplace_alter_table(): Allocate ctx for every
case of CHANGE_CREATE_OPTION, because all changes to InnoDB data
(including the auto-increment value) will now require a ctx object.
innobase_rollback_sec_index(): Replace prebuilt with user_table. Add
the parameter ibool locked instead of hard-wiring locked=FALSE,
because this can be invoked during a commit.
innobase_rename_columns_try(): Replace new_clustered, user_table with ctx.
commit_get_autoinc(), innobase_update_foreign_try(): commit_try_rebuild():
Replace user_table with ctx.
innobase_update_foreign_cache(): commit_cache_rebuild(): Replace all
parameters with ctx.
commit_try_norebuild(): Add the ctx parameter, because there is a 1:N
mapping between ha_alter_info and ctx.
commit_cache_norebuild(): Replace ha_alter_info, user_table with ctx.
commit_update_stats(): Split to alter_stats_norebuild() and
alter_stats_rebuild().
ha_innobase::commit_inplace_alter_table(): Support them
ha_alter_info->group_commit_ctx API. Remove the UNIV_DDL_DEBUG code
that would check the table after a successful ALTER TABLE. (It would
be better done in the caller of commit_inplace_alter_table().)
Before starting the data dictionary modifications, invoke
dict_stats_stop_bg() on every affected dict_table_t object.
dict_stats_wait_bg_to_stop_using_table(): Renamed and simplified from
from dict_stats_wait_bg_to_stop_using_tables().
dict_stats_stop_bg(): New predicate.
DICT_STATS_BG_YIELD(trx): New auxiliary macro.
rb#1939 approved by Jon Olav Hauglid, Sunny Bains1 parent 0e8390c commit 9039dc1
10 files changed
Lines changed: 1061 additions & 855 deletions
File tree
- sql
- storage/innobase
- dict
- handler
- include
- row
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7835 | 7835 | | |
7836 | 7836 | | |
7837 | 7837 | | |
7838 | | - | |
7839 | 7838 | | |
7840 | 7839 | | |
7841 | 7840 | | |
7842 | 7841 | | |
7843 | 7842 | | |
7844 | 7843 | | |
7845 | 7844 | | |
7846 | | - | |
7847 | 7845 | | |
7848 | 7846 | | |
7849 | 7847 | | |
| |||
7862 | 7860 | | |
7863 | 7861 | | |
7864 | 7862 | | |
7865 | | - | |
7866 | 7863 | | |
7867 | 7864 | | |
7868 | 7865 | | |
| 7866 | + | |
7869 | 7867 | | |
7870 | | - | |
7871 | | - | |
7872 | | - | |
7873 | 7868 | | |
7874 | 7869 | | |
7875 | 7870 | | |
| |||
7878 | 7873 | | |
7879 | 7874 | | |
7880 | 7875 | | |
7881 | | - | |
7882 | | - | |
7883 | | - | |
7884 | | - | |
7885 | | - | |
7886 | | - | |
7887 | | - | |
7888 | | - | |
7889 | | - | |
7890 | | - | |
| 7876 | + | |
7891 | 7877 | | |
7892 | | - | |
7893 | | - | |
7894 | | - | |
7895 | | - | |
7896 | | - | |
7897 | | - | |
7898 | 7878 | | |
7899 | 7879 | | |
7900 | 7880 | | |
7901 | 7881 | | |
7902 | 7882 | | |
7903 | 7883 | | |
7904 | | - | |
| 7884 | + | |
7905 | 7885 | | |
7906 | 7886 | | |
7907 | 7887 | | |
7908 | | - | |
| 7888 | + | |
| 7889 | + | |
7909 | 7890 | | |
7910 | 7891 | | |
7911 | 7892 | | |
| |||
7915 | 7896 | | |
7916 | 7897 | | |
7917 | 7898 | | |
| 7899 | + | |
| 7900 | + | |
| 7901 | + | |
| 7902 | + | |
| 7903 | + | |
| 7904 | + | |
| 7905 | + | |
| 7906 | + | |
| 7907 | + | |
| 7908 | + | |
7918 | 7909 | | |
7919 | 7910 | | |
7920 | 7911 | | |
7921 | 7912 | | |
7922 | 7913 | | |
| 7914 | + | |
7923 | 7915 | | |
| 7916 | + | |
| 7917 | + | |
| 7918 | + | |
| 7919 | + | |
| 7920 | + | |
| 7921 | + | |
| 7922 | + | |
7924 | 7923 | | |
7925 | 7924 | | |
7926 | | - | |
7927 | 7925 | | |
7928 | 7926 | | |
7929 | 7927 | | |
| |||
8004 | 8002 | | |
8005 | 8003 | | |
8006 | 8004 | | |
8007 | | - | |
8008 | 8005 | | |
| 8006 | + | |
8009 | 8007 | | |
8010 | 8008 | | |
8011 | 8009 | | |
| |||
8019 | 8017 | | |
8020 | 8018 | | |
8021 | 8019 | | |
8022 | | - | |
8023 | | - | |
8024 | | - | |
8025 | | - | |
| 8020 | + | |
8026 | 8021 | | |
8027 | | - | |
8028 | | - | |
8029 | | - | |
| 8022 | + | |
| 8023 | + | |
| 8024 | + | |
| 8025 | + | |
| 8026 | + | |
| 8027 | + | |
| 8028 | + | |
| 8029 | + | |
8030 | 8030 | | |
8031 | | - | |
8032 | | - | |
8033 | | - | |
8034 | | - | |
8035 | | - | |
8036 | | - | |
8037 | | - | |
| 8031 | + | |
| 8032 | + | |
| 8033 | + | |
| 8034 | + | |
| 8035 | + | |
| 8036 | + | |
| 8037 | + | |
| 8038 | + | |
| 8039 | + | |
| 8040 | + | |
| 8041 | + | |
8038 | 8042 | | |
8039 | | - | |
8040 | | - | |
8041 | | - | |
8042 | | - | |
8043 | | - | |
8044 | | - | |
| 8043 | + | |
| 8044 | + | |
| 8045 | + | |
| 8046 | + | |
8045 | 8047 | | |
8046 | | - | |
8047 | | - | |
8048 | | - | |
8049 | | - | |
8050 | | - | |
8051 | | - | |
8052 | | - | |
8053 | | - | |
8054 | | - | |
8055 | | - | |
8056 | | - | |
8057 | | - | |
8058 | | - | |
8059 | | - | |
8060 | | - | |
8061 | | - | |
8062 | | - | |
8063 | | - | |
8064 | | - | |
8065 | | - | |
8066 | | - | |
8067 | | - | |
8068 | | - | |
8069 | | - | |
8070 | | - | |
8071 | | - | |
8072 | | - | |
8073 | | - | |
8074 | | - | |
8075 | | - | |
8076 | | - | |
8077 | | - | |
8078 | | - | |
8079 | | - | |
8080 | | - | |
8081 | | - | |
8082 | | - | |
8083 | | - | |
8084 | | - | |
8085 | | - | |
8086 | | - | |
8087 | | - | |
8088 | | - | |
8089 | | - | |
8090 | | - | |
8091 | | - | |
8092 | | - | |
8093 | | - | |
8094 | | - | |
8095 | | - | |
8096 | | - | |
8097 | | - | |
8098 | | - | |
8099 | | - | |
8100 | | - | |
8101 | | - | |
8102 | | - | |
8103 | | - | |
8104 | | - | |
8105 | 8048 | | |
8106 | | - | |
8107 | | - | |
8108 | | - | |
| 8049 | + | |
| 8050 | + | |
| 8051 | + | |
| 8052 | + | |
| 8053 | + | |
8109 | 8054 | | |
| 8055 | + | |
8110 | 8056 | | |
8111 | 8057 | | |
8112 | 8058 | | |
8113 | | - | |
8114 | | - | |
8115 | | - | |
8116 | | - | |
8117 | | - | |
8118 | | - | |
8119 | | - | |
8120 | | - | |
| 8059 | + | |
8121 | 8060 | | |
8122 | | - | |
8123 | | - | |
8124 | | - | |
8125 | | - | |
8126 | | - | |
8127 | | - | |
8128 | 8061 | | |
8129 | | - | |
| 8062 | + | |
8130 | 8063 | | |
8131 | 8064 | | |
8132 | | - | |
| 8065 | + | |
8133 | 8066 | | |
8134 | 8067 | | |
8135 | 8068 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1264 | 1264 | | |
1265 | 1265 | | |
1266 | 1266 | | |
| 1267 | + | |
| 1268 | + | |
| 1269 | + | |
| 1270 | + | |
| 1271 | + | |
| 1272 | + | |
| 1273 | + | |
| 1274 | + | |
| 1275 | + | |
| 1276 | + | |
| 1277 | + | |
| 1278 | + | |
1267 | 1279 | | |
1268 | 1280 | | |
1269 | 1281 | | |
| |||
1311 | 1323 | | |
1312 | 1324 | | |
1313 | 1325 | | |
| 1326 | + | |
1314 | 1327 | | |
1315 | 1328 | | |
1316 | 1329 | | |
| |||
2926 | 2939 | | |
2927 | 2940 | | |
2928 | 2941 | | |
| 2942 | + | |
| 2943 | + | |
| 2944 | + | |
| 2945 | + | |
2929 | 2946 | | |
2930 | 2947 | | |
2931 | 2948 | | |
| |||
2940 | 2957 | | |
2941 | 2958 | | |
2942 | 2959 | | |
2943 | | - | |
| 2960 | + | |
| 2961 | + | |
| 2962 | + | |
| 2963 | + | |
| 2964 | + | |
2944 | 2965 | | |
2945 | 2966 | | |
2946 | 2967 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
31 | 35 | | |
32 | 36 | | |
33 | 37 | | |
| |||
174 | 178 | | |
175 | 179 | | |
176 | 180 | | |
177 | | - | |
| 181 | + | |
178 | 182 | | |
179 | 183 | | |
180 | 184 | | |
181 | | - | |
182 | | - | |
| 185 | + | |
| 186 | + | |
183 | 187 | | |
184 | 188 | | |
185 | 189 | | |
186 | 190 | | |
187 | | - | |
188 | | - | |
189 | | - | |
190 | | - | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
191 | 194 | | |
192 | 195 | | |
193 | 196 | | |
194 | | - | |
195 | | - | |
196 | | - | |
197 | | - | |
198 | | - | |
199 | | - | |
200 | | - | |
201 | | - | |
202 | | - | |
203 | | - | |
204 | | - | |
205 | | - | |
206 | | - | |
207 | | - | |
| 197 | + | |
| 198 | + | |
208 | 199 | | |
209 | 200 | | |
210 | 201 | | |
| |||
0 commit comments