非superuser管理会话
在gp中取消或者中断某个用户的超长时间或者SQL存在问题的会话,如果无法拥有超级用户将无法执行该类操作。 首先我们创建两个用户t1、t2,并且使用t1登录到数据库。 [gpadmin@wx60 ~]$ psql gtlionspsql (8.2.15)Type help for help. gtlions=# select version
在gp中取消或者中断某个用户的超长时间或者SQL存在问题的会话,如果无法拥有超级用户将无法执行该类操作。首先我们创建两个用户t1、t2,并且使用t1登录到数据库。
[gpadmin@wx60 ~]$ psql gtlions psql (8.2.15) Type "help" for help. gtlions=# select version(); version ------------------------------------------------------------------------------------------------------------------------------------------------------ PostgreSQL 8.2.15 (Greenplum Database 4.2.7.2 build 1) on x86_64-unknown-linux-gnu, compiled by GCC gcc (GCC) 4.4.2 compiled on Feb 25 2014 18:05:04 (1 row) gtlions=# \du List of roles Role name | Attributes | Member of -----------+-----------------------------------+----------- gpadmin | Superuser, Create role, Create DB | gtlions=# \dn List of schemas Name | Owner --------------------+--------- gp_toolkit | gpadmin information_schema | gpadmin pg_aoseg | gpadmin pg_bitmapindex | gpadmin pg_catalog | gpadmin pg_toast | gpadmin public | gpadmin (7 rows) gtlions=# create user t1 ; NOTICE: resource queue required -- using default resource queue "pg_default" CREATE ROLE gtlions=# create user t2; NOTICE: resource queue required -- using default resource queue "pg_default" CREATE ROLE gtlions=# \c gtlions t1 You are now connected to database "gtlions" as user "t1". 接下来我们使用用户t2登录到数据库,检查当前会话并尝试取消或者中断用户t1的会话。
[gpadmin@wx60 ~]$ psql -U t2 gtlions psql (8.2.15) Type "help" for help. gtlions=> select * from pg_stat_activity ; datid | datname | procpid | sess_id | usesysid | usename | current_query | waiting | query_start | backend_start | client_addr | client_port | application_name | xact_start -------+---------+---------+---------+----------+---------+----------------------------------+---------+-------------------------------+------------------------------- +-------------+-------------+------------------+------------------------------- 16992 | gtlions | 3395 | 13 | 25881 | t2 | select * from pg_stat_activity ; | f | 2014-10-11 09:25:56.197394+08 | 2014-10-11 09:25:43.293684+08 | | -1 | psql | 2014-10-11 09:25:56.197394+08 16992 | gtlions | 3384 | 12 | 25880 | t1 | <insufficient privilege> | | | | | | psql | (2 rows) gtlions=> select pg_cancel_backend(3384); ERROR: must be superuser to signal other server processes gtlions=> 会发现非超级用户无法执行取消或者中断其他用户的会话操作。 解决办法是自定义一个函数,并授权给t2用户执行权限,这样就可以实现上述操作了。
create or replace function session_mgr(procpid integer, opertype character) returns boolean as $BODY$ declare ret boolean; begin if opertype = 'c' then ret := (select pg_catalog.pg_cancel_backend(procpid)); elsif opertype = 'k' then ret := (select pg_catalog.pg_terminate_backend(procpid)); end if; return ret; end; $BODY$ LANGUAGE plpgsql security definer; gtlions=# grant execute on function session_mgr(integer, character) to t2; GRANT gtlions=# \c gtlions t1 You are now connected to database "gtlions" as user "t1". gtlions=> 接着使用用户t2进行相关操作。
[gpadmin@wx60 ~]$ psql -U t2 gtlions psql (8.2.15) Type "help" for help. gtlions=> select * from pg_stat_activity ; datid | datname | procpid | sess_id | usesysid | usename | current_query | waiting | query_start | backend_start | client_addr | client_port | application_name | xact_start -------+---------+---------+---------+----------+---------+----------------------------------+---------+-------------------------------+------------------------------- +-------------+-------------+----------------------------+------------------------------- 16992 | gtlions | 4034 | 19 | 25881 | t2 | select * from pg_stat_activity ; | f | 2014-10-11 09:48:53.767859+08 | 2014-10-11 09:48:51.285594+08 | | -1 | psql | 2014-10-11 09:48:53.767859+08 16992 | gtlions | 3678 | 15 | 10 | gpadmin | <insufficient privilege> | | | | | | pgAdmin III - ????????? | 16992 | gtlions | 3704 | 16 | 10 | gpadmin | <insufficient privilege> | | | | | | pgAdmin III - ???????????? | 16992 | gtlions | 4023 | 18 | 25880 | t1 | <insufficient privilege> | | | | | | psql | (4 rows) gtlions=> select session_mgr(4023,'c'); session_mgr ------------- t (1 row) gtlions=> select * from pg_stat_activity ; datid | datname | procpid | sess_id | usesysid | usename | current_query | waiting | query_start | backend_start | client_addr | client_port | application_name | xact_start -------+---------+---------+---------+----------+---------+----------------------------------+---------+-------------------------------+------------------------------- +-------------+-------------+----------------------------+------------------------------- 16992 | gtlions | 4034 | 19 | 25881 | t2 | select * from pg_stat_activity ; | f | 2014-10-11 09:52:03.279186+08 | 2014-10-11 09:48:51.285594+08 | | -1 | psql | 2014-10-11 09:52:03.279186+08 16992 | gtlions | 4065 | 20 | 10 | gpadmin | <insufficient privilege> | | | | | | pgAdmin III - ???????????? | 16992 | gtlions | 3678 | 15 | 10 | gpadmin | <insufficient privilege> | | | | | | pgAdmin III - ????????? | 16992 | gtlions | 3704 | 16 | 10 | gpadmin | <insufficient privilege> | | | | | | pgAdmin III - ???????????? | 16992 | gtlions | 4023 | 18 | 25880 | t1 | <insufficient privilege> | | | | | | psql | (5 rows) gtlions=> select session_mgr(4023,'k'); session_mgr ------------- t (1 row) gtlions=> select * from pg_stat_activity ; datid | datname | procpid | sess_id | usesysid | usename | current_query | waiting | query_start | backend_start | client_addr | client_port | application_name | xact_start -------+---------+---------+---------+----------+---------+----------------------------------+---------+-------------------------------+------------------------------- +-------------+-------------+----------------------------+------------------------------- 16992 | gtlions | 4034 | 19 | 25881 | t2 | select * from pg_stat_activity ; | f | 2014-10-11 09:52:28.473137+08 | 2014-10-11 09:48:51.285594+08 | | -1 | psql | 2014-10-11 09:52:28.473137+08 16992 | gtlions | 4065 | 20 | 10 | gpadmin | <insufficient privilege> | | | | | | pgAdmin III - ???????????? | 16992 | gtlions | 3678 | 15 | 10 | gpadmin | <insufficient privilege> | | | | | | pgAdmin III - ????????? | 16992 | gtlions | 3704 | 16 | 10 | gpadmin | <insufficient privilege> | | | | | | pgAdmin III - ???????????? | 16992 | gtlions | 4189 | 21 | 25880 | t1 | <insufficient privilege> | | | | | | psql | (5 rows) gtlions=> 最后检查下t1当前进程。
gtlions=> select version(); FATAL: terminating connection due to administrator command server closed the connection unexpectedly This probably means the server terminated abnormally before or while processing the request. The connection to the server was lost. Attempting reset: Succeeded. -EOF-

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



