KingbaseES运维案例之---服务进程(backend process)终止

news2025/1/19 8:17:27

案例说明:
如下图所示:KingbaseES服务进程结构

KingbaseES使用客户端/服务器的模型。 对于每个客户端的连接,KingbaseES主进程接收到客户端连接后,会为其创建一个新的服务进程。 KingbaseES 用服务进程来处理连接到数据库服务的客户端请求。 该进程负责实际处理客户端的数据库请求,连接断开时退出。当Client连接到数据库时,会有对应的kingbase的服务进程为其提供服务,如以下Client查询访问:

如下所示,操作系统对应的服务进程(backend process):

当Client结束访问正常退出数据库连接时,对应的kingbase的服务进程也将结束;但是当客户端异常退出时,会导致数据库端的kingbase服务进程没有正常结束,并占用数据库资源,本案例将详细描述手工方式对服务进程(backend process)终止。手工结束backend process可以使用数据库工具或者操作系统的kill进程方式,但是不同方式对数据库造成的影响不同。

适用版本: KingbaseES V8R3/R6

系统架构:

一、客户端访问

[kingbase@node1 bin]$ ./ksql -h 192.168.8.201 -U system -W prod
Password: 
ksql (V8.0)
Type "help" for help.

prod=#  select count(*) from t1;
 count  
--------
 100000
(1 row)

二、backend process终止方案

1、pg_terminate_backend(pid)方式

Tips:函数 pg_terminate_backend() 实际上是给进程发送了一个 SIGTERM 信号。

# 查询backend process状态信息
prod=# select * from sys_stat_activity where client_addr='192.168.8.200';
 datid | datname |  pid  | usesysid | usename | application_name |  client_addr  | client_hostname | client_port |         backend_start         | xact_start |          quer
y_start          |         state_change          | wait_event_type | wait_event | state | backend_xid | backend_xmin |          query           |  backend_type  
-------+---------+-------+----------+---------+------------------+---------------+-----------------+-------------+-------------------------------+------------+--------------
-----------------+-------------------------------+-----------------+------------+-------+-------------+--------------+--------------------------+----------------
 16385 | prod    | 17100 |       10 | system  | kingbase_*&+_    | 192.168.8.200 |                 |       57476 | 2022-11-29 15:04:57.131987+08 |            | 2022-11-29 15
:05:05.526379+08 | 2022-11-29 15:05:05.539018+08 | Client          | ClientRead | idle  |             |              | select count(*) from t1; | client backend
(1 row)

#终止backend process对应的pid
prod=# select pg_terminate_backend(17100);
 pg_terminate_backend 
----------------------
 t
(1 row)

#进程被终止
prod=# select * from sys_stat_activity where client_addr='192.168.8.200';
 datid | datname | pid | usesysid | usename | application_name | client_addr | client_hostname | client_port | backend_start | xact_start | query_start | state_change | wait
_event_type | wait_event | state | backend_xid | backend_xmin | query | backend_type 
-------+---------+-----+----------+---------+------------------+-------------+-----------------+-------------+---------------+------------+-------------+--------------+-----
------------+------------+-------+-------------+--------------+-------+--------------
(0 rows)

#如下所示,数据库进程正常,对应的backend pross被安全终止
[root@node2 sys_log]# ps -ef |grep kingbase
kingbase 13089     1  0 14:39 ?        00:00:00 /opt/Kingbase/ES/V8R6_054/KESRealPro/V008R006C005B0054/Server/bin/kingbase -D /db/kingbase/v8r6_054/data
kingbase 13090 13089  0 14:39 ?        00:00:00 kingbase: logger   
kingbase 16474 13089  0 14:59 ?        00:00:00 kingbase: checkpointer   
kingbase 16475 13089  0 14:59 ?        00:00:00 kingbase: background writer   
kingbase 16476 13089  0 14:59 ?        00:00:00 kingbase: walwriter   
kingbase 16477 13089  0 14:59 ?        00:00:00 kingbase: autovacuum launcher   
kingbase 16478 13089  0 14:59 ?        00:00:00 kingbase: stats collector   
kingbase 16479 13089  0 14:59 ?        00:00:00 kingbase: ksh writer   
kingbase 16480 13089  0 14:59 ?        00:00:00 kingbase: ksh collector   
kingbase 16481 13089  0 14:59 ?        00:00:00 kingbase: kwr collector   
kingbase 16482 13089  0 14:59 ?        00:00:00 kingbase: logical replication launcher   
kingbase 17100 13089  0 15:04 ?        00:00:00 kingbase: system prod 192.168.8.200(57476) idle
kingbase 17212 12416  0 15:05 pts/0    00:00:00 ./ksql -U system test
kingbase 17214 13089  0 15:05 ?        00:00:00 kingbase: system prod [local] idle

