Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

schema : make update to partition tables when 'set tiflash replica' #5267

Merged
merged 8 commits into from
Jul 7, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 21 additions & 4 deletions dbms/src/TiDB/Schema/SchemaBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1200,21 +1200,38 @@ void SchemaBuilder<Getter, NameMapper>::applySetTiFlashReplica(TiDB::DBInfoPtr d
{
throw TiFlashException(fmt::format("miss table in TiKV : {}", table_id), Errors::DDL::StaleSchema);
}

if (latest_table_info->isLogicalPartitionTable())
{
for (const auto & part_def : latest_table_info->partition.definitions)
{
auto new_table_info = latest_table_info->producePartitionTableInfo(part_def.id, name_mapper);
applySetTiFlashReplica(db_info, new_table_info);
hongyunyan marked this conversation as resolved.
Show resolved Hide resolved
}
}

applySetTiFlashReplica(db_info, latest_table_info);
}

template <typename Getter, typename NameMapper>
void SchemaBuilder<Getter, NameMapper>::applySetTiFlashReplica(TiDB::DBInfoPtr db_info, TiDB::TableInfoPtr table_info)
hongyunyan marked this conversation as resolved.
Show resolved Hide resolved
{
auto & tmt_context = context.getTMTContext();
auto storage = tmt_context.getStorages().get(latest_table_info->id);
auto storage = tmt_context.getStorages().get(table_info->id);
if (unlikely(storage == nullptr))
{
throw TiFlashException(fmt::format("miss table in TiFlash : {}", name_mapper.debugCanonicalName(*db_info, *latest_table_info)),
throw TiFlashException(fmt::format("miss table in TiFlash : {}", name_mapper.debugCanonicalName(*db_info, *table_info)),
Errors::DDL::MissingTable);
}

auto managed_storage = std::dynamic_pointer_cast<IManageableStorage>(storage);
if (unlikely(!managed_storage))
throw Exception(fmt::format("{} is not a ManageableStorage", name_mapper.debugCanonicalName(*db_info, *latest_table_info)));
throw Exception(fmt::format("{} is not a ManageableStorage", name_mapper.debugCanonicalName(*db_info, *table_info)));

applySetTiFlashReplica(db_info, latest_table_info, managed_storage);
applySetTiFlashReplica(db_info, table_info, managed_storage);
}


template <typename Getter, typename NameMapper>
void SchemaBuilder<Getter, NameMapper>::applySetTiFlashReplica(
hongyunyan marked this conversation as resolved.
Show resolved Hide resolved
TiDB::DBInfoPtr db_info,
Expand Down
1 change: 1 addition & 0 deletions dbms/src/TiDB/Schema/SchemaBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ struct SchemaBuilder
void applyExchangeTablePartition(const SchemaDiff & diff);

void applySetTiFlashReplica(TiDB::DBInfoPtr db_info, TableID table_id);
void applySetTiFlashReplica(TiDB::DBInfoPtr db_info, TiDB::TableInfoPtr table_info);
void applySetTiFlashReplica(TiDB::DBInfoPtr db_info, TiDB::TableInfoPtr table_info, ManageableStoragePtr storage);
};

Expand Down