With the rapid development of social media, Xiaohongshu has become one of the most popular social platforms. Users can create a Xiaohongshu account to show their personal identity and communicate and interact with other users. If you need to find a user’s Xiaohongshu number, you can follow these simple steps. 1. How to use Xiaohongshu account to find users? 1. Open the Xiaohongshu APP, click the "Discover" button in the lower right corner, and then select the "Notes" option. 2. In the note list, find the note posted by the user you want to find. Click to enter the note details page. 3. On the note details page, click the "Follow" button below the user's avatar to enter the user's personal homepage. 4. In the upper right corner of the user's personal homepage, click the three-dot button and select "Personal Information"

In Ubuntu systems, the root user is usually disabled. To activate the root user, you can use the passwd command to set a password and then use the su- command to log in as root. The root user is a user with unrestricted system administrative rights. He has permissions to access and modify files, user management, software installation and removal, and system configuration changes. There are obvious differences between the root user and ordinary users. The root user has the highest authority and broader control rights in the system. The root user can execute important system commands and edit system files, which ordinary users cannot do. In this guide, I'll explore the Ubuntu root user, how to log in as root, and how it differs from a normal user. Notice

When placing orders using Meituan, users can choose to cancel the orders they do not want. Many users do not know how to cancel Meituan orders. Users can click on the My page to enter the order to be received, select the order that needs to be canceled and click Cancel. How to cancel an order with Meituan 1. First, click on Meituan My Page to enter the order to be received. 2. Then click to enter the order that needs to be canceled. 3. Click Cancel Order. 4. Click OK to cancel the order. 5. Finally, select the reason for cancellation according to your personal situation and click Submit.