2、操作系统kill pid方式

#查询backend process状态信息
prod=# select * from sys_stat_activity where client_addr='192.168.8.200';
 datid | datname |  pid  | usesysid | usename | application_name |  client_addr  | client_hostname | client_port |         backend_start         | xact_start |          quer
y_start          |         state_change          | wait_event_type | wait_event | state | backend_xid | backend_xmin |          query           |  backend_type  
-------+---------+-------+----------+---------+------------------+---------------+-----------------+-------------+-------------------------------+------------+--------------
-----------------+-------------------------------+-----------------+------------+-------+-------------+--------------+--------------------------+----------------
 16385 | prod    | 18424 |       10 | system  | kingbase_*&+_    | 192.168.8.200 |                 |       57480 | 2022-11-29 15:15:26.813035+08 |            | 2022-11-29 15
:15:28.912910+08 | 2022-11-29 15:15:28.922719+08 | Client          | ClientRead | idle  |             |              | select count(*) from t1; | client backend
(1 row)

#操作系统下执行kill pid结束进程
[root@node2 sys_log]# kill 18424

#如下所示,数据库进程正常,对应的backend pross被安全kill
[root@node2 sys_log]# ps -ef |grep kingbase
kingbase 13089     1  0 14:39 ?        00:00:00 /opt/Kingbase/ES/V8R6_054/KESRealPro/V008R006C005B0054/Server/bin/kingbase -D /db/kingbase/v8r6_054/data
kingbase 13090 13089  0 14:39 ?        00:00:00 kingbase: logger   
kingbase 16474 13089  0 14:59 ?        00:00:00 kingbase: checkpointer   
kingbase 16475 13089  0 14:59 ?        00:00:00 kingbase: background writer   
kingbase 16476 13089  0 14:59 ?        00:00:00 kingbase: walwriter   
kingbase 16477 13089  0 14:59 ?        00:00:00 kingbase: autovacuum launcher   
kingbase 16478 13089  0 14:59 ?        00:00:00 kingbase: stats collector   
kingbase 16479 13089  0 14:59 ?        00:00:00 kingbase: ksh writer   
kingbase 16480 13089  0 14:59 ?        00:00:00 kingbase: ksh collector   
kingbase 16481 13089  0 14:59 ?        00:00:00 kingbase: kwr collector   
kingbase 16482 13089  0 14:59 ?        00:00:00 kingbase: logical replication launcher   
kingbase 17212 12416  0 15:05 pts/0    00:00:00 ./ksql -U system test
kingbase 17214 13089  0 15:05 ?        00:00:00 kingbase: system prod [local] idle

#在数据库视图中已经无此backend process记录
prod=# select * from sys_stat_activity where client_addr='192.168.8.200';
 datid | datname | pid | usesysid | usename | application_name | client_addr | client_hostname | client_port | backend_start | xact_start | query_start | state_change | wait
_event_type | wait_event | state | backend_xid | backend_xmin | query | backend_type 
-------+---------+-----+----------+---------+------------------+-------------+-----------------+-------------+---------------+------------+-------------+--------------+-----
------------+------------+-------+-------------+--------------+-------+--------------
(0 rows)

3、操作系统kill -15 pid和数据库sys_ctl kill TERM PID

1)操作系统kill -15 pid

#查询backend process状态信息
test=# select * from sys_stat_activity where client_addr='192.168.8.200';
 datid | datname |  pid  | usesysid | usename | application_name |  client_addr  | client_hostname | client_port |         backend_start         | xact_start |          quer
y_start          |         state_change          | wait_event_type | wait_event | state | backend_xid | backend_xmin |          query           |  backend_type  
-------+---------+-------+----------+---------+------------------+---------------+-----------------+-------------+-------------------------------+------------+--------------
-----------------+-------------------------------+-----------------+------------+-------+-------------+--------------+--------------------------+----------------
 16385 | prod    | 22955 |       10 | system  | kingbase_*&+_    | 192.168.8.200 |                 |       57498 | 2022-11-29 15:44:29.993305+08 |            | 2022-11-29 15
:44:32.090913+08 | 2022-11-29 15:44:32.100617+08 | Client          | ClientRead | idle  |             |              | select count(*) from t1; | client backend
(1 row)

#操作系统下执行kill -15 pid结束进程
[kingbase@node2 bin]$ kill -15 22955 

[kingbase@node2 bin]$ ps -ef |grep kingbase

