diff --git "a/content/zh/docs/AboutopenGauss/\345\206\205\347\275\256perf\345\267\245\345\205\267.md" "b/content/zh/docs/AboutopenGauss/\345\206\205\347\275\256perf\345\267\245\345\205\267.md" new file mode 100644 index 0000000000000000000000000000000000000000..8515289445348ed62a84e194918dcb7fb5dbc527 --- /dev/null +++ "b/content/zh/docs/AboutopenGauss/\345\206\205\347\275\256perf\345\267\245\345\205\267.md" @@ -0,0 +1,48 @@ +# 内置perf工具 + +## 可获得性 + +本特性自5.1.0版本开始引入。 + +## 特性简介 + +perf工具是在一定时间范围内,采集数据库中各线程的调用栈及其时间占比的工具,用于辅助数据库运维人员定位性能问题。 + +## 客户价值 + +提供函数级别的调用栈信息,提供视图支持查询当前节点下所有活跃线程的函数调用栈及时间占比,提升数据库内核运维人员分析、定位性能问题的效率。 + +## 特性描述 + +可以通过gs\_perf\_start\(\),gs\_perf\_query\(\)、gs\_perf\_clean\(\)分别采集,查询和删除堆栈数据。通过dbe\_perf.perf\_query视图查询堆栈数据。 + + + +- gs\_perf\_start\(\) 函数详见《SQL参考 》中的[ 函数和操作符 \> 统计信息函数](../SQLReference/统计信息函数.md)章节。 + +- gs\_perf\_query\(\)函数详见《SQL参考 》中的[ 函数和操作符 \> 统计信息函数](../SQLReference/统计信息函数.md)章节。 + +- gs\_perf\_clean\(\)函数详见《SQL参考 》中的[ 函数和操作符 \> 统计信息函数](../SQLReference/统计信息函数.md)章节。 + +- dbe\_perf.perf\_query视图详见《SQL参考 》中的[ Schema \> DBE\_PERF Schema \> OS \> PERF\_QUERY](../SQLReference/PERF_QUERY.md)章节。 +《开发者指南》章节。 + +## 特性增强 + +无。 + +## 特性约束 + +- 执行性能采集时,需要数据库在normal、degrade状态,unavailable状态不支持。在degrade状态,异常cn/dn不支持采集。 + +- 仅支持CN、DN、DN备、不支持logger节点,不支持cm\_server、cm\_agent、gtm、UDF等组件。 +- 仅支持on cpu采集,不支持off cpu采集。 +- 采集时间为1s-60s。 +- 采集周期为10HZ-1000HZ。 +- 采集结果不落盘,以tuplestore格式存储在内存中。如果执行gs\_perf\_start后重启进程,则采集结果丢失。 +- 不支持并发采集。同一进程,同一时间,最多有一个session可以执行gs\_perf\_start操作。且同一进程内,在执行gs\_perf\_start操作期间,不支持执行gs\_perf\_query或gs\_perf\_clean操作。 +- 同一时间不支持Linux perf工具和gs\_perf\_start同时操作同一个进程。 + +## 依赖关系 + +无。 diff --git "a/content/zh/docs/AboutopenGauss/\347\273\264\346\212\244\346\200\247.md" "b/content/zh/docs/AboutopenGauss/\347\273\264\346\212\244\346\200\247.md" index 8e388173613befadf627acd73fc23134a4e28120..7938a68e4ed3351bcabd1f9b03ede437cde77bc1 100644 --- "a/content/zh/docs/AboutopenGauss/\347\273\264\346\212\244\346\200\247.md" +++ "b/content/zh/docs/AboutopenGauss/\347\273\264\346\212\244\346\200\247.md" @@ -1,15 +1,2 @@ # 维护性 -- **[灰度升级](灰度升级.md)** - -- **[指定节点升级](指定节点升级.md)** - -- **[支持WDR诊断报告](支持WDR诊断报告.md)** - -- **[慢SQL诊断](慢SQL诊断.md)** - -- **[Session性能诊断](Session性能诊断.md)** - -- **[系统KPI辅助诊断](系统KPI辅助诊断.md)** - - diff --git a/content/zh/docs/DatabaseReference/GAUSS-58001---GAUSS-58500.md b/content/zh/docs/DatabaseReference/GAUSS-58001---GAUSS-58500.md new file mode 100644 index 0000000000000000000000000000000000000000..47bee40edb59d0e3544c024d3e5625585bb61592 --- /dev/null +++ b/content/zh/docs/DatabaseReference/GAUSS-58001---GAUSS-58500.md @@ -0,0 +1,110 @@ +# GAUSS-58001-- GAUSS-58500 + +GAUSS-58331: "perf mmap failed, errno is , fd is , mmap size is " + +SQLSTATE: + +CAUSE: "system perf\_event\_mlock\_kb is not enough" + +ACTION: "try to increase /proc/sys/kernel/perf\_event\_mlock\_kb" + +

