Skip to content

Commit bb48d43

Browse files
committed
Merge branch 'master' into PMM-2569_MySQL_8
2 parents 177331f + 80a192b commit bb48d43

33 files changed

+843
-251
lines changed

.travis.yml

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,6 @@ env:
4040
- MONGODB_IMAGE=percona/percona-server-mongodb:3.4
4141
- MONGODB_IMAGE=percona/percona-server-mongodb:3.6
4242

43-
matrix:
44-
include:
45-
- go: master
46-
env:
47-
allow_failures:
48-
- go: master
49-
5043
addons:
5144
apt:
5245
sources:
@@ -67,7 +60,7 @@ before_script:
6760
# run docker containers
6861
- docker-compose up -d
6962
# wait for MySQL to become available
70-
- ./with_backoff.sh docker-compose exec mysql mysql -u"${MYSQL_USER}" -e 'SELECT 1'
63+
- ./with_backoff.sh docker-compose exec mysql mysql --protocol=tcp -u"${MYSQL_USER}" -e 'SELECT 1'
7164
# log versions
7265
- docker --version
7366
- docker-compose --version

agent/agent_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,6 @@ func (s *AgentTestSuite) TestStartStopService(t *C) {
287287
Interval: 60, // seconds
288288
MaxSlowLogSize: 1073741824, // 1 GiB
289289
ExampleQueries: &exampleQueries,
290-
WorkerRunTime: 120, // seconds
291290
}
292291