#如下所示,数据库进程正常,对应的backend pross被安全kill
kingbase 13089     1  0 14:39 ?        00:00:00 /opt/Kingbase/ES/V8R6_054/KESRealPro/V008R006C005B0054/Server/bin/kingbase -D /db/kingbase/v8r6_054/data
kingbase 22197 13089  0 15:38 ?        00:00:00 kingbase: checkpointer   
kingbase 22198 13089  0 15:38 ?        00:00:00 kingbase: background writer   
kingbase 22199 13089  0 15:38 ?        00:00:00 kingbase: walwriter   
kingbase 22200 13089  0 15:38 ?        00:00:00 kingbase: autovacuum launcher   
kingbase 22201 13089  0 15:38 ?        00:00:00 kingbase: stats collector   
kingbase 22202 13089  0 15:38 ?        00:00:00 kingbase: ksh writer   
kingbase 22203 13089  0 15:38 ?        00:00:00 kingbase: ksh collector   
kingbase 22204 13089  0 15:38 ?        00:00:00 kingbase: kwr collector   
kingbase 22205 13089  0 15:38 ?        00:00:00 kingbase: logical replication launcher   
kingbase 22444 12416  0 15:40 pts/0    00:00:00 ./ksql -U system test
kingbase 22445 13089  0 15:40 ?        00:00:00 kingbase: system test [local] idle

#在数据库视图中已经无此backend process记录
test=# select * from sys_stat_activity where client_addr='192.168.8.200';
 datid | datname | pid | usesysid | usename | application_name | client_addr | client_hostname | client_port | backend_start | xact_start | query_start | state_change | wait
_event_type | wait_event | state | backend_xid | backend_xmin | query | backend_type 
-------+---------+-----+----------+---------+------------------+-------------+-----------------+-------------+---------------+------------+-------------+--------------+-----
------------+------------+-------+-------------+--------------+-------+--------------
(0 rows)

2)数据库sys_ctl kill TERM pid

#查询backend process状态信息
test=# select * from sys_stat_activity where client_addr='192.168.8.200';
 datid | datname |  pid  | usesysid | usename | application_name |  client_addr  | client_hostname | client_port |         backend_start         | xact_start |          quer
y_start          |         state_change          | wait_event_type | wait_event | state | backend_xid | backend_xmin |          query           |  backend_type  
-------+---------+-------+----------+---------+------------------+---------------+-----------------+-------------+-------------------------------+------------+--------------
-----------------+-------------------------------+-----------------+------------+-------+-------------+--------------+--------------------------+----------------
 16385 | prod    | 22443 |       10 | system  | kingbase_*&+_    | 192.168.8.200 |                 |       57494 | 2022-11-29 15:40:42.804868+08 |            | 2022-11-29 15
:40:44.972533+08 | 2022-11-29 15:40:44.985340+08 | Client          | ClientRead | idle  |             |              | select count(*) from t1; | client backend
(1 row)

#执行数据库命令kill进程
[kingbase@node2 bin]$ ./sys_ctl kill  TERM 22443

#如下所示,数据库进程正常,对应的backend pross被安全kill
[kingbase@node2 bin]$ ps -ef |grep kingbase     
kingbase 13089     1  0 14:39 ?        00:00:00 /opt/Kingbase/ES/V8R6_054/KESRealPro/V008R006C005B0054/Server/bin/kingbase -D /db/kingbase/v8r6_054/data
kingbase 22197 13089  0 15:38 ?        00:00:00 kingbase: checkpointer   
kingbase 22198 13089  0 15:38 ?        00:00:00 kingbase: background writer   
kingbase 22199 13089  0 15:38 ?        00:00:00 kingbase: walwriter   
kingbase 22200 13089  0 15:38 ?        00:00:00 kingbase: autovacuum launcher   
kingbase 22201 13089  0 15:38 ?        00:00:00 kingbase: stats collector   
kingbase 22202 13089  0 15:38 ?        00:00:00 kingbase: ksh writer   
kingbase 22203 13089  0 15:38 ?        00:00:00 kingbase: ksh collector   
kingbase 22204 13089  0 15:38 ?        00:00:00 kingbase: kwr collector   
kingbase 22205 13089  0 15:38 ?        00:00:00 kingbase: logical replication launcher   
kingbase 22444 12416  0 15:40 pts/0    00:00:00 ./ksql -U system test
kingbase 22445 13089  0 15:40 ?        00:00:00 kingbase: system test [local] idle

#在数据库视图中已经无此backend process记录
test=# select * from sys_stat_activity where client_addr='192.168.8.200';
 datid | datname | pid | usesysid | usename | application_name | client_addr | client_hostname | client_port | backend_start | xact_start | query_start | state_change | wait
