/
transfer_queue_standby_task_executor.go
670 lines (601 loc) · 21.4 KB
/
transfer_queue_standby_task_executor.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
// The MIT License
//
// Copyright (c) 2020 Temporal Technologies Inc. All rights reserved.
//
// Copyright (c) 2020 Uber Technologies, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
package history
import (
"context"
"errors"
"fmt"
"time"
commonpb "go.temporal.io/api/common/v1"
enumspb "go.temporal.io/api/enums/v1"
"go.temporal.io/api/serviceerror"
taskqueuepb "go.temporal.io/api/taskqueue/v1"
"go.temporal.io/server/api/historyservice/v1"
"go.temporal.io/server/common"
"go.temporal.io/server/common/log"
"go.temporal.io/server/common/log/tag"
"go.temporal.io/server/common/metrics"
"go.temporal.io/server/common/namespace"
"go.temporal.io/server/common/persistence/visibility/manager"
"go.temporal.io/server/common/resource"
"go.temporal.io/server/common/xdc"
"go.temporal.io/server/service/history/consts"
"go.temporal.io/server/service/history/ndc"
"go.temporal.io/server/service/history/queues"
"go.temporal.io/server/service/history/shard"
"go.temporal.io/server/service/history/tasks"
"go.temporal.io/server/service/history/workflow"
wcache "go.temporal.io/server/service/history/workflow/cache"
)
const (
recordChildCompletionVerificationFailedMsg = "Failed to verify child execution completion recoreded"
firstWorkflowTaskVerificationFailedMsg = "Failed to verify first workflow task scheduled"
)
type (
transferQueueStandbyTaskExecutor struct {
*transferQueueTaskExecutorBase
clusterName string
nDCHistoryResender xdc.NDCHistoryResender
}
verificationErr struct {
msg string
err error
}
)
func newTransferQueueStandbyTaskExecutor(
shard shard.Context,
workflowCache wcache.Cache,
nDCHistoryResender xdc.NDCHistoryResender,
logger log.Logger,
metricProvider metrics.Handler,
clusterName string,
historyRawClient resource.HistoryRawClient,
matchingRawClient resource.MatchingRawClient,
visibilityManager manager.VisibilityManager,
) queues.Executor {
return &transferQueueStandbyTaskExecutor{
transferQueueTaskExecutorBase: newTransferQueueTaskExecutorBase(
shard,
workflowCache,
logger,
metricProvider,
historyRawClient,
matchingRawClient,
visibilityManager,
),
clusterName: clusterName,
nDCHistoryResender: nDCHistoryResender,
}
}
func (t *transferQueueStandbyTaskExecutor) Execute(
ctx context.Context,
executable queues.Executable,
) queues.ExecuteResponse {
task := executable.GetTask()
taskType := queues.GetStandbyTransferTaskTypeTagValue(task)
metricsTags := []metrics.Tag{
getNamespaceTagByID(t.shardContext.GetNamespaceRegistry(), task.GetNamespaceID()),
metrics.TaskTypeTag(taskType),
metrics.OperationTag(taskType), // for backward compatibility
}
var err error
switch task := task.(type) {
case *tasks.ActivityTask:
err = t.processActivityTask(ctx, task)
case *tasks.WorkflowTask:
err = t.processWorkflowTask(ctx, task)
case *tasks.CancelExecutionTask:
err = t.processCancelExecution(ctx, task)
case *tasks.SignalExecutionTask:
err = t.processSignalExecution(ctx, task)
case *tasks.StartChildExecutionTask:
err = t.processStartChildExecution(ctx, task)
case *tasks.ResetWorkflowTask:
// no reset needed for standby
// TODO: add error logs
err = nil
case *tasks.CloseExecutionTask:
err = t.processCloseExecution(ctx, task)
case *tasks.DeleteExecutionTask:
err = t.processDeleteExecutionTask(ctx, task, false)
default:
err = errUnknownTransferTask
}
return queues.ExecuteResponse{
ExecutionMetricTags: metricsTags,
ExecutedAsActive: false,
ExecutionErr: err,
}
}
func (t *transferQueueStandbyTaskExecutor) processActivityTask(
ctx context.Context,
transferTask *tasks.ActivityTask,
) error {
processTaskIfClosed := false
actionFn := func(_ context.Context, wfContext workflow.Context, mutableState workflow.MutableState) (interface{}, error) {
activityInfo, ok := mutableState.GetActivityInfo(transferTask.ScheduledEventID)
if !ok {
return nil, nil
}
err := CheckTaskVersion(t.shardContext, t.logger, mutableState.GetNamespaceEntry(), activityInfo.Version, transferTask.Version, transferTask)
if err != nil {
return nil, err
}
if activityInfo.StartedEventId == common.EmptyEventID {
return newActivityTaskPostActionInfo(mutableState, activityInfo.ScheduleToStartTimeout.AsDuration(), activityInfo.UseCompatibleVersion)
}
return nil, nil
}
return t.processTransfer(
ctx,
processTaskIfClosed,
transferTask,
actionFn,
getStandbyPostActionFn(
transferTask,
t.getCurrentTime,
t.config.StandbyTaskMissingEventsResendDelay(transferTask.GetType()),
t.config.StandbyTaskMissingEventsDiscardDelay(transferTask.GetType()),
t.fetchHistoryFromRemote,
t.pushActivity,
),
)
}
func (t *transferQueueStandbyTaskExecutor) processWorkflowTask(
ctx context.Context,
transferTask *tasks.WorkflowTask,
) error {
actionFn := func(_ context.Context, wfContext workflow.Context, mutableState workflow.MutableState) (interface{}, error) {
wtInfo := mutableState.GetWorkflowTaskByID(transferTask.ScheduledEventID)
if wtInfo == nil {
return nil, nil
}
_, scheduleToStartTimeout := mutableState.TaskQueueScheduleToStartTimeout(transferTask.TaskQueue)
// Task queue is ignored here because at standby, always use original normal task queue,
// disregards the transferTask.TaskQueue which could be sticky.
// NOTE: scheduleToStart timeout is respected. If workflow was sticky before namespace become standby,
// transferTask.TaskQueue is sticky, and there is timer already created for this timeout.
// Use this sticky timeout as TTL.
taskQueue := &taskqueuepb.TaskQueue{
Name: mutableState.GetExecutionInfo().TaskQueue,
Kind: enumspb.TASK_QUEUE_KIND_NORMAL,
}
err := CheckTaskVersion(t.shardContext, t.logger, mutableState.GetNamespaceEntry(), wtInfo.Version, transferTask.Version, transferTask)
if err != nil {
return nil, err
}
if wtInfo.StartedEventID == common.EmptyEventID {
return newWorkflowTaskPostActionInfo(
mutableState,
scheduleToStartTimeout.AsDuration(),
taskQueue,
)
}
return nil, nil
}
return t.processTransfer(
ctx,
false,
transferTask,
actionFn,
getStandbyPostActionFn(
transferTask,
t.getCurrentTime,
t.config.StandbyTaskMissingEventsResendDelay(transferTask.GetType()),
t.config.StandbyTaskMissingEventsDiscardDelay(transferTask.GetType()),
t.fetchHistoryFromRemote,
t.pushWorkflowTask,
),
)
}
func (t *transferQueueStandbyTaskExecutor) processCloseExecution(
ctx context.Context,
transferTask *tasks.CloseExecutionTask,
) error {
processTaskIfClosed := true
actionFn := func(ctx context.Context, wfContext workflow.Context, mutableState workflow.MutableState) (interface{}, error) {
if mutableState.IsWorkflowExecutionRunning() {
// this can happen if workflow is reset.
return nil, nil
}
executionInfo := mutableState.GetExecutionInfo()
lastWriteVersion, err := mutableState.GetLastWriteVersion()
if err != nil {
return nil, err
}
err = CheckTaskVersion(t.shardContext, t.logger, mutableState.GetNamespaceEntry(), lastWriteVersion, transferTask.Version, transferTask)
if err != nil {
return nil, err
}
// verify if parent got the completion event
verifyCompletionRecorded := mutableState.HasParentExecution() && executionInfo.NewExecutionRunId == ""
if verifyCompletionRecorded {
// load close event only if needed.
completionEvent, err := mutableState.GetCompletionEvent(ctx)
if err != nil {
return nil, err
}
verifyCompletionRecorded = verifyCompletionRecorded && !ndc.IsTerminatedByResetter(completionEvent)
}
if verifyCompletionRecorded {
_, err := t.historyRawClient.VerifyChildExecutionCompletionRecorded(ctx, &historyservice.VerifyChildExecutionCompletionRecordedRequest{
NamespaceId: executionInfo.ParentNamespaceId,
ParentExecution: &commonpb.WorkflowExecution{
WorkflowId: executionInfo.ParentWorkflowId,
RunId: executionInfo.ParentRunId,
},
ChildExecution: &commonpb.WorkflowExecution{
WorkflowId: transferTask.WorkflowID,
RunId: transferTask.RunID,
},
ParentInitiatedId: executionInfo.ParentInitiatedId,
ParentInitiatedVersion: executionInfo.ParentInitiatedVersion,
Clock: executionInfo.ParentClock,
})
switch err.(type) {
case nil, *serviceerror.NamespaceNotFound, *serviceerror.Unimplemented:
// Case 1: Target workflow is in the desired state.
return nil, nil
case *serviceerror.NotFound, *serviceerror.WorkflowNotReady:
// Case 2: Target workflow is not in the desired state.
// Returning a non-nil pointer as postActionInfo here to indicate that verification is not done yet.
return &struct{}{}, nil
default:
// Case 3: Verification itself failed.
// NOTE: Returning an error as postActionInfo here so that post action can decide whether to retry or not.
// Post action will propagate the error to upper layer to backoff and emit metrics properly if retry is needed.
// NOTE: Wrapping the error as a verification error to prevent mutable state from being cleared and reloaded upon retry.
// That's unnecessary as the error is in the target workflow, not this workflow.
return &verificationErr{
msg: recordChildCompletionVerificationFailedMsg,
err: err,
}, nil
}
}
return nil, nil
}
return t.processTransfer(
ctx,
processTaskIfClosed,
transferTask,
actionFn,
getStandbyPostActionFn(
transferTask,
t.getCurrentTime,
t.config.StandbyTaskMissingEventsResendDelay(transferTask.GetType()),
t.config.StandbyTaskMissingEventsDiscardDelay(transferTask.GetType()),
standbyTaskPostActionNoOp,
standbyTransferTaskPostActionTaskDiscarded,
),
)
}
func (t *transferQueueStandbyTaskExecutor) processCancelExecution(
ctx context.Context,
transferTask *tasks.CancelExecutionTask,
) error {
processTaskIfClosed := false
actionFn := func(_ context.Context, wfContext workflow.Context, mutableState workflow.MutableState) (interface{}, error) {
requestCancelInfo, ok := mutableState.GetRequestCancelInfo(transferTask.InitiatedEventID)
if !ok {
return nil, nil
}
err := CheckTaskVersion(t.shardContext, t.logger, mutableState.GetNamespaceEntry(), requestCancelInfo.Version, transferTask.Version, transferTask)
if err != nil {
return nil, err
}
return getHistoryResendInfo(mutableState)
}
return t.processTransfer(
ctx,
processTaskIfClosed,
transferTask,
actionFn,
getStandbyPostActionFn(
transferTask,
t.getCurrentTime,
t.config.StandbyTaskMissingEventsResendDelay(transferTask.GetType()),
t.config.StandbyTaskMissingEventsDiscardDelay(transferTask.GetType()),
t.fetchHistoryFromRemote,
standbyTransferTaskPostActionTaskDiscarded,
),
)
}
func (t *transferQueueStandbyTaskExecutor) processSignalExecution(
ctx context.Context,
transferTask *tasks.SignalExecutionTask,
) error {
processTaskIfClosed := false
actionFn := func(_ context.Context, wfContext workflow.Context, mutableState workflow.MutableState) (interface{}, error) {
signalInfo, ok := mutableState.GetSignalInfo(transferTask.InitiatedEventID)
if !ok {
return nil, nil
}
err := CheckTaskVersion(t.shardContext, t.logger, mutableState.GetNamespaceEntry(), signalInfo.Version, transferTask.Version, transferTask)
if err != nil {
return nil, err
}
return getHistoryResendInfo(mutableState)
}
return t.processTransfer(
ctx,
processTaskIfClosed,
transferTask,
actionFn,
getStandbyPostActionFn(
transferTask,
t.getCurrentTime,
t.config.StandbyTaskMissingEventsResendDelay(transferTask.GetType()),
t.config.StandbyTaskMissingEventsDiscardDelay(transferTask.GetType()),
t.fetchHistoryFromRemote,
standbyTransferTaskPostActionTaskDiscarded,
),
)
}
func (t *transferQueueStandbyTaskExecutor) processStartChildExecution(
ctx context.Context,
transferTask *tasks.StartChildExecutionTask,
) error {
processTaskIfClosed := true
actionFn := func(ctx context.Context, wfContext workflow.Context, mutableState workflow.MutableState) (interface{}, error) {
childWorkflowInfo, ok := mutableState.GetChildExecutionInfo(transferTask.InitiatedEventID)
if !ok {
return nil, nil
}
err := CheckTaskVersion(t.shardContext, t.logger, mutableState.GetNamespaceEntry(), childWorkflowInfo.Version, transferTask.Version, transferTask)
if err != nil {
return nil, err
}
workflowClosed := !mutableState.IsWorkflowExecutionRunning()
childStarted := childWorkflowInfo.StartedEventId != common.EmptyEventID
childAbandon := childWorkflowInfo.ParentClosePolicy == enumspb.PARENT_CLOSE_POLICY_ABANDON
if workflowClosed && !(childStarted && childAbandon) {
// NOTE: ideally for workflowClosed, child not started, parent close policy is abandon case,
// we should continue to start the child workflow in active cluster, so standby logic also need to
// perform the verification. However, we can't do that due to some technial reasons.
// Please check the comments in processStartChildExecution in transferQueueActiveTaskExecutor.go
// for details.
return nil, nil
}
if !childStarted {
historyResendInfo, err := getHistoryResendInfo(mutableState)
if err != nil {
return nil, err
}
return historyResendInfo, nil
}
_, err = t.historyRawClient.VerifyFirstWorkflowTaskScheduled(ctx, &historyservice.VerifyFirstWorkflowTaskScheduledRequest{
NamespaceId: transferTask.TargetNamespaceID,
WorkflowExecution: &commonpb.WorkflowExecution{
WorkflowId: childWorkflowInfo.StartedWorkflowId,
RunId: childWorkflowInfo.StartedRunId,
},
Clock: childWorkflowInfo.Clock,
})
switch err.(type) {
case nil, *serviceerror.NamespaceNotFound, *serviceerror.Unimplemented:
// Case 1: Target workflow is in the desired state.
return nil, nil
case *serviceerror.NotFound, *serviceerror.WorkflowNotReady:
// Case 2:Ttarget workflow is not in the desired state.
// Return a non-nil pointer as postActionInfo here to indicate that verification is not done yet.
return &struct{}{}, nil
default:
// Case 3: Verification itself failed.
// NOTE: Returning an error as postActionInfo here so that post action can decide whether to retry or not.
// Post action will propagate the error to upper layer to backoff and emit metrics properly if retry is needed.
// NOTE: Wrapping the error as a verification error to prevent mutable state from being cleared and reloaded upon retry.
// That's unnecessary as the error is in the target workflow, not this workflow.
return &verificationErr{
msg: recordChildCompletionVerificationFailedMsg,
err: err,
}, nil
}
}
return t.processTransfer(
ctx,
processTaskIfClosed,
transferTask,
actionFn,
getStandbyPostActionFn(
transferTask,
t.getCurrentTime,
t.config.StandbyTaskMissingEventsResendDelay(transferTask.GetType()),
t.config.StandbyTaskMissingEventsDiscardDelay(transferTask.GetType()),
t.startChildExecutionResendPostAction,
standbyTransferTaskPostActionTaskDiscarded,
),
)
}
func (t *transferQueueStandbyTaskExecutor) processTransfer(
ctx context.Context,
processTaskIfClosed bool,
taskInfo tasks.Task,
actionFn standbyActionFn,
postActionFn standbyPostActionFn,
) (retError error) {
ctx, cancel := context.WithTimeout(ctx, taskTimeout)
defer cancel()
nsRecord, err := t.shardContext.GetNamespaceRegistry().GetNamespaceByID(namespace.ID(taskInfo.GetNamespaceID()))
if err != nil {
return err
}
if !nsRecord.IsOnCluster(t.clusterName) {
// namespace is not replicated to local cluster, ignore corresponding tasks
return nil
}
weContext, release, err := getWorkflowExecutionContextForTask(ctx, t.shardContext, t.cache, taskInfo)
if err != nil {
return err
}
defer func() {
var verificationErr *verificationErr
if retError == consts.ErrTaskRetry || errors.As(retError, &verificationErr) {
release(nil)
} else {
release(retError)
}
}()
mutableState, err := loadMutableStateForTransferTask(ctx, t.shardContext, weContext, taskInfo, t.metricHandler, t.logger)
if err != nil || mutableState == nil {
return err
}
if !mutableState.IsWorkflowExecutionRunning() && !processTaskIfClosed {
// workflow already finished, no need to process transfer task.
return nil
}
postActionInfo, err := actionFn(ctx, weContext, mutableState)
if err != nil {
return err
}
// NOTE: do not access anything related mutable state after this lock release
release(nil)
return postActionFn(ctx, taskInfo, postActionInfo, t.logger)
}
func (t *transferQueueStandbyTaskExecutor) pushActivity(
ctx context.Context,
task tasks.Task,
postActionInfo interface{},
logger log.Logger,
) error {
if postActionInfo == nil {
return nil
}
pushActivityInfo := postActionInfo.(*activityTaskPostActionInfo)
timeout := pushActivityInfo.activityTaskScheduleToStartTimeout
return t.transferQueueTaskExecutorBase.pushActivity(
ctx,
task.(*tasks.ActivityTask),
timeout,
pushActivityInfo.versionDirective,
)
}
func (t *transferQueueStandbyTaskExecutor) pushWorkflowTask(
ctx context.Context,
task tasks.Task,
postActionInfo interface{},
logger log.Logger,
) error {
if postActionInfo == nil {
return nil
}
pushwtInfo := postActionInfo.(*workflowTaskPostActionInfo)
return t.transferQueueTaskExecutorBase.pushWorkflowTask(
ctx,
task.(*tasks.WorkflowTask),
pushwtInfo.taskqueue,
pushwtInfo.workflowTaskScheduleToStartTimeout,
pushwtInfo.versionDirective,
)
}
func (t *transferQueueStandbyTaskExecutor) startChildExecutionResendPostAction(
ctx context.Context,
taskInfo tasks.Task,
postActionInfo interface{},
log log.Logger,
) error {
if postActionInfo == nil {
return nil
}
if historyResendInfo, ok := postActionInfo.(*historyResendInfo); ok {
return t.fetchHistoryFromRemote(ctx, taskInfo, historyResendInfo, log)
}
return standbyTaskPostActionNoOp(ctx, taskInfo, postActionInfo, log)
}
func (t *transferQueueStandbyTaskExecutor) fetchHistoryFromRemote(
ctx context.Context,
taskInfo tasks.Task,
postActionInfo interface{},
logger log.Logger,
) error {
var resendInfo *historyResendInfo
switch postActionInfo := postActionInfo.(type) {
case nil:
return nil
case *historyResendInfo:
resendInfo = postActionInfo
case *activityTaskPostActionInfo:
resendInfo = postActionInfo.historyResendInfo
case *workflowTaskPostActionInfo:
resendInfo = postActionInfo.historyResendInfo
default:
logger.Fatal("unknown post action info for fetching remote history", tag.Value(postActionInfo))
}
remoteClusterName, err := getRemoteClusterName(
t.currentClusterName,
t.registry,
taskInfo.GetNamespaceID(),
)
if err != nil {
return err
}
scope := t.metricHandler.WithTags(metrics.OperationTag(metrics.HistoryRereplicationByTransferTaskScope))
scope.Counter(metrics.ClientRequests.Name()).Record(1)
startTime := time.Now().UTC()
defer func() { scope.Timer(metrics.ClientLatency.Name()).Record(time.Since(startTime)) }()
if resendInfo.lastEventID == common.EmptyEventID || resendInfo.lastEventVersion == common.EmptyVersion {
t.logger.Error("Error re-replicating history from remote: transferQueueStandbyProcessor encountered empty historyResendInfo.",
tag.ShardID(t.shardContext.GetShardID()),
tag.WorkflowNamespaceID(taskInfo.GetNamespaceID()),
tag.WorkflowID(taskInfo.GetWorkflowID()),
tag.WorkflowRunID(taskInfo.GetRunID()),
tag.SourceCluster(remoteClusterName))
return consts.ErrTaskRetry
}
// NOTE: history resend may take long time and its timeout is currently
// controlled by a separate dynamicconfig config: StandbyTaskReReplicationContextTimeout
if err = t.nDCHistoryResender.SendSingleWorkflowHistory(
ctx,
remoteClusterName,
namespace.ID(taskInfo.GetNamespaceID()),
taskInfo.GetWorkflowID(),
taskInfo.GetRunID(),
resendInfo.lastEventID,
resendInfo.lastEventVersion,
0,
0,
); err != nil {
if _, isNotFound := err.(*serviceerror.NamespaceNotFound); isNotFound {
// Don't log NamespaceNotFound error because it is valid case, and return error to stop retrying.
return err
}
t.logger.Error("Error re-replicating history from remote.",
tag.ShardID(t.shardContext.GetShardID()),
tag.WorkflowNamespaceID(taskInfo.GetNamespaceID()),
tag.WorkflowID(taskInfo.GetWorkflowID()),
tag.WorkflowRunID(taskInfo.GetRunID()),
tag.SourceCluster(remoteClusterName),
tag.Error(err))
}
// Return retryable error, so task processing will retry.
return consts.ErrTaskRetry
}
func (t *transferQueueStandbyTaskExecutor) getCurrentTime() time.Time {
return t.shardContext.GetCurrentTime(t.clusterName)
}
func (e *verificationErr) Error() string {
return fmt.Sprintf("%v: %v", e.msg, e.err.Error())
}
func (e *verificationErr) Unwrap() error {
return e.err
}