Skip to content

Commit

Permalink
Add parent workflow info to visibility schema (#5054)
Browse files Browse the repository at this point in the history
<!-- Describe what has changed in this PR -->
**What changed?**
Add parent workflow info to visibibility schema

<!-- Tell your future self why have you made these changes -->
**Why?**


<!-- How have you verified this change? Tested locally? Added a unit
test? Checked in staging env? -->
**How did you test it?**
Unit tests

<!-- Assuming the worst case, what can be broken when deploying this
change to production? -->
**Potential risks**
No.

<!-- Is this PR a hotfix candidate or require that a notification be
sent to the broader community? (Yes/No) -->
**Is hotfix candidate?**
No.
  • Loading branch information
rodrigozhou authored Nov 3, 2023
1 parent 8bb1792 commit 595b9ce
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 4 deletions.
4 changes: 4 additions & 0 deletions schema/mysql/v8/visibility/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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);
5 changes: 3 additions & 2 deletions schema/mysql/v8/visibility/versioned/v1.4/manifest.json
Original file line number Diff line number Diff line change
@@ -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"
]
}
4 changes: 4 additions & 0 deletions schema/postgresql/v12/visibility/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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);
5 changes: 3 additions & 2 deletions schema/postgresql/v12/visibility/versioned/v1.4/manifest.json
Original file line number Diff line number Diff line change
@@ -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"
]
}
4 changes: 4 additions & 0 deletions schema/sqlite/v3/visibility/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 595b9ce

Please sign in to comment.