Skip to content
Merged
Show file tree
Hide file tree
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
24 changes: 24 additions & 0 deletions server/internal/dashboardstore/conformance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,30 @@ func readConformance(t *testing.T, fixture readFixture, backend string) {
t.Fatal(err)
}
})
t.Run("keyset-continuation-keys", func(t *testing.T) {
definitions := []query.Definition{{
Name: "subjects", From: "$workflows",
Select: []query.SelectedField{{Field: "repositoryId"}, {Field: "path"}, {Field: "id"}},
OrderBy: []query.OrderField{{Field: "repositoryId"}, {Field: "path"}, {Field: "id"}},
Page: &query.PageBoundary{
Keys: []string{"repositoryId", "path", "id"}, Revision: "workflow-subjects", Comparator: "utf8-bytewise-v1",
},
}, {Name: "visible", From: "subjects"}}
err := store.WithReadTransaction(t.Context(), func(ctx context.Context, reader dashboardstore.Reader) error {
_, _, err := reader.ExecuteSQLPlanWithOptions(ctx, definitions, []string{"visible"}, dashboardstore.ExecutionOptions{
Pages: map[string]dashboardstore.Page{"visible": {Limit: 1, Keyset: &dashboardstore.KeysetPage{
Boundary: "subjects", Comparator: "utf8-bytewise-v1", Keys: []string{"id", "path", "repositoryId"},
}}},
})
if err == nil || !strings.Contains(err.Error(), "invalid or stale continuation token") {
t.Fatalf("mismatched continuation keys were accepted: %v", err)
}
return nil
})
if err != nil {
t.Fatal(err)
}
})
t.Run("cancellation", func(t *testing.T) {
ctx, cancel := context.WithCancel(t.Context())
cancel()
Expand Down
8 changes: 7 additions & 1 deletion server/internal/sqlitex/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,15 @@ func (r *reader) ExecuteSQLPlanWithOptions(ctx context.Context, definitions []qu
if err != nil {
return nil, metrics, err
}
if plan == nil || plan.Boundary != page.Keyset.Boundary || plan.Comparator != page.Keyset.Comparator {
if plan == nil || plan.Boundary != page.Keyset.Boundary ||
plan.Comparator != page.Keyset.Comparator || len(plan.Keys) != len(page.Keyset.Keys) {
return nil, metrics, fmt.Errorf("invalid or stale continuation token for %q", output)
}
for index, key := range plan.Keys {
if key.Output != page.Keyset.Keys[index] {
return nil, metrics, fmt.Errorf("invalid or stale continuation token for %q", output)
}
}
keysetPage = &page
}
executionDefinitions, fields := projectSnapshotPlan(definitions, requested, order)
Expand Down
Loading