// somehow the page requested no longer exists.
//resolve - what will happen if the user page doesnt exist
// wait to get the latch on the page
Page page = heap_control.getUserPageWait(pageno);
boolean purgingDone = false;
if (page != null)
{
try
{
// The number records that can be reclaimed is:
// total recs - recs_not_deleted
int num_possible_commit_delete =
page.recordCount() - page.nonDeletedRecordCount();
if (num_possible_commit_delete > 0)
{
// loop backward so that purges which affect the slot table
// don't affect the loop (ie. they only move records we
// have already looked at).
for (int slot_no = page.recordCount() - 1;
slot_no >= 0;
slot_no--)
{
boolean row_is_committed_delete =
page.isDeletedAtSlot(slot_no);
if (row_is_committed_delete)
{
// At this point we only know that the row is
// deleted, not whether it is committed.
// see if we can purge the row, by getting an
// exclusive lock on the row. If it is marked
// deleted and we can get this lock, then it
// must be a committed delete and we can purge
// it.
RecordHandle rh =
page.fetchFromSlot(
(RecordHandle) null,
slot_no,
RowUtil.EMPTY_ROW,
RowUtil.EMPTY_ROW_FETCH_DESCRIPTOR,
true);
row_is_committed_delete =
heap_control.lockRowAtSlotNoWaitExclusive(rh);
if (row_is_committed_delete)
{
purgingDone = true;
page.purgeAtSlot(slot_no, 1, false);
if (SanityManager.DEBUG)
{
if (SanityManager.DEBUG_ON(
"verbose_heap_post_commit"))
{
SanityManager.DEBUG_PRINT(
"HeapPostCommit",
"Purging row[" + slot_no + "]" +
"on page:" + pageno + ".\n");
}
}
}
}
}
}
if (page.recordCount() == 0)
{
purgingDone = true;
// Deallocate the current page with 0 rows on it.
heap_control.removePage(page);
// removePage guarantees to unlatch the page even if an
// exception is thrown. The page is protected against reuse
// because removePage locks it with a dealloc lock, so it
// is OK to release the latch even after a purgeAtSlot is
// called.
// @see ContainerHandle#removePage
if (SanityManager.DEBUG)
{
if (SanityManager.DEBUG_ON("verbose_heap_post_commit"))
{
SanityManager.DEBUG_PRINT(
"HeapPostCommit",
"Calling Heap removePage().; pagenumber="+pageno+"\n");
}
}
}
}
finally
{
// If no purge happened on the page and the page is not
// removed, feel free to unlatch it. Otherwise, let
// transaction commit take care of it.
if (!purgingDone)
{
page.unlatch();
page = null;
}
}
}
else