-
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-23620] Destroy temp file in tempcache when temp volume is full #5524
base: develop
Are you sure you want to change the base?
Changes from 4 commits
8355065
c26c95c
9cd4608
3380483
930c355
56f547d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -798,6 +798,7 @@ STATIC_INLINE FILE_TEMPCACHE_ENTRY *file_tempcache_pop_tran_file (THREAD_ENTRY * | |
STATIC_INLINE void file_tempcache_push_tran_file (THREAD_ENTRY * thread_p, FILE_TEMPCACHE_ENTRY * entry) | ||
__attribute__ ((ALWAYS_INLINE)); | ||
STATIC_INLINE void file_tempcache_dump (FILE * fp) __attribute__ ((ALWAYS_INLINE)); | ||
STATIC_INLINE bool file_tempcache_find_victim_and_destroy (THREAD_ENTRY * thread_p, bool is_numerable); | ||
|
||
/************************************************************************/ | ||
/* File tracker section */ | ||
|
@@ -8535,12 +8536,30 @@ file_temp_alloc (THREAD_ENTRY * thread_p, PAGE_PTR page_fhead, FILE_ALLOC_TYPE a | |
{ | ||
/* expand file by one sector */ | ||
FILE_PARTIAL_SECTOR partsect_new = FILE_PARTIAL_SECTOR_INITIALIZER; | ||
|
||
retry: | ||
/* reserve a sector */ | ||
error_code = | ||
disk_reserve_sectors (thread_p, DB_TEMPORARY_DATA_PURPOSE, fhead->volid_last_expand, 1, &partsect_new.vsid); | ||
if (error_code != NO_ERROR) | ||
{ | ||
if (error_code == ER_BO_MAXTEMP_SPACE_HAS_BEEN_EXCEEDED) | ||
{ | ||
file_tempcache_lock (); | ||
|
||
if (file_tempcache_find_victim_and_destroy (thread_p, FILE_IS_NUMERABLE (fhead))) | ||
{ | ||
file_tempcache_unlock (); | ||
goto retry; | ||
} | ||
|
||
if (file_tempcache_find_victim_and_destroy (thread_p, !FILE_IS_NUMERABLE (fhead))) | ||
{ | ||
file_tempcache_unlock (); | ||
goto retry; | ||
} | ||
|
||
file_tempcache_unlock (); | ||
} | ||
assert_release (false); | ||
goto exit; | ||
} | ||
|
@@ -9606,6 +9625,52 @@ file_tempcache_dump (FILE * fp) | |
* manages its own list freely. */ | ||
} | ||
|
||
/* | ||
* file_tempcache_find_victim_and_destroy () - find a victim temp file from tempcache and destroy it | ||
* | ||
* return : true if a temp file was destroyed, false otherwise | ||
* thread_p (in) : thread entry | ||
* is_numerable (in) : true if numerable file is to be destroyed, false otherwise | ||
*/ | ||
STATIC_INLINE bool | ||
file_tempcache_find_victim_and_destroy (THREAD_ENTRY * thread_p, bool is_numerable) | ||
{ | ||
if (is_numerable) | ||
{ | ||
if (file_Tempcache.ncached_numerable > 0) | ||
{ | ||
if (file_destroy (thread_p, &file_Tempcache.cached_numerable->vfid, true) != NO_ERROR) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. file_destroy()가 호출된 이후에는 file_tempcache_retire_entry()를 호출해서 FILE_TEMPCACHE_ENTRY 메모리를 정리해야 합니다. file_tempcache_cache_or_drop_entries() 등을 참고해 보세요. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
{ | ||
assert (false); | ||
return false; | ||
} | ||
|
||
file_Tempcache.cached_numerable = file_Tempcache.cached_numerable->next; | ||
file_Tempcache.ncached_numerable--; | ||
return true; | ||
} | ||
|
||
return false; | ||
} | ||
else | ||
{ | ||
if (file_Tempcache.ncached_not_numerable > 0) | ||
{ | ||
if (file_destroy (thread_p, &file_Tempcache.cached_not_numerable->vfid, true) != NO_ERROR) | ||
{ | ||
assert (false); | ||
return false; | ||
} | ||
|
||
file_Tempcache.cached_not_numerable = file_Tempcache.cached_not_numerable->next; | ||
file_Tempcache.ncached_not_numerable--; | ||
return true; | ||
} | ||
|
||
return false; | ||
} | ||
} | ||
|
||
/************************************************************************/ | ||
/* File tracker section */ | ||
/************************************************************************/ | ||
|
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.
file_tempcache_ 접두어를 갖는 함수를 하나 소개하는게 좋겠습니다. (ex) file_tempcache_find_victim_and_destroy())
또한, numerable 기준으로 먼저 접근하는 캐쉬를 결정하는게 일관성 있어 보입니다. 위 논의된 컨텍스트는 생성 비용 관점이네요. 문맥상 numerable에서 못찾았는데 !numerable을 먼저 날리거나 그 반대가 되면 문맥이 자연스럽지 않습니다.
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.
file_tempcache_find_victim_and_destroy
함수를 통해 temp file을 지우도록 하였습니다.input 중
is_numerable
값은 numerable file을 지울지, non-numerable file을 지울 지의 option이고, 제거하는데 성공하였다면 true, 해당 temp file이 tempcache에 존재하지 않아서 제거에 실패하였다면 false를 return 합니다.또한, file head를 통해 file의 numerable 여부를 판단하여, 먼저 제거를 시도할 file의 type을 정하도록 변경하였습니다.
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.
file_tempcache_lock(), file_tempcache_unlock()는 file_tempcache_find_victim_and_destroy() 안쪽으로 들어가도 되겠네요.
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.
file_tempcache_lock
,file_tempcache_unlock
함수를file_tempcache_find_victim_and_destroy
안으로 위치시켰습니다.