Skip to content

Commit

Permalink
add comment for SchemaBuilder
Browse files Browse the repository at this point in the history
  • Loading branch information
hongyunyan committed Jun 14, 2022
1 parent 04d99ff commit 0b5b619
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion dbms/src/TiDB/Schema/SchemaBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,8 @@ void SchemaBuilder<Getter, NameMapper>::applyAlterPhysicalTable(DBInfoPtr db_inf
const auto & schema_change = schema_changes[i];
/// Update column infos by applying schema change in this step.
schema_change.second(orig_table_info);
/// Update schema version aggressively for the sake of correctness.
/// Update schema version aggressively for the sake of correctness(for read part).
/// In read action, we will use table_info.schema_version(storage_version) and TiDBSchemaSyncer.cur_version(global_version) to compare with query_version, to decide whether we can read under this query_version, or we need to make the schema newer. In our comparison logic, we must ensure storage_version <= gloabl_version. Thus, when the table need apply multi diffs here, we must update schema version aggressively to ensure storage_version <= gloabl_version. The more detail info you can refer the comments in DAGStorageInterpreter::getAndLockStorages.
orig_table_info.schema_version = target_version;
auto alter_lock = storage->lockForAlter(getThreadName());
storage->alterFromTiDB(
Expand Down

0 comments on commit 0b5b619

Please sign in to comment.