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-25510] Removed unnecessary loop in heap_get_insert_location_with_lock() function execution #5654

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from
58 changes: 25 additions & 33 deletions src/storage/heap_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -20455,7 +20455,8 @@ static int
heap_get_insert_location_with_lock (THREAD_ENTRY * thread_p, HEAP_OPERATION_CONTEXT * context,
PGBUF_WATCHER * home_hint_p)
{
int slot_count, slot_id, lk_result;
int slot_count, lk_result;
int slot_id = 0;
YeunjunLee marked this conversation as resolved.
Show resolved Hide resolved
LOCK lock;
int error_code = NO_ERROR;

Expand Down Expand Up @@ -20519,45 +20520,36 @@ heap_get_insert_location_with_lock (THREAD_ENTRY * thread_p, HEAP_OPERATION_CONT
slot_count = spage_number_of_slots (context->home_page_watcher_p->pgptr);

/* find REC_DELETED_WILL_REUSE slot or add new slot */
/* slot_id == slot_count means add new slot */
for (slot_id = 0; slot_id <= slot_count; slot_id++)
{
slot_id = spage_find_free_slot (context->home_page_watcher_p->pgptr, NULL, slot_id);
if (slot_id == SP_ERROR)
{
break; /* this will not happen */
}
YeunjunLee marked this conversation as resolved.
Show resolved Hide resolved
slot_id = spage_find_free_slot (context->home_page_watcher_p->pgptr, NULL, slot_id);

context->res_oid.slotid = slot_id;
context->res_oid.slotid = slot_id;

if (lock == NULL_LOCK)
{
/* immediately return without locking it */
return NO_ERROR;
}
if (lock == NULL_LOCK)
{
/* immediately return without locking it */
return NO_ERROR;
}

/* lock the object to be inserted conditionally */
lk_result = lock_object (thread_p, &context->res_oid, &context->class_oid, lock, LK_COND_LOCK);
if (lk_result == LK_GRANTED)
/* lock the object to be inserted conditionally */
lk_result = lock_object (thread_p, &context->res_oid, &context->class_oid, lock, LK_COND_LOCK);
if (lk_result == LK_GRANTED)
{
/* successfully locked! */
return NO_ERROR;
}
else if (lk_result != LK_NOTGRANTED_DUE_TIMEOUT)
hornetmj marked this conversation as resolved.
Show resolved Hide resolved
{
#if !defined(NDEBUG)
if (lk_result == LK_NOTGRANTED_DUE_ABORTED)
{
/* successfully locked! */
return NO_ERROR;
LOG_TDES *tdes = LOG_FIND_CURRENT_TDES (thread_p);
assert (tdes->tran_abort_reason == TRAN_ABORT_DUE_ROLLBACK_ON_ESCALATION);
}
else if (lk_result != LK_NOTGRANTED_DUE_TIMEOUT)
else
{
#if !defined(NDEBUG)
if (lk_result == LK_NOTGRANTED_DUE_ABORTED)
{
LOG_TDES *tdes = LOG_FIND_CURRENT_TDES (thread_p);
assert (tdes->tran_abort_reason == TRAN_ABORT_DUE_ROLLBACK_ON_ESCALATION);
}
else
{
assert (false); /* unknown locking error */
}
#endif
break; /* go to error case */
assert (false); /* unknown locking error */
}
#endif
Copy link
Contributor

Choose a reason for hiding this comment

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

endif 위치가 잘못된 것 같습니다.

Copy link
Author

Choose a reason for hiding this comment

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

수정하였습니다.

}

/* either lock error or no slot was found in page (which should not happen) */
Expand Down
Loading