293292
// Second, the service config is encoded and encapsulated in a ServiceData:
@@ -385,7 +384,6 @@ func (s *AgentTestSuite) TestStartServiceSlow(t *C) {
385384
Interval: 60, // seconds
386385
MaxSlowLogSize: 1073741824, // 1 GiB
387386
ExampleQueries: &exampleQueries,
388-
WorkerRunTime: 120, // seconds
389387
}
390388
qanConfigData, _ := json.Marshal(qanConfig)
391389
serviceCmd := &proto.ServiceData{

docs/agent.rst

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,6 @@ Stop (varies) List of MySQL queries to execute to un-configure
141141

142142
Interval 60 How often to collect and aggregate data
143143

144-
WorkerRunTime 55 Max runtime for each worker per interval
145-
146144
MaxSlowLogSize 1073741824 Rotate slow log when it becomes this large (bytes)
147145

148146
RemoveOldSlowLogs true Remove slow log after rotating if true

glide.lock

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

glide.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import:
2121
- src/go/mongolib/stats
2222
- package: github.com/percona/pmgo
2323
- package: github.com/percona/pmm
24+
version: 9cb15efc1ab783e17a03174254356a7b800cd1bd
2425
subpackages:
2526
- proto
2627
- proto/config

qan/analyzer/mysql/analyzer_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,6 @@ func (s *AnalyzerTestSuite) SetUpTest(t *C) {
129129
UUID: s.mysqlUUID,
130130
CollectFrom: "slowlog",
131131
Interval: 60,
132-
WorkerRunTime: 60,
133132
MaxSlowLogSize: MAX_SLOW_LOG_SIZE,
134133
SlowLogRotation: &slowLogRotation,
135134
Start: []string{

qan/analyzer/mysql/config/config.go

Lines changed: 17 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package config
1919

2020
import (
2121
"database/sql/driver"
22+
"encoding/json"
2223
"fmt"
2324
"strings"
2425

@@ -27,15 +28,7 @@ import (
2728
)
2829

2930
var (
30-
DefaultInterval uint = 60 // 1 minute
31-
DefaultMaxSlowLogSize int64 = 1073741824 // 1G
32-
DefaultSlowLogRotation = true // whether to rotate slow logs
33-
DefaultRemoveOldSlowLogs = true // whether to remove old slow logs after rotation
34-
DefaultRetainSlowLogs = 1 // how many slow logs to keep on filesystem
35-
DefaultExampleQueries = true
36-
// internal
37-
DefaultWorkerRuntime uint = 55
38-
DefaultReportLimit uint = 200
31+
DefaultRemoveOldSlowLogs = true // whether to remove old slow logs after rotation
3932
)
4033

4134
type MySQLVarType int
@@ -109,34 +102,23 @@ func ReadInfoFromShowGlobalStatus(conn mysql.Connector) (info map[string]interfa
109102
}
110103

111104
func ValidateConfig(setConfig pc.QAN) (pc.QAN, error) {
112-
runConfig := pc.QAN{
113-
UUID: setConfig.UUID,
114-
Interval: DefaultInterval,
115-
ExampleQueries: new(bool),
116-
// "slowlog" specific options.
117-
MaxSlowLogSize: DefaultMaxSlowLogSize,
118-
SlowLogRotation: new(bool),
119-
RetainSlowLogs: new(int),
120-
// internal
121-
WorkerRunTime: DefaultWorkerRuntime,
122-
ReportLimit: DefaultReportLimit,
105+
runConfig := pc.NewQAN()
106+
fmt.Printf("%+v\n", runConfig)
107+
108+
// Marshal setConfig and unmarshal it back on default config.
109+
// This way we keep defaults if they are not set in setConfig.
110+
b, err := json.Marshal(setConfig)
111+
if err != nil {
112+
return runConfig, err
123113
}
124-
// I know this is an ugly hack, but we need runConfig.ExampleQueries to be a pointer since
125-
// the default value for a boolean is false, there is no way to tell if it was false in the
126-
// config or if the value was missing.
127-
// If it was missing (nil) we should take the default=true
128-
*runConfig.ExampleQueries = DefaultExampleQueries
129-
if setConfig.ExampleQueries != nil {
130-
runConfig.ExampleQueries = setConfig.ExampleQueries
131-
}
132-
*runConfig.SlowLogRotation = DefaultSlowLogRotation
133-
if setConfig.SlowLogRotation != nil {
134-
runConfig.SlowLogRotation = setConfig.SlowLogRotation
135-
}
136-
*runConfig.RetainSlowLogs = DefaultRetainSlowLogs
137-
if setConfig.RetainSlowLogs != nil {
138-
runConfig.RetainSlowLogs = setConfig.RetainSlowLogs
114+
err = json.Unmarshal(b, &runConfig)
115+
if err != nil {
116+
return runConfig, err
139117
}
118+
fmt.Printf("%+v\n", runConfig)
119+
120+
// Set UUID.
121+
runConfig.UUID = setConfig.UUID
140122

141123
// Strings
142124
if setConfig.CollectFrom != "slowlog" && setConfig.CollectFrom != "perfschema" {
@@ -152,8 +134,6 @@ func ValidateConfig(setConfig pc.QAN) (pc.QAN, error) {
152134
runConfig.Interval = setConfig.Interval
153135
}
154136

155-
runConfig.WorkerRunTime = uint(float64(runConfig.Interval) * 0.9) // 90% of interval
156-
157137
return runConfig, nil
158138
}
159139

qan/analyzer/mysql/config/config_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ func TestValidateConfig(t *testing.T) {
1515
Interval: 300, // 5 min
1616
MaxSlowLogSize: 1073741824, // 1 GiB
1717
ExampleQueries: &exampleQueries,
18-
WorkerRunTime: 600, // 10 min
1918
CollectFrom: "slowlog",
2019
}
2120
_, err := ValidateConfig(cfg)

qan/analyzer/mysql/mysql.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,12 +190,11 @@ func (m *MySQLAnalyzer) GetDefaults(uuid string) map[string]interface{} {
190190
cfg := map[string]interface{}{
191191
"CollectFrom": m.config.CollectFrom,
192192
"Interval": m.config.Interval,
193-
"MaxSlowLogSize": config.DefaultMaxSlowLogSize,
193+
"MaxSlowLogSize": m.config.MaxSlowLogSize,
194194
"RetainSlowLogs": m.config.RetainSlowLogs,
195195
"SlowLogRotation": m.config.SlowLogRotation,
196196
"ExampleQueries": m.config.ExampleQueries,
197-
"WorkerRunTime": config.DefaultWorkerRuntime,
198-
"ReportLimit": config.DefaultReportLimit,
197+
"ReportLimit": m.config.ReportLimit,
199198
}
200199

201200
// Info from SHOW GLOBAL STATUS

qan/analyzer/mysql/worker/slowlog/slowlog_test.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ func (s *WorkerTestSuite) SetUpSuite(t *C) {
9696
Interval: 60, // 1 min
9797
MaxSlowLogSize: 1073741824, // 1 GiB
9898
ExampleQueries: &exampleQueries,
99-
WorkerRunTime: 60, // 1 min
10099
CollectFrom: "slowlog",
101100
}
102101
s.nullmysql = mock.NewNullMySQL()
@@ -294,7 +293,6 @@ func (s *WorkerTestSuite) TestRotateAndRemoveSlowLog(t *C) {
294293
ExampleQueries: &exampleQueries,
295294
SlowLogRotation: &slowLogsRotation,
296295
RetainSlowLogs: &slowLogsToKeep,
297-
WorkerRunTime: 600,
298296
Start: []string{
299297
"-- start",
300298
},
@@ -397,7 +395,6 @@ func (s *WorkerTestSuite) TestRotateSlowLog(t *C) {
397395
ExampleQueries: &exampleQueries,
398396
SlowLogRotation: &slowLogsRotation,
399397
RetainSlowLogs: &slowLogsToKeep,
400-
WorkerRunTime: 600,
401398
Start: []string{
402399
"-- start",
403400
},
@@ -552,7 +549,6 @@ func (s *WorkerTestSuite) TestRotateRealSlowLog(t *C) {
552549
Interval: 300,
553550
MaxSlowLogSize: 1000,
554551
ExampleQueries: &exampleQueries,
555-
WorkerRunTime: 600,
556552
Start: []string{
557553
"SET GLOBAL slow_query_log=1",
558554
fmt.Sprintf("SET GLOBAL slow_query_log_file='%s'", slowlogFile),
@@ -629,7 +625,6 @@ func (s *WorkerTestSuite) TestStop(t *C) {
629625
UUID: s.mysqlInstance.UUID,
630626
Interval: 300,
631627
MaxSlowLogSize: 1024 * 1024 * 1024,
632-
WorkerRunTime: 60,
633628
Start: []string{},
634629
Stop: []string{},
635630
CollectFrom: "slowlog",
@@ -716,7 +711,6 @@ func (s *WorkerTestSuite) TestResult014(t *C) {
716711
UUID: "1",
717712
CollectFrom: "slowlog",
718713
Interval: 60,
719-
WorkerRunTime: 60,
720714
ReportLimit: 500,
721715
MaxSlowLogSize: 1024 * 1024 * 1000,
722716
}

qan/analyzer/mysql/worker/slowlog/worker.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,13 +155,14 @@ func (w *Worker) Setup(interval *iter.Interval) error {
155155
}
156156
}
157157

158+
workerRunTime := time.Duration(uint(float64(w.config.Interval)*0.9)) * time.Second // 90% of interval
158159
// Create new Job.
159160
w.job = &Job{
160161
Id: fmt.Sprintf("%d", interval.Number),
161162
SlowLogFile: interval.Filename,
162163
StartOffset: interval.StartOffset,
163164
EndOffset: interval.EndOffset,
164-
RunTime: time.Duration(w.config.WorkerRunTime) * time.Second,
165+
RunTime: workerRunTime,
165166
ExampleQueries: boolValue(w.config.ExampleQueries),
166167
RetainSlowLogs: intValue(w.config.RetainSlowLogs),
167168
}

qan/manager_test.go

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,6 @@ func (s *ManagerTestSuite) TestStartWithConfig(t *C) {
175175
UUID: mysqlInstance.UUID,
176176
CollectFrom: analyzerType,
177177
Interval: 300,
178-
WorkerRunTime: 270,
179178
ExampleQueries: &exampleQueries, // specify optional args
180179
ReportLimit: 200, // specify optional args
181180
}
@@ -267,7 +266,6 @@ func (s *ManagerTestSuite) TestStart2RemoteQAN(t *C) {
267266
UUID: mysqlInstance.UUID,
268267
CollectFrom: "perfschema",
269268
Interval: 300,
270-
WorkerRunTime: 270,
271269
ExampleQueries: &exampleQueries, // specify optional args
272270
ReportLimit: 200, // specify optional args
273271
}
@@ -348,10 +346,9 @@ func (s *ManagerTestSuite) TestGetConfig(t *C) {
348346

349347
// Write a realistic qan.conf config to disk.
350348
pcQANSetExpected := pc.QAN{
351-
UUID: mysqlUUID,
352-
CollectFrom: "slowlog",
353-
Interval: 300,
354-
WorkerRunTime: 270,
349+
UUID: mysqlUUID,
350+
CollectFrom: "slowlog",
351+
Interval: 300,
355352
}
356353
err := pct.Basedir.WriteConfig("qan-"+mysqlUUID, &pcQANSetExpected)
357354
t.Assert(err, IsNil)
@@ -441,7 +438,6 @@ func (s *ManagerTestSuite) TestAddInstance(t *C) {
441438
Interval: 300, // 5 min
442439
MaxSlowLogSize: 1073741824, // 1 GiB
443440
ExampleQueries: &exampleQueries,
444-
WorkerRunTime: 600, // 10 min
445441
CollectFrom: "slowlog",
446442
}
447443

@@ -537,7 +533,6 @@ func (s *ManagerTestSuite) TestStartTool(t *C) {
537533
Interval: 300, // 5 min
538534
MaxSlowLogSize: 1073741824, // 1 GiB
539535
ExampleQueries: &exampleQueries,
540-
WorkerRunTime: 600, // 10 min
541536
CollectFrom: "slowlog",
542537
}
543538

qan/qan_test.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,9 @@ func TestWithRealMySQL(t *testing.T) {
8282

8383
// Write a realistic qan.conf config to disk.
8484
pcQANSetExpected := pc.QAN{
85-
UUID: protoInstance.UUID,
86-
CollectFrom: "slowlog",
87-
Interval: 300,
88-
WorkerRunTime: 270,
85+
UUID: protoInstance.UUID,
86+
CollectFrom: "slowlog",
87+
Interval: 300,
8988
}
9089
err = pct.Basedir.WriteConfig("qan-"+protoInstance.UUID, &pcQANSetExpected)
9190
require.NoError(t, err)

vendor/golang.org/x/net/http2/server.go

Lines changed: 4 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/golang.org/x/net/http2/server_test.go

Lines changed: 19 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/golang.org/x/sys/unix/dev_openbsd_test.go

Lines changed: 2 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/golang.org/x/sys/unix/mkerrors.sh

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/golang.org/x/sys/unix/openbsd_pledge.go

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)