Server Signal Functions
Server signal functions send control signals to other server processes. Only the system administrator has the permission to execute the following functions:
- pg_cancel_backend(pid int)
Description: Cancels the current query of a backend.
Return type: Boolean
Note: pg_cancel_backend sends a query cancellation (SIGINT) signal to the backend process identified by pid. The PID of an active backend process can be found in the pid column of the pg_stat_activity view, or can be found by listing the database process using ps on the server. A user with the SYSADMIN permission, the owner of the database connected to the backend process, the owner of the backend process, or a user who inherits the gs_role_signal_backend permission of the built-in role has the permission to use this function.
- pg_cancel_session(pid bigint, sessionid bigint)
Description: Cancels a backend session.
Return type: Boolean
Note: The input parameters of pg_cancel_session can be queried using the pid and sessionid fields in pg_stat_activity. It can be used to clear inactive sessions in thread pool mode.
- pg_cancel_invalid_query()
Description: Cancels the invalid query of a backend.
Return type: Boolean
Note: Only the system administrator has the permission to cancel queries that are running in the backend of a degraded GTM.
- pg_reload_conf()
Description: Causes all server processes to reload their configuration files.
Return type: Boolean
Note: pg_reload_conf sends a SIGHUP signal to the server. As a result, all server processes reload their configuration files.
- pg_rotate_logfile()
Description: Rotates the log files of the server.
Return type: Boolean
Note: pg_rotate_logfile sends a signal to the log file manager, instructing the manager to immediately switch to a new output file. This function works only when redirect_stderr is used for log output. Otherwise, no log file manager subprocess exists.
- pg_terminate_session(pid bigint, sessionid bigint)
Description: Terminates a backend session.
Return type: Boolean
Note: The input parameters of this function can be queried using the pid and sessionid fields in pg_stat_activity. It can be used to clear inactive sessions in thread pool mode. A user with the SYSADMIN permission, the owner of the database connected to the session, the owner of the session, or a user who inherits the gs_role_signal_backend permission of the built-in role has the permission to use this function.
- pg_terminate_backend(pid int)
Description: Terminates a backend thread. Only the system administrator and thread owner can use this function.
Return type: Boolean
Note: Each of these functions returns true if they are successful and false otherwise. A user with the SYSADMIN permission, the owner of the database connected to the backend thread, the owner of the backend thread, or a user who inherits the gs_role_signal_backend permission of the built-in role can use this function.
Example:
1 2 3 4 5 6 7 8 9 10 11
openGauss=# SELECT pid from pg_stat_activity; pid ----------------- 140657876268816 (1 rows) openGauss=# SELECT pg_terminate_backend(140657876268816); pg_terminate_backend ---------------------- t (1 row)
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot