Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extract workflow execution delete code to workflow.DeleteManager #2388

Merged
merged 4 commits into from
Jan 22, 2022

Conversation

alexshtin
Copy link
Member

@alexshtin alexshtin commented Jan 18, 2022

What changed?
Extract workflow execution delete code to workflow.DeleteManager.

Why?
Refactoring for future code reuse.

How did you test it?
Modified existing tests.

Potential risks
No risks.

Is hotfix candidate?
No.

@alexshtin alexshtin requested a review from a team January 18, 2022 22:57
Comment on lines 47 to 48
DeleteDeletedWorkflowExecution(namespaceID namespace.ID, we commonpb.WorkflowExecution, weCtx Context, ms MutableState, transferTaskVersion int64) error
DeleteWorkflowExecutionRetention(namespaceID namespace.ID, we commonpb.WorkflowExecution, weCtx Context, ms MutableState, timerTaskVersion int64) error
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DeleteDeleted? What does that mean? Could you put some comment on them, what are the differences of these 2 APIs.
And, ctx is usually first input argument.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1. DeleteDeleted will be used by transfer queue I guess?
nit : DeleteForWorkflowRetention makes more sense to me but no strong opinion.

Also, probably do not reference any queue type (transfer, time) in new code as we are doing the refactoring for queue processors. Maybe taskVersion is sufficient in this case.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR was cherry-picked from another bigger PR. DeleteDeleted makes perfect sense there but here it looks confusing, I agree. I am renaming it. At least for now.
This is workflow.Context not context.Context, so I believe it is ok it pass it with other workflow related params.
Renaming DeleteWorkflowExecutionRetention to DeleteWorkflowExecutionByRetention.
And also giving task version parameters more generic names.

@@ -60,12 +60,14 @@ type (
matchingClient matchingservice.MatchingServiceClient
config *configs.Config
searchAttributesProvider searchattribute.Provider
workflowDeleteManager workflow.DeleteManager
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like it's not used? Do we plan to use it in the future?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this will be used in next PR.

@@ -99,9 +95,6 @@ func (t *timerQueueTaskExecutorBase) executeDeleteHistoryEventTask(
if err != nil {
return err
}
if mutableState == nil || mutableState.IsWorkflowExecutionRunning() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we still need to check if mutableState is nil or not here I think. Otherwise the GetLastWriteVersion call may panic on L106.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

loadMutableStateForTimerTask never returns nil mutable state and nil error. If there is an error it will be handled, if not, it can go through.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but don't you need to make sure workflow is not running? We don't want to delete history for running workflow.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to move as much logic as possible to deleteManager. So this check is there now.

@temporalio temporalio deleted a comment from yycptt Jan 19, 2022
@alexshtin alexshtin force-pushed the feature/extract-delete-manager branch from f5016f2 to b08afa1 Compare January 22, 2022 01:50
@@ -99,9 +95,6 @@ func (t *timerQueueTaskExecutorBase) executeDeleteHistoryEventTask(
if err != nil {
return err
}
if mutableState == nil || mutableState.IsWorkflowExecutionRunning() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but don't you need to make sure workflow is not running? We don't want to delete history for running workflow.

return deleteManager
}

func (m *DeleteManagerImpl) DeleteWorkflowExecution(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so the difference from DeleteWorkflowExecutionByRetention is this method allow delete running workflow? Why do we need to delete running workflow? Isn't that we require workflow to be closed before you can delete them?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because of cherry-picking I missed check for running workflow. Restored.

@alexshtin alexshtin merged commit 43b4531 into temporalio:master Jan 22, 2022
@alexshtin alexshtin deleted the feature/extract-delete-manager branch January 22, 2022 03:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants