-
Notifications
You must be signed in to change notification settings - Fork 808
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
fix(SqlExecutionRepository): fixed bug in sql repository in orca-sql … #4697
fix(SqlExecutionRepository): fixed bug in sql repository in orca-sql … #4697
Conversation
if (where == null) { | ||
it.where("1=1") | ||
} else { | ||
where(it) | ||
} |
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.
For the case in which the cursor is null (it always starts as null in the first iteration), the custom where statements that are passed to the function are not used on the query, effectively not filtering the first page.
it.where(field("id").lt(cursor)) | ||
} else { | ||
where(it).and(field("id").gt(cursor)) | ||
where(it).and(field("id").lt(cursor)) |
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.
The pagination is broken, which makes it only show the first page, for example, in the unit tests on orca-sql/src/test/groovy/com/netflix/spinnaker/orca/sql/cleanup/OldPipelineCleanupPollingNotificationAgentSpec.groovy
, we have a page size 10, and executions with id: 1, 2, 11, 12, ..., 20
Then, iteration 1 returns the first 10 elements in desc order:
--> 20, ..., 11 (10 elements)
And cursor = 11
Then the second page gets the elements greater than the cursor, which are
--> 20, ..., 12 (9 elements)
Then the stop condition in the PagedIterator is triggered:
isLastPage = currentPage.size < pageSize
Thus, the second page is never returned and only 10 elements are present, when there should be 12.
When we change greater than, for lesser than, we get:
Iteration 1:
--> 20, ..., 11 (10 elements)
Cursor = 11
Iteration 2, elements lesser than 11:
--> 1, 2
Then we get the correct response.
Isn't SqlExecutionRepository.selectExecutions also called from TaskController.list via SqlExecutionRepository.retrieve ? |
Thanks for this @juangod-wise! I tried reverting back to |
I came up with one. OK if I push?
|
Good stuff! Please do! |
Yes it looks like it is also used in TaskController |
which also verifies the behavior of selectExections when cursor is null
|
@Mergifyio backport release-1.32.x release-1.33.x |
✅ Backports have been created
|
#4697) * fix(SqlExecutionRepository): fixed bug in sql repository in orca-sql module * test(sql): demonstrate behavior of retrievePipelinesForApplication which also verifies the behavior of selectExections when cursor is null --------- Co-authored-by: David Byron <[email protected]> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> (cherry picked from commit fc072b3) # Conflicts: # orca-sql/src/test/kotlin/com/netflix/spinnaker/orca/sql/pipeline/persistence/SqlExecutionRepositoryTest.kt
#4697) * fix(SqlExecutionRepository): fixed bug in sql repository in orca-sql module * test(sql): demonstrate behavior of retrievePipelinesForApplication which also verifies the behavior of selectExections when cursor is null --------- Co-authored-by: David Byron <[email protected]> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> (cherry picked from commit fc072b3) # Conflicts: # orca-sql/src/test/kotlin/com/netflix/spinnaker/orca/sql/pipeline/persistence/SqlExecutionRepositoryTest.kt
…… (backport #4697) (#4701) * fix(SqlExecutionRepository): fixed bug in sql repository in orca-sql … (#4697) * fix(SqlExecutionRepository): fixed bug in sql repository in orca-sql module * test(sql): demonstrate behavior of retrievePipelinesForApplication which also verifies the behavior of selectExections when cursor is null --------- Co-authored-by: David Byron <[email protected]> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> (cherry picked from commit fc072b3) # Conflicts: # orca-sql/src/test/kotlin/com/netflix/spinnaker/orca/sql/pipeline/persistence/SqlExecutionRepositoryTest.kt * fix(sql/test): remove compression-related tests since compression was added after cutting the release-1.32.x branch --------- Co-authored-by: juangod-wise <[email protected]> Co-authored-by: David Byron <[email protected]>
…… (backport #4697) (#4702) * fix(SqlExecutionRepository): fixed bug in sql repository in orca-sql … (#4697) * fix(SqlExecutionRepository): fixed bug in sql repository in orca-sql module * test(sql): demonstrate behavior of retrievePipelinesForApplication which also verifies the behavior of selectExections when cursor is null --------- Co-authored-by: David Byron <[email protected]> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> (cherry picked from commit fc072b3) # Conflicts: # orca-sql/src/test/kotlin/com/netflix/spinnaker/orca/sql/pipeline/persistence/SqlExecutionRepositoryTest.kt * fix(sql/test): remove compression-related tests since compression was added after cutting the release-1.33.x branch --------- Co-authored-by: juangod-wise <[email protected]> Co-authored-by: David Byron <[email protected]>
This fixes two bugs in the
selectExecutions
method of theorca-sql/src/main/kotlin/com/netflix/spinnaker/orca/sql/pipeline/persistence/SqlExecutionRepository.kt
file. These were probably never found because they are only used for some cleanup job:OldPipelineCleanupPollingNotificationAgent
.