Skip to content

Commit a2404e6

Browse files
authored
Update resgroup option names for latest versions (#15)
* Update resgroup option names for latest versions * Update name in comment The Greenplum upstream had renamed resgroup option names two times in gpdb7. The latest names are not updated in cbcopy. The commits to rename option names are: greenplum-db/gpdb-archive@7a4c80d7e3dbab86c greenplum-db/gpdb-archive@483adea86b50c1759 The affected name changes are: cpu_rate_limit -> cpu_hard_quota_limit -> cpu_max_percent cpu_soft_priority -> cpu_weight
1 parent 0c03713 commit a2404e6

File tree

6 files changed

+37
-37
lines changed

6 files changed

+37
-37
lines changed

integration/metadata_globals_create_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ var _ = Describe("cbcopy integration create statement tests", func() {
163163
} else { // GPDB7+
164164
return
165165
/* comment out, due to CBDB/PG14 - GP7/PG12 behavior diff
166-
someGroup := builtin.ResourceGroupAtLeast7{ResourceGroup: builtin.ResourceGroup{Oid: 1, Name: "some_group", Concurrency: "15", Cpuset: "-1"}, CpuHardQuotaLimit: "10", CpuSoftPriority: "100"}
166+
someGroup := builtin.ResourceGroupAtLeast7{ResourceGroup: builtin.ResourceGroup{Oid: 1, Name: "some_group", Concurrency: "15", Cpuset: "-1"}, CpuMaxPercent: "10", CpuWeight: "100"}
167167
builtin.PrintCreateResourceGroupStatementsAtLeast7(backupfile, tocfile, []builtin.ResourceGroupAtLeast7{someGroup}, emptyMetadataMap)
168168
testhelper.AssertQueryRuns(connectionPool, buffer.String())
169169
defer testhelper.AssertQueryRuns(connectionPool, `DROP RESOURCE GROUP some_group`)
@@ -200,9 +200,9 @@ var _ = Describe("cbcopy integration create statement tests", func() {
200200
return
201201
/* comment out, due to CBDB/PG14 - GP7/PG12 behavior diff
202202
expectedDefaults := builtin.ResourceGroupAtLeast7{ResourceGroup: builtin.ResourceGroup{Oid: 1, Name: "some_group", Concurrency: concurrencyDefault, Cpuset: cpuSetDefault},
203-
CpuHardQuotaLimit: "10", CpuSoftPriority: "100"}
203+
CpuMaxPercent: "10", CpuWeight: "100"}
204204
205-
testhelper.AssertQueryRuns(connectionPool, "CREATE RESOURCE GROUP some_group WITH (CPU_HARD_QUOTA_LIMIT=10, CPU_SOFT_PRIORITY=100);")
205+
testhelper.AssertQueryRuns(connectionPool, "CREATE RESOURCE GROUP some_group WITH (CPU_MAX_PERCENT=10, CPU_WEIGHT=100);")
206206
defer testhelper.AssertQueryRuns(connectionPool, `DROP RESOURCE GROUP some_group`)
207207
208208
resultResourceGroups := builtin.GetResourceGroups[builtin.ResourceGroupAtLeast7](connectionPool)
@@ -243,9 +243,9 @@ var _ = Describe("cbcopy integration create statement tests", func() {
243243
return
244244
/* comment out, due to CBDB/PG14 - GP7/PG12 behavior diff
245245
expectedDefaults := builtin.ResourceGroupAtLeast7{ResourceGroup: builtin.ResourceGroup{Oid: 1, Name: "some_group", Concurrency: concurrencyDefault, Cpuset: cpuSetDefault},
246-
CpuHardQuotaLimit: "10", CpuSoftPriority: "100"}
246+
CpuMaxPercent: "10", CpuWeight: "100"}
247247
248-
testhelper.AssertQueryRuns(connectionPool, "CREATE RESOURCE GROUP some_group WITH (CPU_HARD_QUOTA_LIMIT=10, CPU_SOFT_PRIORITY=100);")
248+
testhelper.AssertQueryRuns(connectionPool, "CREATE RESOURCE GROUP some_group WITH (CPU_MAX_PERCENT=10, CPU_WEIGHT=100);")
249249
defer testhelper.AssertQueryRuns(connectionPool, `DROP RESOURCE GROUP some_group`)
250250
251251
resultResourceGroups := builtin.GetResourceGroups[builtin.ResourceGroupAtLeast7](connectionPool)
@@ -285,7 +285,7 @@ var _ = Describe("cbcopy integration create statement tests", func() {
285285
return
286286
/* comment out, due to CBDB/PG14 - GP7/PG12 behavior diff
287287
defaultGroup := builtin.ResourceGroupAtLeast7{ResourceGroup: builtin.ResourceGroup{Oid: 1, Name: "default_group", Concurrency: "15", Cpuset: "-1"},
288-
CpuHardQuotaLimit: "10", CpuSoftPriority: "100"}
288+
CpuMaxPercent: "10", CpuWeight: "100"}
289289
emptyMetadataMap := map[builtin.UniqueID]builtin.ObjectMetadata{}
290290
291291
builtin.PrintCreateResourceGroupStatementsAtLeast7(backupfile, tocfile, []builtin.ResourceGroupAtLeast7{defaultGroup}, emptyMetadataMap)

integration/metadata_globals_queries_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -179,13 +179,13 @@ var _ = Describe("cbcopy integration tests", func() {
179179
} else { // GPDB7+
180180
return
181181
/* comment out, due to CBDB/PG14 - GP7/PG12 behavior diff
182-
testhelper.AssertQueryRuns(connectionPool, `CREATE RESOURCE GROUP someGroup WITH (CPU_HARD_QUOTA_LIMIT=10, CPU_SOFT_PRIORITY=100, CONCURRENCY=15);`)
182+
testhelper.AssertQueryRuns(connectionPool, `CREATE RESOURCE GROUP someGroup WITH (CPU_MAX_PERCENT=10, CPU_WEIGHT=100, CONCURRENCY=15);`)
183183
defer testhelper.AssertQueryRuns(connectionPool, `DROP RESOURCE GROUP someGroup`)
184184
185185
results := builtin.GetResourceGroups[builtin.ResourceGroupAtLeast7](connectionPool)
186186
187187
someGroup := builtin.ResourceGroupAtLeast7{ResourceGroup: builtin.ResourceGroup{Oid: 1, Name: `somegroup`, Concurrency: "15", Cpuset: "-1"},
188-
CpuHardQuotaLimit: "10", CpuSoftPriority: "100"}
188+
CpuMaxPercent: "10", CpuWeight: "100"}
189189
190190
for _, resultGroup := range results {
191191
if resultGroup.Name == `somegroup` {
@@ -236,13 +236,13 @@ var _ = Describe("cbcopy integration tests", func() {
236236
} else {
237237
return
238238
/* comment out, due to CBDB/PG14 - GP7/PG12 behavior diff
239-
testhelper.AssertQueryRuns(connectionPool, `CREATE RESOURCE GROUP someGroup WITH (CPU_HARD_QUOTA_LIMIT=10, CPU_SOFT_PRIORITY=100);`)
239+
testhelper.AssertQueryRuns(connectionPool, `CREATE RESOURCE GROUP someGroup WITH (CPU_MAX_PERCENT=10, CPU_WEIGHT=100);`)
240240
defer testhelper.AssertQueryRuns(connectionPool, `DROP RESOURCE GROUP someGroup`)
241241
242242
results := builtin.GetResourceGroups[builtin.ResourceGroupAtLeast7](connectionPool)
243243
244244
expectedDefaults := builtin.ResourceGroupAtLeast7{ResourceGroup: builtin.ResourceGroup{Oid: 1, Name: `somegroup`, Concurrency: concurrencyDefault, Cpuset: cpuSetDefault},
245-
CpuHardQuotaLimit: "10", CpuSoftPriority: "100"}
245+
CpuMaxPercent: "10", CpuWeight: "100"}
246246
247247
for _, resultGroup := range results {
248248
if resultGroup.Name == `somegroup` {

meta/builtin/extract_helper.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ func backupResourceGroups(conn *dbconn.DBConn, metadataFile *utils.FileWithByteC
324324
gplog.Verbose("Writing CREATE RESOURCE GROUP statements to metadata file")
325325

326326
// at resource group part, CBDB is still same as 3x/GP6.
327-
if (conn.Version.IsGPDB() && conn.Version.Before("7")) || conn.Version.IsCBDB() {
327+
if (conn.Version.IsGPDB() && conn.Version.Before("7")) {
328328
resGroups := GetResourceGroups[ResourceGroupBefore7](conn)
329329
objectCounts["Resource Groups"] = len(resGroups)
330330
resGroupMetadata := GetCommentsForObjectType(conn, TYPE_RESOURCEGROUP)

meta/builtin/metadata_globals.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -115,18 +115,18 @@ func PrintResetResourceGroupStatements(metadataFile *utils.FileWithByteCount, to
115115
}
116116
defSettings := make([]DefSetting, 0)
117117

118-
if (gpdbVersion.IsGPDB() && gpdbVersion.Before("7")) || gpdbVersion.IsCBDB() {
118+
if gpdbVersion.IsGPDB() && gpdbVersion.Before("7") {
119119
defSettings = append(defSettings, DefSetting{"admin_group", "SET CPU_RATE_LIMIT 1"})
120120
defSettings = append(defSettings, DefSetting{"admin_group", "SET MEMORY_LIMIT 1"})
121121
defSettings = append(defSettings, DefSetting{"default_group", "SET CPU_RATE_LIMIT 1"})
122122
defSettings = append(defSettings, DefSetting{"default_group", "SET MEMORY_LIMIT 1"})
123123
} else { // GPDB7+
124-
defSettings = append(defSettings, DefSetting{"admin_group", "SET CPU_HARD_QUOTA_LIMIT 1"})
125-
defSettings = append(defSettings, DefSetting{"admin_group", "SET CPU_SOFT_PRIORITY 100"})
126-
defSettings = append(defSettings, DefSetting{"default_group", "SET CPU_HARD_QUOTA_LIMIT 1"})
127-
defSettings = append(defSettings, DefSetting{"default_group", "SET CPU_SOFT_PRIORITY 100"})
128-
defSettings = append(defSettings, DefSetting{"system_group", "SET CPU_HARD_QUOTA_LIMIT 1"})
129-
defSettings = append(defSettings, DefSetting{"system_group", "SET CPU_SOFT_PRIORITY 100"})
124+
defSettings = append(defSettings, DefSetting{"admin_group", "SET CPU_MAX_PERCENT 1"})
125+
defSettings = append(defSettings, DefSetting{"admin_group", "SET CPU_WEIGHT 100"})
126+
defSettings = append(defSettings, DefSetting{"default_group", "SET CPU_MAX_PERCENT 1"})
127+
defSettings = append(defSettings, DefSetting{"default_group", "SET CPU_WEIGHT 100"})
128+
defSettings = append(defSettings, DefSetting{"system_group", "SET CPU_MAX_PERCENT 1"})
129+
defSettings = append(defSettings, DefSetting{"system_group", "SET CPU_WEIGHT 100"})
130130
}
131131

132132
for _, prepare := range defSettings {
@@ -147,7 +147,7 @@ func PrintCreateResourceGroupStatementsAtLeast7(metadataFile *utils.FileWithByte
147147
setting string
148148
value string
149149
}{
150-
{"CPU_SOFT_PRIORITY", resGroup.CpuSoftPriority},
150+
{"CPU_WEIGHT", resGroup.CpuWeight},
151151
{"CONCURRENCY", resGroup.Concurrency},
152152
}
153153
for _, property := range resGroupList {
@@ -161,9 +161,9 @@ func PrintCreateResourceGroupStatementsAtLeast7(metadataFile *utils.FileWithByte
161161
// TODO -- why do we handle these separately?
162162
// TODO -- is this still necessary for 7?
163163
start = metadataFile.ByteCount
164-
if !strings.HasPrefix(resGroup.CpuHardQuotaLimit, "-") {
164+
if !strings.HasPrefix(resGroup.CpuMaxPercent, "-") {
165165
/* cpu rate mode */
166-
metadataFile.MustPrintf("\n\nALTER RESOURCE GROUP %s SET CPU_HARD_QUOTA_LIMIT %s;", resGroup.Name, resGroup.CpuHardQuotaLimit)
166+
metadataFile.MustPrintf("\n\nALTER RESOURCE GROUP %s SET CPU_MAX_PERCENT %s;", resGroup.Name, resGroup.CpuMaxPercent)
167167
} else {
168168
/* cpuset mode */
169169
metadataFile.MustPrintf("\n\nALTER RESOURCE GROUP %s SET CPUSET '%s';", resGroup.Name, resGroup.Cpuset)
@@ -178,14 +178,14 @@ func PrintCreateResourceGroupStatementsAtLeast7(metadataFile *utils.FileWithByte
178178
/* special handling for cpu properties */
179179
// TODO -- why do we handle these separately?
180180
// TODO -- is this still necessary for 7?
181-
if !strings.HasPrefix(resGroup.CpuHardQuotaLimit, "-") {
181+
if !strings.HasPrefix(resGroup.CpuMaxPercent, "-") {
182182
/* cpu rate mode */
183-
attributes = append(attributes, fmt.Sprintf("CPU_HARD_QUOTA_LIMIT=%s", resGroup.CpuHardQuotaLimit))
183+
attributes = append(attributes, fmt.Sprintf("CPU_MAX_PERCENT=%s", resGroup.CpuMaxPercent))
184184
} else if (gpdbVersion.IsGPDB() && gpdbVersion.AtLeast("5.9.0")) || gpdbVersion.IsCBDB() {
185185
/* cpuset mode */
186186
attributes = append(attributes, fmt.Sprintf("CPUSET='%s'", resGroup.Cpuset))
187187
}
188-
attributes = append(attributes, fmt.Sprintf("CPU_SOFT_PRIORITY=%s", resGroup.CpuSoftPriority))
188+
attributes = append(attributes, fmt.Sprintf("CPU_WEIGHT=%s", resGroup.CpuWeight))
189189
attributes = append(attributes, fmt.Sprintf("CONCURRENCY=%s", resGroup.Concurrency))
190190
metadataFile.MustPrintf("\n\nCREATE RESOURCE GROUP %s WITH (%s);", resGroup.Name, strings.Join(attributes, ", "))
191191

meta/builtin/metadata_globals_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -264,20 +264,20 @@ GRANT TEMPORARY,CONNECT ON DATABASE testdb TO testrole;`,
264264
It("prints prepare resource groups", func() {
265265
builtin.PrintResetResourceGroupStatements(backupfile, tocfile)
266266
testutils.ExpectEntry(tocfile.GlobalEntries, 0, "", "", "admin_group", "RESOURCE GROUP")
267-
if (connectionPool.Version.IsGPDB() && connectionPool.Version.Before("7")) || connectionPool.Version.IsCBDB() {
267+
if (connectionPool.Version.IsGPDB() && connectionPool.Version.Before("7")) {
268268
testutils.AssertBufferContents(tocfile.GlobalEntries, buffer,
269269
`ALTER RESOURCE GROUP admin_group SET CPU_RATE_LIMIT 1;`,
270270
`ALTER RESOURCE GROUP admin_group SET MEMORY_LIMIT 1;`,
271271
`ALTER RESOURCE GROUP default_group SET CPU_RATE_LIMIT 1;`,
272272
`ALTER RESOURCE GROUP default_group SET MEMORY_LIMIT 1;`)
273273
} else { // GPDB7+
274274
testutils.AssertBufferContents(tocfile.GlobalEntries, buffer,
275-
`ALTER RESOURCE GROUP admin_group SET CPU_HARD_QUOTA_LIMIT 1;`,
276-
`ALTER RESOURCE GROUP admin_group SET CPU_SOFT_PRIORITY 100;`,
277-
`ALTER RESOURCE GROUP default_group SET CPU_HARD_QUOTA_LIMIT 1;`,
278-
`ALTER RESOURCE GROUP default_group SET CPU_SOFT_PRIORITY 100;`,
279-
`ALTER RESOURCE GROUP system_group SET CPU_HARD_QUOTA_LIMIT 1;`,
280-
`ALTER RESOURCE GROUP system_group SET CPU_SOFT_PRIORITY 100;`)
275+
`ALTER RESOURCE GROUP admin_group SET CPU_MAX_PERCENT 1;`,
276+
`ALTER RESOURCE GROUP admin_group SET CPU_WEIGHT 100;`,
277+
`ALTER RESOURCE GROUP default_group SET CPU_MAX_PERCENT 1;`,
278+
`ALTER RESOURCE GROUP default_group SET CPU_WEIGHT 100;`,
279+
`ALTER RESOURCE GROUP system_group SET CPU_MAX_PERCENT 1;`,
280+
`ALTER RESOURCE GROUP system_group SET CPU_WEIGHT 100;`)
281281

282282
}
283283
})

meta/builtin/queries_globals.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -231,15 +231,15 @@ type ResourceGroupBefore7 struct {
231231
}
232232

233233
type ResourceGroupAtLeast7 struct {
234-
ResourceGroup // embedded common rg fields+methods
235-
CpuHardQuotaLimit string `db:"cpu_hard_quota_limit"`
236-
CpuSoftPriority string `db:"cpu_soft_priority"`
234+
ResourceGroup // embedded common rg fields+methods
235+
CpuMaxPercent string `db:"cpu_max_percent"`
236+
CpuWeight string `db:"cpu_weight"`
237237
}
238238

239239
func GetResourceGroups[T ResourceGroupBefore7 | ResourceGroupAtLeast7](connectionPool *dbconn.DBConn) []T {
240240
var query string
241241

242-
if (connectionPool.Version.IsGPDB() && connectionPool.Version.Before("7")) || connectionPool.Version.IsCBDB() {
242+
if connectionPool.Version.IsGPDB() && connectionPool.Version.Before("7") {
243243
before7SelectClause := ""
244244
// This is when pg_dumpall was changed to use the actual values
245245
if (connectionPool.Version.IsGPDB() && connectionPool.Version.AtLeast("5.2.0")) || connectionPool.Version.IsCBDB() {
@@ -296,8 +296,8 @@ func GetResourceGroups[T ResourceGroupBefore7 | ResourceGroupAtLeast7](connectio
296296
g.oid AS oid,
297297
g.rsgname AS name,
298298
t1.value AS concurrency,
299-
t2.value AS cpu_hard_quota_limit,
300-
t3.value AS cpu_soft_priority,
299+
t2.value AS cpu_max_percent,
300+
t3.value AS cpu_weight,
301301
t4.value AS cpuset
302302
FROM pg_resgroup g
303303
JOIN pg_resgroupcapability t1 ON g.oid = t1.resgroupid AND t1.reslimittype = 1

0 commit comments

Comments
 (0)