Skip to content
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

chore: avoid querying a dataset in case AfterJobID falls after said dataset #3478

Merged
merged 3 commits into from
Jun 15, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions jobsdb/jobsdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -3105,6 +3105,7 @@
}
defer jd.dsListLock.RUnlock()

dsRangeList := jd.getDSRangeList()
atzoum marked this conversation as resolved.
Show resolved Hide resolved
dsList := jd.getDSList()

limitByEventCount := false
Expand All @@ -3124,7 +3125,15 @@
if jd.dsLimit != nil {
dsLimit = *jd.dsLimit
}
for _, ds := range dsList {
for idx, ds := range dsList {
if params.AfterJobID != nil {
if idx < len(dsRangeList) { // ranges are not stored for the last ds
// so the following condition cannot be applied the last ds
if *params.AfterJobID > dsRangeList[idx].maxJobID {
continue

Check warning on line 3133 in jobsdb/jobsdb.go

View check run for this annotation

Codecov / codecov/patch

jobsdb/jobsdb.go#L3131-L3133

Added lines #L3131 - L3133 were not covered by tests
}
}
}
if dsLimit > 0 && dsQueryCount >= dsLimit {
break
}
Expand Down Expand Up @@ -3224,6 +3233,7 @@
}
defer jd.dsListLock.RUnlock()

dsRangeList := jd.getDSRangeList()
dsList := jd.getDSList()

limitByEventCount := false
Expand All @@ -3245,7 +3255,15 @@
if jd.dsLimit != nil {
dsLimit = *jd.dsLimit
}
for _, ds := range dsList {
for idx, ds := range dsList {
if params.AfterJobID != nil {
if idx < len(dsRangeList) { // ranges are not stored for the last ds
// so the following condition cannot be applied the last ds
if *params.AfterJobID > dsRangeList[idx].maxJobID {
continue

Check warning on line 3263 in jobsdb/jobsdb.go

View check run for this annotation

Codecov / codecov/patch

jobsdb/jobsdb.go#L3261-L3263

Added lines #L3261 - L3263 were not covered by tests
}
}
}
if dsLimit > 0 && dsQueryCount >= dsLimit {
break
}
Expand Down
Loading