Skip to content

there are some memory leak in TTL's implement #45510

@lcwangchao

Description

@lcwangchao

If you run tidb with a very long time with many TTL tables, you can seem some memory leak:

image

  1. dettachStatsCollector , see:

tidb/session/session.go

Lines 3660 to 3665 in 9e20208

func detachStatsCollector(s *session) *session {
s.statsCollector = nil
s.idxUsageCollector = nil
return s
}

it only sets two collectors to nil but did not call Delete for it.

  1. The context created here is not guaranteed to be cancelled finally:

ctx, cancel := context.WithCancel(m.ctx)
scanTask := &ttlScanTask{
ctx: ctx,
TTLTask: task,
tbl: table,
statistics: &ttlStatistics{},
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions