diff --git a/.github/workflows/linters.yml b/.github/workflows/linters.yml index 6702833..72d5d4d 100644 --- a/.github/workflows/linters.yml +++ b/.github/workflows/linters.yml @@ -18,6 +18,6 @@ jobs: - name: Run linter uses: golangci/golangci-lint-action@v6.0.1 # Action page: with: - version: v1.57 # without patch version + version: v1.59 # without patch version only-new-issues: false # show only new issues if it's a pull request args: --timeout=10m --build-tags=race diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 7dcf927..860c016 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -26,7 +26,7 @@ jobs: strategy: fail-fast: false matrix: - php: ["8.2"] + php: ["8.3"] go: [stable] os: ["ubuntu-latest"] steps: diff --git a/pool/static_pool/pool_test.go b/pool/static_pool/pool_test.go index 7ade03c..4f9735b 100644 --- a/pool/static_pool/pool_test.go +++ b/pool/static_pool/pool_test.go @@ -178,7 +178,8 @@ func Test_StaticPool_RemoveWorker(t *testing.T) { _, err = p.Exec(ctx, &payload.Payload{Body: []byte("hello"), Context: nil}, make(chan struct{})) assert.NoError(t, err) - assert.Len(t, p.Workers(), 1) + // after removing all workers, we should have 1 worker + 1 we added + assert.Len(t, p.Workers(), 2) p.Destroy(ctx) } diff --git a/pool/static_pool/supervisor_test.go b/pool/static_pool/supervisor_test.go index be74819..a2d8709 100644 --- a/pool/static_pool/supervisor_test.go +++ b/pool/static_pool/supervisor_test.go @@ -174,7 +174,7 @@ func Test_SupervisedPool_RemoveNoWorkers(t *testing.T) { assert.NoError(t, p.RemoveWorker(ctx)) } - assert.Len(t, p.Workers(), 0) + assert.Len(t, p.Workers(), 1) p.Destroy(ctx) } @@ -208,7 +208,7 @@ func Test_SupervisedPool_RemoveWorker(t *testing.T) { _, err = p.Exec(ctx, &payload.Payload{Body: []byte("hello"), Context: nil}, make(chan struct{})) assert.NoError(t, err) - assert.Len(t, p.Workers(), 1) + assert.Len(t, p.Workers(), 2) p.Destroy(ctx) } diff --git a/worker_watcher/worker_watcher.go b/worker_watcher/worker_watcher.go index 1a54885..ce0f866 100644 --- a/worker_watcher/worker_watcher.go +++ b/worker_watcher/worker_watcher.go @@ -80,6 +80,12 @@ func (ww *WorkerWatcher) RemoveWorker(ctx context.Context) error { return err } + // can't remove the last worker + if atomic.LoadUint64(&ww.numWorkers) == 1 { + ww.log.Warn("can't remove the last worker", zap.Int64("pid", w.Pid())) + return nil + } + // destroy and stop w.State().Transition(fsm.StateDestroyed) _ = w.Stop() @@ -403,6 +409,10 @@ func (ww *WorkerWatcher) wait(w *worker.Process) { err = ww.Allocate() if err != nil { ww.log.Error("failed to allocate the worker", zap.String("internal_event_name", events.EventWorkerError.String()), zap.Error(err)) + if atomic.LoadUint64(&ww.numWorkers) == 0 { + panic("no workers available, can't run the application") + } + return }