diff --git a/ddl/partition.go b/ddl/partition.go index 2da94facae0e1..ea28cfaa32bfd 100644 --- a/ddl/partition.go +++ b/ddl/partition.go @@ -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 diff --git a/ddl/placement_policy_test.go b/ddl/placement_policy_test.go index 0b2c3f29b21ca..eeed00751e416 100644 --- a/ddl/placement_policy_test.go +++ b/ddl/placement_policy_test.go @@ -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) {