Node.js 에서 발생한 Transaction 이 부족해서 문제가 발생했고, 해결하는 과정에서 Idle in transaction에 대해서 알게 되었습니다.
Idle in transaction 이란 무엇인가?
문서에 따르면 다음과 같은 의미를 가집니다.
idle in transaction (waiting for client inside a BEGIN block)
클라이언트가 시작을 열어놓고 기다리고 있다.
즉, 클라이언트가 정상적으로 트랜잭션을 닫지 않았다. 대부분의 Application은 ConnectionPool 을 통해 N개의 Connection 을 쥐고 있습니다. N개의 Connection이 모두다 정상적으로 동작하지 않을 경우에는 다음 Connection 이 열리지 않아 문제가 발생합니다.
그외에 idle 은 클라이언트의 command 를 기다리는 것을 말합니다.
이 부분을 해결하기 위해서는 postgresSQL 의 특정 옵션을 추가해야 합니다. idle_in_transaction_session_timeout 을 설정합니다.
최소 설정은 Disabled 되어있고, 이를 적절한 시간을 설정하여 해결할 수 있습니다.
[참고자료]
https://www.postgresql.org/docs/8.3/monitoring-ps.html
Standard Unix Tools
On most platforms, PostgreSQL modifies its command title as reported by ps, so that individual server processes can readily be identified. A sample display is $ ps auxww | grep ^postgres postgres 960 0.0 1.1 6104 1480 pts/1 SN 13:17 0:00 postgres -i postgr
www.postgresql.org
Client Connection Defaults
Sets the display format for date and time values, as well as the rules for interpreting ambiguous date input values. For historical reasons, this variable contains two independent components: the output format specification (ISO, Postgres, SQL, or German)
www.postgresql.org
https://www.dbi-services.com/blog/a-look-at-postgresql-9-6-killing-idle-transactions-automatically/
A look at PostgreSQL 9.6 – Killing idle transactions automatically - dbi Blog
A common issue with databases: The guy at floor 2 did some work on the database and then rashly left for lunch because the lady on floor 1 is already waiting for him. Unfortunately he did not close his transaction and now his session is blocking others. In
www.dbi-services.com
'개발 관련됨 > 개발 관련 유용한 정보함' 카테고리의 다른 글
Intellij 북마크 기능(스타 부대지정 같은) / 이전 단어 재사용하기 (0) | 2023.08.22 |
---|---|
조영호님과 객체지향에 대해서 이야기하기 (2) | 2022.12.22 |
안전하게 코드 리팩토링하기 - 1 (0) | 2022.07.24 |
gradle 기반의 여러 모듈에서 공통으로 쓰인 스크립트가 있다면? (0) | 2022.02.06 |
MAC OS 에서 Icon 이 Bouncing 하지 않도록 하는 방법 (0) | 2021.09.26 |
댓글