Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Goroutine leak at conn_http_query.go #1456

Open
4 of 9 tasks
Wmuga opened this issue Dec 20, 2024 · 0 comments
Open
4 of 9 tasks

Goroutine leak at conn_http_query.go #1456

Wmuga opened this issue Dec 20, 2024 · 0 comments

Comments

@Wmuga
Copy link

Wmuga commented Dec 20, 2024

Observed

goroutine leak at github.com/ClickHouse/clickhouse-go/v2.(*httpConnect).query.func1 (conn_http_query.go:98)

I guess these are just errors that are not read from a channel

Pprof output
pprof output
pprof raw

Expected behaviour

no goroutine leak :)

Code example

Select from clickhouse using *sql.DB

package dh

func (d *dataHolder) Select(ctx context.Context, query string, timeStr string) (res [][]interface{}, err error) {
  t, err := time.Parse(time.DateTime, timeStr)
  if err != nil {
    return nil, err
  }  

  rows, err = d.db.QueryContext(ctx, query, timeStr)
  if err != nil {
    return nil, err
  }
  defer rows.Close()
  cols, err := rows.Columns()
  if err != nil {
    return nil, err
  }
  
  for rows.Next() {
    vals := make([]interface{}, len(cols), len(cols)+1)
    for i := range vals {
      vals[i] = new(interface{})
    }
    err = rows.Scan(vals...)
    vals = append(vals, t.Unix())
    if err != nil {
      return nil, err
    }
    res = append(res, vals)
  }
  return res, nil
}

But I'm not sure if Its Select's "fault". Maybe it's a ping check on interval

func (d *dataHolder) ping(ctx context.Context) (err error) {
	ctxTimeout, cancel := context.WithTimeout(ctx, pingTimeout)
	defer cancel()
	return d.db.PingContext(ctxTimeout)
}

Details

Environment

  • clickhouse-go version: v2.30.0
  • Interface: database/sql compatible driver
  • Go version: 1.22.3
  • Operating system: linux/amd64
  • ClickHouse version:
  • Is it a ClickHouse Cloud?
  • ClickHouse Server non-default settings, if any:
  • CREATE TABLE statements for tables involved:
  • Sample data for all these tables, use clickhouse-obfuscator if necessary
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant