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-23620] Destroy temp file in tempcache when temp volume is full #5524

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions src/storage/disk_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -4276,8 +4276,8 @@ disk_reserve_sectors (THREAD_ENTRY * thread_p, DB_VOLPURPOSE purpose, VOLID voli
log_sysop_abort (thread_p);

if (error_code == ER_INTERRUPTED /* interrupted error */
|| error_code == ER_IO_MOUNT_FAIL || error_code == ER_IO_FORMAT_OUT_OF_SPACE || error_code == ER_IO_WRITE
|| error_code == ER_BO_CANNOT_CREATE_VOL /* IO errors */ )
|| error_code == ER_IO_MOUNT_FAIL || error_code == ER_IO_FORMAT_OUT_OF_SPACE || error_code == ER_IO_WRITE || error_code == ER_BO_CANNOT_CREATE_VOL /* IO errors */
|| error_code == ER_BO_MAXTEMP_SPACE_HAS_BEEN_EXCEEDED /* temp volume is full */ )
{
/* this is expected. */
return error_code;
Expand Down Expand Up @@ -4361,7 +4361,6 @@ disk_reserve_from_cache (THREAD_ENTRY * thread_p, DISK_RESERVE_CONTEXT * context
>= disk_Temp_max_sects)
{
/* too much temporary space */
assert (false);
er_set (ER_ERROR_SEVERITY, ARG_FILE_LINE, ER_BO_MAXTEMP_SPACE_HAS_BEEN_EXCEEDED, 1, disk_Temp_max_sects);
disk_cache_unlock_reserve_for_purpose (context->purpose);
return ER_BO_MAXTEMP_SPACE_HAS_BEEN_EXCEEDED;
Expand Down
36 changes: 35 additions & 1 deletion src/storage/file_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -8535,12 +8535,46 @@ 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 ();
Copy link
Contributor

@hornetmj hornetmj Oct 10, 2024

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을 먼저 날리거나 그 반대가 되면 문맥이 자연스럽지 않습니다.

Copy link
Contributor Author

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을 정하도록 변경하였습니다.

Copy link
Contributor

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() 안쪽으로 들어가도 되겠네요.

Copy link
Contributor Author

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 안으로 위치시켰습니다.

if (file_Tempcache.ncached_not_numerable > 0)
{
if (file_destroy (thread_p, &file_Tempcache.cached_not_numerable->vfid, true) != NO_ERROR)
{
file_tempcache_unlock ();
assert_release (false);
goto exit;
}
file_Tempcache.cached_not_numerable = file_Tempcache.cached_not_numerable->next;
file_Tempcache.ncached_not_numerable--;

file_tempcache_unlock ();
goto retry;
}
else if (file_Tempcache.ncached_numerable > 0)
{
if (file_destroy (thread_p, &file_Tempcache.cached_numerable->vfid, true) != NO_ERROR)
{
file_tempcache_unlock ();
assert_release (false);
goto exit;
}
file_Tempcache.cached_numerable = file_Tempcache.cached_numerable->next;
file_Tempcache.ncached_numerable--;

file_tempcache_unlock ();
goto retry;
}
file_tempcache_unlock ();
}

assert_release (false);
goto exit;
}
Expand Down
Loading