_event_type | wait_event | state | backend_xid | backend_xmin | query | backend_type 
-------+---------+-----+----------+---------+------------------+-------------+-----------------+-------------+---------------+------------+-------------+--------------+-----
------------+------------+-------+-------------+--------------+-------+--------------
(0 rows)

4、操作系统kill -3 pid和数据库sys_ctl kill QUIT PID

1)操作系统kill -3 pid

#查询backend process状态信息
prod=# select * from sys_stat_activity where client_addr='192.168.8.200';
 datid | datname |  pid  | usesysid | usename | application_name |  client_addr  | client_hostname | client_port |         backend_start         | xact_start |          quer
y_start          |         state_change          | wait_event_type | wait_event | state | backend_xid | backend_xmin |                                query                  
              |  backend_type  
-------+---------+-------+----------+---------+------------------+---------------+-----------------+-------------+-------------------------------+------------+--------------
-----------------+-------------------------------+-----------------+------------+-------+-------------+--------------+-------------------------------------------------------
--------------+----------------
 16385 | prod    | 18666 |       10 | system  | kingbase_*&+_    | 192.168.8.200 |                 |       57486 | 2022-11-29 15:17:34.726155+08 |            | 2022-11-29 15
:17:34.736202+08 | 2022-11-29 15:17:34.740584+08 | Client          | ClientRead | idle  |             |              | select setting from pg_settings where name = 'enable_u
pper_colname' | client backend
(1 row)

#操作系统下执行kill -3 pid结束进程
[root@node2 sys_log]# kill -3 18666

#如下所示,除了对应的backend process被终止外,其余的后台辅助进程也被终止并重启
[root@node2 sys_log]# ps -ef |grep kingbase
kingbase 13089     1  0 14:39 ?        00:00:00 /opt/Kingbase/ES/V8R6_054/KESRealPro/V008R006C005B0054/Server/bin/kingbase -D /db/kingbase/v8r6_054/data
kingbase 13090 13089  0 14:39 ?        00:00:00 kingbase: logger   
kingbase 17212 12416  0 15:05 pts/0    00:00:00 ./ksql -U system test
kingbase 18795 13089  0 15:18 ?        00:00:00 kingbase: startup 

#查看对应的sys_log日志(backend process被终止导致数据库的辅助进程也将重启)
prod=# select * from sys_stat_activity where client_addr='192.168.8.200';
WARNING:  terminating connection because of crash of another server process
DETAIL:  The kingbase has commanded this server process to roll back the current transaction and exit, because another server process exited abnormally and possibly corrupted shared memory.
HINT:  In a moment you should be able to reconnect to the database and repeat your command.
server closed the connection unexpectedly
        This probably means the server terminated abnormally
        before or while processing the request.
2022-11-29 15:18:06.741 CST [18666] WARNING:  terminating connection because of crash of another server process
2022-11-29 15:18:06.741 CST [18666] DETAIL:  The kingbase has commanded this server process to roll back the current transaction and exit, because another server process exited abnormally and possibly corrupted shared memory.
2022-11-29 15:18:06.741 CST [18666] HINT:  In a moment you should be able to reconnect to the database and repeat your command.
2022-11-29 15:18:06.742 CST [13089] LOG:  server process (PID 18666) exited with exit code 2
2022-11-29 15:18:06.742 CST [13089] DETAIL:  Failed process was running: select setting from pg_settings where name = 'enable_upper_colname'
2022-11-29 15:18:06.742 CST [13089] LOG:  terminating any other active server processes
2022-11-29 15:18:06.743 CST [17214] WARNING:  terminating connection because of crash of another server process
2022-11-29 15:18:06.743 CST [17214] DETAIL:  The kingbase has commanded this server process to roll back the current transaction and exit, because another server process exited abnormally and possibly corrupted shared memory.
2022-11-29 15:18:06.743 CST [17214] HINT:  In a moment you should be able to reconnect to the database and repeat your command.
2022-11-29 15:18:06.744 CST [16477] WARNING:  terminating connection because of crash of another server process
2022-11-29 15:18:06.744 CST [16477] DETAIL:  The kingbase has commanded this server process to roll back the current transaction and exit, because another server process exited abnormally and possibly corrupted shared memory.
2022-11-29 15:18:06.744 CST [16477] HINT:  In a moment you should be able to reconnect to the database and repeat your command.
2022-11-29 15:18:06.745 CST [13089] LOG:  all server processes terminated; reinitializing
2022-11-29 15:18:06.823 CST [18795] LOG:  database system was interrupted; last known up at 2022-11-29 14:59:17 CST
2022-11-29 15:19:29.897 CST [18795] LOG:  database system was not properly shut down; automatic recovery in progress
2022-11-29 15:19:30.063 CST [18795] LOG:  redo starts at 0/22935D8
2022-11-29 15:19:30.063 CST [18795] LOG:  redo wal segment count 2
2022-11-29 15:19:30.063 CST [18795] LOG:  invalid record length at 0/2293608: wanted 24, got 0
2022-11-29 15:19:30.063 CST [18795] LOG:  redo done at 0/22935D8
2022-11-29 15:19:30.739 CST [13089] LOG:  database system is ready to accept connections

