【标题】
解决分布式锁超时时间与lockwait_timeout参数设置不符的问题

【实现内容】:
解决分布式锁超时时间与lockwait_timeout参数设置不符的问题

【根因分析】:
分布式锁加锁时未与lockwait_timeout参数比较,因此超时时间不受lockwait_timeout参数控制

【实现方案】:
加锁时等待时间与lockwait_timeout比较,超过该时间认定为加锁超时

【关联需求或issue】:
#I642AE:【测试类型:SQL功能】【测试版本:3.1.1】 【资源池化】锁等待超时,主节点获取X锁,备节点获取S锁,锁冲突,等待锁超时时间备节点处于等待状态

【开发自验报告】:

  1. 请附上自验结果(内容或者截图)
    a.备机加锁超时场景
    step1:主机端
[chendong@openGauss37 Thu Dec 01 20:28 dev]$ gsql -d postgres -p 12580 -r
gsql ((openGauss 3.1.0 build b8672a02) compiled at 2022-12-01 20:12:25 commit 0 last mr  debug)
Non-SSL connection (SSL connection is recommended when requiring high-security)
Type "help" for help.

openGauss=# show lockwait_timeout;
 lockwait_timeout
------------------
 5s
(1 row)

openGauss=# begin;
BEGIN
openGauss=# truncate student;
TRUNCATE TABLE

step2:备机端

[chendong@openGauss37 Thu Dec 01 20:29 ~]$ gsql -d postgres -p 13580 -r
gsql ((openGauss 3.1.0 build b8672a02) compiled at 2022-12-01 20:12:25 commit 0 last mr  debug)
Non-SSL connection (SSL connection is recommended when requiring high-security)
Type "help" for help.

openGauss=# show lockwait_timeout;
 lockwait_timeout
------------------
 5s
(1 row)

openGauss=# begin;
BEGIN
openGauss=# select * from student;
ERROR:  SSLock wait timeout after 10109 ms
LINE 1: select * from student;
                      ^
openGauss=# commit;
ROLLBACK

b.主机加锁超时场景
step1:备机端

[chendong@openGauss37 Thu Dec 01 20:31 ~]$ gsql -d postgres -p 13580 -r
gsql ((openGauss 3.1.0 build b8672a02) compiled at 2022-12-01 20:12:25 commit 0 last mr  debug)
Non-SSL connection (SSL connection is recommended when requiring high-security)
Type "help" for help.

openGauss=# show lockwait_timeout;
 lockwait_timeout
------------------
 5s
(1 row)

openGauss=# begin;
BEGIN
openGauss=# select * from student;
 id | name
----+------
  1 | aaa
  1 | aaa
  1 | aaa
  1 | aaa
  1 | aaa
  1 | aaa
  1 | aaa
  1 | aaa
  1 | aaa
(9 rows)

step2:主机端

[chendong@openGauss37 Thu Dec 01 20:32 dev]$ gsql -d postgres -p 12580 -r
gsql ((openGauss 3.1.0 build b8672a02) compiled at 2022-12-01 20:12:25 commit 0 last mr  debug)
Non-SSL connection (SSL connection is recommended when requiring high-security)
Type "help" for help.

openGauss=# show lockwait_timeout;
 lockwait_timeout
------------------
 5s
(1 row)

openGauss=# begin;
BEGIN
openGauss=# truncate student;
ERROR:  SSLock wait timeout after 5003 ms
  1. 是否可以添加fastcheck测试用例,如是,请补充fastcheck用例
  2. 是否涉及资料修改,如是,在docs仓库补充资料
    是,https://gitee.com/opengauss/docs/pulls/3981
  3. 是否考虑支撑升级和在线扩容等扩展场景
    不涉及
  4. 是否考虑异常场景/并发场景/前向兼容/性能场景
  5. 是否对其他模块产生影响

【其他说明】:无