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 (pingcap#44043) (pingcap#44061)

close pingcap#44031
  • Loading branch information
ti-chi-bot authored and lcwangchao committed May 24, 2023
1 parent e189cd5 commit 0535004
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 @@ -1883,6 +1883,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 @@ -1835,6 +1835,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 0535004

Please sign in to comment.