#数据库服务重启后
[root@node2 sys_log]# ps -ef |grep kingbase
kingbase 13089     1  0 14:39 ?        00:00:00 /opt/Kingbase/ES/V8R6_054/KESRealPro/V008R006C005B0054/Server/bin/kingbase -D /db/kingbase/v8r6_054/data
kingbase 13090 13089  0 14:39 ?        00:00:00 kingbase: logger   
kingbase 17212 12416  0 15:05 pts/0    00:00:00 ./ksql -U system test
kingbase 18953 13089  0 15:19 ?        00:00:00 kingbase: checkpointer   
kingbase 18954 13089  0 15:19 ?        00:00:00 kingbase: background writer   
kingbase 18955 13089  0 15:19 ?        00:00:00 kingbase: walwriter   
kingbase 18957 13089  0 15:19 ?        00:00:00 kingbase: stats collector   
kingbase 18958 13089  0 15:19 ?        00:00:00 kingbase: ksh writer   
kingbase 18959 13089  0 15:19 ?        00:00:00 kingbase: ksh collector   
kingbase 18960 13089  0 15:19 ?        00:00:00 kingbase: kwr collector

---如上所示,kill -3 pid用于终止backend process将给数据库带来极大的风险 。

2)数据库sys_ctl kill QUIT PID

#查询backend process状态信息
test=# select * from sys_stat_activity where client_addr='192.168.8.200';
 datid | datname |  pid  | usesysid | usename | application_name |  client_addr  | client_hostname | client_port |         backend_start         | xact_start |          quer
y_start          |         state_change          | wait_event_type | wait_event | state | backend_xid | backend_xmin |          query           |  backend_type  
-------+---------+-------+----------+---------+------------------+---------------+-----------------+-------------+-------------------------------+------------+--------------
-----------------+-------------------------------+-----------------+------------+-------+-------------+--------------+--------------------------+----------------
 16385 | prod    | 21894 |       10 | system  | kingbase_*&+_    | 192.168.8.200 |                 |       57490 | 2022-11-29 15:36:10.034020+08 |            | 2022-11-29 15
:36:13.902728+08 | 2022-11-29 15:36:13.917841+08 | Client          | ClientRead | idle  |             |              | select count(*) from t1; | client backend
(1 row)

#执行数据库命令sys_ctl kill QUIT终止backend process
[kingbase@node2 bin]$ ./sys_ctl kill QUIT  21894

#如下所示,除了对应的backend process被终止外,其余的后台辅助进程也被终止并重启
[kingbase@node2 bin]$ ps -ef |grep kingbase
kingbase 13089     1  0 14:39 ?        00:00:00 /opt/Kingbase/ES/V8R6_054/KESRealPro/V008R006C005B0054/Server/bin/kingbase -D /db/kingbase/v8r6_054/data
kingbase 13090 13089  0 14:39 ?        00:00:00 kingbase: logger   
kingbase 21895 12416  0 15:36 pts/0    00:00:00 ./ksql -U system test
kingbase 22071 13089  0 15:37 ?        00:00:00 kingbase: startup   

#查看对应的sys_log日志(backend process被终止导致数据库的辅助进程也将重启)
test=# select * from sys_stat_activity where client_addr='192.168.8.200';
WARNING:  terminating connection because of crash of another server process
DETAIL:  The kingbase has commanded this server process to roll back the current transaction and exit, because another server process exited abnormally and possibly corrupted shared memory.
HINT:  In a moment you should be able to reconnect to the database and repeat your command.
server closed the connection unexpectedly
        This probably means the server terminated abnormally
        before or while processing the request.

