statistics: fix the panic when to async load stats with dropped index (#58887)

close pingcap/tidb#58865
This commit is contained in:
Weizhen Wang
2025-01-15 21:23:19 +08:00
committed by GitHub
parent aa21818786
commit 6180fb7358

View File

@ -746,6 +746,10 @@ func loadNeededIndexHistograms(sctx sessionctx.Context, is infoschema.InfoSchema
return nil
}
idxInfo := tblInfo.Meta().FindIndexByID(idx.ID)
if idxInfo == nil {
asyncload.AsyncLoadHistogramNeededItems.Delete(idx)
return errors.NotFoundf("index %d in table %d", idx.ID, idx.TableID)
}
hg, err := HistogramFromStorageWithPriority(sctx, idx.TableID, idx.ID, types.NewFieldType(mysql.TypeBlob), hgMeta.NDV, 1, hgMeta.LastUpdateVersion, hgMeta.NullCount, hgMeta.TotColSize, hgMeta.Correlation, kv.PriorityHigh)
if err != nil {
return errors.Trace(err)