@@ -104,7 +104,8 @@ func (rb *redisBackend) GetWorkflowTask(ctx context.Context) (*task.Workflow, er
104
104
105
105
if instanceState .State == backend .WorkflowStateFinished {
106
106
l := rb .Logger ().With (
107
- "task_id" , instanceTask .ID ,
107
+ "task_id" , instanceTask .TaskID ,
108
+ "id" , instanceTask .ID ,
108
109
"instance_id" , instanceState .Instance .InstanceID )
109
110
110
111
// This should never happen. For now, log information and then panic.
@@ -153,8 +154,8 @@ var removePendingEventsCmd = redis.NewScript(`
153
154
var requeueInstanceCmd = redis .NewScript (`
154
155
local pending_events = redis.call("XLEN", KEYS[1])
155
156
if pending_events > 0 then
156
- local already_queued = redis.call("SADD", KEYS[3], ARGV[1])
157
- if already_queued ~= 0 then
157
+ local added = redis.call("SADD", KEYS[3], ARGV[1])
158
+ if added == 1 then
158
159
redis.call("XADD", KEYS[2], "*", "id", ARGV[1], "data", "")
159
160
end
160
161
end
@@ -181,7 +182,7 @@ func (rb *redisBackend) CompleteWorkflowTask(
181
182
p := rb .rdb .TxPipeline ()
182
183
183
184
// Add executed events to the history
184
- if err := addEventsToStreamP (ctx , p , historyKey (instance .InstanceID ), executedEvents ); err != nil {
185
+ if err := addEventsToHistoryStreamP (ctx , p , historyKey (instance .InstanceID ), executedEvents ); err != nil {
185
186
return fmt .Errorf ("serializing : %w" , err )
186
187
}
187
188
@@ -192,7 +193,7 @@ func (rb *redisBackend) CompleteWorkflowTask(
192
193
}
193
194
}
194
195
195
- // Scheduler timers
196
+ // Schedule timers
196
197
for _ , timerEvent := range timerEvents {
197
198
if err := addFutureEventP (ctx , p , instance , & timerEvent ); err != nil {
198
199
return err
@@ -220,12 +221,10 @@ func (rb *redisBackend) CompleteWorkflowTask(
220
221
}
221
222
}
222
223
223
- // If any pending message was added, try to queue workflow task
224
+ // Try to queue workflow task
224
225
if targetInstance != instance {
225
226
if err := rb .workflowQueue .Enqueue (ctx , p , targetInstance .InstanceID , nil ); err != nil {
226
- if err != errTaskAlreadyInQueue {
227
- return fmt .Errorf ("adding instance to locked instances set: %w" , err )
228
- }
227
+ return fmt .Errorf ("enqueuing workflow task: %w" , err )
229
228
}
230
229
}
231
230
}
0 commit comments