-
Notifications
You must be signed in to change notification settings - Fork 131
TRT-2741: Add partitioned prefix sum tables for matview refresh optimization #3762
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
openshift-merge-bot
merged 1 commit into
openshift:main
from
mstaeble:trt-2741-prefix-sum-tables
Jul 13, 2026
+996
−242
Merged
Changes from all commits
Commits
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,102 @@ | ||
| package main | ||
|
|
||
| import ( | ||
| "fmt" | ||
| "time" | ||
|
|
||
| "cloud.google.com/go/civil" | ||
| log "github.com/sirupsen/logrus" | ||
| "github.com/spf13/cobra" | ||
| "github.com/spf13/pflag" | ||
| "k8s.io/apimachinery/pkg/util/sets" | ||
|
|
||
| "github.com/openshift/sippy/pkg/flags" | ||
| "github.com/openshift/sippy/pkg/sippyserver" | ||
| ) | ||
|
|
||
| type BackfillFlags struct { | ||
| DBFlags *flags.PostgresFlags | ||
| Table string | ||
| StartDate string | ||
| EndDate string | ||
| } | ||
|
|
||
| func NewBackfillFlags() *BackfillFlags { | ||
| return &BackfillFlags{ | ||
| DBFlags: flags.NewPostgresDatabaseFlags(), | ||
| } | ||
| } | ||
|
|
||
| func (f *BackfillFlags) BindFlags(fs *pflag.FlagSet) { | ||
| f.DBFlags.BindFlags(fs) | ||
| fs.StringVar(&f.Table, "table", "", "Table to backfill (daily-summaries, daily-totals, cumulative-summaries)") | ||
| fs.StringVar(&f.StartDate, "start-date", "", "Start date (YYYY-MM-DD)") | ||
| fs.StringVar(&f.EndDate, "end-date", "", "End date (YYYY-MM-DD)") | ||
| } | ||
|
|
||
| func NewBackfillCommand() *cobra.Command { | ||
| f := NewBackfillFlags() | ||
|
|
||
| cmd := &cobra.Command{ | ||
| Use: "backfill", | ||
| Short: "Backfill a specific summary table for a date range", | ||
| RunE: func(cmd *cobra.Command, args []string) error { | ||
| validTables := sets.New[string]("daily-summaries", "daily-totals", "cumulative-summaries") | ||
| if f.Table == "" { | ||
| return fmt.Errorf("--table is required") | ||
| } | ||
| if !validTables.Has(f.Table) { | ||
| return fmt.Errorf("invalid --table %q: must be one of %v", f.Table, sets.List(validTables)) | ||
| } | ||
| if f.StartDate == "" { | ||
| return fmt.Errorf("--start-date is required") | ||
| } | ||
|
|
||
| startDate, err := civil.ParseDate(f.StartDate) | ||
| if err != nil { | ||
| return fmt.Errorf("invalid --start-date %q: %w", f.StartDate, err) | ||
| } | ||
|
|
||
| endDate := civil.DateOf(time.Now().UTC()) | ||
| if f.EndDate != "" { | ||
| endDate, err = civil.ParseDate(f.EndDate) | ||
| if err != nil { | ||
| return fmt.Errorf("invalid --end-date %q: %w", f.EndDate, err) | ||
| } | ||
| } | ||
|
|
||
| if startDate.After(endDate) { | ||
| return fmt.Errorf("--start-date (%s) is after --end-date (%s)", startDate, endDate) | ||
| } | ||
|
|
||
| dbc, err := f.DBFlags.GetDBClient() | ||
| if err != nil { | ||
| return fmt.Errorf("getting db client: %w", err) | ||
| } | ||
|
|
||
| log.WithFields(log.Fields{ | ||
| "table": f.Table, | ||
| "start": startDate, | ||
| "end": endDate, | ||
| }).Info("starting backfill") | ||
|
|
||
| var releases []string | ||
| if err := dbc.DB.Table("release_definitions"). | ||
| Order("major DESC, minor DESC"). | ||
| Pluck("release", &releases).Error; err != nil { | ||
| return fmt.Errorf("querying releases: %w", err) | ||
| } | ||
| startTime := time.Date(startDate.Year, startDate.Month, startDate.Day, 0, 0, 0, 0, time.UTC) | ||
| endTime := time.Date(endDate.Year, endDate.Month, endDate.Day, 0, 0, 0, 0, time.UTC).AddDate(0, 0, 1) | ||
| if _, err := dbc.EnsurePartitions(releases, startTime, endTime, false); err != nil { | ||
| return fmt.Errorf("ensuring partitions: %w", err) | ||
| } | ||
|
|
||
| return sippyserver.BackfillData(dbc, f.Table, startDate, endDate) | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| }, | ||
| } | ||
|
|
||
| f.BindFlags(cmd.Flags()) | ||
|
|
||
| return cmd | ||
| } | ||
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
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.