📄 heappostcommit.java
字号:
{ 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 { if (SanityManager.DEBUG) { if (SanityManager.DEBUG_ON("verbose_heap_post_commit")) { SanityManager.DEBUG_PRINT( "HeapPostCommit", "Get No Wait returned null. page num = " + pageno + "\n"); SanityManager.showTrace(new Throwable()); } } } return; } /************************************************************************** * Public Methods implementing the Serviceable interface: ************************************************************************** */ /** * The urgency of this post commit work. * <p> * This determines where this Serviceable is put in the post commit * queue. Post commit work in the heap can be safely delayed until there * is not user work to do. * * @return false, this work should not be serviced ASAP **/ public boolean serviceASAP() { return(true); } // @return true, if this work needs to be done on a user thread immediately public boolean serviceImmediately() { return false; } /** * perform the work described in the postcommit work. * <p> * In this implementation the only work that can be executed by this * post commit processor is this class itself. * <p> * * @return Returns Serviceable.DONE when work has completed, or * returns Serviceable.REQUEUE if work needs to be requeued. * * @param contextMgr the context manager started by the post commit daemon * * @exception StandardException Standard exception policy. **/ public int performWork(ContextManager contextMgr) throws StandardException { TransactionManager tc = (TransactionManager) this.access_factory.getAndNameTransaction( contextMgr, AccessFactoryGlobals.SYS_TRANS_NAME); TransactionManager internal_xact = tc.getInternalTransaction(); // only requeue if work was not completed in this try. boolean requeue_work = false; HeapController heapcontroller; if (SanityManager.DEBUG) { if (SanityManager.DEBUG_ON("verbose_heap_post_commit")) SanityManager.DEBUG_PRINT( "HeapPostCommit", "starting internal xact\n"); } try { // This call will attempt to open the heap table locked with // table level IX mode, preparing to do record level locked space // reclamation. // // The call will either succeed immediately, or throw an exception // which could mean the container does not exist or that the lock // could not be granted immediately. //Reversed the fix for 4255: //page reclaimation is done asynchronosly by raswstore daemon //not good to WAIT FOR LOCKS , as it can freeze the daemon //If we can not get the lock this reclamation request will //requeued. heapcontroller = (HeapController) heap.open( internal_xact, internal_xact.getRawStoreXact(), false, ContainerHandle.MODE_FORUPDATE | ContainerHandle.MODE_LOCK_NOWAIT, TransactionController.MODE_RECORD, internal_xact.getRawStoreXact().newLockingPolicy( LockingPolicy.MODE_RECORD, TransactionController.ISOLATION_REPEATABLE_READ, true), heap, (DynamicCompiledOpenConglomInfo) null); // We got a table intent lock, all deleted rows we encounter can // be reclaimed, once an "X" row lock is obtained on them. // Process all the rows on the page while holding the latch. purgeCommittedDeletes(heapcontroller, this.page_number); } catch (StandardException se) { // exception might have occured either container got dropper or lock not granted. // It is possible by the time this post commit work gets scheduled // that the container has been dropped and that the open container // call will return null - in this case just return assuming no // work to be done. //If this expcetion is because lock could not be obtained , work is requeued. if (se.getMessageId().equals(SQLState.LOCK_TIMEOUT) || se.getMessageId().equals(SQLState.DEADLOCK)) { requeue_work = true; } // Do not close the controller because that will unlatch the // page. Let the commit and destroy do release the latch and // close the controller. // heapcontroller.close(); } // It is ok to not sync this post work. If no subsequent log record // is sync'd to disk then it is ok that this transaction not make // it to the database. If any subsequent transaction is sync'd to // the log file, then this transaction will be sync'd as part of that // work. internal_xact.commitNoSync(Transaction.RELEASE_LOCKS); internal_xact.destroy(); if (SanityManager.DEBUG) { if (SanityManager.DEBUG_ON("verbose_heap_post_commit")) { if (requeue_work) SanityManager.DEBUG_PRINT( "HeapPostCommit", "requeueing on page num = " + page_number); } } return(requeue_work ? Serviceable.REQUEUE : Serviceable.DONE); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -