Skip to content

Commit

Permalink
Fixing saving custom search attribute after upgrading SQL DB (#4062)
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigozhou committed Mar 21, 2023
1 parent e7b4276 commit dc018cd
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions temporal/fx.go
Expand Up @@ -708,7 +708,6 @@ func ApplyClusterMetadataConfigProvider(
if err != nil {
return config.ClusterMetadata, config.Persistence, fmt.Errorf("error while fetching cluster metadata: %w", err)
}

currentMetadata := resp.ClusterMetadata

// TODO (rodrigozhou): Remove this block for v1.21.
Expand All @@ -726,7 +725,10 @@ func ApplyClusterMetadataConfigProvider(
if needSave {
_, err := clusterMetadataManager.SaveClusterMetadata(
ctx,
&persistence.SaveClusterMetadataRequest{ClusterMetadata: currentMetadata},
&persistence.SaveClusterMetadataRequest{
ClusterMetadata: currentMetadata,
Version: resp.Version,
},
)
if err != nil {
logger.Warn(
Expand All @@ -736,6 +738,16 @@ func ApplyClusterMetadataConfigProvider(
)
}
logger.Info("Successfully registered search attributes.", tag.ClusterName(clusterName))

// need to re-fetch cluster metadata since it might need to be updated again below
resp, err = clusterMetadataManager.GetClusterMetadata(
ctx,
&persistence.GetClusterMetadataRequest{ClusterName: clusterName},
)
if err != nil {
return config.ClusterMetadata, config.Persistence, fmt.Errorf("error while fetching cluster metadata: %w", err)
}
currentMetadata = resp.ClusterMetadata
}
}

Expand Down

0 comments on commit dc018cd

Please sign in to comment.