From 595b9cee385e8398634935d0b6df6dc37746d697 Mon Sep 17 00:00:00 2001 From: Rodrigo Zhou Date: Fri, 3 Nov 2023 17:10:16 -0500 Subject: [PATCH] Add parent workflow info to visibility schema (#5054) **What changed?** Add parent workflow info to visibibility schema **Why?** **How did you test it?** Unit tests **Potential risks** No. **Is hotfix candidate?** No. --- schema/mysql/v8/visibility/schema.sql | 4 ++++ .../visibility/versioned/v1.4/add_parent_workflow_info.sql | 4 ++++ schema/mysql/v8/visibility/versioned/v1.4/manifest.json | 5 +++-- schema/postgresql/v12/visibility/schema.sql | 4 ++++ .../visibility/versioned/v1.4/add_parent_workflow_info.sql | 4 ++++ .../postgresql/v12/visibility/versioned/v1.4/manifest.json | 5 +++-- schema/sqlite/v3/visibility/schema.sql | 4 ++++ 7 files changed, 26 insertions(+), 4 deletions(-) create mode 100644 schema/mysql/v8/visibility/versioned/v1.4/add_parent_workflow_info.sql create mode 100644 schema/postgresql/v12/visibility/versioned/v1.4/add_parent_workflow_info.sql diff --git a/schema/mysql/v8/visibility/schema.sql b/schema/mysql/v8/visibility/schema.sql index dc27a239412..db93dd0787d 100644 --- a/schema/mysql/v8/visibility/schema.sql +++ b/schema/mysql/v8/visibility/schema.sql @@ -15,6 +15,8 @@ CREATE TABLE executions_visibility ( encoding VARCHAR(64) NOT NULL, task_queue VARCHAR(255) NOT NULL DEFAULT '', search_attributes JSON NULL, + parent_workflow_id VARCHAR(255) NULL, + parent_run_id VARCHAR(255) NULL, -- Each search attribute has its own generated column. -- For string types (keyword and text), we need to unquote the json string, @@ -54,6 +56,8 @@ CREATE INDEX by_history_size_bytes ON executions_visibility (namespace_id, CREATE INDEX by_execution_duration ON executions_visibility (namespace_id, execution_duration, (COALESCE(close_time, CAST('9999-12-31 23:59:59' AS DATETIME))) DESC, start_time DESC, run_id); CREATE INDEX by_state_transition_count ON executions_visibility (namespace_id, state_transition_count, (COALESCE(close_time, CAST('9999-12-31 23:59:59' AS DATETIME))) DESC, start_time DESC, run_id); CREATE INDEX by_task_queue ON executions_visibility (namespace_id, task_queue, (COALESCE(close_time, CAST('9999-12-31 23:59:59' AS DATETIME))) DESC, start_time DESC, run_id); +CREATE INDEX by_parent_workflow_id ON executions_visibility (namespace_id, parent_workflow_id, (COALESCE(close_time, CAST('9999-12-31 23:59:59' AS DATETIME))) DESC, start_time DESC, run_id); +CREATE INDEX by_parent_run_id ON executions_visibility (namespace_id, parent_run_id, (COALESCE(close_time, CAST('9999-12-31 23:59:59' AS DATETIME))) DESC, start_time DESC, run_id); -- Indexes for the predefined search attributes CREATE INDEX by_temporal_change_version ON executions_visibility (namespace_id, (CAST(TemporalChangeVersion AS CHAR(255) ARRAY)), (COALESCE(close_time, CAST('9999-12-31 23:59:59' AS DATETIME))) DESC, start_time DESC, run_id); diff --git a/schema/mysql/v8/visibility/versioned/v1.4/add_parent_workflow_info.sql b/schema/mysql/v8/visibility/versioned/v1.4/add_parent_workflow_info.sql new file mode 100644 index 00000000000..abdb233edda --- /dev/null +++ b/schema/mysql/v8/visibility/versioned/v1.4/add_parent_workflow_info.sql @@ -0,0 +1,4 @@ +ALTER TABLE executions_visibility ADD COLUMN parent_workflow_id VARCHAR(255) NULL; +ALTER TABLE executions_visibility ADD COLUMN parent_run_id VARCHAR(255) NULL; +CREATE INDEX by_parent_workflow_id ON executions_visibility (namespace_id, parent_workflow_id, (COALESCE(close_time, CAST('9999-12-31 23:59:59' AS DATETIME))) DESC, start_time DESC, run_id); +CREATE INDEX by_parent_run_id ON executions_visibility (namespace_id, parent_run_id, (COALESCE(close_time, CAST('9999-12-31 23:59:59' AS DATETIME))) DESC, start_time DESC, run_id); diff --git a/schema/mysql/v8/visibility/versioned/v1.4/manifest.json b/schema/mysql/v8/visibility/versioned/v1.4/manifest.json index a1f41e0ff11..8d9482a647c 100644 --- a/schema/mysql/v8/visibility/versioned/v1.4/manifest.json +++ b/schema/mysql/v8/visibility/versioned/v1.4/manifest.json @@ -1,9 +1,10 @@ { "CurrVersion": "1.4", "MinCompatibleVersion": "0.1", - "Description": "add execution duration and state transition count columns and indices", + "Description": "add execution duration, state transition count and parent workflow info columns, and indices", "SchemaUpdateCqlFiles": [ "add_execution_duration.sql", - "add_state_transition_count.sql" + "add_state_transition_count.sql", + "add_parent_workflow_info.sql" ] } diff --git a/schema/postgresql/v12/visibility/schema.sql b/schema/postgresql/v12/visibility/schema.sql index d11fe087124..44386e09b56 100644 --- a/schema/postgresql/v12/visibility/schema.sql +++ b/schema/postgresql/v12/visibility/schema.sql @@ -24,6 +24,8 @@ CREATE TABLE executions_visibility ( encoding VARCHAR(64) NOT NULL, task_queue VARCHAR(255) NOT NULL DEFAULT '', search_attributes JSONB NULL, + parent_workflow_id VARCHAR(255) NULL, + parent_run_id VARCHAR(255) NULL, -- Each search attribute has its own generated column. -- Since PostgreSQL doesn't support virtual columns, all columns are stored. @@ -83,6 +85,8 @@ CREATE INDEX by_history_size_bytes ON executions_visibility (namespace_id, CREATE INDEX by_execution_duration ON executions_visibility (namespace_id, execution_duration, (COALESCE(close_time, '9999-12-31 23:59:59')) DESC, start_time DESC, run_id); CREATE INDEX by_state_transition_count ON executions_visibility (namespace_id, state_transition_count, (COALESCE(close_time, '9999-12-31 23:59:59')) DESC, start_time DESC, run_id); CREATE INDEX by_task_queue ON executions_visibility (namespace_id, task_queue, (COALESCE(close_time, '9999-12-31 23:59:59')) DESC, start_time DESC, run_id); +CREATE INDEX by_parent_workflow_id ON executions_visibility (namespace_id, parent_workflow_id, (COALESCE(close_time, '9999-12-31 23:59:59')) DESC, start_time DESC, run_id); +CREATE INDEX by_parent_run_id ON executions_visibility (namespace_id, parent_run_id, (COALESCE(close_time, '9999-12-31 23:59:59')) DESC, start_time DESC, run_id); -- Indexes for the predefined search attributes CREATE INDEX by_temporal_change_version ON executions_visibility USING GIN (namespace_id, TemporalChangeVersion jsonb_path_ops); diff --git a/schema/postgresql/v12/visibility/versioned/v1.4/add_parent_workflow_info.sql b/schema/postgresql/v12/visibility/versioned/v1.4/add_parent_workflow_info.sql new file mode 100644 index 00000000000..bb01d309aeb --- /dev/null +++ b/schema/postgresql/v12/visibility/versioned/v1.4/add_parent_workflow_info.sql @@ -0,0 +1,4 @@ +ALTER TABLE executions_visibility ADD COLUMN parent_workflow_id VARCHAR(255) NULL; +ALTER TABLE executions_visibility ADD COLUMN parent_run_id VARCHAR(255) NULL; +CREATE INDEX by_parent_workflow_id ON executions_visibility (namespace_id, parent_workflow_id, (COALESCE(close_time, '9999-12-31 23:59:59')) DESC, start_time DESC, run_id); +CREATE INDEX by_parent_run_id ON executions_visibility (namespace_id, parent_run_id, (COALESCE(close_time, '9999-12-31 23:59:59')) DESC, start_time DESC, run_id); diff --git a/schema/postgresql/v12/visibility/versioned/v1.4/manifest.json b/schema/postgresql/v12/visibility/versioned/v1.4/manifest.json index a1f41e0ff11..8d9482a647c 100644 --- a/schema/postgresql/v12/visibility/versioned/v1.4/manifest.json +++ b/schema/postgresql/v12/visibility/versioned/v1.4/manifest.json @@ -1,9 +1,10 @@ { "CurrVersion": "1.4", "MinCompatibleVersion": "0.1", - "Description": "add execution duration and state transition count columns and indices", + "Description": "add execution duration, state transition count and parent workflow info columns, and indices", "SchemaUpdateCqlFiles": [ "add_execution_duration.sql", - "add_state_transition_count.sql" + "add_state_transition_count.sql", + "add_parent_workflow_info.sql" ] } diff --git a/schema/sqlite/v3/visibility/schema.sql b/schema/sqlite/v3/visibility/schema.sql index e6c79b7ba8a..626be04b433 100644 --- a/schema/sqlite/v3/visibility/schema.sql +++ b/schema/sqlite/v3/visibility/schema.sql @@ -15,6 +15,8 @@ CREATE TABLE executions_visibility ( encoding VARCHAR(64) NOT NULL, task_queue VARCHAR(255) NOT NULL DEFAULT '', search_attributes TEXT NULL, + parent_workflow_id VARCHAR(255) NULL, + parent_run_id VARCHAR(255) NULL, -- Predefined search attributes TemporalChangeVersion TEXT GENERATED ALWAYS AS (JSON_EXTRACT(search_attributes, "$.TemporalChangeVersion")) STORED, @@ -69,6 +71,8 @@ CREATE INDEX by_history_size_bytes ON executions_visibility (namespace_id, CREATE INDEX by_execution_duration ON executions_visibility (namespace_id, execution_duration, (COALESCE(close_time, '9999-12-31 23:59:59+00:00')) DESC, start_time DESC, run_id); CREATE INDEX by_state_transition_count ON executions_visibility (namespace_id, state_transition_count, (COALESCE(close_time, '9999-12-31 23:59:59+00:00')) DESC, start_time DESC, run_id); CREATE INDEX by_task_queue ON executions_visibility (namespace_id, task_queue, (COALESCE(close_time, '9999-12-31 23:59:59+00:00')) DESC, start_time DESC, run_id); +CREATE INDEX by_parent_workflow_id ON executions_visibility (namespace_id, parent_workflow_id, (COALESCE(close_time, '9999-12-31 23:59:59+00:00')) DESC, start_time DESC, run_id); +CREATE INDEX by_parent_run_id ON executions_visibility (namespace_id, parent_run_id, (COALESCE(close_time, '9999-12-31 23:59:59+00:00')) DESC, start_time DESC, run_id); -- Indexes for the predefined search attributes CREATE INDEX by_batcher_user ON executions_visibility (namespace_id, BatcherUser, (COALESCE(close_time, '9999-12-31 23:59:59+00:00')) DESC, start_time DESC, run_id);