-
Notifications
You must be signed in to change notification settings - Fork 124
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[CBRD-25414] The phenomenon of heap memory usage increasing each time utilities are executed #5529
base: develop
Are you sure you want to change the base?
Conversation
…nside the csql_exit_session function
…_end_session before the db_shutdown function
|
||
if (thread_p != NULL && thread_p->conn_entry != NULL && thread_p->conn_entry->session_p != NULL | ||
&& thread_p->conn_entry->session_p == session_p) | ||
if (session_p->ref_count > 0) | ||
{ | ||
thread_p->conn_entry->session_p = NULL; | ||
thread_p->conn_entry->session_id = DB_EMPTY_SESSION; | ||
if (thread_p != NULL && thread_p->conn_entry != NULL && thread_p->conn_entry->session_p != NULL | ||
&& thread_p->conn_entry->session_p == session_p) | ||
{ | ||
thread_p->conn_entry->session_p = NULL; | ||
thread_p->conn_entry->session_id = DB_EMPTY_SESSION; | ||
|
||
session_state_decrease_ref_count (thread_p, session_p); | ||
} | ||
else | ||
{ | ||
/* do we accept this case?? if we don't, add safe-guard here. */ | ||
} | ||
session_state_decrease_ref_count (thread_p, session_p); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이 코드부는 main 쓰레드에서 수행되고, worker 쓰레드는 css_shutdown_conn() -> session_state_decrease_ref_count()를 수행할 경우 ref_count < 0인 경우 등이 발생할 수 있을 것으로 보여집니다.
이 경우에 대해 어떻게 방어되어지고 있나요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
방어되어지고 있지 않아서 해당 부분을 어떻게 처리할까 고민하다
삭제하는 방향으로 수정하였습니다.
세션을 정리해줄 떄 hashmap에서 erase해주는 부분이 있는데 erase하기 위해서는 thread_p 정보가 필요합니다.
하지만 worker thread에서는 thread_p 정보를 받고있지 않아, 매개변수를 추가로 받는 것보다
main thread에서 destroy함수로 전부 처리하도록 수정하는 것이 나아보여 위와같이 수정하였습니다.
http://jira.cubrid.org/browse/CBRD-25414
Purpose
문제 상황
세션포인터와 세션아이디, 세션의 ref_count를 decrease하는 문제
1번 문제 원인
세션을 할당받는 모든 유틸리티 대상으로 세션을 반환하도록 수정하였습니다.
2번 문제 원인
강제로 끊어진 세션을 체크하는 쓰레드에서 세션이 끊어짐을 감지하게 되는데
이 때, 처리하는 작업에 세션이 할당받았던 힙메모리 영역을 반환시켜주는 작업이 빠져있었습니다.
3번 문제 원인
주요 함수
해당 함수를 사용하였습니다.
Implementation
shutdown 이전 세션이 할당받은 힙메모리 영역을 반환하도록 수정하였습니다.
end_session을 하여 힙메모리 영역을 반환하도록 수정하였습니다.
db_shutdown 함수 호출 전 db_end_session을 호출하는 코드를 제거하였습니다.
Remarks