lightning: check counter value to make code more robust (#37380)
lightning: check counter value to make code more robust (#37380)

ref pingcap/tidb#37338
pingcap/tidb,pingcap/tidb,pingcap/tidb,pingcap/tidb,pingcap/tidb,pingcap/tidb