+ + +GAUSS-58333: "perf start corrupt during refresh hashtable resource, thread id: " + +SQLSTATE: 29000 + +CAUSE: "refer to the hash table error message" + +ACTION: "check perf hash table thread resources" + +

+ +GAUSS-58334: "perf start corrupt during refresh hashtable status, thread id: " + +SQLSTATE: 29000 + +CAUSE: "refer to the hash table error message" + +ACTION: "check perf hash table thread status" + +

+ +GAUSS-58344: "perf corrupt during release hashtable, thread id: " + +SQLSTATE: 29000 + +CAUSE: "refer to the hash table error message" + +ACTION: "check perf hash table release status" + +

+ +GAUSS-58346: "perf failed to obtain lock, another perf is processing" + +SQLSTATE: 29000 + +CAUSE: "another gs\_perf\_start\(\), gs\_perf\_query\(\) or gs\_perf\_clean\(\) is processing" + +ACTION: "wait for another perf finish" + +

+ +GAUSS-58347: "perf failed to release lock" + +SQLSTATE: 29000 + +CAUSE: "perf lock is not hold, concurrency error occurs" + +ACTION: "do not perf concurrently" + +

+ +GAUSS-58352: "perf query failed, no data for perf query. Please collect perf data first" + +SQLSTATE: P0002 + +CAUSE: "perf query before perf start or perf data has be cleaned" + +ACTION: "use gs\_perf\_start\(duration, \[freq\]\) to collect perf data first" + +

+ +GAUSS-58353: "only system admin or monitor admin can use perf" + +SQLSTATE: 42501 + +CAUSE: "user is not system admin or monitor" + +ACTION: "please use system admin or monitor user" + +

+ +GAUSS-58354: "perf start failed, input duration should be between 1 and 60" + +SQLSTATE: 22023 + +CAUSE: "perf start duration input error" + +ACTION: "check input parameter duration of gs\_perf\_start\(duration, \[freq\]\)" + +

+ +GAUSS-58355: "perf start failed, input freq should be between 10 and 1000" + +SQLSTATE: 22023 + +CAUSE: "perf start freq input error" + +ACTION: "check input parameter freq of gs\_perf\_start\(duration, \[freq\]\)" + +

+ +GAUSS-58360: "perf clean failed, no data for perf to clean." + +SQLSTATE: 29000 + +CAUSE: "try to clean perf data but has nothing to clean" + +ACTION: "do not clean perf data when it is empty" diff --git a/content/zh/docs/SQLReference/OS.md b/content/zh/docs/SQLReference/OS.md index 32c89afe515765c37c54c604277117b22c9be184..1a2dee968af03da40724716260756fb3a4c16e53 100644 --- a/content/zh/docs/SQLReference/OS.md +++ b/content/zh/docs/SQLReference/OS.md @@ -1,11 +1,4 @@ # OS -- **[OS\_RUNTIME](OS_RUNTIME.md)** - -- **[GLOBAL\_OS\_RUNTIME](GLOBAL_OS_RUNTIME.md)** - -- **[OS\_THREADS](OS_THREADS.md)** - -- **[GLOBAL\_OS\_THREADS](GLOBAL_OS_THREADS.md)** diff --git a/content/zh/docs/SQLReference/PERF_QUERY.md b/content/zh/docs/SQLReference/PERF_QUERY.md new file mode 100644 index 0000000000000000000000000000000000000000..d48df437ed833d5e6dfcd414ac1a4d1217d1a799 --- /dev/null +++ b/content/zh/docs/SQLReference/PERF_QUERY.md @@ -0,0 +1,31 @@ +# PERF\_QUERY + +提供当前节点下采集到堆栈信息的名称、树状结构和百分比。需要有sysadmin权限或者monadmin权限。 + +**表 1** PERF\_QUERY字段 + + + + + + + + + + + + + + + + +

名称

+

类型

+

描述

+

backtrace

+

text

+

堆栈信息树状结构文本。

+

overhead

+

float

+

当前堆栈信息在整个堆栈采集过程中所占时间百分比。

+
diff --git "a/content/zh/docs/SQLReference/\347\273\237\350\256\241\344\277\241\346\201\257\345\207\275\346\225\260.md" "b/content/zh/docs/SQLReference/\347\273\237\350\256\241\344\277\241\346\201\257\345\207\275\346\225\260.md" index 2bd8f67ffc09de19be3a30fbccd9d40f5dcb5796..a16c90bbd47473060661662f59260236143d69ca 100644 --- "a/content/zh/docs/SQLReference/\347\273\237\350\256\241\344\277\241\346\201\257\345\207\275\346\225\260.md" +++ "b/content/zh/docs/SQLReference/\347\273\237\350\256\241\344\277\241\346\201\257\345\207\275\346\225\260.md" @@ -3349,6 +3349,206 @@ ``` +- gs\_perf\_start\(\) + + 描述:调用perf\_event\_open,采集各个线程的调用栈及各函数运行时间。查询该函数需要有sysadmin权限或者monadmin权限。 + + 参数说明如下: + + + + + + + + + + + + + + + + + + +

参数名称

+

描述

+

类型

+

范围

+

duration

+

采集堆栈时长(单位为秒,如输入浮点型,会对浮点型小数点后第一位进行四舍五入后取整处理)。

+

integer

+

1~60

+

freq

+

采集堆栈频率(可选参数,单位为HZ,默认为100)。

+

integer

+

10~1000

+
+ 返回值类型:text + + 示例: + + SELECT \* FROM gs\_perf\_start\(10, 100\);设置采集频率为100HZ,采集10s堆栈信息。 + ``` + openGauss=# SELECT * FROM gs_perf_start(10, 100); + gs_perf_start + --------------------- + Perf start succeed. + (1 row) + ``` + >![](public_sys-resources/icon-caution.png) **注意:** + > + > gs\_perf\_start在采集过程中,需要申请环形buffer,该buffer的大小受操作系统中/proc/sys/kernel/perf_event_mlock_kb控制。如果采集过程出现“perf mmap failed”错误,可以通过调整/proc/sys/kernel/perf_event_mlock_kb的大小,在重新开始采集。 + + + + +- gs\_perf\_query\(\) + + 描述:归并各个线程的函数调用栈并求和函数运行时间,显示聚集后的结果。查询该函数需要有sysadmin权限或者monadmin权限。 + + 参数:nan + + 返回值类型:setof record + + 函数返回字段说明: + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

名称

+

类型

+

描述

+

backtrace

+

text

+

堆栈名称(带树状结构)。

+

period

+

bigint

+

堆栈的执行时间。

+

level

+

integer

+

堆栈所在堆栈调用树的层级。

+

sequence

+

integer

+

堆栈调用树排序后的顺序。

+

thread_name

+

text

+

该堆栈所在的线程名称。

+

overhead

+

float

+

该堆栈执行所占时间百分比。

