-
Notifications
You must be signed in to change notification settings - Fork 229
PMM-9630 Use status, status_code only for some versions. #912
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
Changes from 10 commits
3ac854a
4ff36c4
801ce30
85183ce
dfbc797
ee020fd
afbc284
e41a13a
15ed8b9
7a972ff
f4062de
a3a2119
666a236
e4769af
fb205ba
8292912
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -72,6 +72,9 @@ const ( | |
| pgStatMonitorVersion10PG12 | ||
| pgStatMonitorVersion10PG13 | ||
| pgStatMonitorVersion10PG14 | ||
| pgStatMonitorVersion11PG12 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. new variables are not added to this function https://github.com/percona/pmm/pull/912/files#diff-ae12be77883993fc7d2b5ebc501e2fb0b0078ea1d4645c2f9327095ae0661d30R153
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added. |
||
| pgStatMonitorVersion11PG13 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚫 [golangci-lint] reported by reviewdog 🐶 |
||
| pgStatMonitorVersion11PG14 | ||
| ) | ||
|
|
||
| const ( | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,7 +27,7 @@ import ( | |
| ) | ||
|
|
||
| var ( | ||
| v10 = version.Must(version.NewVersion("1.0.0-beta-2")) | ||
| v10 = version.Must(version.NewVersion("1.0.0")) | ||
| v09 = version.Must(version.NewVersion("0.9")) | ||
| v08 = version.Must(version.NewVersion("0.8")) | ||
| ) | ||
|
|
@@ -82,13 +82,6 @@ type pgStatMonitor struct { | |
| WalRecords int64 | ||
| WalFpi int64 | ||
| WalBytes int64 | ||
| // state_code = 0 state 'PARSING' | ||
| // state_code = 1 state 'PLANNING' | ||
| // state_code = 2 state 'ACTIVE' | ||
| // state_code = 3 state 'FINISHED' | ||
| // state_code = 4 state 'FINISHED WITH ERROR' | ||
| StateCode int64 | ||
| State string | ||
|
|
||
| // < pg0.6 | ||
|
|
||
|
|
@@ -179,9 +172,7 @@ func NewPgStatMonitorStructs(v pgStatMonitorVersion) (*pgStatMonitor, reform.Vie | |
| field{info: parse.FieldInfo{Name: "Message", Type: "*string", Column: "message"}, pointer: &s.Message}, | ||
| field{info: parse.FieldInfo{Name: "WalRecords", Type: "int64", Column: "wal_records"}, pointer: &s.WalRecords}, | ||
| field{info: parse.FieldInfo{Name: "WalFpi", Type: "int64", Column: "wal_fpi"}, pointer: &s.WalFpi}, | ||
| field{info: parse.FieldInfo{Name: "WalBytes", Type: "int64", Column: "wal_bytes"}, pointer: &s.WalBytes}, | ||
| field{info: parse.FieldInfo{Name: "StateCode", Type: "int64", Column: "state_code"}, pointer: &s.StateCode}, | ||
| field{info: parse.FieldInfo{Name: "State", Type: "string", Column: "state"}, pointer: &s.State}) | ||
| field{info: parse.FieldInfo{Name: "WalBytes", Type: "int64", Column: "wal_bytes"}, pointer: &s.WalBytes}) | ||
| } | ||
|
|
||
| if v <= pgStatMonitorVersion10PG12 { | ||
|
|
@@ -257,7 +248,7 @@ func (v *pgStatMonitorAllViewType) NewStruct() reform.Struct { | |
|
|
||
| // String returns a string representation of this struct or record. | ||
| func (s pgStatMonitor) String() string { | ||
| res := make([]string, 51) | ||
| res := make([]string, 49) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚫 [golangci-lint] reported by reviewdog 🐶 |
||
| res[0] = "Bucket: " + reform.Inspect(s.Bucket, true) | ||
| res[1] = "BucketStartTime: " + reform.Inspect(s.BucketStartTime, true) | ||
| res[2] = "UserID: " + reform.Inspect(s.UserID, true) | ||
|
|
@@ -307,8 +298,6 @@ func (s pgStatMonitor) String() string { | |
| res[46] = "WalRecords: " + reform.Inspect(s.WalRecords, true) | ||
| res[47] = "WalFpi: " + reform.Inspect(s.WalFpi, true) | ||
| res[48] = "WalBytes: " + reform.Inspect(s.WalBytes, true) | ||
| res[49] = "StateCode: " + reform.Inspect(s.StateCode, true) | ||
| res[50] = "State: " + reform.Inspect(s.State, true) | ||
| return strings.Join(res, ", ") | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -82,7 +82,7 @@ func (ssc *statMonitorCache) getStatMonitorExtended(ctx context.Context, q *refo | |
| databases := queryDatabases(q) | ||
| usernames := queryUsernames(q) | ||
|
|
||
| pgMonitorVersion, _, err := getPGMonitorVersion(q) | ||
| pgMonitorVersion, prerelease, err := getPGMonitorVersion(q) | ||
| if err != nil { | ||
| err = errors.Wrap(err, "failed to get row and view for pg_stat_monitor version") | ||
| return | ||
|
|
@@ -91,10 +91,11 @@ func (ssc *statMonitorCache) getStatMonitorExtended(ctx context.Context, q *refo | |
|
|
||
| row, view := NewPgStatMonitorStructs(pgMonitorVersion) | ||
| conditions := "WHERE queryid IS NOT NULL AND query IS NOT NULL" | ||
| if pgMonitorVersion >= pgStatMonitorVersion09 { | ||
| // only pg_stat_monitor 0.9.0 and above supports state_code. It tells what is the query's current state. | ||
| if pgMonitorVersion >= pgStatMonitorVersion09 && pgMonitorVersion <= pgStatMonitorVersion11PG14 && prerelease != "" { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I thought that we decided to have a check like
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Changed. |
||
| // only pg_stat_monitor 0.9.0, 1.0.0-beta-2, 1.0.0-rc.1, 1.0.0-rc.2, 1.0.0 and 1.1.0 supports state_code. It tells what is the query's current state. | ||
| // To have correct data in QAN, we have to get only queries that are either 'FINISHED' or 'FINISHED WITH ERROR'. | ||
| conditions += " AND (state_code = 3 OR state_code = 4)" | ||
| ssc.l.Debug("PGSM version with state and state_code") | ||
| } | ||
| rows, e := q.SelectRows(view, conditions) | ||
| if e != nil { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚫 [golangci-lint] reported by reviewdog 🐶
pgStatMonitorVersion11PG12is unused (deadcode)