From 6039cd3ab46ef313dd2089333f5116028cd80006 Mon Sep 17 00:00:00 2001 From: Quinn Klassen Date: Sat, 23 Sep 2023 21:26:54 -0700 Subject: [PATCH] Disable running sessions on a versioned worker (#1241) --- internal/internal_worker.go | 6 ++++++ internal/internal_worker_test.go | 11 +++++++++++ internal/worker.go | 1 + 3 files changed, 18 insertions(+) diff --git a/internal/internal_worker.go b/internal/internal_worker.go index 39947ceb5..998d7b91f 100644 --- a/internal/internal_worker.go +++ b/internal/internal_worker.go @@ -1483,6 +1483,12 @@ func NewAggregatedWorker(client *WorkflowClient, taskQueue string, options Worke panic("cannot set MaxConcurrentWorkflowTaskExecutionSize to 1") } + // Sessions are not currently compatible with worker versioning + // See: https://github.com/temporalio/sdk-go/issues/1227 + if options.EnableSessionWorker && options.UseBuildIDForVersioning { + panic("cannot set both EnableSessionWorker and UseBuildIDForVersioning") + } + // Need reference to result for fatal error handler var aw *AggregatedWorker fatalErrorCallback := func(err error) { diff --git a/internal/internal_worker_test.go b/internal/internal_worker_test.go index 9058891b6..14d857088 100644 --- a/internal/internal_worker_test.go +++ b/internal/internal_worker_test.go @@ -2778,6 +2778,17 @@ func TestWorkerRegisterDisabledWorkflow(t *testing.T) { require.Equal(t, "workflow worker disabled, cannot register workflow", recovered) } +func TestWorkerBuildIDAndSessionPanic(t *testing.T) { + // Expect panic + var recovered interface{} + func() { + defer func() { recovered = recover() }() + worker := NewAggregatedWorker(&WorkflowClient{}, "some-task-queue", WorkerOptions{EnableSessionWorker: true, UseBuildIDForVersioning: true}) + worker.RegisterWorkflow(testReplayWorkflow) + }() + require.Equal(t, "cannot set both EnableSessionWorker and UseBuildIDForVersioning", recovered) +} + func TestHistoryFromJSON(t *testing.T) { // Load sample history and just make sure it has the right event count r, err := os.Open("testdata/sampleHistory.json") diff --git a/internal/worker.go b/internal/worker.go index 433128b93..125942c91 100644 --- a/internal/worker.go +++ b/internal/worker.go @@ -238,6 +238,7 @@ type ( // operate on workflows it claims to be compatible with. You must set BuildID if this flag // is true. // NOTE: Experimental + // Note: Cannot be enabled at the same time as EnableSessionWorker UseBuildIDForVersioning bool } )