When many users experience Mango TV, a video software, they choose to become members in order to enjoy more film and television resources and more comprehensive services. In the process of using Mango TV membership services, some users will choose to turn on the automatic renewal function to enjoy the discounts to ensure that they will not miss any exciting content. However, when users no longer need membership services or want to change the payment method, canceling the automatic renewal function is a very important thing to protect the safety of property. How to cancel the automatic renewal service of Mango TV? Users who want to know Come and follow this article to learn more! How to cancel the automatic renewal of membership on Mango TV? 1. First enter [My] in the Mango TV mobile APP, and then select [VIP Membership]. 2. Then find [Tube

1. The ear symbol is the voice receiver mode. First, we open WeChat. 2. Click me in the lower right corner. 3. Click Settings. 4. Find the chat and click to enter. 5. Uncheck Use earpiece to play voice.

You can open the management automatic renewal function on the My Gold VIP Member interface to cancel. Tutorial Applicable Model: Huawei P50 System: HarmonyOS2.0 Version: iQiyi 12.1.0 Analysis 1 Open the iQiyi app on your phone, and then enter the My page. 2 Then click Gold VIP Membership at the top of my page, and then click Manage Automatic Renewal Options. 3. Click Cancel automatic renewal in the pop-up window. If you are not interested, continue to cancel. 4Finally confirm to turn off automatic renewal and click I understand, just reject it cruelly. Supplement: How to cancel the automatic renewal function of iQiyi on Apple mobile phone 1. Open the settings on the phone, and then click [AppleID] at the top of the settings interface. 2Click [Subscribe] on the AppleID interface to select

1. Click the [iTunesStore and AppStore] option in the phone settings. 2. Click [View AppleID], and then enter the login password. 3. Enter the [Account Settings] interface and click [Payment Information]. 4. Check the payment method as [None] and click [Finish]. After completion, return to the WeChat interface. At this time, you will receive the [Successful Cancellation Notification] message, and WeChat will no longer automatically deduct fees.

Alipay is a very practical life service platform. This software is very powerful. It provides users with functions such as life payment, travel, medical insurance, etc., bringing convenience to everyone's life. The Alipay platform has many functions waiting for everyone to unlock, so how do you cancel face-swiping payment on Alipay? Detailed tutorial on canceling face-swiping payment on Alipay: 1. First open Alipay 2. Click on My in the lower right corner 3. Click on Settings in the upper right corner 4. Click on payment settings 5. Click on biometric payment 6. Find the mobile phone to scan the face to pay 7. Uncheck the software features 1. Support various scene relationships, group chat and group payment are more convenient; 2. Establish family accounts for children and parents; 3. Free long-distance inter-bank transfers and credit card repayments
