This is an automated email from the ASF dual-hosted git repository.

Smyatkin-Maxim pushed a commit to branch pg-dump-rebase-REL-2
in repository https://gitbox.apache.org/repos/asf/cloudberry.git

commit 7d0d807775ba3f39a9c79b2ea6b33d285cef4b44
Author: Kevin Yeap <[email protected]>
AuthorDate: Mon Nov 20 17:31:55 2023 -0800

    pg_dumpall: dump 6x resource groups correctly for 6 > 7 upgrade
    
    In order to support 6 > 7 upgrade using pg_upgrade. 7x pg_dumpall needs
    to be able to dump 6x resource groups correctly. Supporting the dumping
    of 6x resource group resolves the following error when trying to upgrade
    from 6 > 7.
    
    ```
    ALTER RESOURCE GROUP "default_group" SET cpu_weight 0;
    psql:pg_upgrade_dump_globals.sql:27: ERROR:  cpu_weight range is [1, 500]
    ```
    
    This happens because some of the attribute ordering in
    pg_resgroupcapability changed from 6x to 7x. To resolve this issue, the
    following mapping was done based on 6x and 7x resource group docs. New
    attribute cpu_weight is set to 7x default value of 100.
    
    6x             |  7x
    ---------------+-----------------
    concurrency    | concurrency
    cpu_rate_limit | cpu_max_percent
    100            | cpu_weight
    cpuset         | cputset
    
    reference resource group docs:
    
https://docs.vmware.com/en/VMware-Greenplum/6/greenplum-database/admin_guide-workload_mgmt_resgroups.html
---
 src/bin/pg_dump/pg_dumpall.c | 35 +++++++++++++++++++++++++----------
 1 file changed, 25 insertions(+), 10 deletions(-)

diff --git a/src/bin/pg_dump/pg_dumpall.c b/src/bin/pg_dump/pg_dumpall.c
index dfb6f3f0c67..074505a2852 100644
--- a/src/bin/pg_dump/pg_dumpall.c
+++ b/src/bin/pg_dump/pg_dumpall.c
@@ -845,16 +845,31 @@ dumpResGroups(PGconn *conn)
                        i_cpu_weight,
                        i_cpuset;
 
-       printfPQExpBuffer(buf, "SELECT g.rsgname AS groupname, "
-                                         "t1.value AS concurrency, "
-                                         "t2.value AS cpu_max_percent, "
-                                         "t3.value AS cpu_weight, "
-                                         "t4.value AS cpuset "
-                                         "FROM pg_resgroup g "
-                                         "     JOIN pg_resgroupcapability t1 
ON g.oid = t1.resgroupid AND t1.reslimittype = 1 "
-                                         "     JOIN pg_resgroupcapability t2 
ON g.oid = t2.resgroupid AND t2.reslimittype = 2 "
-                                         "     JOIN pg_resgroupcapability t3 
ON g.oid = t3.resgroupid AND t3.reslimittype = 3 "
-                                         "LEFT JOIN pg_resgroupcapability t4 
ON g.oid = t4.resgroupid AND t4.reslimittype = 4;");
+       if (server_version >= GPDB7_MAJOR_PGVERSION)
+       {
+               printfPQExpBuffer(buf, "SELECT g.rsgname AS groupname, "
+                                                 "t1.value AS concurrency, "
+                                                 "t2.value AS cpu_max_percent, 
"
+                                                 "t3.value AS cpu_weight, "
+                                                 "t4.value AS cpuset "
+                                                 "FROM pg_resgroup g "
+                                                 "     JOIN 
pg_resgroupcapability t1 ON g.oid = t1.resgroupid AND t1.reslimittype = 1 "
+                                                 "     JOIN 
pg_resgroupcapability t2 ON g.oid = t2.resgroupid AND t2.reslimittype = 2 "
+                                                 "     JOIN 
pg_resgroupcapability t3 ON g.oid = t3.resgroupid AND t3.reslimittype = 3 "
+                                                 "LEFT JOIN 
pg_resgroupcapability t4 ON g.oid = t4.resgroupid AND t4.reslimittype = 4;");
+       }
+       else
+       {
+               printfPQExpBuffer(buf, "SELECT g.rsgname AS groupname, "
+                                                 "t1.value AS concurrency, "
+                                                 "t2.value AS cpu_max_percent, 
"
+                                                 "     100 AS cpu_weight, "
+                                                 "t7.value AS cpuset "
+                                                 "FROM pg_resgroup g "
+                                                 "     JOIN 
pg_resgroupcapability t1 ON g.oid = t1.resgroupid AND t1.reslimittype = 1 "
+                                                 "     JOIN 
pg_resgroupcapability t2 ON g.oid = t2.resgroupid AND t2.reslimittype = 2 "
+                                                 "LEFT JOIN 
pg_resgroupcapability t7 ON g.oid = t7.resgroupid AND t7.reslimittype = 7;");
+       }
 
        res = executeQuery(conn, buf->data);
 


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to