Skip to content

Commit 48d5575

Browse files
committed
Fix typos. Use default kill-mode. Require MaxQueryTime.
1 parent 22abd8b commit 48d5575

File tree

6 files changed

+63
-44
lines changed

6 files changed

+63
-44
lines changed

deploy/mysqlclusters.yaml

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -63,27 +63,30 @@ spec:
6363
type: object
6464
resources: {}
6565
queryLimits:
66+
description: 'QueryLimits represents the pt-kill parameters, more info
67+
can be found here: https://www.percona.com/doc/percona-toolkit/LATEST/pt-kill.html'
6668
properties:
6769
ignoreCommands:
68-
description: IgnoreCommands
70+
description: IgnoreCommands the list of commands to be ignored.
6971
items:
7072
type: string
7173
type: array
7274
ignoreDb:
73-
description: IgnoreDb is the lost of tatabase that are ignored by
74-
pt-kill (--ignore-db flag)
75+
description: IgnoreDb is the list of database that are ignored by
76+
pt-kill (--ignore-db flag).
7577
items:
7678
type: string
7779
type: array
7880
ignoreUser:
79-
description: IgnoreUser
81+
description: IgnoreUser the list of users to be ignored.
8082
items:
8183
type: string
8284
type: array
8385
kill:
8486
description: Kill represents the mode of which the matching queries
8587
in each class will be killed, (the --victims flag). Can be one
86-
of oldest|all|all-but-oldest
88+
of oldest|all|all-but-oldest. By default, the matching query with
89+
the highest Time value is killed (the oldest query.
8790
type: string
8891
killMode:
8992
description: 'KillMode can be: `connection` or `query`, when it''s
@@ -92,15 +95,18 @@ spec:
9295
that the query is killed (using --kill-query flag)'
9396
type: string
9497
maxIdleTime:
95-
description: MaxIdleTime match queries that have benn idle for longer
96-
then this time. (--idle-time flag)
98+
description: MaxIdleTime match queries that have been idle for longer
99+
then this time, in seconds. (--idle-time flag)
97100
format: int32
98101
type: integer
99102
maxQueryTime:
100103
description: MaxQueryTime match queries that have been running for
101-
longer then this time. (--busy-time flag)
104+
longer then this time, in seconds. This field is required. (--busy-time
105+
flag)
102106
format: int32
103107
type: integer
108+
required:
109+
- maxQueryTime
104110
replicas:
105111
description: The number of pods. This updates replicas filed Defaults
106112
to 0

pkg/apis/mysql/v1alpha1/cluster.go

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -280,28 +280,34 @@ func (c *MysqlCluster) GetLabels() map[string]string {
280280
func (ql *QueryLimits) GetOptions() []string {
281281
options := []string{
282282
"--print",
283+
// The purpose of this is to give blocked queries a chance to execute,
284+
// so we don’t kill a query that’s blocking a bunch of others, and then
285+
// kill the others immediately afterwards.
286+
"--wait-after-kill=1",
287+
"--busy-time", fmt.Sprintf("%d", ql.MaxQueryTime),
283288
}
284-
if ql.MaxIdleTime != nil {
285-
options = append(options, "--idle-time", fmt.Sprintf("%d", *ql.MaxIdleTime))
289+
290+
if ql.KillMode != nil {
291+
switch *ql.KillMode {
292+
case "connection":
293+
options = append(options, "--kill")
294+
case "query":
295+
options = append(options, "--kill-query")
296+
default:
297+
options = append(options, "--kill-query")
298+
}
299+
} else {
300+
options = append(options, "--kill-query")
286301
}
287302

288-
if ql.MaxQueryTime != nil {
289-
options = append(options, "--busy-time", fmt.Sprintf("%d", *ql.MaxQueryTime))
303+
if ql.MaxIdleTime != nil {
304+
options = append(options, "--idle-time", fmt.Sprintf("%d", *ql.MaxIdleTime))
290305
}
291306

292307
if ql.Kill != nil {
293308
options = append(options, "--victims", *ql.Kill)
294309
}
295310

296-
switch ql.KillMode {
297-
case "connection":
298-
options = append(options, "--kill")
299-
case "query":
300-
options = append(options, "--kill-query")
301-
default:
302-
options = append(options, "--kill-query")
303-
}
304-
305311
if len(ql.IgnoreDb) > 0 {
306312
options = append(options, "--ignore-db", strings.Join(ql.IgnoreDb, "|"))
307313
}

pkg/apis/mysql/v1alpha1/types.go

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -165,37 +165,43 @@ type VolumeSpec struct {
165165
core.PersistentVolumeClaimSpec `json:",inline"`
166166
}
167167

168+
// QueryLimits represents the pt-kill parameters, more info can be found
169+
// here: https://www.percona.com/doc/percona-toolkit/LATEST/pt-kill.html
168170
type QueryLimits struct {
169-
// MaxIdleTime match queries that have benn idle for longer then this time.
170-
// (--idle-time flag)
171+
// MaxIdleTime match queries that have been idle for longer then this time,
172+
// in seconds. (--idle-time flag)
171173
// + optional
172174
MaxIdleTime *int `json:"maxIdleTime,omitempty"`
173175

174176
// MaxQueryTime match queries that have been running for longer then this
175-
// time. (--busy-time flag)
176-
// +optional
177-
MaxQueryTime *int `json:"maxQueryTime,omitempty"`
177+
// time, in seconds. This field is required. (--busy-time flag)
178+
MaxQueryTime int `json:"maxQueryTime"`
178179

179180
// Kill represents the mode of which the matching queries in each class will
180-
// be killed, (the --victims flag). Can be one of oldest|all|all-but-oldest
181+
// be killed, (the --victims flag). Can be one of oldest|all|all-but-oldest.
182+
// By default, the matching query with the highest Time value is killed (the
183+
// oldest query.
181184
// +optional
182185
Kill *string `json:"kill,omitempty"`
183186

184187
// KillMode can be: `connection` or `query`, when it's used `connection`
185188
// means that when a query is matched the connection is killed (using --kill
186189
// flag) and if it's used `query` means that the query is killed (using
187190
// --kill-query flag)
188-
KillMode string `json:"killMode,omitempty"`
191+
// +optional
192+
KillMode *string `json:"killMode,omitempty"`
189193

190-
// IgnoreDb is the lost of tatabase that are ignored by pt-kill (--ignore-db
191-
// flag)
194+
// IgnoreDb is the list of database that are ignored by pt-kill (--ignore-db
195+
// flag).
192196
// +optional
193197
IgnoreDb []string `json:"ignoreDb,omitempty"`
194198

195-
// IgnoreCommands
199+
// IgnoreCommands the list of commands to be ignored.
200+
// +optional
196201
IgnoreCommand []string `json:"ignoreCommands,omitempty"`
197202

198-
//IgnoreUser
203+
// IgnoreUser the list of users to be ignored.
204+
// +optional
199205
IgnoreUser []string `json:"ignoreUser,omitempty"`
200206
}
201207

pkg/apis/mysql/v1alpha1/zz_generated.deepcopy.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -393,17 +393,17 @@ func (in *QueryLimits) DeepCopyInto(out *QueryLimits) {
393393
**out = **in
394394
}
395395
}
396-
if in.MaxQueryTime != nil {
397-
in, out := &in.MaxQueryTime, &out.MaxQueryTime
396+
if in.Kill != nil {
397+
in, out := &in.Kill, &out.Kill
398398
if *in == nil {
399399
*out = nil
400400
} else {
401-
*out = new(int)
401+
*out = new(string)
402402
**out = **in
403403
}
404404
}
405-
if in.Kill != nil {
406-
in, out := &in.Kill, &out.Kill
405+
if in.KillMode != nil {
406+
in, out := &in.KillMode, &out.KillMode
407407
if *in == nil {
408408
*out = nil
409409
} else {

pkg/mysqlcluster/statefullset.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,6 @@ func (f *cFactory) ensureContainersSpec(in []core.Container) []core.Container {
390390
if f.cluster.Spec.QueryLimits != nil {
391391
command := []string{
392392
"pt-kill",
393-
"--wait-after-kill=1",
394393
// host need to be specified, see pt-kill bug: https://jira.percona.com/browse/PT-1223
395394
"--host=127.0.0.1",
396395
fmt.Sprintf("--defaults-file=%s/client.cnf", ConfVolumeMountPath),

pkg/openapi/openapi_generated.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -680,24 +680,25 @@ func schema_pkg_apis_mysql_v1alpha1_QueryLimits(ref common.ReferenceCallback) co
680680
return common.OpenAPIDefinition{
681681
Schema: spec.Schema{
682682
SchemaProps: spec.SchemaProps{
683+
Description: "QueryLimits represents the pt-kill parameters, more info can be found here: https://www.percona.com/doc/percona-toolkit/LATEST/pt-kill.html",
683684
Properties: map[string]spec.Schema{
684685
"maxIdleTime": {
685686
SchemaProps: spec.SchemaProps{
686-
Description: "MaxIdleTime match queries that have benn idle for longer then this time. (--idle-time flag)",
687+
Description: "MaxIdleTime match queries that have been idle for longer then this time, in seconds. (--idle-time flag)",
687688
Type: []string{"integer"},
688689
Format: "int32",
689690
},
690691
},
691692
"maxQueryTime": {
692693
SchemaProps: spec.SchemaProps{
693-
Description: "MaxQueryTime match queries that have been running for longer then this time. (--busy-time flag)",
694+
Description: "MaxQueryTime match queries that have been running for longer then this time, in seconds. This field is required. (--busy-time flag)",
694695
Type: []string{"integer"},
695696
Format: "int32",
696697
},
697698
},
698699
"kill": {
699700
SchemaProps: spec.SchemaProps{
700-
Description: "Kill represents the mode of which the matching queries in each class will be killed, (the --victims flag). Can be one of oldest|all|all-but-oldest",
701+
Description: "Kill represents the mode of which the matching queries in each class will be killed, (the --victims flag). Can be one of oldest|all|all-but-oldest. By default, the matching query with the highest Time value is killed (the oldest query.",
701702
Type: []string{"string"},
702703
Format: "",
703704
},
@@ -711,7 +712,7 @@ func schema_pkg_apis_mysql_v1alpha1_QueryLimits(ref common.ReferenceCallback) co
711712
},
712713
"ignoreDb": {
713714
SchemaProps: spec.SchemaProps{
714-
Description: "IgnoreDb is the lost of tatabase that are ignored by pt-kill (--ignore-db flag)",
715+
Description: "IgnoreDb is the list of database that are ignored by pt-kill (--ignore-db flag).",
715716
Type: []string{"array"},
716717
Items: &spec.SchemaOrArray{
717718
Schema: &spec.Schema{
@@ -725,7 +726,7 @@ func schema_pkg_apis_mysql_v1alpha1_QueryLimits(ref common.ReferenceCallback) co
725726
},
726727
"ignoreCommands": {
727728
SchemaProps: spec.SchemaProps{
728-
Description: "IgnoreCommands",
729+
Description: "IgnoreCommands the list of commands to be ignored.",
729730
Type: []string{"array"},
730731
Items: &spec.SchemaOrArray{
731732
Schema: &spec.Schema{
@@ -739,7 +740,7 @@ func schema_pkg_apis_mysql_v1alpha1_QueryLimits(ref common.ReferenceCallback) co
739740
},
740741
"ignoreUser": {
741742
SchemaProps: spec.SchemaProps{
742-
Description: "IgnoreUser",
743+
Description: "IgnoreUser the list of users to be ignored.",
743744
Type: []string{"array"},
744745
Items: &spec.SchemaOrArray{
745746
Schema: &spec.Schema{
@@ -752,6 +753,7 @@ func schema_pkg_apis_mysql_v1alpha1_QueryLimits(ref common.ReferenceCallback) co
752753
},
753754
},
754755
},
756+
Required: []string{"maxQueryTime"},
755757
},
756758
},
757759
Dependencies: []string{},

0 commit comments

Comments
 (0)