Skip to content

Commit

Permalink
Skip updating the tombstone_ts if the table is already tombstone.
Browse files Browse the repository at this point in the history
Signed-off-by: JaySon-Huang <tshent@qq.com>
  • Loading branch information
JaySon-Huang committed Jul 12, 2024
1 parent 4fd8b86 commit 63e72c4
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions dbms/src/TiDB/Schema/SchemaBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1285,8 +1285,16 @@ void SchemaBuilder<Getter, NameMapper>::applyDropPhysicalTable(const String & db
LOG_DEBUG(log, "table {} does not exist.", table_id);
return;
}

// Skip updating the tombstone_ts if the table is already tombstone.
if (auto tombstone_ts = storage->getTombstone(); tombstone_ts != 0)
{
LOG_INFO(log, "Tombstone table {}.{} has been done before, tombstone={}", db_name, name_mapper.debugTableName(storage->getTableInfo()), tombstone_ts);
return;
}

GET_METRIC(tiflash_schema_internal_ddl_count, type_drop_table).Increment();
LOG_INFO(log, "Tombstoning table {}.{}", db_name, name_mapper.debugTableName(storage->getTableInfo()));
LOG_INFO(log, "Tombstone table {}.{} begin", db_name, name_mapper.debugTableName(storage->getTableInfo()));
const UInt64 tombstone_ts = PDClientHelper::getTSO(tmt_context.getPDClient(), PDClientHelper::get_tso_maxtime);
AlterCommands commands;
{
Expand All @@ -1302,7 +1310,7 @@ void SchemaBuilder<Getter, NameMapper>::applyDropPhysicalTable(const String & db
}
auto alter_lock = storage->lockForAlter(getThreadNameAndID());
storage->alterFromTiDB(alter_lock, commands, db_name, storage->getTableInfo(), name_mapper, context);
LOG_INFO(log, "Tombstoned table {}.{}, tombstone={}", db_name, name_mapper.debugTableName(storage->getTableInfo()), tombstone_ts);
LOG_INFO(log, "Tombstone table {}.{} end, tombstone={}", db_name, name_mapper.debugTableName(storage->getTableInfo()), tombstone_ts);
}

template <typename Getter, typename NameMapper>
Expand Down

0 comments on commit 63e72c4

Please sign in to comment.