Skip to content
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-25292] [CBRD-25389] COMMIT/ROLLBACK 시 PL에서 사용된 query handler를 지연해서 제거 #5698

Merged
merged 1 commit into from
Dec 11, 2024

Conversation

hgryoo
Copy link
Member

@hgryoo hgryoo commented Dec 10, 2024

http://jira.cubrid.org/browse/CBRD-25292

Description
CBRD-25292, CBRD-25389는 COMMIT, ROLLBACK 시 PL의 Static SQL, Dynamic SQL 생성 시 만들어지는 method_query_handler 객체에 대해서, COMMIT , ROLLBACK 시 객체가 바로 제거되어서 이미 할당 해제된 메모리를 접근하기 때문에 발생한다.
COMMIT, ROLLBACK 되더라도, 이전에 생성한 질의 핸들러와 커서는 제한적으로 접근이 가능해야하기 때문에 바로 제거하지 않고, deferred free list에 넣어둔 후 libcas 모드 (PL 실행 모드) 를 벗어나는 시점에 지연하여 제거하도록 수정한다.

Implementation

  • prepare 시 TRANID 전송
  • query_handler 생성 시 TRANID 설정
  • TRANID가 다르면 새로운 query_handler를 할당받도록 수정
  • COMMIT/ROLLBACK/END SESSION 시 할당된 query_handler 목록을 모두 deferred_query_handler 리스트로 등록
  • 메인 SQL 호출 종료 시 (libcas 모드가 아닌 경우), deferred_query_handler 리스트의 객체들을 모두 제거
    • 이 시점에 DB_SESSION, QUERY CURSOR 등의 자원이 제거됨

Remarks
이슈의 이유로 CAS core 발생 후 인터럽트 에러 처리 동기화 문제로, PL 세션 종료가 끝나지 않아 서버 종료가 되지 않는 문제로 regression 테스트가 진행되지 않으므로 CBRD-25272의 일부 변경을 적용했다.

…s called, query handlers should not be freed immediately, they should be accessable with limitation (e.g.) closed cursor)
@hgryoo hgryoo self-assigned this Dec 10, 2024
@hgryoo hgryoo requested a review from beyondykk9 as a code owner December 10, 2024 13:00
@@ -207,9 +208,11 @@ namespace cubmethod
}
}

/* DDL audit */
if (handler)
if (handler != nullptr)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (handler != nullptr)
else

@@ -199,6 +199,7 @@ namespace cubmethod
{
// add to statement handler cache
m_sql_handler_map.emplace (sql, handler->get_id ());
handler->set_tran_id (tid);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

valid한 tid인지 체크할 필요는 없나요?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TRANID는 서버에서 설정된 값을 보내주므로 여기서는 valid 체크가 필요 없습니다.

{
delete *it;
}
m_deferred_query_free_handler.clear();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nullptr 체크는 안해도 될까요?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

네 포인터가 아닌 멤버변수입니다

@hgryoo hgryoo requested a review from hyunikn December 11, 2024 02:36
@hgryoo hgryoo merged commit b8a1a53 into CUBRID:feature/plcsql-p1n Dec 11, 2024
8 of 10 checks passed
@hyunikn
Copy link
Contributor

hyunikn commented Dec 11, 2024

설명 remark 에 CBRD-25272는 아마도 오타겠지요?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants