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

Decouple StateBuilder from TaskGenerator #4991

Merged

Conversation

vytautas-karpavicius
Copy link
Contributor

@vytautas-karpavicius vytautas-karpavicius commented Sep 6, 2022

What changed?
Decoupled StateBuilder from TaskGenerator by moving task generation to Replicate<...> functions on mutable state. Task generation is needed on both active and passive side, so there is no need to call them separately. There were only a few places where active/passive side differs slightly. For them we can simply pass additional flag modifying that behavior. In particular, more attention is needed for:

  • ReplicateWorkflowExecutionStartedEvent will GenerateDelayedDecisionTasks only for passive side. Active side does that separately during AddFirstDecisionTaskScheduled.
  • After rebuilding GenerateActivityTimerTasks/GenerateUserTimerTasks was called. This can be skipped here, and instead call when closing a transaction. Previously it was not done due to transactionPolicy == TransactionPolicyPassive, now this is removed. And they will be generated for both active/passive cases.

Why?

  • Reduced tech debt as indicates by // TODO merge active & passive task generation.
  • This also decouples StateBuilder which makes it possible to further refactor and simplify.
  • Task generation is more centralized.

How did you test it?
Existing tests

Potential risks

Release notes

Documentation Changes

@coveralls
Copy link

coveralls commented Sep 6, 2022

Pull Request Test Coverage Report for Build 01845b66-af76-468b-b785-8fd9f14ff9ae

  • 62 of 71 (87.32%) changed or added relevant lines in 3 files are covered.
  • 118 unchanged lines in 16 files lost coverage.
  • Overall coverage decreased (-0.06%) to 57.253%

Changes Missing Coverage Covered Lines Changed/Added Lines %
service/history/execution/mutable_state_decision_task_manager.go 9 12 75.0%
service/history/execution/mutable_state_builder.go 37 43 86.05%
Files with Coverage Reduction New Missed Lines %
common/types/shared.go 1 41.66%
service/history/execution/mutable_state_builder.go 1 68.81%
common/task/parallelTaskProcessor.go 2 92.75%
common/util.go 2 52.44%
service/history/execution/mutable_state_util.go 2 36.14%
service/history/task/transfer_active_task_executor.go 2 72.15%
service/matching/taskListManager.go 2 75.87%
common/persistence/statsComputer.go 3 93.57%
common/persistence/serialization/parser.go 4 62.41%
common/persistence/serialization/thrift_decoder.go 4 53.06%
Totals Coverage Status
Change from base Build 018451f7-faad-49b3-945b-1604e2186a55: -0.06%
Covered Lines: 85070
Relevant Lines: 148586

💛 - Coveralls

@vytautas-karpavicius vytautas-karpavicius marked this pull request as ready for review September 6, 2022 13:45
@vytautas-karpavicius vytautas-karpavicius requested a review from a team September 6, 2022 13:45
@@ -2174,12 +2166,6 @@ func (e *mutableStateBuilder) AddActivityTaskScheduledEvent(
activityStartedScope.IncCounter(metrics.CadenceRequests)
return event, ai, nil, true, true, nil
}
// TODO merge active & passive task generation
Copy link
Contributor

Choose a reason for hiding this comment

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

This will change the behavior of activity local dispatch.

Before, we try dispatch activity task and if it succeeds, we skip the transfer task creation.
After, we always create the transfer task.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, updated. Good catch.

@@ -4690,8 +4628,7 @@ func (e *mutableStateBuilder) closeTransactionHandleActivityUserTimerTasks(
transactionPolicy TransactionPolicy,
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems that we can remove this parameter

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, updated.

@vytautas-karpavicius vytautas-karpavicius merged commit 946f677 into uber:master Nov 9, 2022
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.

None yet

3 participants