Files
Yichao YangandGitHub 63839f1a9d CHASM: Propagate ArchetypeID (#8693)
## What changed?
- Use archetypeID everywhere in history service and pass them to
persistence

## Why?
- Required for separate ID space work.

## How did you test it?
- [x] built
- [ ] run locally and tested manually
- [x] covered by existing tests
- [x] added new unit test(s)
- [ ] added new functional test(s)
2025-11-26 16:04:44 -08:00

68 lines
1.8 KiB
Go

package describemutablestate
import (
"context"
"go.temporal.io/server/api/historyservice/v1"
"go.temporal.io/server/chasm"
"go.temporal.io/server/common/definition"
"go.temporal.io/server/common/locks"
"go.temporal.io/server/common/namespace"
"go.temporal.io/server/service/history/api"
historyi "go.temporal.io/server/service/history/interfaces"
"go.temporal.io/server/service/history/workflow"
)
func Invoke(
ctx context.Context,
req *historyservice.DescribeMutableStateRequest,
shardContext historyi.ShardContext,
workflowConsistencyChecker api.WorkflowConsistencyChecker,
) (_ *historyservice.DescribeMutableStateResponse, retError error) {
namespaceID := namespace.ID(req.GetNamespaceId())
err := api.ValidateNamespaceUUID(namespaceID)
if err != nil {
return nil, err
}
archetypeID := req.GetArchetypeId()
if archetypeID == chasm.UnspecifiedArchetypeID {
archetypeID = chasm.WorkflowArchetypeID
}
chasmLease, err := workflowConsistencyChecker.GetChasmLease(
ctx,
nil,
definition.NewWorkflowKey(
req.NamespaceId,
req.Execution.WorkflowId,
req.Execution.RunId,
),
archetypeID,
locks.PriorityHigh,
)
if err != nil {
return nil, err
}
defer func() { chasmLease.GetReleaseFn()(retError) }()
response := &historyservice.DescribeMutableStateResponse{}
if chasmLease.GetContext().(*workflow.ContextImpl).MutableState != nil {
msb := chasmLease.GetContext().(*workflow.ContextImpl).MutableState
response.CacheMutableState = msb.CloneToProto()
}
if !req.GetSkipForceReload() {
// Clear mutable state to force reload from persistence.
chasmLease.GetContext().Clear()
}
mutableState, err := chasmLease.GetContext().LoadMutableState(ctx, shardContext)
if err != nil {
return nil, err
}
response.DatabaseMutableState = mutableState.CloneToProto()
return response, nil
}