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

Refactor: not require db visibility when ES visibility is provided #4241

Merged
merged 20 commits into from
Jun 3, 2021

Conversation

longquanzheng
Copy link
Contributor

@longquanzheng longquanzheng commented May 29, 2021

What changed?

  1. Remove the requirement of db visibility when ES visibility is provided
  2. Move dynamic config to dynamicconfig package

Why?

  1. This will make implementing nosql plugin much easier. It's unecessary to implement basic visibility with nosql as ES is much better
  2. For consistency

How did you test it?
existing tests

Potential risks
Low

Release notes
Announce this change in release to the community

Documentation Changes
cadence-workflow/Cadence-Docs#51

@longquanzheng longquanzheng changed the title Not require db visibility when ES visibility is provided Refactor: not require db visibility when ES visibility is provided May 31, 2021
@longquanzheng longquanzheng marked this pull request as ready for review June 1, 2021 00:58
@coveralls
Copy link

coveralls commented Jun 1, 2021

Pull Request Test Coverage Report for Build be9fe5f2-bf33-46a7-8cc4-52450f1a04b2

  • 195 of 309 (63.11%) changed or added relevant lines in 11 files are covered.
  • 79 unchanged lines in 17 files lost coverage.
  • Overall coverage increased (+0.05%) to 60.177%

Changes Missing Coverage Covered Lines Changed/Added Lines %
common/resource/resourceImpl.go 4 6 66.67%
service/worker/service.go 0 5 0.0%
common/config/persistence.go 0 9 0.0%
common/persistence/client/factory.go 53 63 84.13%
common/persistence/persistence-tests/dbVisibilityPersistenceTest.go 0 29 0.0%
common/persistence/visibilityDualManager.go 90 149 60.4%
Files with Coverage Reduction New Missed Lines %
common/resource/resourceImpl.go 1 79.11%
client/history/client.go 2 44.78%
client/history/metricClient.go 2 49.43%
common/task/fifoTaskScheduler.go 2 85.57%
common/task/parallelTaskProcessor.go 2 92.48%
service/history/handler.go 2 46.67%
service/history/queue/timer_queue_processor.go 2 58.77%
service/history/queue/transfer_queue_processor.go 2 57.37%
service/matching/matcher.go 2 91.46%
service/worker/service.go 2 22.34%
Totals Coverage Status
Change from base Build cc06e01c-2f64-4613-aac2-df53334a6488: 0.05%
Covered Lines: 88797
Relevant Lines: 147559

💛 - Coveralls

@@ -39,8 +39,20 @@ func (c *Persistence) DefaultStoreType() string {

// Validate validates the persistence config
func (c *Persistence) Validate() error {
stores := []string{c.DefaultStore, c.VisibilityStore}
for _, st := range stores {
if _, ok := c.DataStores[c.DefaultStore]; !ok {
Copy link
Member

Choose a reason for hiding this comment

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

nit: line 42 - 44 is already covered in the for loop

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed. Good catch, thanks!


type (
// ResourceConfig is a subset of the service dynamic config
ResourceConfig struct {
Copy link
Contributor

Choose a reason for hiding this comment

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

shall we move this to common/resource package?

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 did that initially, but that would cause a circular dependency issue. We can also have a separate package for this: common/resource/config package.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved to resource/config/ pkg

ctx context.Context,
request *VisibilityDeleteWorkflowExecutionRequest,
) error {
return v.chooseVisibilityManagerForWrite(
Copy link
Member

Choose a reason for hiding this comment

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

Original behavior deletes workflows from all available storages, which is better for data cleaning. What do you think of it?

Copy link
Contributor Author

@longquanzheng longquanzheng Jun 3, 2021

Choose a reason for hiding this comment

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

Yes I changed that. I don't see it necessary. People uses dual write mode only for migration. After the migration, one of them will be removed anyway. Changing it here will make the behavior consistent with the configuration, or under the expectation of the configuration. It would be very hard to explain/documenting to have such a exceptional behavior in deleting. Another downside of keeping it is that would send more unnecessary DB requests. After switching from dual write mode to ES only mode, new workflows will only be written into ES, and deleting from DB will not delete anything.

if visConfig != nil && visConfig.EnableSampling() {
result = p.NewVisibilitySamplingClient(result, visConfig, f.metricsClient, f.logger)
if visibilityConfig.EnableDBVisibilitySampling() {
result = p.NewVisibilitySamplingClient(result, &p.SamplingConfig{
Copy link
Member

Choose a reason for hiding this comment

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

Fields in ResourceConfig can be nil, but we are not doing any checks on the caller side or callee side.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What kind of checking do you think we should have? I am open to add more. There is one checking in the factoryImpl which would return nil when both read and write mode are nil.

Copy link
Member

Choose a reason for hiding this comment

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

Something similar to line 324 before invoking the functions

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah I see. Added the nil check here.

logger log.Logger,
) (persistence.VisibilityManager, error) {
return persistenceBean.GetVisibilityManager(), nil
common.MatchingServiceName,
Copy link
Member

Choose a reason for hiding this comment

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

common.WorkerServiceName

@longquanzheng longquanzheng merged commit 208edf4 into master Jun 3, 2021
@longquanzheng longquanzheng deleted the qlong-visibility-require branch June 3, 2021 17:39
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