ERROR org.springframework.dao.TransientDataAccessResourceException:
### Error updating database. Cause: java.sql.SQLTransientConnectionException: (conn=3359025)
Lock wait timeout exceeded; try restarting transaction
### The error may involve com.goom.app.iam.mapper.UserTimeMapper.modifyLogOnTime-Inline
### The error occurred while setting parameters
### SQL: UPDATE TIM_USER_TIME SET LAST_LOGON = ?, LAST_LOGOUT = ? WHERE TENANT_ID = ? AND USER_ID = ?
### Cause: java.sql.SQLTransientConnectionException:(conn=3359025)
Lock wait timeout exceeded;try restarting transaction ;SQL []; (conn=3359025)
Lock wait timeout exceeded; try restarting transaction; nested exception is java.sql.SQLTransientConnectionException: (conn=3359025)
Lock wait timeout exceeded; try restarting transaction
앱 모바일 https 로그인 관련 테스트 중 갑자기 잘 되던 로그인이 안돼서.. 뭔가 문제 있나? 하고 iPhone으로도 해보고, 스토어에서 바로 다운받은 앱에서도 해봤는데 안돼서 서버 로그를 확인해보니 해당 로그가 오전 11시부터 다수 발견;
이 참에 한번 제대로 알아보자.
-- 모든 프로세스 조회
SHOW FULL PROCESSLIST;
Lock 걸린 테이블이 있으면 status 컬럼에 "Waiting for table metadata lock"이라고 표시됨.
참고로 해당 프로세스의 id 값을 이용해 프로세스 종료할 수 있다
-- KILL {id}
KILL 3343315;
-- 락 테이블 조회
SELECT * FROM information_schema.INNODB_LOCKS
-- 대기 중인 락 조회
SELECT * FROM information_schema.INNODB_LOCK_WAITS
-- 트랜잭션 조회
SELECT * FROM information_schema.INNODB_TRX
이번 경우는 트랜잭션의 문제 였다 trx_wait_started 가 몇 시간 전으로 찍혀있었다.
트랜잭션은 id(trx_id)가 아닌 trx_mysql_thread_id 값을 이용해 kill 시켜줌
-- kill {trx_mysql_thread_id}
KILL 38299;
참고 사이트:
https://hjjungdev.tistory.com/153
Mysql (Maria) Db 테이블락 확인하고 강제중지 방법.
1. 개요 보통 기본설정의 Rdbms는 Select문을 제외하고 Delete/Update/Insert문에 대해서 테이블 락을 걸게됩니다. 가령 A라는 사람이 Delete Table;의 명령문을 실행한 상태에서 커밋을 치지않는 다면 해당커
hjjungdev.tistory.com
https://m.blog.naver.com/PostView.naver?isHttpsRedirect=true&blogId=abc2185&logNo=220756357378
'SQL > mySQL' 카테고리의 다른 글
Data truncation: Incorrect string value: '\xF0\x9F\ (1) | 2023.11.24 |
---|---|
A TABLE 특정 컬럼, B TABLE에 INSERT 하기 (중복 데이터 제외) (0) | 2021.12.06 |
[SQL Exception] Borrow prepareStatement from pool failed; (0) | 2021.08.19 |