context_impl.go ×9

Frontier kind: Code frontier

unlabeled · c_8de7affffdc1

6 tests · 4066 LOC · 179 files · introduces 0 tests · 63 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
9 ranges63 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
615 ranges4066 lines · 179 files · Browse complete extent
All tests (intent)
6 testsBrowse complete intent

Neighbourhood graph

The orange circle is the focus. Violet and green circles are every ancestor and descendant, broader and narrower, at any distance; blue squares and pink diamonds are the introduced files and exact introduced tests of every visible concept, not only the focus's. Arrows point from broader to narrower concepts and bridge only concepts omitted from this view. Undirected links show source or test introduction. Concept and file size follows LOC; exact test nodes use test-count units.

Introduced files, introduced tests, and structurally relevant concept specialization

In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the native relationship evidence on this page.

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the native relationship evidence on this page while the interactive map is unavailable.

Native relationship evidence

Every exact file and test below is linked only from the concept that introduces it.

Introduced tests

Every collected test enters the hierarchy at exactly one concept.

No tests are introduced at this concept. Its intent tests are introduced by other concepts.

Introduced code

Every collected source range enters the hierarchy at exactly one concept.

1 file ranked by introduced lines: 63 introduced LOC across 9 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

go.temporal.io/server/service/history/shard/context_impl.go 63 introduced LOC · 9 ranges

Open complete file

916 stage *tasks.DeleteWorkflowExecutionStage,
917 retentionDelete bool,
918 > ) (retErr error) { context_impl.go
919 > // DeleteWorkflowExecution is a 4 stages process (order is very important and should not be changed):
920 > // 1. Add visibility delete task, i.e. schedule visibility record delete, and execution replication delete task,
921 > // 2. Delete current workflow execution pointer,
922 > // 3. Delete workflow mutable state,
923 > // 4. Delete history branch.
924 >
925 > // This function is called from task processor and should not be called directly.
926 > // It may fail at any stage and task processor will retry. All stages are idempotent.
927 >
928 > // If process fails after stage 1 then workflow execution becomes invisible but mutable state is still there and task can be safely retried.
929 > // Stage 2 doesn't affect mutable state neither and doesn't block retry.
930 > // After stage 3 task can't be retried because mutable state is gone and this might leave history branch in DB.
931 > // The history branch won't be accessible (because mutable state is deleted) and special garbage collection workflow will delete it eventually.
932 > // Stage 4 shouldn't be done earlier because if this func fails after it, workflow execution will be accessible but won't have history (inconsistent state).
933 >
934 > engine, err := s.GetEngine(ctx)
935 > if err != nil {
936 return err
937 }
938
939 // Do not get namespace cache within shard lock.
940 > _, err = s.GetNamespaceRegistry().GetNamespaceByID(namespace.ID(key.NamespaceID)) context_impl.go
941 > deleteVisibilityRecord := true
942 > if err != nil {
943 if _, isNotFound := err.(*serviceerror.NamespaceNotFound); isNotFound {
944 // If namespace is not found, skip visibility record delete but proceed with other deletions.
950 }
951
952 > validateCtxAndShardState := func() (context.Context, context.CancelFunc, error) { context_impl.go
953 > s.wLock()
954 > defer s.wUnlock()
955 >
956 > ctx, cancel, err := s.newDetachedContext(ctx)
957 > if err != nil {
958 return nil, nil, err
959 }
960
961 > if err := s.errorByState(); err != nil { context_impl.go
962 cancel()
963 return nil, nil, err
964 }
965
966 > return ctx, cancel, nil context_impl.go
967 }
968
969 // Don't acquire shard lock or io semaphore if all stages that require lock are already processed.
970 > if !stage.IsProcessed( context_impl.go
971 > tasks.DeleteWorkflowExecutionStageVisibility |
972 > tasks.DeleteWorkflowExecutionStageReplication |
973 > tasks.DeleteWorkflowExecutionStageCurrent |
974 > tasks.DeleteWorkflowExecutionStageMutableState) {
975 >
976 > // Wrap stage 1, 2, and 3 with function to release io semaphore with defer after stage 3.
977 > if err = func() error {
978 >
979 > if err := s.ioSemaphoreAcquire(ctx); err != nil {
980 return err
981 }
982 > defer s.ioSemaphoreRelease() context_impl.go
983 >
984 > // Stage 1. Add visibility delete task and delete execution replication task.
985 > if !stage.IsProcessed(tasks.DeleteWorkflowExecutionStageVisibility) {
986 newTasks := make(map[tasks.Category][]tasks.Task)
987 if deleteVisibilityRecord {
1030 }
1031 }
1032 > stage.MarkProcessed(tasks.DeleteWorkflowExecutionStageVisibility) context_impl.go
1033 > stage.MarkProcessed(tasks.DeleteWorkflowExecutionStageReplication)
1034 >
1035 > // Stage 2. Delete current workflow execution pointer.
1036 > if !stage.IsProcessed(tasks.DeleteWorkflowExecutionStageCurrent) {
1037 > ctx, cancel, err := validateCtxAndShardState()
1038 > if err != nil {
1039 return err
1040 }
1041 > defer cancel() context_impl.go
1042 >
1043 > delCurRequest := &persistence.DeleteCurrentWorkflowExecutionRequest{
1044 > ShardID: s.shardID,
1045 > NamespaceID: key.NamespaceID,
1046 > WorkflowID: key.WorkflowID,
1047 > ArchetypeID: archetypeID,
1048 > RunID: key.RunID,
1049 > }
1050 > if err := s.GetExecutionManager().DeleteCurrentWorkflowExecution(
1051 > ctx,
1052 > delCurRequest,
1053 > ); err != nil {
1054 return err
1055 }