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

Runtime: Refactor conn cache to contain and detect hanging opens/closes #3666

Merged
344 changes: 75 additions & 269 deletions runtime/connection_cache.go

Large diffs are not rendered by default.

417 changes: 0 additions & 417 deletions runtime/connection_cache_test.go

This file was deleted.

4 changes: 2 additions & 2 deletions runtime/connections.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func (r *Runtime) AcquireSystemHandle(ctx context.Context, connector string) (dr
cfg[strings.ToLower(k)] = v
}
cfg["allow_host_access"] = r.opts.AllowHostAccess
return r.connCache.get(ctx, "", c.Type, cfg, true)
return r.getConnection(ctx, "", c.Type, cfg, true)
}
}
return nil, nil, fmt.Errorf("connector %s doesn't exist", connector)
Expand All @@ -36,7 +36,7 @@ func (r *Runtime) AcquireHandle(ctx context.Context, instanceID, connector strin
// So we take this moment to make sure the ctx gets checked for cancellation at least every once in a while.
return nil, nil, ctx.Err()
}
return r.connCache.get(ctx, instanceID, driver, cfg, false)
return r.getConnection(ctx, instanceID, driver, cfg, false)
}

func (r *Runtime) Repo(ctx context.Context, instanceID string) (drivers.RepoStore, func(), error) {
Expand Down
2 changes: 1 addition & 1 deletion runtime/drivers/duckdb/duckdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -806,7 +806,7 @@ func (c *connection) periodicallyCheckConnDurations(d time.Duration) {
c.connTimesMu.Lock()
for connID, connTime := range c.connTimes {
if time.Since(connTime) > maxAcquiredConnDuration {
c.logger.Error("duckdb: a connection has been held for more longer than the maximum allowed duration", zap.Int("conn_id", connID), zap.Duration("duration", time.Since(connTime)))
c.logger.Error("duckdb: a connection has been held for longer than the maximum allowed duration", zap.Int("conn_id", connID), zap.Duration("duration", time.Since(connTime)))
}
}
c.connTimesMu.Unlock()
Expand Down
Loading