Skip to content

Commit

Permalink
Update GetRecordSchemas function to avoid making new query when previ…
Browse files Browse the repository at this point in the history
…ous query cursor is not yet closed.

Problem only happen when the queries are run in the same transaction, we don’t have db transaction in v1
schema create handler. So only apply this fix to next.
Related issue: lib/pq#635
  • Loading branch information
carmenlau committed Nov 1, 2018
1 parent 2a4191c commit 5047e06
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkg/record/dependency/record/pq/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ func (s *recordStore) GetRecordSchemas() (map[string]record.Schema, error) {
return nil, err
}

tables := []string{}
result := map[string]record.Schema{}
for rows.Next() {
var recordTable string
Expand All @@ -166,7 +167,10 @@ func (s *recordStore) GetRecordSchemas() (map[string]record.Schema, error) {
}

s.logger.Debugf("%s\n", recordTable)
tables = append(tables, recordTable)
}

for _, recordTable := range tables {
recordType := strings.TrimPrefix(recordTable, "_record__")
schema, err := s.GetSchema(recordType)
if err != nil {
Expand Down

0 comments on commit 5047e06

Please sign in to comment.