void ShadowTree::commit(ShadowTreeCommitTransaction transaction) const { SystraceSection s("ShadowTree::commit"); int attempts = 0; while (true) { attempts++; if (tryCommit(transaction)) { return; } // After multiple attempts, we failed to commit the transaction. // Something internally went terribly wrong. assert(attempts < 1024); } }
void TPIO::refreshOldPages(page_id_t threshold, size_t pgsPerTx) { // rOP: refreshOldPages // // case 1: // rOP s---e // Rebase s---e // // no prob // // case 2: // rOP s---e // Rebase s---e s---e // // no prob // // case 3: // rOP s-!---e // Rebase s-----e // // no prob. rOP waits until rebase is done // // case 4: // rOP s---e // Rebase s-!---e // // rebase need to wait until rOP finishes... BAD! // if(m_bDuringRefresh) { std::cout << "already during refresh" << std::endl; return; } PTNK_MEMBARRIER_COMPILER; if(! PTNK_CAS(&m_bDuringRefresh, false, true)) { std::cout << "already during refresh (CAS failed)" << std::endl; return; } PTNK_MEMBARRIER_COMPILER; #ifdef VERBOSE_REFRESH std::cout << "refresh start" << std::endl << *this; #endif void* cursor = NULL; do { unique_ptr<TPIOTxSession> tx(newTransaction()); Page pgStart(tx->readPage(tx->pgidStartPage())); pgStart.refreshAllLeafPages(&cursor, threshold, pgsPerTx, tx.get()); #ifdef VERBOSE_REFRESH tx->dumpStat(); #endif if(! tryCommit(tx.get(), COMMIT_REFRESH)) { std::cerr << "refresh ci failed!" << std::endl; } } while(cursor); PTNK_MEMBARRIER_COMPILER; m_bDuringRefresh = false; #ifdef VERBOSE_REFRESH std::cout << "refresh end" << std::endl << *this; #endif rebase(/* force = */ true); }