2022-11-29 15:37:13.828 CST [21894] WARNING:  terminating connection because of crash of another server process
2022-11-29 15:37:13.828 CST [21894] DETAIL:  The kingbase has commanded this server process to roll back the current transaction and exit, because another server process exited abnormally and possibly corrupted shared memory.
2022-11-29 15:37:13.828 CST [21894] HINT:  In a moment you should be able to reconnect to the database and repeat your command.
2022-11-29 15:37:13.829 CST [13089] LOG:  server process (PID 21894) exited with exit code 2
2022-11-29 15:37:13.829 CST [13089] DETAIL:  Failed process was running: select count(*) from t1;
2022-11-29 15:37:13.829 CST [13089] LOG:  terminating any other active server processes
2022-11-29 15:37:13.830 CST [21896] WARNING:  terminating connection because of crash of another server process
2022-11-29 15:37:13.830 CST [21896] DETAIL:  The kingbase has commanded this server process to roll back the current transaction and exit, because another server process exited abnormally and possibly corrupted shared memory.
2022-11-29 15:37:13.830 CST [21896] HINT:  In a moment you should be able to reconnect to the database and repeat your command.
2022-11-29 15:37:13.831 CST [18956] WARNING:  terminating connection because of crash of another server process
2022-11-29 15:37:13.831 CST [18956] DETAIL:  The kingbase has commanded this server process to roll back the current transaction and exit, because another server process exited abnormally and possibly corrupted shared memory.
2022-11-29 15:37:13.831 CST [18956] HINT:  In a moment you should be able to reconnect to the database and repeat your command.
2022-11-29 15:37:13.833 CST [13089] LOG:  all server processes terminated; reinitializing
2022-11-29 15:37:13.933 CST [22071] LOG:  database system was interrupted; last known up at 2022-11-29 15:19:30 CST
2022-11-29 15:38:29.154 CST [22071] LOG:  database system was not properly shut down; automatic recovery in progress
2022-11-29 15:38:29.232 CST [22071] LOG:  redo starts at 0/2293680
2022-11-29 15:38:29.232 CST [22071] LOG:  redo wal segment count 2
2022-11-29 15:38:29.232 CST [22071] LOG:  invalid record length at 0/22936B0: wanted 24, got 0
2022-11-29 15:38:29.232 CST [22071] LOG:  redo done at 0/2293680
2022-11-29 15:38:29.767 CST [13089] LOG:  database system is ready to accept connection

---如上所示,sys_ctl kill QUIT pid用于终止backend process将给数据库带来极大的风险 。

5、操作系统kill -9 pid

#查询backend process状态信息
prod=# select * from sys_stat_activity where client_addr='192.168.8.200';
 datid | datname |  pid  | usesysid | usename | application_name  |  client_addr  | client_hostname | client_port |         backend_start         |          xact_start      
     |          query_start          |         state_change          | wait_event_type |     wait_event      | state  | backend_xid | backend_xmin |              query      
         |         backend_type         
-------+---------+-------+----------+---------+-------------------+---------------+-----------------+-------------+-------------------------------+--------------------------
-----+-------------------------------+-------------------------------+-----------------+---------------------+--------+-------------+--------------+-------------------------
---------+------------------------------

 16385 | prod    | 14114 |       10 | system  | kingbase_*&+_     | 192.168.8.200 |                 |       57472 | 2022-11-29 14:48:06.372451+08 |                          
     | 2022-11-29 14:50:16.618969+08 | 2022-11-29 14:50:16.627572+08 | Client          | ClientRead          | idle   |             |              | select count(*) from t1;
         | client backend
       
(1 rows)

#操作系统下执行kill -9 pid结束进程
[root@node2 ~]# kill -9  14114 

#如下所示,除了对应的backend process被终止外,其余的后台辅助进程也被终止并重启
[root@node2 ~]# ps -ef |grep kingbase
.......

kingbase 13089     1  0 14:39 ?        00:00:00 /opt/Kingbase/ES/V8R6_054/KESRealPro/V008R006C005B0054/Server/bin/kingbase -D /db/kingbase/v8r6_054/data
kingbase 13090 13089  0 14:39 ?        00:00:00 kingbase: logger   
kingbase 14010 12416  0 14:47 pts/0    00:00:00 ./ksql -U system test
kingbase 15651 13089  0 14:57 ?        00:00:00 kingbase: startup   

