Skip to content

Commit

Permalink
chore: change order of queries on connect to an engine (#13)
Browse files Browse the repository at this point in the history
When a connection to an engine is established, the `SET...` queries must
be run after `USE ENGINE..` statement, otherwise they will be discarder
  • Loading branch information
alexkaplun-firebolt authored Sep 9, 2024
1 parent 9b15380 commit d63c390
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ jobs:
- name: Lint
uses: golangci/golangci-lint-action@v6
with:
version: v1.58
version: v1.60
- name: Test
run: go test -vet=all ./...
12 changes: 6 additions & 6 deletions internal/fetcher/fetcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,18 +223,18 @@ func (f *fetcher) connect(ctx context.Context, accountName string, engineName st

// switch to the engine if engineName is provided
if engineName != "" {
// prevent engine from auto stopping caused by exporter queries
_, err = db.ExecContext(ctx, `SET auto_start_stop_control=ignore;`)
if err != nil {
return nil, fmt.Errorf("failed to set auto_start_stop_control = ignore for engine %s: %w", engineName, err)
}

// switch to an engine
_, err = db.ExecContext(ctx, fmt.Sprintf(`USE ENGINE "%s";`, engineName))
if err != nil {
return nil, fmt.Errorf("failed to switch to engine %s: %w", engineName, err)
}

// prevent engine from auto stopping caused by exporter queries
_, err = db.ExecContext(ctx, `SET auto_start_stop_control=ignore;`)
if err != nil {
return nil, fmt.Errorf("failed to set auto_start_stop_control = ignore for engine %s: %w", engineName, err)
}

// add a query label to appear in query history
_, err = db.ExecContext(ctx, `SET query_label=otel-exporter;`)
if err != nil {
Expand Down

0 comments on commit d63c390

Please sign in to comment.