-
Notifications
You must be signed in to change notification settings - Fork 911
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
Worker versioning - add BuildIDs search attribute #4284
Merged
bergundy
merged 14 commits into
temporalio:worker-versioning
from
bergundy:worker-versioning-build-id-search-attribute
May 8, 2023
Merged
Changes from 8 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
858686e
Add build ID search attribute in history service
bergundy 048efbd
Add visibility schemas
bergundy 74c6836
Add advanced visibility test
bergundy f0af5a7
Fix lint
bergundy a5be540
Undo unwanted test changes
bergundy a4e101e
go mod tidy :(
bergundy dd8d707
Fix test
bergundy 69f1f51
I think I fixed the test
bergundy d055e97
Minor fix
bergundy f718731
s/BuildIDs/BuildIds/g
bergundy da5d26f
s/BuildID/BuildId/g
bergundy f7b043e
Use s.Eventually
bergundy 0ad5213
Fix mock client
bergundy 37e4561
Regen protos
bergundy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule api
updated
4 files
+4 −0 | temporal/api/common/v1/message.proto | |
+1 −0 | temporal/api/history/v1/message.proto | |
+4 −0 | temporal/api/workflow/v1/message.proto | |
+0 −5 | temporal/api/workflowservice/v1/request_response.proto |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
versioned/v4/index_template_v7.json | ||
versioned/v5/index_template_v7.json |
87 changes: 87 additions & 0 deletions
87
schema/elasticsearch/visibility/versioned/v5/index_template_v7.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,87 @@ | ||||||
{ | ||||||
"order": 0, | ||||||
"index_patterns": ["temporal_visibility_v1*"], | ||||||
"settings": { | ||||||
"index": { | ||||||
"number_of_shards": "1", | ||||||
"number_of_replicas": "0", | ||||||
"auto_expand_replicas": "0-2", | ||||||
"search.idle.after": "365d", | ||||||
"sort.field": ["CloseTime", "StartTime", "RunId"], | ||||||
"sort.order": ["desc", "desc", "desc"], | ||||||
"sort.missing": ["_first", "_first", "_first"] | ||||||
} | ||||||
}, | ||||||
"mappings": { | ||||||
"dynamic": "false", | ||||||
"properties": { | ||||||
"NamespaceId": { | ||||||
"type": "keyword" | ||||||
}, | ||||||
"TemporalNamespaceDivision": { | ||||||
"type": "keyword" | ||||||
}, | ||||||
"WorkflowId": { | ||||||
"type": "keyword" | ||||||
}, | ||||||
"RunId": { | ||||||
"type": "keyword" | ||||||
}, | ||||||
"WorkflowType": { | ||||||
"type": "keyword" | ||||||
}, | ||||||
"StartTime": { | ||||||
"type": "date_nanos" | ||||||
}, | ||||||
"ExecutionTime": { | ||||||
"type": "date_nanos" | ||||||
}, | ||||||
"CloseTime": { | ||||||
"type": "date_nanos" | ||||||
}, | ||||||
"ExecutionDuration": { | ||||||
"type": "long" | ||||||
}, | ||||||
"ExecutionStatus": { | ||||||
"type": "keyword" | ||||||
}, | ||||||
"TaskQueue": { | ||||||
"type": "keyword" | ||||||
}, | ||||||
"TemporalChangeVersion": { | ||||||
"type": "keyword" | ||||||
}, | ||||||
"BatcherNamespace": { | ||||||
"type": "keyword" | ||||||
}, | ||||||
"BatcherUser": { | ||||||
"type": "keyword" | ||||||
}, | ||||||
"BinaryChecksums": { | ||||||
"type": "keyword" | ||||||
}, | ||||||
"HistoryLength": { | ||||||
"type": "long" | ||||||
}, | ||||||
"StateTransitionCount": { | ||||||
"type": "long" | ||||||
}, | ||||||
"TemporalScheduledStartTime": { | ||||||
"type": "date_nanos" | ||||||
}, | ||||||
"TemporalScheduledById": { | ||||||
"type": "keyword" | ||||||
}, | ||||||
"TemporalSchedulePaused": { | ||||||
"type": "boolean" | ||||||
}, | ||||||
"HistorySizeBytes": { | ||||||
"type": "long" | ||||||
}, | ||||||
"BuildIDs": { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
"type": "keyword" | ||||||
} | ||||||
} | ||||||
}, | ||||||
"aliases": {} | ||||||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -eu -o pipefail | ||
|
||
# Prerequisites: | ||
# - jq | ||
# - curl | ||
|
||
# Input parameters. | ||
: "${ES_SCHEME:=http}" | ||
: "${ES_SERVER:=127.0.0.1}" | ||
: "${ES_PORT:=9200}" | ||
: "${ES_USER:=}" | ||
: "${ES_PWD:=}" | ||
: "${ES_VERSION:=v7}" | ||
: "${ES_VIS_INDEX_V1:=temporal_visibility_v1_dev}" | ||
: "${AUTO_CONFIRM:=}" | ||
: "${SLICES_COUNT:=auto}" | ||
|
||
es_endpoint="${ES_SCHEME}://${ES_SERVER}:${ES_PORT}" | ||
|
||
echo "=== Step 0. Sanity check if Elasticsearch index is accessible ===" | ||
|
||
if ! curl --silent --fail --user "${ES_USER}":"${ES_PWD}" "${es_endpoint}/${ES_VIS_INDEX_V1}/_stats/docs" --write-out "\n"; then | ||
echo "Elasticsearch index ${ES_VIS_INDEX_V1} is not accessible at ${es_endpoint}." | ||
exit 1 | ||
fi | ||
|
||
echo "=== Step 1. Add new builtin search attributes ===" | ||
|
||
new_mapping=' | ||
{ | ||
"properties": { | ||
"BuildIDs": { | ||
"type": "keyword" | ||
} | ||
} | ||
} | ||
' | ||
|
||
if [ -z "${AUTO_CONFIRM}" ]; then | ||
read -p "Add new builtin search attributes to the index ${ES_VIS_INDEX_V1}? (N/y)" -n 1 -r | ||
echo | ||
else | ||
REPLY="y" | ||
fi | ||
if [ "${REPLY}" = "y" ]; then | ||
curl --silent --fail --user "${ES_USER}":"${ES_PWD}" -X PUT "${es_endpoint}/${ES_VIS_INDEX_V1}/_mapping" -H "Content-Type: application/json" --data-binary "$new_mapping" | jq | ||
# Wait for mapping changes to go through. | ||
until curl --silent --user "${ES_USER}":"${ES_PWD}" "${es_endpoint}/_cluster/health/${ES_VIS_INDEX_V1}" | jq --exit-status '.status=="green" | .'; do | ||
echo "Waiting for Elasticsearch index ${ES_VIS_INDEX_V1} become green." | ||
sleep 1 | ||
done | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
schema/mysql/v8/visibility/versioned/v1.3/add_build_ids_search_attribute.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
ALTER TABLE executions_visibility ADD COLUMN BuildIDs JSON GENERATED ALWAYS AS (search_attributes->'BuildIDs'); | ||
CREATE INDEX by_build_ids ON executions_visibility (namespace_id, (CAST(BuildIDs AS CHAR(255) ARRAY)), (COALESCE(close_time, CAST('9999-12-31 23:59:59' AS DATETIME))) DESC, start_time DESC, run_id); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
{ | ||
"CurrVersion": "1.3", | ||
"MinCompatibleVersion": "0.1", | ||
"Description": "add history size bytes", | ||
"Description": "add history size bytes and build IDs visibility columns and indices", | ||
"SchemaUpdateCqlFiles": [ | ||
"add_history_size_bytes.sql" | ||
"add_history_size_bytes.sql", | ||
"add_build_ids_search_attribute.sql" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
schema/postgresql/v12/visibility/versioned/v1.3/add_build_ids_search_attribute.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
ALTER TABLE executions_visibility ADD COLUMN BuildIDs JSONB GENERATED ALWAYS AS (search_attributes->'BuildIDs') STORED; | ||
CREATE INDEX by_build_ids ON executions_visibility USING GIN (namespace_id, BuildIDs jsonb_path_ops); |
5 changes: 3 additions & 2 deletions
5
schema/postgresql/v12/visibility/versioned/v1.3/manifest.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
{ | ||
"CurrVersion": "1.3", | ||
"MinCompatibleVersion": "0.1", | ||
"Description": "add history size bytes", | ||
"Description": "add history size bytes and build IDs visibility columns and indices", | ||
"SchemaUpdateCqlFiles": [ | ||
"add_history_size_bytes.sql" | ||
"add_history_size_bytes.sql", | ||
"add_build_ids_search_attribute.sql" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given that the other "ids" above are capitalized (
WorkflowId
,RunId
), should it be better if this wereBuildIds
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, I thought about that but because it's plural I think it'd be clearer if IDs stands out more.
I'm now not so convinced.
I'll get another opinion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here you are.