File tree 1 file changed +9
-0
lines changed
1 file changed +9
-0
lines changed Original file line number Diff line number Diff line change 8
8
"time"
9
9
10
10
"github.com/content-services/content-sources-backend/pkg/config"
11
+ ce "github.com/content-services/content-sources-backend/pkg/errors"
11
12
m "github.com/content-services/content-sources-backend/pkg/instrumentation"
12
13
"github.com/content-services/content-sources-backend/pkg/models"
13
14
"github.com/content-services/content-sources-backend/pkg/tasks"
@@ -175,6 +176,14 @@ func (w *worker) process(ctx context.Context, taskInfo *models.TaskInfo) {
175
176
176
177
handlerErr := handler (ctx , taskInfo , & w .queue )
177
178
179
+ // Exit early if the server exits to allow the task to requeue. Finish is not needed.
180
+ // We do not want to clear the running task, mark the worker as ready, or record a message result
181
+ // because we expect the task to requeue and the worker to exit
182
+ if errors .Is (handlerErr , ce .ErrServerExited ) {
183
+ w .runningTask .taskCancelFunc (queue .ErrNotRunning )
184
+ return
185
+ }
186
+
178
187
// Exit early if the task is canceled. Finish is not needed.
179
188
// During a db transaction, a canceled Context doesn't always result in a proper error
180
189
// We can check for ErrTxDone in that case: https://github.com/golang/go/issues/43507
You can’t perform that action at this time.
0 commit comments