sonarqube 5.2 MySQLTransactionRollbackException:尝试获取锁定时发现死锁

时间:2015-12-18 17:59:38

标签: sonarqube

使用SonarQube 5.2我发现以下死锁问题:


    05:48:22 ERROR: Error during Sonar runner execution
    05:48:22 java.lang.IllegalStateException: Fail to execute request 
    [code=500, url=http://192.168.109.6/api/ce/submit?projectKey=CoprHD&projectName=CoprHD-controller&projectBranch=bugfix-COP-19001-hotfix]:
     {"errors":[{"msg":"\n### Error updating database.  
    Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLTransactionRollbackException: 
    Deadlock found when trying to get lock; try restarting transaction\n
    ### The error may involve org.sonar.db.user.RoleMapper.insertGroupRole-Inline\n### The error occurred while setting parameters\n
    ### SQL: INSERT INTO group_roles (group_id, resource_id, role)     VALUES (?, ?, ?)\n
    ### Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLTransactionRollbackException: Deadlock found when trying to get lock; try restarting transaction"}]}
    05:48:22    at org.sonar.batch.report.ReportPublisher.uploadMultiPartReport(ReportPublisher.java:182)
    05:48:22    at org.sonar.batch.report.ReportPublisher.sendOrDumpReport(ReportPublisher.java:151)
    05:48:22    at org.sonar.batch.report.ReportPublisher.execute(ReportPublisher.java:115)
    05:48:22    at org.sonar.batch.phases.PhaseExecutor.publishReportJob(PhaseExecutor.java:116)
    05:48:22    at org.sonar.batch.phases.PhaseExecutor.execute(PhaseExecutor.java:106)
    05:48:22    at org.sonar.batch.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:192)
    05:48:22    at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:100)
    05:48:22    at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:85)
    05:48:22    at org.sonar.batch.scan.ProjectScanContainer.scan(ProjectScanContainer.java:258)
    05:48:22    at org.sonar.batch.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:253)
    05:48:22    at org.sonar.batch.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:243)
    05:48:22    at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:100)
    05:48:22    at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:85)
    05:48:22    at org.sonar.batch.bootstrap.GlobalContainer.executeAnalysis(GlobalContainer.java:153)
    05:48:22    at org.sonar.batch.bootstrapper.Batch.executeTask(Batch.java:110)
    05:48:22    at org.sonar.runner.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:55)
    05:48:22    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    05:48:22    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    05:48:22    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    05:48:22    at java.lang.reflect.Method.invoke(Method.java:606)
    05:48:22    at org.sonar.runner.impl.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:61)
    05:48:22    at com.sun.proxy.$Proxy0.execute(Unknown Source)
    05:48:22    at org.sonar.runner.api.EmbeddedRunner.doExecute(EmbeddedRunner.java:275)
    05:48:22    at org.sonar.runner.api.EmbeddedRunner.runAnalysis(EmbeddedRunner.java:166)
    05:48:22    at org.sonar.runner.api.EmbeddedRunner.runAnalysis(EmbeddedRunner.java:153)
    05:48:22    at org.sonar.runner.cli.Main.runAnalysis(Main.java:118)
    05:48:22    at org.sonar.runner.cli.Main.execute(Main.java:80)
    05:48:22    at org.sonar.runner.cli.Main.main(Main.java:66)

搜索类似的报告时,我发现此参考文献说明问题已得到解决:https://jira.sonarsource.com/browse/SONAR-1945

我还发现了一个引用,即事务隔离应该从REPEATABLE-READ更改为READ-COMMITTED。这对于Sonar的mysql来说是否合理?


    mysql> show variables like '%wait_timeout%';
    +--------------------------+----------+
    | Variable_name            | Value    |
    +--------------------------+----------+
    | innodb_lock_wait_timeout | 500      |
    | lock_wait_timeout        | 31536000 |
    | wait_timeout             | 28800    |
    +--------------------------+----------+
    3 rows in set (0.25 sec)

    mysql> show variables like '%tx_isolation%';
    +---------------+-----------------+
    | Variable_name | Value           |
    +---------------+-----------------+
    | tx_isolation  | REPEATABLE-READ |
    +---------------+-----------------+
    1 row in set (0.00 sec)

    mysql> SELECT @@GLOBAL.tx_isolation, @@tx_isolation;
    +-----------------------+-----------------+
    | @@GLOBAL.tx_isolation | @@tx_isolation  |
    +-----------------------+-----------------+
    | REPEATABLE-READ       | REPEATABLE-READ |
    +-----------------------+-----------------+

有关死锁问题的更多信息,这里有一些数据。

有没有人知道这个问题是否应该在mysql中进行调整,或者这是一个需要在SonarQube应用程序中修复的问题?


    mysql> show engine innodb status

    =====================================
    2015-12-18 07:42:25 7f61f03cd700 INNODB MONITOR OUTPUT
    =====================================
    Per second averages calculated from the last 31 seconds
    -----------------
    BACKGROUND THREAD
    -----------------
    srv_master_thread loops: 44635 srv_active, 0 srv_shutdown, 1284536 srv_idle
    srv_master_thread log flush and writes: 1329157
    ----------
    SEMAPHORES
    ----------
    OS WAIT ARRAY INFO: reservation count 224853
    OS WAIT ARRAY INFO: signal count 1727534
    Mutex spin waits 1578113, rounds 7231747, OS waits 74673
    RW-shared spins 483413, rounds 5257332, OS waits 110301
    RW-excl spins 197945, rounds 3737144, OS waits 35005
    Spin rounds per wait: 4.58 mutex, 10.88 RW-shared, 18.88 RW-excl


    ------------------------
    LATEST DETECTED DEADLOCK
    ------------------------
    2015-12-17 05:46:47 7f61f0594700
    *** (1) TRANSACTION:
    TRANSACTION 17641507, ACTIVE 0 sec inserting
    mysql tables in use 1, locked 1
    LOCK WAIT 8 lock struct(s), heap size 1184, 7 row lock(s), undo log entries 9
    MySQL thread id 5021, OS thread handle 0x7f61f071a700, query id 33269201 localhost 127.0.0.1 sonar update
    INSERT INTO group_roles (group_id, resource_id, role)
        VALUES (null, 1515106, 'codeviewer')
    *** (1) WAITING FOR THIS LOCK TO BE GRANTED:
    RECORD LOCKS space id 310 page no 6 n bits 472 index `group_roles_resource` of table `sonar`.`group_roles` trx id 17641507 lock_mode X insert intention waiting
    Record lock, heap no 1 PHYSICAL RECORD: n_fields 1; compact format; info bits 0
     0: len 8; hex 73757072656d756d; asc supremum;;

    *** (2) TRANSACTION:
    TRANSACTION 17641509, ACTIVE 0 sec inserting
    mysql tables in use 1, locked 1
    7 lock struct(s), heap size 1184, 4 row lock(s), undo log entries 3
    MySQL thread id 5005, OS thread handle 0x7f61f0594700, query id 33269204 localhost 127.0.0.1 sonar update
    INSERT INTO group_roles (group_id, resource_id, role)
        VALUES (1, 1515107, 'admin')
    *** (2) HOLDS THE LOCK(S):
    RECORD LOCKS space id 310 page no 6 n bits 472 index `group_roles_resource` of table `sonar`.`group_roles` trx id 17641509 lock_mode X
    Record lock, heap no 1 PHYSICAL RECORD: n_fields 1; compact format; info bits 0
     0: len 8; hex 73757072656d756d; asc supremum;;

    *** (2) WAITING FOR THIS LOCK TO BE GRANTED:
    RECORD LOCKS space id 310 page no 6 n bits 472 index `group_roles_resource` of table `sonar`.`group_roles` trx id 17641509 lock_mode X insert intention waiting
    Record lock, heap no 1 PHYSICAL RECORD: n_fields 1; compact format; info bits 0
     0: len 8; hex 73757072656d756d; asc supremum;;

    *** WE ROLL BACK TRANSACTION (2)


    ------------
    TRANSACTIONS
    ------------
    Trx id counter 18864174
    Purge done for trx's n:o 

<pre>
LIST OF TRANSACTIONS FOR EACH SESSION:
---TRANSACTION 0, not started
MySQL thread id 7482, OS thread handle 0x7f61f03cd700, query id 38116433 localhost sonar init
show engine innodb status
---TRANSACTION 18864038, not started
MySQL thread id 7478, OS thread handle 0x7f61f3349700, query id 38115903 localhost 127.0.0.1 sonar cleaning up
---TRANSACTION 18864173, not started
MySQL thread id 7475, OS thread handle 0x7f61f040e700, query id 38116432 localhost 127.0.0.1 sonar cleaning up
--------
FILE I/O
--------
I/O thread 0 state: waiting for completed aio requests (insert buffer thread)
I/O thread 1 state: waiting for completed aio requests (log thread)
I/O thread 2 state: waiting for completed aio requests (read thread)
I/O thread 3 state: waiting for completed aio requests (read thread)
I/O thread 4 state: waiting for completed aio requests (read thread)
I/O thread 5 state: waiting for completed aio requests (read thread)
I/O thread 6 state: waiting for completed aio requests (write thread)
I/O thread 7 state: waiting for completed aio requests (write thread)
I/O thread 8 state: waiting for completed aio requests (write thread)
I/O thread 9 state: waiting for completed aio requests (write thread)
Pending normal aio reads: 0 [0, 0, 0, 0] , aio writes: 0 [0, 0, 0, 0] ,
 ibuf aio reads: 0, log i/o's: 0, sync i/o's: 0
Pending flushes (fsync) log: 0; buffer pool: 0
7146308 OS file reads, 6478063 OS file writes, 1783568 OS fsyncs
0.00 reads/s, 0 avg bytes/read, 0.00 writes/s, 0.00 fsyncs/s
-------------------------------------
 INSERT BUFFER AND ADAPTIVE HASH INDEX
-------------------------------------
    Ibuf: size 1, free list len 3077, seg size 3079, 22965 merges
    merged operations:
     insert 45672, delete mark 7198683, delete 214896
    discarded operations:
     insert 0, delete mark 0, delete 0
    Hash table size 6374777, node heap has 11107 buffer(s)
    0.00 hash searches/s, 0.00 non-hash searches/s
---
LOG
---
Log sequence number 219765124434
Log flushed up to   219765124434
Pages flushed up to 219765124434
Last checkpoint at  219765124434
0 pending log writes, 0 pending chkp writes
1189792 log i/o's done, 0.00 log i/o's/second
----------------------
BUFFER POOL AND MEMORY
----------------------
Total memory allocated 3296722944; in additional pool allocated 0
Dictionary memory allocated 359878
Buffer pool size   196600
Free buffers       8192
Database pages     177301
Old database pages 65285
Modified db pages  0
Pending reads 0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 1567756, not young 296705943
0.00 youngs/s, 0.00 non-youngs/s
Pages read 7146255, created 1592527, written 5004155
0.00 reads/s, 0.00 creates/s, 0.00 writes/s
Buffer pool hit rate 1000 / 1000, young-making rate 0 / 1000 not 0 / 1000
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
LRU len: 177301, unzip_LRU len: 0
I/O sum[0]:cur[0], unzip sum[0]:cur[0]

0 个答案:

没有答案