feat(active-active): Add MySQL support for cluster selection policy#8014
feat(active-active): Add MySQL support for cluster selection policy#8014joannalauu wants to merge 2 commits intocadence-workflow:masterfrom
Conversation
| func (mdb *DB) SelectFromActiveClusterSelectionPolicy(ctx context.Context, filter *sqlplugin.ActiveClusterSelectionPolicyFilter) (*sqlplugin.ActiveClusterSelectionPolicyRow, error) { | ||
| dbShardID := sqlplugin.GetDBShardIDFromHistoryShardID(filter.ShardID, mdb.GetTotalNumDBShards()) | ||
| var row sqlplugin.ActiveClusterSelectionPolicyRow | ||
| err := mdb.driver.GetContext( | ||
| ctx, | ||
| dbShardID, | ||
| &row, | ||
| getActiveClusterSelectionPolicyQuery, | ||
| filter.ShardID, | ||
| filter.DomainID, | ||
| filter.WorkflowID, | ||
| filter.RunID, | ||
| ) | ||
| if err != nil { | ||
| return nil, err |
There was a problem hiding this comment.
💡 Quality: MySQL SELECT query doesn't use db struct tags for column mapping
In SelectFromActiveClusterSelectionPolicy (mysql/active_cluster_selection_policy.go:62-71), the query selects columns like shard_id, domain_id, workflow_id, run_id, data, data_encoding and scans into ActiveClusterSelectionPolicyRow via GetContext. The struct relies on sqlx.MapperFunc(strcase.ToSnake) for automatic mapping (e.g., DataEncoding → data_encoding). This is consistent with the existing codebase pattern, but worth noting that ShardID maps to shard_i_d under strcase.ToSnake in some implementations. Verify that the mapper correctly handles the ID suffix — if it produces shard_i_d instead of shard_id, the SELECT will fail silently with zero values. Other structs in the codebase have the same pattern so this is likely fine, but worth a quick integration test.
Was this helpful? React with 👍 / 👎 | Reply gitar fix to apply this suggestion
77b0cf9 to
dd36720
Compare
Signed-off-by: Joanna Lau <118241363+joannalauu@users.noreply.github.com>
dd36720 to
1fe09c2
Compare
…postgres and sqlite Signed-off-by: Joanna Lau <118241363+joannalauu@users.noreply.github.com>
CI failed: The CI analysis identified no build or test failures in the provided logs, as they only captured the successful setup and initialization phases of the job.OverviewThe provided logs contain only successful repository checkout and Go environment setup; no actual test execution or build output was present to analyze. FailuresIncomplete Log Output (confidence: high)
Summary
Code Review 👍 Approved with suggestions 1 resolved / 2 findingsAdds MySQL support for the cluster selection policy and resolves the silent error handling bug in Postgres/SQLite delete operations. Ensure the MySQL SELECT query is updated to use db struct tags for consistent column mapping. 💡 Quality: MySQL SELECT query doesn't use db struct tags for column mapping📄 common/persistence/sql/sqlplugin/mysql/active_cluster_selection_policy.go:59-73 In ✅ 1 resolved✅ Bug: Postgres/SQLite Delete silently succeeds instead of returning error
🤖 Prompt for agentsRules ❌ No requirements metRepository Rules
2 rules not applicable. Show all rules by commenting Tip Comment OptionsAuto-apply is off → Gitar will not commit updates to this branch. Comment with these commands to change:
Was this helpful? React with 👍 / 👎 | Gitar |
|
all unit tests are passing locally |
What changed?
Added MySQL support for cluster selection policy
GetActiveClusterSelectionPolicyandDeleteActiveClusterSelectionPolicyfor sql storesinsertActiveClusterSelectionPolicywhen new workflow is createdWhy?
Implement MySQL support for active-active domains
How did you test it?
go test ./common/persistence/sql/sqlplugin/mysql ./common/persistence/sql/Integration tests for MySQL
Potential risks
Release notes
Documentation Changes
Detailed Description
[In-depth description of the changes made to the schema or interfaces, specifying new fields, removed fields, or modified data structures]
Added MySQL support for cluster selection policy
GetActiveClusterSelectionPolicyandDeleteActiveClusterSelectionPolicyfor sql storesinsertActiveClusterSelectionPolicywhen new workflow is createdImpact Analysis
Testing Plan
go test ./common/persistence/sql/sqlplugin/mysql ./common/persistence/sql/Rollout Plan