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

Support visibility dual write to different ES indices #2359

Merged
merged 8 commits into from
Jan 12, 2022

Conversation

meiliang86
Copy link
Contributor

What changed?
Support visibility dual write to different ES indices
Add additional dynamic configs to control visibility dual write and read behavior

Why?
To support seamless switch to new ES visibility index

How did you test it?
Local test with 2 ES indices

Potential risks
No. The old index should only be deleted after the new index is verified working.

Is hotfix candidate?
No

@meiliang86 meiliang86 requested review from alexshtin, yiminc and a team January 10, 2022 21:40
Comment on lines 610 to 618
if overStartTime {
params.Sorter = append(params.Sorter, elastic.NewFieldSort(searchattribute.StartTime).Desc())
} else {
params.Sorter = append(params.Sorter, elastic.NewFieldSort(searchattribute.CloseTime).Desc())
}

// RunID is explicit tiebreaker.
params.Sorter = append(params.Sorter, elastic.NewFieldSort(searchattribute.RunID).Desc())
// RunID is explicit tiebreaker.
params.Sorter = append(params.Sorter, elastic.NewFieldSort(searchattribute.RunID).Desc())
}
Copy link
Member

Choose a reason for hiding this comment

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

Please add TODO to remove this else block together with v2IndexPrefix const as soon as new approach is proven to work.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed to use the default sorting order in all cases.

@@ -138,7 +179,7 @@ func NewStandardManager(
}

func NewAdvancedManager(
defaultIndexName string,
indexName string,
Copy link
Member

Choose a reason for hiding this comment

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

The reason is was called defaultIndexName because there is partial support for index per namespace. Metadata has indexName field which is not propagated and used yet. The one from config supposed to be default index name if it is not configured on namespace level. I think you should rename it back.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

reverted

@@ -70,7 +70,9 @@ var Keys = map[Key]string{
AdvancedVisibilityPersistenceMaxReadQPS: "system.advancedVisibilityPersistenceMaxReadQPS",
AdvancedVisibilityPersistenceMaxWriteQPS: "system.advancedVisibilityPersistenceMaxWriteQPS",
AdvancedVisibilityWritingMode: "system.advancedVisibilityWritingMode",
EnableWriteToSecondaryVisibility: "system.enableWriteToSecondaryVisibility",
Copy link
Member

Choose a reason for hiding this comment

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

may be:

Suggested change
EnableWriteToSecondaryVisibility: "system.enableWriteToSecondaryVisibility",
EnableWriteToSecondaryAdvancedVisibility: "system.enableWriteToSecondaryAdvancedVisibility",

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@@ -44,7 +44,7 @@ func NewManager(
persistenceCfg config.Persistence,
persistenceResolver resolver.ServiceResolver,

defaultIndexName string,
esConfig *esclient.Config,
Copy link
Member

Choose a reason for hiding this comment

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

I would pass both index names here rather than taking dependency on the config.

@@ -80,12 +81,18 @@ type (
// GetVisibilityIndex return visibility index name from Elasticsearch config or empty string if it is not defined.
func (cfg *Config) GetVisibilityIndex() string {
if cfg == nil {
// Empty string is be used as default index name when Elasticsearch is not configured.
Copy link
Member

Choose a reason for hiding this comment

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

It was important comment. Why did you remove it? It had grammar errors though.

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 will add this back. But how is it supposed to work if user does not specify index name?

Comment on lines 43 to 55
managerSelector interface {
readManager(namespace namespace.Name) manager.VisibilityManager
writeManagers() ([]manager.VisibilityManager, error)
}

sqlToESManagerSelector struct {
enableAdvancedVisibilityRead dynamicconfig.BoolPropertyFnWithNamespaceFilter
advancedVisibilityWritingMode dynamicconfig.StringPropertyFn
stdVisibilityManager manager.VisibilityManager
advVisibilityManager manager.VisibilityManager
}

esManagerSelector struct {
Copy link
Member

Choose a reason for hiding this comment

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

Please place all these structs and their methods in separate files. I hate to mix structs with methods in one file (I know we have many of those but it is just a legacy and I am constantly fixing it).

@@ -383,8 +385,12 @@ const (
AdvancedVisibilityPersistenceMaxWriteQPS
// AdvancedVisibilityWritingMode is key for how to write to advanced visibility
AdvancedVisibilityWritingMode
// EnableWriteToSecondaryAdvancedVisibility is the config to enable write to secondary visibility for elastic search
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// EnableWriteToSecondaryAdvancedVisibility is the config to enable write to secondary visibility for elastic search
// EnableWriteToSecondaryAdvancedVisibility is the config to enable write to secondary visibility for Elasticsearch.

// EnableReadVisibilityFromES is key for enable read from elastic search
EnableReadVisibilityFromES
// EnableReadFromSecondaryAdvancedVisibility is the config to enable read from secondary elastic search
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// EnableReadFromSecondaryAdvancedVisibility is the config to enable read from secondary elastic search
// EnableReadFromSecondaryAdvancedVisibility is the config to enable read from secondary Elasticsearch.

@meiliang86 meiliang86 merged commit c61e2c8 into temporalio:master Jan 12, 2022
yiminc pushed a commit to yiminc/temporal that referenced this pull request Jan 12, 2022
* Change order by clauses in query and update V1 index template. Index created by the old template will continue to function, but won't see the query performance improvement.
* Support visibility dual write to different ES indices.
* Add additional dynamic configs to control visibility dual write behavior.
yiminc pushed a commit that referenced this pull request Jan 12, 2022
* Change order by clauses in query and update V1 index template. Index created by the old template will continue to function, but won't see the query performance improvement.
* Support visibility dual write to different ES indices.
* Add additional dynamic configs to control visibility dual write behavior.
johanforssell added a commit to johanforssell/temporal that referenced this pull request Feb 8, 2023
PR temporalio#2359 added support for dual write to different ES indices. There was no change to the config template to enable this feature.
johanforssell added a commit to johanforssell/temporal that referenced this pull request Feb 8, 2023
PR temporalio#2359 added support for dual write to different ES indices.
There was no change to the config template to enable this feature.
This commit will set secondary_visibility if env ES_SEC_VIS_INDEX is set.
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.

2 participants