Skip to content

Commit

Permalink
Update schema version in set tiflash mode (#5402)
Browse files Browse the repository at this point in the history
ref #5252
  • Loading branch information
hongyunyan authored Jul 19, 2022
1 parent 6560ada commit c0f7cac
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
1 change: 1 addition & 0 deletions dbms/src/TiDB/Schema/SchemaBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1323,6 +1323,7 @@ void SchemaBuilder<Getter, NameMapper>::applySetTiFlashModeOnPhysicalTable(

TiDB::TableInfo table_info = storage->getTableInfo();
table_info.tiflash_mode = latest_table_info->tiflash_mode;
table_info.schema_version = target_version;
AlterCommands commands;

LOG_FMT_INFO(log, "Updating tiflash mode for {} to {}", name_mapper.debugCanonicalName(*db_info, table_info), TiFlashModeToString(table_info.tiflash_mode));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,4 +142,27 @@ mysql> set session tidb_isolation_read_engines='tiflash'; select * from test.t;
| 1 | 2|
| 2 | 4|
| 5 | 7|
+------+-----+
+------+-----+

## test the case across 'do query' and 'set tiflash mode'

=> DBGInvoke __enable_schema_sync_service('false')

## TODO: case1 can not simulation in this script
# case 1 : start query (set failpoint) --> set tiflash mode and refresh schema --> continue query, and due to query_version < local_schema, query fail

# case 2 : set tiflash mode first, then do query --> local_schema < query_schema_version --> sync schema and do query in the new mode
mysql> alter table test.t set tiflash mode normal;

# query in normal mode
mysql> set session tidb_isolation_read_engines='tiflash'; select * from test.t;
+------+-----+
| a | b |
+------+-----+
| 2 | 4|
| 5 | 7|
+------+-----+


=> DBGInvoke __enable_schema_sync_service('true')

0 comments on commit c0f7cac

Please sign in to comment.