programing

mysql(오로라)에서 "Lock wait timeout exceeded"를 디버깅하는 방법

telebox 2023. 9. 4. 19:43
반응형

mysql(오로라)에서 "Lock wait timeout exceeded"를 디버깅하는 방법

MySQL 테이블(정확히는 아마존 오로라)에 레코드를 삽입할 때 "Lock wait timeout exceeded" 오류가 발생합니다.한 번의 거래에 수백 개의 레코드를 삽입하고 몇 개의 삽입마다 저장 지점을 사용합니다.우리는 InnoDB 엔진을 사용하고 있습니다.우리는 가지고 있다.innodb_lock_wait_timeout50초로 설정합니다.우리는 생산 과정에서만 이 오류가 발생해서 여기서 디버깅 기능에 한계가 있습니다.

삽입 문이 실행될 때 잠긴 트랜잭션에 대한 정보를 가져오려고 시도했는데 다음과 같습니다.

MySQL [(none)]> SELECT w.* FROM information_schema.innodb_lock_waits w INNER JOIN information_schema.innodb_trx b ON b.trx_id = w.blocking_trx_id INNER JOIN information_schema.processlist p on b.trx_mysql_thread_id = p.ID LIMIT 10;
+-------------------+--------------------------+-----------------+--------------------------+
| requesting_trx_id | requested_lock_id        | blocking_trx_id | blocking_lock_id         |
+-------------------+--------------------------+-----------------+--------------------------+
| 1177444193        | 1177444193:5437:2161:286 | 1177444168      | 1177444168:5437:2161:286 |
+-------------------+--------------------------+-----------------+--------------------------+
1 row in set (0.01 sec)

MySQL [(none)]> select * from information_schema.innodb_trx where trx_id=1177444168 limit 10;
+------------+-----------+---------------------+-----------------------+------------------+------------+---------------------+-----------+---------------------+-------------------+-------------------+------------------+-----------------------+-----------------+-------------------+-------------------------+---------------------+-------------------+------------------------+----------------------------+---------------------------+---------------------------+------------------+----------------------------+
| trx_id     | trx_state | trx_started         | trx_requested_lock_id | trx_wait_started | trx_weight | trx_mysql_thread_id | trx_query | trx_operation_state | trx_tables_in_use | trx_tables_locked | trx_lock_structs | trx_lock_memory_bytes | trx_rows_locked | trx_rows_modified | trx_concurrency_tickets | trx_isolation_level | trx_unique_checks | trx_foreign_key_checks | trx_last_foreign_key_error | trx_adaptive_hash_latched | trx_adaptive_hash_timeout | trx_is_read_only | trx_autocommit_non_locking |
+------------+-----------+---------------------+-----------------------+------------------+------------+---------------------+-----------+---------------------+-------------------+-------------------+------------------+-----------------------+-----------------+-------------------+-------------------------+---------------------+-------------------+------------------------+----------------------------+---------------------------+---------------------------+------------------+----------------------------+
| 1177444168 | RUNNING   | 2022-09-26 12:08:49 | NULL                  | NULL             |       1844 |            64308215 | NULL      | NULL                |                 0 |                 8 |              908 |                  1136 |            2579 |               936 |                       0 | READ COMMITTED      |                 1 |                      1 | NULL                       |                         0 |                         0 |                0 |                          0 |
+------------+-----------+---------------------+-----------------------+------------------+------------+---------------------+-----------+---------------------+-------------------+-------------------+------------------+-----------------------+-----------------+-------------------+-------------------------+---------------------+-------------------+------------------------+----------------------------+---------------------------+---------------------------+------------------+----------------------------+
1 row in set (0.01 sec)

내가 보기에 tx를 차단하는 것은 쿼리가 아니라 내가 아무것도 보지 못했기 때문에 잠긴 레코드가 많은 어떤 트랜잭션입니다.trx_query.

그래서 제 질문은 이 차단 트랜잭션에 대한 더 많은 정보를 어떻게 얻을 수 있을까요? 시간이 초과될 때까지 50초 동안 삽입을 차단하는 것이 정확히 무엇인지 알 수 있을까요?

p.s. 독립 실행형 MySQL에서는 이러한 문제가 발생하지 않았지만 Aurora로 마이그레이션할 때 잠금 대기 오류가 발생하기 시작했습니다.

언급URL : https://stackoverflow.com/questions/73896233/how-to-debug-lock-wait-timeout-exceeded-in-mysql-aurora

반응형