-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Changes ListClosedWorkflow result ordering for SQL-based visibility stores to be based off of workflow close time #578
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
Merged
mastermanu
merged 5 commits into
temporalio:master
from
mastermanu:listclosedworkflowexecutions_order_sql
Jul 21, 2020
Merged
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
4031aac
adds correct listworkflowexecution ordering for SQL-backed visibility…
mastermanu 70bf09b
fixes paging
mastermanu 02ff324
fix postgres paging
mastermanu 17bddc2
Merge branch 'master' of https://github.com/temporalio/temporal into …
mastermanu 32a78c1
Merge branch 'master' into listclosedworkflowexecutions_order_sql
mastermanu 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -57,17 +57,31 @@ const ( | |
| templateConditions1 = ` AND namespace_id = $1 | ||
| AND start_time >= $2 | ||
| AND start_time <= $3 | ||
| AND (run_id > $4 OR start_time < $5) | ||
| AND ((run_id > $4 and start_time = $5) OR (start_time < $6)) | ||
| ORDER BY start_time DESC, run_id | ||
| LIMIT $6` | ||
| LIMIT $7` | ||
|
|
||
| templateConditions2 = ` AND namespace_id = $2 | ||
| AND start_time >= $3 | ||
| AND start_time <= $4 | ||
| AND (run_id > $5 OR start_time < $6) | ||
| AND ((run_id > $5 and start_time = $6) OR (start_time < $7)) | ||
| ORDER BY start_time DESC, run_id | ||
| LIMIT $8` | ||
|
|
||
| templateConditionsClosedWorkflow1 = ` AND namespace_id = $1 | ||
| AND close_time >= $2 | ||
| AND close_time <= $3 | ||
| AND ((run_id > $4 and close_time = $5) OR (close_time < $6)) | ||
| ORDER BY close_time DESC, run_id | ||
| LIMIT $7` | ||
|
|
||
| templateConditionsClosedWorkflow2 = ` AND namespace_id = $2 | ||
| AND close_time >= $3 | ||
| AND close_time <= $4 | ||
| AND ((run_id > $5 and close_time = $6) OR (close_time < $7)) | ||
| ORDER BY close_time DESC, run_id | ||
| LIMIT $8` | ||
|
|
||
| templateOpenFieldNames = `workflow_id, run_id, start_time, execution_time, workflow_type_name, status, memo, encoding` | ||
| templateOpenSelect = `SELECT ` + templateOpenFieldNames + ` FROM executions_visibility WHERE status = 1 ` | ||
|
|
||
|
|
@@ -76,17 +90,17 @@ const ( | |
|
|
||
| templateGetOpenWorkflowExecutions = templateOpenSelect + templateConditions1 | ||
|
|
||
| templateGetClosedWorkflowExecutions = templateClosedSelect + templateConditions1 | ||
| templateGetClosedWorkflowExecutions = templateClosedSelect + templateConditionsClosedWorkflow1 | ||
|
|
||
| templateGetOpenWorkflowExecutionsByType = templateOpenSelect + `AND workflow_type_name = $1` + templateConditions2 | ||
|
|
||
| templateGetClosedWorkflowExecutionsByType = templateClosedSelect + `AND workflow_type_name = $1` + templateConditions2 | ||
| templateGetClosedWorkflowExecutionsByType = templateClosedSelect + `AND workflow_type_name = $1` + templateConditionsClosedWorkflow2 | ||
|
|
||
| templateGetOpenWorkflowExecutionsByID = templateOpenSelect + `AND workflow_id = $1` + templateConditions2 | ||
|
|
||
| templateGetClosedWorkflowExecutionsByID = templateClosedSelect + `AND workflow_id = $1` + templateConditions2 | ||
| templateGetClosedWorkflowExecutionsByID = templateClosedSelect + `AND workflow_id = $1` + templateConditionsClosedWorkflow2 | ||
|
|
||
| templateGetClosedWorkflowExecutionsByStatus = templateClosedSelect + `AND status = $1` + templateConditions2 | ||
| templateGetClosedWorkflowExecutionsByStatus = templateClosedSelect + `AND status = $1` + templateConditionsClosedWorkflow2 | ||
|
|
||
| templateGetClosedWorkflowExecution = `SELECT workflow_id, run_id, start_time, execution_time, memo, encoding, close_time, workflow_type_name, status, history_length | ||
| FROM executions_visibility | ||
|
|
@@ -172,7 +186,8 @@ func (pdb *db) SelectFromVisibility(filter *sqlplugin.VisibilityFilter) ([]sqlpl | |
| pdb.converter.ToPostgresDateTime(*filter.MinStartTime), | ||
| pdb.converter.ToPostgresDateTime(*filter.MaxStartTime), | ||
| *filter.RunID, | ||
| *filter.MinStartTime, | ||
| *filter.MaxStartTime, | ||
|
Member
Author
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. @shawnhathaway - ditto here |
||
| *filter.MaxStartTime, | ||
| *filter.PageSize) | ||
| case filter.MinStartTime != nil && filter.WorkflowTypeName != nil: | ||
| qry := templateGetOpenWorkflowExecutionsByType | ||
|
|
@@ -187,6 +202,7 @@ func (pdb *db) SelectFromVisibility(filter *sqlplugin.VisibilityFilter) ([]sqlpl | |
| pdb.converter.ToPostgresDateTime(*filter.MaxStartTime), | ||
| *filter.RunID, | ||
| *filter.MaxStartTime, | ||
| *filter.MaxStartTime, | ||
| *filter.PageSize) | ||
| case filter.MinStartTime != nil && filter.Status != 0 && filter.Status != 1: // 0 is UNSPECIFIED, 1 is RUNNING | ||
| err = pdb.conn.Select(&rows, | ||
|
|
@@ -197,6 +213,7 @@ func (pdb *db) SelectFromVisibility(filter *sqlplugin.VisibilityFilter) ([]sqlpl | |
| pdb.converter.ToPostgresDateTime(*filter.MaxStartTime), | ||
| *filter.RunID, | ||
| pdb.converter.ToPostgresDateTime(*filter.MaxStartTime), | ||
| pdb.converter.ToPostgresDateTime(*filter.MaxStartTime), | ||
| *filter.PageSize) | ||
| case filter.MinStartTime != nil: | ||
| qry := templateGetOpenWorkflowExecutions | ||
|
|
@@ -212,6 +229,7 @@ func (pdb *db) SelectFromVisibility(filter *sqlplugin.VisibilityFilter) ([]sqlpl | |
| maxSt, | ||
| *filter.RunID, | ||
| maxSt, | ||
| maxSt, | ||
| *filter.PageSize) | ||
| default: | ||
| return nil, fmt.Errorf("invalid query filter") | ||
|
|
||
This file contains hidden or 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 hidden or 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.
Uh oh!
There was an error while loading. Please reload this page.
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.
@shawnhathaway - this also seemed like a bug to me. can you confirm that this change makes sense
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.
Yea this does look like a bug as it doesn't appear MinStartTime is even affected by the paging token and this would break the contract of returning earlier records than specified with the filter it appears.