Potential Resource Leaks and Tenant Isolation Issues in Changefeed Creation and SchemaStorage Initialization
Open
@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
- 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
}
- 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.