pingcap / pingcap/ticdc

Potential Resource Leaks and Tenant Isolation Issues in Changefeed Creation and SchemaStorage Initialization

Open
#2,352 1 comment 0 reactions 1 assignee View on GitHub

@tenfyzhong is already working on this.

Since Sep 26, 2025.

ga-optional type/enhancement
Dominant language
Go
Stars
56
Forks
63
Avg merge
2d 20h
Merged PRs (30d)
34

Description

  1. When creating a changefeed, RegisterKeyspace is directly called during API request processing with context.Background(). If the subsequent changefeed creation process fails, this will lead to resource leaks.
	// The ctx's lifecycle is the same as the HTTP request.
	// The schema store may use the context to fetch database information asynchronously.
	// Therefore, we cannot use the context of the HTTP request.
	// We create a new context here.
	schemaCxt := context.Background()
	if err := schemaStore.RegisterKeyspace(schemaCxt, keyspaceName); err != nil {
		_ = c.Error(err)
		return
	}
  1. There are numerous fatal and panic logs in the schemaStorage initialization path. After supporting multi-keyspace, these logs may become a hidden danger - if one tenant encounters problems, it will affect all tenants.
if err := os.RemoveAll(dbPath); err != nil {
		**log.Panic("fail to remove path")**
	}

	isDataReusable := false
	if exists(dbPath) {
		isDataReusable = true
		db := openDB(dbPath)
		// check whether the data on disk is reusable
		gcTs, err := readGcTs(db)
		if err != nil {
			isDataReusable = false
		}
		if gcSafePoint < gcTs {
			**log.Panic("gc safe point should never go back")**
		}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.