#查看对应的sys_log日志(backend process被终止导致数据库的辅助进程也将重启)
2022-11-29 14:58:00.093 CST [13089] LOG:  server process (PID 14114) was terminated by signal 9: Killed
2022-11-29 14:58:00.093 CST [13089] DETAIL:  Failed process was running: select count(*) from t1;
2022-11-29 14:58:00.093 CST [13089] LOG:  terminating any other active server processes
2022-11-29 14:58:00.093 CST [14602] WARNING:  terminating connection because of crash of another server process
2022-11-29 14:58:00.093 CST [14602] DETAIL:  The kingbase has commanded this server process to roll back the current transaction and exit, because another server process exited abnormally and possibly corrupted shared memory.
2022-11-29 14:58:00.093 CST [14602] HINT:  In a moment you should be able to reconnect to the database and repeat your command.
2022-11-29 14:58:00.095 CST [13095] WARNING:  terminating connection because of crash of another server process
2022-11-29 14:58:00.095 CST [13095] DETAIL:  The kingbase has commanded this server process to roll back the current transaction and exit, because another server process exited abnormally and possibly corrupted shared memory.
2022-11-29 14:58:00.095 CST [13095] HINT:  In a moment you should be able to reconnect to the database and repeat your command.
2022-11-29 14:58:00.384 CST [13089] LOG:  all server processes terminated; reinitializing
2022-11-29 14:58:00.464 CST [15651] LOG:  database system was interrupted; last known up at 2022-11-29 14:53:42 CST
2022-11-29 14:59:16.706 CST [15651] LOG:  database system was not properly shut down; automatic recovery in progress
2022-11-29 14:59:16.806 CST [15651] LOG:  redo starts at 0/2293488
2022-11-29 14:59:16.806 CST [15651] LOG:  redo wal segment count 2
2022-11-29 14:59:16.806 CST [15651] LOG:  invalid record length at 0/2293560: wanted 24, got 0
2022-11-29 14:59:16.806 CST [15651] LOG:  redo done at 0/2293530
2022-11-29 14:59:17.563 CST [13089] LOG:  database system is ready to accept connections

---如上所示,kill -9 pid用于终止backend process将给数据库带来极大的风险 。

三、总结

对于KingbaseES数据库中异常的backend proces可以采用手工方式终止,执行时选择的方式要注意对数据库带来的风险:

1)相对安全方式:pg_terminate_backend(pid);kill pid;kill -15 pid;sys_ctl kill  TERM pid。
2)不安全方式: kill -3 pid;sys_ctl kill  QUIT pid;kill -9 pid。

注意:千万不要kill -9,SIGKILL没有信号处理函数,OS会直接停掉进程;Kingbase父进程发现子进程异常退出,会停掉所有进程,释放共享内存,
再重新申请共享内存,拉起所有进程。效果就等于异常重启,启动时肯定会需要时间redo,可能造成几分钟的停止服务。(除非后果可以接受,否则不要kill -9)。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/106285.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

Java Swing JTextField:单行文本框组件

Swing 中使用 JTextField 类实现一个单行文本框,它允许用户输入单行的文本信息。该类的常用构造方法如下。 JTextField():创建一个默认的文本框。JTextField(String text):创建一个指定初始化文本信息的文本框。JTextField(int columns)&…

Nacos学习笔记 (4)Nacos整合SpringBoot流程

前提,先下载Nacos并启动 Nacos Server。 1. Nacos 融合 Spring Boot 为注册配置中心 实现: 通过 Nacos Server 和 nacos-config-spring-boot-starter 实现配置的动态变更;通过 Nacos Server 和 nacos-discovery-spring-boot-starter 实现服…

OpenAI 3D 模型生成器Point-E极速体验

OpenAI 3D 模型生成器Point-E极速体验 3090显卡,极速体验三维模型生成,体验地址:Gradio 文本生成图像的 AI 最近已经火到了圈外,不论是 DALL-E 2、DeepAI 还是 Stable Diffusion,人人都在调用 AI 算法搞绘画艺术&…

Unreal Engine工程项目目录及对应作用

