2014-04-14 113 views
1

我有一個3 percona xtradb 5.5.34-55服務器的集羣,因爲它們都是可寫的,所以在任何實質負載下我都會遇到死鎖錯誤。在一定程度上增加了wsrep_retry_autocommit變量,但ER_LOCK_DEADLOCK沒有完全消失。所以,我試過設置wsrep_retry_autocommit 10000(似乎是最大的),認爲它將使一些查詢很慢,但沒有人會失敗,ER_LOCK_DEADLOCK即使設置wsrep_retry_autocommit真的很高,我仍然會死鎖嗎?

mysql-shm -ss -e 'show global variables like "%wsrep_retry_auto%"' 
wsrep_retry_autocommit 10000 

------------------------ 
LATEST DETECTED DEADLOCK 
------------------------ 
140414 10:29:23 
*** (1) TRANSACTION: 
TRANSACTION 72D8, ACTIVE 0 sec inserting 
mysql tables in use 1, locked 1 
LOCK WAIT 2 lock struct(s), heap size 376, 1 row lock(s), undo log entries 1 
MySQL thread id 34, OS thread handle 0x7f11840d4700, query id 982 localhost shm update 
REPLACE INTO metric(host, name, userid, sampleid, type, priority) VALUES 
('localhost','cpu-3/cpu-nice',8,0,0,0),('localhost','cpu-3/cpu-system',8,0,0,0), 
('localhost','cpu-3/cpu-idle',8,0,0,0),('localhost','cpu-3/cpu-wait',8,0,0,0), 
('localhost','cpu-3/cpu-interrupt',8,0,0,0),('localhost','cpu-3/cpu-softirq',8,0,0,0), 
('localhost','cpu-3/cpu-steal',8,0,0,0),('localhost','cpu-4/cpu-user',8,0,0,0), 
('localhost','cpu-4/cpu-nice',8,0,0,0),('localhost','cpu-4/cpu-system',8,0,0,0), 
('localhost','cpu-4/cpu-idle',8,0,0,0),('localhost','cpu-4/cpu-wait',8,0,0,0), 
('localhost','cpu-4/cpu-interrupt',8,0,0,0),('localhost','cpu-4/cpu-softirq',8,0,0,0), 
('localhost','cpu-4/cpu-steal',8,0,0,0) 
*** (1) WAITING FOR THIS LOCK TO BE GRANTED: 
RECORD LOCKS space id 0 page no 344 n bits 488 index `unique-metric` of 
table `shm`.`metric` trx id 72D8 lock_mode X waiting 
*** (2) TRANSACTION: 
TRANSACTION 72D7, ACTIVE 0 sec updating or deleting 
mysql tables in use 1, locked 1 
7 lock struct(s), heap size 3112, 141 row lock(s), undo log entries 40 
MySQL thread id 50, OS thread handle 0x7f1184115700, query id 980 localhost shm update 
REPLACE INTO metric(host, name, userid, sampleid, type, priority) VALUES 
('localhost','cpu-3/cpu-nice',8,0,0,0),('localhost','cpu-3/cpu-system',8,0,0,0), 
('localhost','cpu-3/cpu-idle',8,0,0,0),('localhost','cpu-3/cpu-wait',8,0,0,0), 
('localhost','cpu-3/cpu-interrupt',8,0,0,0),('localhost','cpu-3/cpu-softirq',8,0,0,0), 
('localhost','cpu-3/cpu-steal',8,0,0,0),('localhost','cpu-4/cpu-user',8,0,0,0), 
('localhost','cpu-4/cpu-nice',8,0,0,0),('localhost','cpu-4/cpu-system',8,0,0,0), 
('localhost','cpu-4/cpu-idle',8,0,0,0),('localhost','cpu-4/cpu-wait',8,0,0,0), 
('localhost','cpu-4/cpu-interrupt',8,0,0,0),('localhost','cpu-4/cpu-softirq',8,0,0,0), 
('localhost','cpu-4/cpu-steal',8,0,0,0),('localhost','cpu-3/cpu-nice',8,0,0,0), 
('localhost','cpu-3/cpu-system',8,0,0,0),('localhost','cpu-3/cpu-idle',8,0,0,0), 
('localhost','cpu-3/cpu-wait',8,0,0,0),('localhost','cpu-3/cpu-interrupt',8,0,0,0), 
('localhost','cpu-3/cpu-softirq',8,0,0,0),('localhost' 
*** (2) HOLDS THE LOCK(S): 
RECORD LOCKS space id 0 page no 344 n bits 488 index `unique-metric` of table 
`shm`.`metric` trx id 72D7 lock_mode X 
*** (2) WAITING FOR THIS LOCK TO BE GRANTED: 
RECORD LOCKS space id 0 page no 344 n bits 504 index `unique-metric` of table 
`shm`.`metric` trx id 72D7 lock_mode X locks gap before rec insert intention waiting 
*** WE ROLL BACK TRANSACTION (1) 

它不應該代替重試?有沒有一種方法來驗證percona實際重試查詢10000次?

回答

1

對於你的問題沒有確切的答案,但是對於任何寫入密集型負載(如果你試圖插入與該Drupal相同的數據),那麼會發生死鎖,並且對我來說唯一的解決方案(仍在等待以確認這是100%正確的解決方案) - 在galera節點前使用haproxy,並定義要使用的第一個節點(haproxy後端定義),並將其他2個節點用作備份。

這樣所有的mysql流量都將從客戶端流經haproxy到單個galera節點,如果該節點失敗,則會使用其他節點。

希望有幫助... Andrija

相關問題