Skip to content

Commit

Permalink
ddl: fix bug that new partition will not set the placement policy aft…
Browse files Browse the repository at this point in the history
…er truncated (#44043)

close #44031
  • Loading branch information
lcwangchao authored May 22, 2023
1 parent d40a94f commit 6d05f7e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
10 changes: 10 additions & 0 deletions ddl/partition.go
Original file line number Diff line number Diff line change
Expand Up @@ -1980,6 +1980,16 @@ func onTruncateTablePartition(d *ddlCtx, t *meta.Meta, job *model.Job) (int64, e
return ver, errors.Trace(err)
}

tableBundle, err := placement.NewTableBundle(t, tblInfo)
if err != nil {
job.State = model.JobStateCancelled
return ver, errors.Trace(err)
}

if tableBundle != nil {
bundles = append(bundles, tableBundle)
}

err = infosync.PutRuleBundlesWithDefaultRetry(context.TODO(), bundles)
if err != nil {
job.State = model.JobStateCancelled
Expand Down
1 change: 1 addition & 0 deletions ddl/placement_policy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1854,6 +1854,7 @@ func TestTruncateTablePartitionWithPlacement(t *testing.T) {
" PARTITION `p1` VALUES LESS THAN (1000) /*T![placement] PLACEMENT POLICY=`p2` */,\n" +
" PARTITION `p2` VALUES LESS THAN (10000) /*T![placement] PLACEMENT POLICY=`p3` */,\n" +
" PARTITION `p3` VALUES LESS THAN (100000))"))
checkExistTableBundlesInPD(t, dom, "test", "tp")
}

func TestTruncatePartitionGCWithPlacement(t *testing.T) {
Expand Down

0 comments on commit 6d05f7e

Please sign in to comment.