目录 .vs Binaries:编译文件 Config:配置文件 Content:资产文件 DerivedDataCache:UE针对平台特化的资源版本 Intermediate:中间文件 Saved:自动保存的内容 Source:源(代码&…

ADI Blackfin DSP处理器-BF533的开发详解66:MP3解码(含源码)

硬件准备 ADSP-EDU-BF533:BF533开发板 AD-HP530ICE:ADI DSP仿真器 软件准备 Visual DSP软件 硬件链接 代码实现功能 代码实现了读取工程目录下的一个 MP3 文件,对文件进行解码后,将生成的数据以 PCM 文件的形式保存在工程目录…

关于数组的一些题---获取数组对象的各种数据

关于数组的一些题—获取数组对象的各种数据 题目1:将数组对象中的属性值提出来生成新的对象 var arr [{label:男,value: 1}, {label:女,value: 0}]function f(arr) {// 写代码,得到 } var obj f(arr); console.log(obj) // obj {1: 男&am…

1 | Trerraform的使用及创建CVM

目录1 Trerraform简介2 Trerraform的安装2.1 参考地址2.2 安装方式3 使用Terraform管理腾讯云3.1 创建帐号并授权3.2 添加Terraform的环境变量3.3 配置provider文件3.4 terraform init3.5 terraform init -upgrade3.6 terraform plan3.7 terraform apply3.8 terraform destroy4…

5分钟让你做出HR一眼看中的简历,方法简单易操作

写简历,真的是个“力气活”。 但凡求职经验丰富的朋友们,可以仔细想一想,之前我们面试求职的过程中,哪次不是通宵达旦在修改和“润色”简历中,在写简历里费劲功夫,目的还是为了引起HR的关注,从…

DASOU知识星球学的知识图谱

1.经典课程 1.经典课程 东南大学研究生课程: 东南大学研究生课程: https://github.com/npubird/KnowledgeGraphCourse 书籍推荐: 知识图谱的书籍的话可以看下作者是王昊奋【知识图谱:方法、实践与应用】那本书,算是近些年出版的里面质量不错的了&…

解决问题:VMware Tools 启动脚本未能在虚拟机中成功运行。

目录 问题 解决 方法一、重装 open-vm-tools-desktop 方法二、重装 vmware-tools 问题 Ubuntu 虚拟机开机时提示报错,具体信息如下: VMware Tools 启动脚本未能在虚拟机中成功运行。如果您在此虚拟机中配置了自定义启动脚本,请确保该脚本…

USB TO SPI(上海同旺电子)调试器调试TC77温度传感器(三线SPI)

所需设备: 1、USB TO SPI(上海同旺电子); 2、TC77 带 SPI 接口的温度传感器; 特别注意TC77温度传感器(三线制SPI) 特性 • 5引脚 SOT-23A 和8引脚SOIC 封装的数字温度传感器 • 以13 位数字字格式输出温度值 • SPI 和 MICROWIRE™ 兼容接口 • 固态…

IB科学课程的Group 4 project是什么?

。IBDP第4科学科目组中的科学类课程是必选课程。中国IB学生常选物理、化学、生物、计算机科学这类IB科学课程。这些IBDP科学课程都有一个共同的课程项目,那就是——The group 4 project! 什么是The group 4 project? The group 4 project是一…

图表控件TeeChart for .NET系列教程四:轴控制(中)

TeeChart for .NET是优秀的工业4.0 WinForm图表控件,官方独家授权汉化,集功能全面、性能稳定、价格实惠等优势于一体。TeeChart for .NET 中文版还可让您在使用和学习上没有任何语言障碍,至少可以节省30%的开发时间。 TeeChart for .NET最新…

【Python黑帽子】——简易的ZIP文件密码破解器

作者名:Demo不是emo 主页面链接:主页传送门 创作初心:舞台再大,你不上台,永远是观众,没人会关心你努不努力,摔的痛不痛,他们只会看你最后站在什么位置,然后羡慕或鄙夷座…

[翻译+笔记]生成对抗网络: 从GAN到WGAN

最近读了一篇社会力模型的论文, 里面用到了GAN, 发现自己不是很懂. 想翻译一下一个大神的博客, 做一下笔记. 并不是全文翻译, 只翻译一部分. 原文地址: from GAN to WGAN 1. K-L和J-S散度 在介绍GAN之前, 首先复习一下衡量两个概率分布相似度的两种指标. (1) K-L散度: KL散度…

java Lambda表达式 省略模式写法

我们先来看一个普通的Lambda表达式 我们创建一个包 下面创建一个接口 testInterface 参考代码如下 public interface testInterface {int eat(int max,int min); }text 测试类 参考代码如下 public class text {public static void main(String args[]) {newTestInterface(…

夺冠热度空前,梅西Instagram粉丝破4亿,跨境卖家如何借这股东风?

阿根廷队世界杯夺冠,35岁的梅西终于实现了职业生涯大满贯,全世界球迷都在为梅西欢呼。梅西夺冠的热度席卷全球,当前其Instagram账号的粉丝就突破了4亿,成为世界上第二个Instagram粉丝超4亿的人。 梅西夺冠当日在Instagram上的发帖…

易观千帆 | 2022年11月银行APP月活跃用户规模盘点

易观分析:11月手机银行服务应用活跃人数52639.05万,环比增长0.68%;排在前三的手机银行APP仍然为中国工商银行、中国农业银行、中国建设银行。 11月城商行手机银行服务应用活跃人数3730.98万,环比增长4.64%,从月活表现来…

Spring Boot 实现 SSE 服务端推送事件

源码地址 关于 SSE SSE 全程 Server Send Event,是 HTTP 协议中的一种,Content-Type 为 text/event-stream,是服务端主动向前端推送数据。类似于 WebSocket。 SSE 优势我们可以划分为两个: 长链接服务端能主动向客户端推送数据…

想要精通算法和SQL的成长之路 - 编辑距离

想要精通算法和SQL的成长之路 - 编辑距离前言一. 编辑距离1.1 定义动态规划数组1.2 定义动态规划方程1.3 定义数组的初始化1.4 最终答案前言 想要精通算法和SQL的成长之路 - 系列导航 一. 编辑距离 原题链接 给你两个单词 word1 和 word2, 请返回将 word1 转换成 …