Skip to content
Open
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
49 changes: 43 additions & 6 deletions dashboard/app/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,14 @@ import (
"reflect"
"runtime"
"slices"
"strconv"
"strings"
"sync"
"sync/atomic"
"testing"
"time"

"cloud.google.com/go/spanner/admin/database/apiv1"
database "cloud.google.com/go/spanner/admin/database/apiv1"
"cloud.google.com/go/spanner/admin/database/apiv1/databasepb"
"github.com/google/go-cmp/cmp"
"github.com/google/syzkaller/dashboard/api"
Expand Down Expand Up @@ -162,12 +163,12 @@ func loadDDLStatements(wildcard string, sortOrder int) ([]string, error) {
if len(files) == 0 {
return nil, fmt.Errorf("loadDDLStatements: wildcard did not match any files: %q", wildcard)
}
// We prefix DDL file names with sequence numbers.
slices.SortFunc(files, func(a, b string) int {
return strings.Compare(a, b) * sortOrder
})
sortedFiles, err := sortMigrationFiles(files, sortOrder)
if err != nil {
return nil, err
}
var all []string
for _, file := range files {
for _, file := range sortedFiles {
data, err := os.ReadFile(file)
if err != nil {
return nil, err
Expand All @@ -180,6 +181,42 @@ func loadDDLStatements(wildcard string, sortOrder int) ([]string, error) {
return all, nil
}

func sortMigrationFiles(files []string, sortOrder int) ([]string, error) {
type migrationFile struct {
num int
file string
}
var mFiles []migrationFile
seen := map[int]string{}
for _, file := range files {
basename := filepath.Base(file)
parts := strings.Split(basename, "_")
if len(parts) == 0 {
return nil, fmt.Errorf("invalid migration filename: %v", basename)
}
num, err := strconv.Atoi(parts[0])
if err != nil {
return nil, fmt.Errorf("migration file %v must start with a number (%w)", file, err)
}
if old, ok := seen[num]; ok {
return nil, fmt.Errorf("duplicate migration number %v: %v and %v", num, old, file)
}
seen[num] = file
mFiles = append(mFiles, migrationFile{num: num, file: file})
}
slices.SortFunc(mFiles, func(a, b migrationFile) int {
if a.num != b.num {
return (a.num - b.num) * sortOrder
}
return strings.Compare(a.file, b.file) * sortOrder
})
var result []string
for _, f := range mFiles {
result = append(result, f.file)
}
return result, nil
}

func (ctx *Ctx) config() *GlobalConfig {
return getConfig(ctx.ctx)
}
Expand Down
2 changes: 2 additions & 0 deletions pkg/email/lore/parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,8 @@ Bug report`,
t.Fatal(err)
}
msg.RawCc = nil
msg.Body = ""
msg.Patch = ""
emails = append(emails, msg)
}

Expand Down
7 changes: 1 addition & 6 deletions pkg/email/lore/read.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,5 @@ func emailFromRaw(body []byte, emails, domains []string) (*Email, error) {
if err != nil {
return nil, err
}
ret := &Email{Email: msg, HasPatch: msg.Patch != ""}
// Keep memory consumption low.
ret.Body = ""
ret.Patch = ""
// TODO: If emails/domains are nil, we also don't need to parse the body at all.
return ret, nil
return &Email{Email: msg, HasPatch: msg.Patch != ""}, nil
}
2 changes: 2 additions & 0 deletions tools/syz-lore/query_lkml.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ func processArchives(paths, emails, domains []string) []*lore.Thread {
skipped.Add(1)
continue
}
msg.Body = ""
msg.Patch = ""
mu.Lock()
repoEmails = append(repoEmails, msg)
mu.Unlock()
Expand Down
Loading