+
+ 示例: + + SELECT \* FROM gs\_perf\_query\(\) WHERE overhead \> 2 AND level < 10;查询采集到的堆栈信息。 + + ``` + openGauss=# SELECT * FROM gs_perf_query() WHERE overhead > 2 AND level < 10; + backtrace | period | level | sequence | thread_name | overhead + -------------------------------------------------------------------------------+-------------+-------+----------+---------------+---------- + root +| 74140000000 | 0 | 1 | root | 100 + | | | | | + worker +| 69930000000 | 1 | 2 | worker | 94.32 + | | | | | + |── start_thread +| 67620000000 | 2 | 3 | worker | 91.21 + | | | | | + | └── ThreadStarterFunc +| 67620000000 | 3 | 4 | worker | 91.21 + | | | | | + | └── internal_thread_func +| 67620000000 | 4 | 5 | worker | 91.21 + | | | | | + | └── int gauss_db_thread_main +| 67620000000 | 5 | 6 | worker | 91.21 + | | | | | + | └── backend_run +| 67620000000 | 6 | 7 | worker | 91.21 + | | | | | + | |── PostgresMain +| 67520000000 | 7 | 8 | worker | 91.07 + | | | | | + | | |── exec_simple_query +| 64800000000 | 8 | 9 | worker | 87.4 + | | | | | + | | | |── OpFusion::opfusion_process +| 30130000000 | 9 | 10 | worker | 40.64 + | | | | | + | | | |── pg_analyze_and_rewrite +| 11290000000 | 9 | 1405 | worker | 15.23 + | | | | | + | | | |── pg_plan_queries +| 9550000000 | 9 | 2660 | worker | 12.88 + | | | | | + | | | |── PortalRun +| 4680000000 | 9 | 4310 | worker | 6.31 + | | | | | + | | | |── finish_xact_command +| 3120000000 | 9 | 4923 | worker | 4.21 + | | | | | + | | | |── pg_parse_query +| 1520000000 | 9 | 5262 | worker | 2.05 + | | | | | + | | | |── OpFusion::opfusion_factory +| 1500000000 | 9 | 5374 | worker | 2.02 + | | | | | + txnsnapworker +| 1640000000 | 1 | 6770 | txnsnapworker | 2.21 + | | | | | + |── start_thread +| 1620000000 | 2 | 6771 | txnsnapworker | 2.19 + | | | | | + | └── ThreadStarterFunc +| 1620000000 | 3 | 6772 | txnsnapworker | 2.19 + | | | | | + | └── internal_thread_func +| 1620000000 | 4 | 6773 | txnsnapworker | 2.19 + | | | | | + | └── int gauss_db_thread_main +| 1620000000 | 5 | 6774 | txnsnapworker | 2.19 + | | | | | + | └── txn_snap_cap_worker_main +| 1620000000 | 6 | 6775 | txnsnapworker | 2.19 + | | | | | + | └── PostgresInitializer::InitTxnSnapWorker +| 1620000000 | 7 | 6776 | txnsnapworker | 2.19 + | | | | | + | |── PostgresInitializer::SetDatabase +| 1600000000 | 8 | 6777 | txnsnapworker | 2.16 + | | | | | + | | └── PostgresInitializer::SetDatabaseByName +| 1600000000 | 9 | 6778 | txnsnapworker | 2.16 + + ``` + + + +- gs\_perf\_clean\(\) + + 描述:清理perf产生的数据。查询该函数需要有sysadmin权限或者monadmin权限。 + + 参数:nan + + 返回值类型:text + + 示例: + + SELECT \* FROM gs\_perf\_clean\(\);清理perf产生的数据。 + + ``` + openGauss=# SELECT * FROM gs_perf_clean(); + gs_perf_clean + --------------------- + Perf clean succeed. + (1 row) + ``` + + - gs\_get\_session\_memctx\_detail\(text\) diff --git a/content/zh/menu/index.md b/content/zh/menu/index.md index 8c391bfe232ebe515eda97161c16e611a43d3fe7..73173fdec0e19184c95e41d262b2c6cd9d0f72dd 100644 --- a/content/zh/menu/index.md +++ b/content/zh/menu/index.md @@ -72,6 +72,7 @@ headless: true - [系统KPI辅助诊断]({{< relref "./docs/AboutopenGauss/系统KPI辅助诊断.md" >}}) - [内置stack工具]({{< relref "./docs/AboutopenGauss/内置stack工具.md" >}}) - [支持SQL PATCH]({{< relref "./docs/AboutopenGauss/支持SQL-PATCH.md" >}}) + - [内置perf工具]({{< relref "./docs/AboutopenGauss/内置perf工具.md" >}}) - [数据库安全]({{< relref "./docs/AboutopenGauss/数据库安全.md" >}}) - [访问控制模型]({{< relref "./docs/AboutopenGauss/访问控制模型.md" >}}) - [控制权和访问权分离]({{< relref "./docs/AboutopenGauss/控制权和访问权分离.md" >}}) @@ -1433,7 +1434,8 @@ headless: true - [OS\_RUNTIME]({{< relref "./docs/SQLReference/OS_RUNTIME.md" >}}) - [GLOBAL\_OS\_RUNTIME]({{< relref "./docs/SQLReference/GLOBAL_OS_RUNTIME.md" >}}) - [OS\_THREADS]({{< relref "./docs/SQLReference/OS_THREADS.md" >}}) - - [GLOBAL\_OS\_THREADS]({{< relref "./docs/SQLReference/GLOBAL_OS_THREADS.md" >}}) + - [GLOBAL\_OS\_THREADS]({{< relref "./docs/SQLReference/GLOBAL_OS_THREADS.md" >}}) + - [PERF\_QUERY]({{< relref "./docs/SQLReference/PERF_QUERY.md" >}}) - [Instance]({{< relref "./docs/SQLReference/Instance.md" >}}) - [INSTANCE\_TIME]({{< relref "./docs/SQLReference/INSTANCE_TIME.md" >}}) - [GLOBAL\_INSTANCE\_TIME]({{< relref "./docs/SQLReference/GLOBAL_INSTANCE_TIME.md" >}}) @@ -2941,6 +2943,7 @@ headless: true - [GAUSS-53400 -- GAUSS-53499]({{< relref "./docs/DatabaseReference/GAUSS-53400----GAUSS-53499.md" >}}) - [GAUSS-53500 -- GAUSS-53599]({{< relref "./docs/DatabaseReference/GAUSS-53500----GAUSS-53599.md" >}}) - [GAUSS-53600 -- GAUSS-53699]({{< relref "./docs/DatabaseReference/GAUSS-53600----GAUSS-53699.md" >}}) + - [GAUSS-58001---GAUSS-58500]({{< relref "./docs/DatabaseReference/GAUSS-58001---GAUSS-58500.md" >}}) - [通信矩阵]({{< relref "./docs/DatabaseReference/通信矩阵.md" >}}) - [附录]({{< relref "./docs/Appendix/附录.md" >}}) - [openGauss资源获取]({{< relref "./docs/Appendix/openGauss资源获取.md" >}}) diff --git "a/sphinx/source/AboutopenGauss/\347\273\264\346\212\244\346\200\247.rst" "b/sphinx/source/AboutopenGauss/\347\273\264\346\212\244\346\200\247.rst" index a0091af838d95b9c969e70e4f402f9e87e67b638..54944330c5286c16507837a7f05c981c2057f219 100644 --- "a/sphinx/source/AboutopenGauss/\347\273\264\346\212\244\346\200\247.rst" +++ "b/sphinx/source/AboutopenGauss/\347\273\264\346\212\244\346\200\247.rst" @@ -9,4 +9,5 @@ ../content/zh/docs/AboutopenGauss/Session性能诊断 ../content/zh/docs/AboutopenGauss/系统KPI辅助诊断 ../content/zh/docs/AboutopenGauss/内置stack工具 - ../content/zh/docs/AboutopenGauss/支持SQL-PATCH \ No newline at end of file + ../content/zh/docs/AboutopenGauss/支持SQL-PATCH + ../content/zh/docs/AboutopenGauss/内置perf工具 \ No newline at end of file diff --git "a/sphinx/source/DatabaseReference/\351\224\231\350\257\257\347\240\201\345\217\202\350\200\203.rst" "b/sphinx/source/DatabaseReference/\351\224\231\350\257\257\347\240\201\345\217\202\350\200\203.rst" index 1470803ae447bdaa680042c53c46e94b81f79b0d..30972c543d55d92180a5fc3b07d74db1b4be3ca4 100644 --- "a/sphinx/source/DatabaseReference/\351\224\231\350\257\257\347\240\201\345\217\202\350\200\203.rst" +++ "b/sphinx/source/DatabaseReference/\351\224\231\350\257\257\347\240\201\345\217\202\350\200\203.rst" @@ -83,4 +83,5 @@ GAUSS-50000----GAUSS-50999 GAUSS-51000----GAUSS-51999 GAUSS-52000----GAUSS-52999 - GAUSS-53000----GAUSS-53999 \ No newline at end of file + GAUSS-53000----GAUSS-53999 + GAUSS-58001---GAUSS-58500 \ No newline at end of file diff --git a/sphinx/source/SQLReference/OS.rst b/sphinx/source/SQLReference/OS.rst index 31e306a3c6a54fb11635e18e5d07596f135efdbe..fc614a8df97a170d754eea6929de9292fd4862a9 100644 --- a/sphinx/source/SQLReference/OS.rst +++ b/sphinx/source/SQLReference/OS.rst @@ -7,4 +7,4 @@ OS ../content/zh/docs/SQLReference/GLOBAL_OS_RUNTIME ../content/zh/docs/SQLReference/OS_THREADS ../content/zh/docs/SQLReference/GLOBAL_OS_THREADS - + ../content/zh/docs/SQLReference/PERF_QUERY