mirror of
https://github.com/temporalio/temporal.git
synced 2026-08-30 18:41:49 -07:00
## What Retry CHASM tasks on standby indefinitely until Active cluster replication invalidates the logical tasks. ## Why Currently, if the standby cluster runs any CHASM task and none are valid, the physical task is then discarded. To prevent stuck execution cases where code deployments lead to stricter task validation and physical task discarding, we need to keep track of the physical task, only invalidating if the active cluster has completed or dropped it. ## How did you test it? - [X] built - [X] run locally and tested manually - [X] covered by existing tests - [X] added new unit test(s) - [ ] added new functional test(s)
51 lines
1.3 KiB
Go
51 lines
1.3 KiB
Go
package chasm
|
|
|
|
import (
|
|
"context"
|
|
"sync"
|
|
)
|
|
|
|
// MockNodePureTask is a lightweight manual mock for the NodePureTask interface.
|
|
// Methods may be stubbed by assigning the corresponding Handle fields. Call history
|
|
// is recorded in the struct fields (thread-safe).
|
|
type MockNodePureTask struct {
|
|
HandleExecutePureTask func(baseCtx context.Context, taskAttributes TaskAttributes, taskInstance any) (bool, error)
|
|
|
|
mu sync.Mutex
|
|
ExecuteCalls []struct {
|
|
BaseCtx context.Context
|
|
Attributes TaskAttributes
|
|
Task any
|
|
}
|
|
}
|
|
|
|
func (m *MockNodePureTask) ExecutePureTask(
|
|
baseCtx context.Context,
|
|
taskAttributes TaskAttributes,
|
|
taskInstance any,
|
|
) (bool, error) {
|
|
if m.HandleExecutePureTask != nil {
|
|
ok, err := m.HandleExecutePureTask(baseCtx, taskAttributes, taskInstance)
|
|
|
|
m.mu.Lock()
|
|
m.ExecuteCalls = append(m.ExecuteCalls, struct {
|
|
BaseCtx context.Context
|
|
Attributes TaskAttributes
|
|
Task any
|
|
}{BaseCtx: baseCtx, Attributes: taskAttributes, Task: taskInstance})
|
|
m.mu.Unlock()
|
|
|
|
return ok, err
|
|
}
|
|
|
|
m.mu.Lock()
|
|
m.ExecuteCalls = append(m.ExecuteCalls, struct {
|
|
BaseCtx context.Context
|
|
Attributes TaskAttributes
|
|
Task any
|
|
}{BaseCtx: baseCtx, Attributes: taskAttributes, Task: taskInstance})
|
|
m.mu.Unlock()
|
|
|
|
return false, nil
|
|
}
|