diff --git a/.github/workflows/e2e-test.yml b/.github/workflows/e2e-test.yml index 89b80dc00..9f8b6d798 100644 --- a/.github/workflows/e2e-test.yml +++ b/.github/workflows/e2e-test.yml @@ -46,7 +46,7 @@ jobs: if: steps.changes.outputs.go == 'true' run: | cd test/e2e/ - go test ./... -run '^TestE2E.*$' -tags e2e -v + go test ./... -run '^TestE2E.*$' -tags e2e -race -v env: # DATA_PROXY_DATABASE_URL: ${{ secrets.DATA_PROXY_DATABASE_URL }} PRISMA_CLIENT_GO_LOG: info diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4f7d7c710..4839e22bd 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -41,4 +41,4 @@ jobs: - name: test if: steps.changes.outputs.go == 'true' - run: go test ./... -v -failfast + run: go test ./... -race -v -failfast diff --git a/.run/test all.run.xml b/.run/test all.run.xml index 70c8da84a..e7adfa394 100644 --- a/.run/test all.run.xml +++ b/.run/test all.run.xml @@ -1,33 +1,34 @@ - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/engine/lifecycle.go b/engine/lifecycle.go index 013ac7b88..eeb1a8f36 100644 --- a/engine/lifecycle.go +++ b/engine/lifecycle.go @@ -286,10 +286,13 @@ func (e *QueryEngine) spawn(file string) error { // send a basic readiness healthcheck and retry if unsuccessful var connectErr error for i := 0; i < 100; i++ { + e.mu.Lock() // return an error early if an engine error already happened if e.lastEngineError != "" { + e.mu.Unlock() return fmt.Errorf("query engine errored: %w", fmt.Errorf(e.lastEngineError)) } + e.mu.Unlock() body, err := e.Request(context.Background(), "GET", "/status", map[string]interface{}{}, false) if err != nil { diff --git a/engine/qe.go b/engine/qe.go index b8259d14f..2f4eae13f 100644 --- a/engine/qe.go +++ b/engine/qe.go @@ -3,6 +3,7 @@ package engine import ( "net/http" "os/exec" + "sync" ) func NewQueryEngine(schema string, hasBinaryTargets bool, datasources string, datasourceURL string) *QueryEngine { @@ -52,6 +53,8 @@ type QueryEngine struct { // lastEngineError contains the last received error lastEngineError string + + mu sync.Mutex } func (e *QueryEngine) Name() string { diff --git a/engine/stream.go b/engine/stream.go index 6a58f3e05..1721f41f5 100644 --- a/engine/stream.go +++ b/engine/stream.go @@ -26,7 +26,9 @@ func (e *QueryEngine) streamStderr(cmd *exec.Cmd, onError chan<- string) error { for { select { case v := <-e.onEngineError: + e.mu.Lock() e.lastEngineError = v + e.mu.Unlock() case <-e.closed: logger.Debug.Printf("query engine closed") break outer