Skip to content

TTL job iteration will iterate the last item for multiple times #59347

@YangKeao

Description

@YangKeao

The code of TTL includes this pattern:

for _, job := range m.runningJobs {
    ...
    m.removeJob(job)
    ...
}

It will have two bad effects:

  1. Some jobs will be skipped during one iteration. If the 4th job is removed, the 5th job will not be iterated.
  2. The last job will be iterated for multiple times.

The best practice (IMO) to solve this issue is to reverse interating:

for i := len(m.runningJobs) - 1; i >= 0; i-- {
    ...
    m.removeJob(job)
    ...
}

Metadata

Metadata

Assignees

Labels

affects-7.1This bug affects the 7.1.x(LTS) versions.affects-7.5This bug affects the 7.5.x(LTS) versions.affects-8.1This bug affects the 8.1.x(LTS) versions.affects-8.5This bug affects the 8.5.x(LTS) versions.severity/majorsig/sql-infraSIG: SQL Infratype/bugThe issue is confirmed as a bug.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions