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

[history] refactor history client with timeout wrapper #5728

Merged

Conversation

shijiesheng
Copy link
Contributor

What changed?

  • added timeout template
  • refactored history client to move out timeout logic
  • added test for timeout client

Why?

make history client simple again

How did you test it?

unit test

Potential risks

Release notes

Documentation Changes

Copy link

codecov bot commented Mar 6, 2024

Codecov Report

Merging #5728 (7328b49) into master (4451121) will increase coverage by 0.03%.
The diff coverage is n/a.

Additional details and impacted files
Files Coverage Δ
client/history/client.go 0.00% <ø> (ø)

... and 3 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 4451121...7328b49. Read the comment docs.

@coveralls
Copy link

coveralls commented Mar 6, 2024

Pull Request Test Coverage Report for Build 018e14e4-59fe-458c-a46a-cab4fa32ae23

Details

  • 1 of 1 (100.0%) changed or added relevant line in 1 file are covered.
  • 76 unchanged lines in 14 files lost coverage.
  • Overall coverage decreased (-0.04%) to 63.421%

Files with Coverage Reduction New Missed Lines %
client/history/client.go 1 35.78%
common/task/weighted_round_robin_task_scheduler.go 2 88.06%
service/frontend/api/handler.go 2 62.05%
service/history/task/transfer_active_task_executor.go 2 72.38%
service/matching/taskReader.go 2 83.55%
common/persistence/nosql/nosqlplugin/cassandra/workflow.go 3 63.03%
common/persistence/statsComputer.go 3 93.57%
service/history/queue/timer_gate.go 3 95.83%
service/history/task/fetcher.go 3 85.57%
common/archiver/filestore/historyArchiver.go 4 80.95%
Totals Coverage Status
Change from base Build 018e14e1-dd9f-43f8-9cd1-6b61780ca148: -0.04%
Covered Lines: 92979
Relevant Lines: 146607

💛 - Coveralls

@@ -41,6 +41,7 @@ import (
"github.com/uber/cadence/client/wrappers/grpc"
"github.com/uber/cadence/client/wrappers/metered"
"github.com/uber/cadence/client/wrappers/thrift"
timoutwrapper "github.com/uber/cadence/client/wrappers/timeout"
Copy link
Member

Choose a reason for hiding this comment

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

typo

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

if ctx == nil {
ctx = context.Background()
}
var cancelFunc func()
Copy link
Member

Choose a reason for hiding this comment

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

nit: cancelFunc is not used in this scope and can be moved inside if block

Copy link
Contributor Author

Choose a reason for hiding this comment

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

no this is to avoid ctx being scoped.

@shijiesheng shijiesheng merged commit 25044cf into cadence-workflow:master Mar 6, 2024
20 checks passed
Comment on lines 1062 to 1066
op := func(ctx context.Context, peer string) error {
var err error
ctx, cancel := c.createContext(ctx)
defer cancel()
response, err = c.client.RespondCrossClusterTasksCompleted(ctx, request, append(opts, yarpc.WithShardKey(peer))...)
return err
}
Copy link
Member

Choose a reason for hiding this comment

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

unless I'm misreading things, this is very different from the now-generated code.

it may be an improvement (createContext is rather terrifying iirc) but it's not clear this is correct.

Copy link
Member

Choose a reason for hiding this comment

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

I didn't get what is the concern about correctness?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think for this method it's correct. What's incorrect is these methods below don't have timeout but now were generated incorrectly with timeout. I'll fix it in the next pr.

GetReplicationMessages
GetDLQReplicationMessages
CountDLQMessages
ReadDLQMessages
PurgeDLQMessages
MergeDLQMessages
GetCrossClusterTasks
GetFailoverInfo

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed in #5737

Copy link
Member

@Groxx Groxx Mar 7, 2024

Choose a reason for hiding this comment

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

previously this was potentially modifying the context on each op call during (possibly multiple) request redirection retries.

now it's only doing that once, and it applies across all ops. (well before that, as it's the outer-most layer currently)

that's not necessarily a small change.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

timeout wrapper is still inside the "redirect client". So I think it's the same.
Basically

ctx, cancel := c.createContext(ctx)
defer cancel()
response, err = c.client.RespondCrossClusterTasksCompleted(ctx, request, append(opts, yarpc.WithShardKey(peer))...)

is modified to

response, err = c.wrappedClient.RespondCrossClusterTasksCompleted(ctx, request, append(opts, yarpc.WithShardKey(peer))...)

shijiesheng added a commit that referenced this pull request Mar 7, 2024
What changed?

#5728 code generated history client should exclude some endpoints.

Why?

Some replication endpoints don't have timeout before

How did you test it?

unit test
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.

4 participants