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

Added Executor Interface and TimerTaskExecutorBase with stop() Method and improve context management in TimerQueueProcessor #5920

Merged
merged 6 commits into from
Apr 18, 2024

Conversation

timl3136
Copy link
Contributor

What changed?
Added stop() to the Executor interface and created an empty stop() function for future implementations in Executors.
Implemented stop() in TimerTaskExecutorBase.
Added context and cancelFn in TimerTaskExecutorBase struct and replaced context.Background() with internal context to prevent memory leaks.
Called executor.stop() in TimerQueueProcessor to prevent context leaks.

Why?
Currently we are creating new context and pass that to downstream without proper stop signal propagation

How did you test it?
Unit tests

Potential risks
We are calling the stop method at the end of the lifecycle so there won't be any added risks.

Release notes

Documentation Changes

…askExecutorBase and calling that in timerqueueprocessor to prevent context leak
Copy link

codecov bot commented Apr 18, 2024

Codecov Report

Merging #5920 (35198e3) into master (6564701) will decrease coverage by 0.01%.
The diff coverage is 88.88%.

❗ Current head 35198e3 differs from pull request most recent head 1552add. Consider uploading reports for the commit 1552add to get more accurate results

Additional details and impacted files
Files Coverage Δ
...history/task/cross_cluster_source_task_executor.go 68.15% <100.00%> (+0.10%) ⬆️
...history/task/cross_cluster_target_task_executor.go 70.11% <100.00%> (+0.11%) ⬆️
service/history/task/timer_active_task_executor.go 72.00% <100.00%> (ø)
...ervice/history/task/timer_standby_task_executor.go 78.94% <100.00%> (ø)
service/history/task/timer_task_executor_base.go 64.05% <100.00%> (+1.46%) ⬆️
...vice/history/task/transfer_active_task_executor.go 68.66% <100.00%> (+0.02%) ⬆️
...ice/history/task/transfer_standby_task_executor.go 80.59% <100.00%> (+0.04%) ⬆️
service/history/queue/timer_queue_processor.go 0.00% <0.00%> (ø)

... and 10 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6564701...1552add. Read the comment docs.

@coveralls
Copy link

coveralls commented Apr 18, 2024

Pull Request Test Coverage Report for Build 018ef2bf-3a4f-49cf-8ec7-63574b6bd290

Details

  • 45 of 49 (91.84%) changed or added relevant lines in 8 files are covered.
  • 45 unchanged lines in 13 files lost coverage.
  • Overall coverage decreased (-0.01%) to 67.577%

Changes Missing Coverage Covered Lines Changed/Added Lines %
service/history/queue/timer_queue_processor.go 8 12 66.67%
Files with Coverage Reduction New Missed Lines %
service/history/queue/timer_queue_processor_base.go 1 78.23%
service/history/task/transfer_standby_task_executor.go 2 87.04%
common/persistence/execution_manager.go 2 83.74%
service/history/task/transfer_active_task_executor.go 2 72.72%
common/util.go 2 91.78%
service/matching/taskListManager.go 2 80.4%
common/membership/hashring.go 2 84.69%
common/persistence/statsComputer.go 2 97.14%
service/history/task/fetcher.go 2 85.05%
common/task/fifo_task_scheduler.go 3 84.54%
Totals Coverage Status
Change from base Build 018ef2b1-f1cf-4ff2-83a2-2995c432965e: -0.01%
Covered Lines: 98958
Relevant Lines: 146438

💛 - Coveralls

@@ -87,7 +87,7 @@ func (t *timerActiveTaskExecutor) Execute(
return nil
}

ctx, cancel := context.WithTimeout(context.Background(), taskDefaultTimeout)
ctx, cancel := context.WithTimeout(t.ctx, taskDefaultTimeout)
Copy link
Contributor

Choose a reason for hiding this comment

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

this line is unnecessary for TaskTypeDeleteHistoryEvent case. so maybe create the context within each case below with corresponding timeout value.

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, I have changed this in the new commit.

@@ -178,6 +178,8 @@ func (t *timerQueueProcessor) Stop() {

if !t.shard.GetConfig().QueueProcessorEnableGracefulSyncShutdown() {
t.activeQueueProcessor.Stop()
// stop active executor after queue processor
t.activeTaskExecutor.Stop()
Copy link
Contributor

Choose a reason for hiding this comment

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

There are also standbyTaskExecutor objects created and passed to newTimerQueueStandbyProcessor in the constructor. We need to stop them as well. Timer queue processor is creating those so it should be responsible of stopping the executors

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, I have added a field accounting for the standbyTaskExecutors and stop then in the end.

@timl3136 timl3136 enabled auto-merge (squash) April 18, 2024 20:35
@timl3136 timl3136 merged commit 16c4775 into uber:master Apr 18, 2024
18 checks passed
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