Skip to content
This repository has been archived by the owner on Feb 6, 2024. It is now read-only.

Commit

Permalink
fix: wrong shard id when drop non-exist table
Browse files Browse the repository at this point in the history
  • Loading branch information
ShiKaiWi committed Sep 13, 2023
1 parent bb34836 commit c7a63d8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
8 changes: 3 additions & 5 deletions server/coordinator/factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ func TestDropTable(t *testing.T) {
re := require.New(t)
ctx := context.Background()
f, m := setupFactory(t)
// Create normal table procedure.
p, err := f.CreateDropTableProcedure(ctx, coordinator.DropTableRequest{
// Drop normal table procedure.
_, err := f.CreateDropTableProcedure(ctx, coordinator.DropTableRequest{
ClusterMetadata: m,
ClusterSnapshot: m.GetClusterSnapshot(),
SourceReq: &metaservicepb.DropTableRequest{
Expand All @@ -91,9 +91,7 @@ func TestDropTable(t *testing.T) {
OnSucceeded: nil,
OnFailed: nil,
})
re.NoError(err)
re.Equal(procedure.DropTable, p.Typ())
re.Equal(procedure.StateInit, string(p.State()))
re.Error(err)

// Create partition table procedure.
_, err = f.CreateDropTableProcedure(ctx, coordinator.DropTableRequest{
Expand Down
2 changes: 1 addition & 1 deletion server/coordinator/procedure/ddl/droptable/drop_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ func validateTable(params ProcedureParams) (storage.ShardID, error) {
}
if !exists {
log.Error("drop non-existing table", zap.String("schema", params.SourceReq.GetSchemaName()), zap.String("table", params.SourceReq.GetName()))
return 0, err
return 0, errors.WithMessagef(metadata.ErrTableNotFound, "The table to drop doesn't exists, schema:%s, table:%s", params.SourceReq.GetSchemaName(), params.SourceReq.GetName())
}

for _, shardView := range params.ClusterSnapshot.Topology.ShardViewsMapping {
Expand Down

0 comments on commit c7a63d8

Please sign in to comment.