Mariadb Galera 集群 |表更新问题

问题描述

我们在系统中创建了一个 3 节点的 galera 集群,然后从现有的单节点独立 mariadb 移动了我们现有的数据库/表。然后,当我们在这个 3 节点集群上启动我们的应用程序时,它可以正常运行少量记录的更新,但之后我们的更新被无限期地触发(锁定),然后我们无法对表进行任何写入或更新。我们不断面对这个问题,我们多次尝试再次重建我们的集群,但同样的问题一次又一次地发生。请帮助为这个问题提供一些指导。 在这种特殊情况下,我(应用程序)只是一个一个地对记录运行更新命令。它一次更新的记录总数约为 250 条(一个一个)。表中的总记录为 40 万条。这个特定的表没有任何主键。在这个java应用程序中使用的更新查询示例 -

"update dost_master_prod set  a2d_api_request = ?,a2d_api_response = ?,a2d_api_status = ?,a2d_api_description = ?,d2r_api_request = ?,d2r_api_response = ?,d2r_api_status = ?,d2r_api_description = ?,updated_date_time = ?,update_description = ? 
where initiator_agent = ? and report_date = ?;"

以这种方式通过应用程序连接到集群 - jdbc:mariadb:sequential。

错误日志 -

SHOW ENGINE INNODB STATUS
------------
TRANSACTIONS
------------
Trx id counter 11316748
Purge done for trx's n:o < 11316747 undo n:o < 0 state: running
History list length 29
LIST OF TRANSACTIONS FOR EACH SESSION:
---TRANSACTION 421357846471208,not started
0 lock struct(s),heap size 1128,0 row lock(s)
---TRANSACTION 421357846466944,0 row lock(s)
---TRANSACTION 11316747,ACTIVE 1785 sec
MysqL tables in use 1,locked 1
51495 lock struct(s),heap size 5726328,3641448 row lock(s),undo log entries 1
MysqL thread id 9627,OS thread handle 139882031507200,query id 5693745 injiffyan01.india.airtel.itm 10.92.228.55 root Commit
update dost_master_prod set  a2d_api_request = '{
  \"amount\" : \"3823.75\",\"currency\" : \"XXX\",\"subType\" : \"commission_otf\",\"type\" : \"adjustment\",\"requestDate\" : \"2021-05-13T11:15:44.011+05:30\",\"debitParty\" : [ {
    \"key\" : \"accountid\",\"value\" : \"994\"
  } ],\"creditParty\" : [ {
    \"key\" : \"accountid\",\"value\" : \"09944890425\"
  } ],\"Metadata\" : [ {
    \"key\" : \"slab_next\",\"value\" : \"Slab for next OTF payout is 61-80 GA\"
  },{
    \"key\" : \"slab_achieved\",\"value\" : \"41-60 GA\"
  },{
    \"key\" : \"de
---TRANSACTION 421357846475472,0 row lock(s)
---TRANSACTION 421357846462680,0 row lock(s)
--------

enter image description here

问题 1) 这个问题是否是因为我们的表中没有主键? 问题 2)galera 集群的限制是什么?将 10 多个高影响应用程序从单节点 mariadb 移动到 3 节点 galera 集群是否可行?如果是,需要采取哪些预防措施? 问题 3)为什么整个集群会因为一张表(在一个数据库上)问题而被击中/挂起/锁定? 问题 4) 我们应该使用顺序、复制或负载平衡哪种模式?

解决方法

添加一个 PRIMARY KEY,即使它只是一个简单的 AUTO_INCREMENT

添加INDEX(initiator_agent,report_date)

然后让我们看看还有什么需要修复。