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

ddl: Do not physical drop table after tiflash replica is set to 0 (#9440) #9441

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
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
10 changes: 8 additions & 2 deletions dbms/src/TiDB/Schema/SchemaBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,6 @@ void SchemaBuilder<Getter, NameMapper>::applySetTiFlashReplica(DatabaseID databa
auto & tmt_context = context.getTMTContext();
if (table_info->replica_info.count == 0)
{
// Replicat number is to 0, mark the table as tombstone in TiFlash
auto storage = tmt_context.getStorages().get(keyspace_id, table_info->id);
if (unlikely(storage == nullptr))
{
Expand All @@ -402,7 +401,14 @@ void SchemaBuilder<Getter, NameMapper>::applySetTiFlashReplica(DatabaseID databa
return;
}

applyDropTable(database_id, table_id, "SetTiFlashReplica-0");
// We can not mark the table is safe to be physically drop from the tiflash instances when
// the number of tiflash replica is set to be 0.
// There could be a concurrent issue that cause data loss. Check the following link for details:
// https://github.com/pingcap/tiflash/issues/9438#issuecomment-2360370761
// applyDropTable(database_id, table_id, "SetTiFlashReplica-0");

// Now only update the replica number to be 0 instead
updateTiFlashReplicaNumOnStorage(database_id, table_id, storage, table_info);
return;
}

Expand Down
4 changes: 1 addition & 3 deletions tests/fullstack-test2/ddl/alter_table_tiflash_replica.test
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,11 @@ mysql> set session tidb_isolation_read_engines='tiflash';select * from test.t;
| x |
+----+
| 1 |
+----+
| 8 |
+----+
| 50 |
+----+

>> DBGInvoke get_partition_tables_tiflash_replica_count("test", "t")
┌─get_partition_tables_tiflash_replica_count(test, t)─┐
│ 1/1/1/ │
└─────────────────────────────────────────────────────┘
└─────────────────────────────────────────────────────┘