|
Zero
0.1.0
|
A buffer manager that exploits the tree structure of indexes. More...
#include <buffer_pool.hpp>
Public Member Functions | |
| BufferPool () | |
| Default constructor for a buffer pool. More... | |
| void | postInitialize () |
| Completes the initialization of this buffer pool. More... | |
| void | shutdown () |
| Shuts down this buffer pool. More... | |
| ~BufferPool () | |
| Default destructor for a buffer pool. More... | |
| bf_idx | getBlockCount () const noexcept |
| Number of buffer frames of this buffer pool. More... | |
| bool | isNoDBMode () const noexcept |
| Whether this buffer pool is in NoDB mode. More... | |
| bool | usesWriteElision () const noexcept |
| Whether this buffer pool uses write elision. More... | |
| bool | isWarmupDone () const noexcept |
| Return whether this buffer pool is already "warmed up". More... | |
| const std::shared_ptr< zero::buffer_pool::Hashtable > | getHashtable () const noexcept |
| Returns the hashtable of this buffer pool. More... | |
| const std::shared_ptr< zero::buffer_pool::FreeListLowContention > | getFreeList () const noexcept |
| Returns the free list of this buffer pool. More... | |
| const std::shared_ptr< page_cleaner_base > | getPageCleaner () const noexcept |
| Returns the page cleaner of this buffer pool. More... | |
| void | wakeupPageCleaner () const |
| const std::shared_ptr< PAGE_EVICTIONER > | getPageEvictioner () const noexcept |
| Returns the page evictioner of this buffer pool. More... | |
| bool | hasDirtyFrames () |
| Whether this buffer pool has dirty buffer frames. More... | |
| void | fixRoot (generic_page *&targetPage, StoreID store, latch_mode_t latchMode, bool conditional, bool virgin) |
| Fixes a root B-Tree page in this buffer pool. More... | |
| w_rc_t | fixRootOldStyleExceptions (generic_page *&targetPage, StoreID store, latch_mode_t latchMode, bool conditional, bool virgin) |
| bool | fixNonRoot (generic_page *&targetPage, generic_page *parentPage, PageID pid, latch_mode_t latchMode, bool conditional=false, bool virgin=false, bool onlyIfHit=false, bool doRecovery=true, lsn_t emlsn=lsn_t::null) |
| Fixes a non-root B-Tree page in this buffer pool. More... | |
| w_rc_t | fixNonRootOldStyleExceptions (generic_page *&targetPage, generic_page *parentPage, PageID pid, latch_mode_t latchMode, bool conditional=false, bool virgin=false, bool onlyIfHit=false, bool doRecovery=true, lsn_t emlsn=lsn_t::null) |
| bf_idx | pinForRefix (const generic_page *pinPage) |
| Pin a page for a cheaper re-fix. More... | |
| void | refixDirect (generic_page *&targetPage, bf_idx refixIndex, latch_mode_t latchMode, bool conditional) |
| Re-fix a pinned page. More... | |
| w_rc_t | refixDirectOldSytleExceptions (generic_page *&targetPage, bf_idx refixIndex, latch_mode_t latchMode, bool conditional) |
| void | unpinForRefix (bf_idx unpinIndex) |
| Unpin a page for re-fix. More... | |
| void | unfix (const generic_page *unfixPage, bool evict=false) |
| Unfixes a page in this buffer pool. More... | |
| bf_tree_cb_t & | getControlBlock (bf_idx index) noexcept |
| Returns the control block corresponding to a buffer pool index. More... | |
| const bf_tree_cb_t & | getControlBlock (bf_idx index) const noexcept |
| Returns the control block corresponding to a buffer pool index. noexcept More... | |
| bf_tree_cb_t & | getControlBlock (const generic_page *page) noexcept |
| Returns the control block corresponding to a buffered page. More... | |
| bf_idx | getIndex (const bf_tree_cb_t &controlBlock) const noexcept |
| The buffer pool index of a control block. More... | |
| bf_idx | getIndex (const generic_page *page) const noexcept |
| The buffer pool index of a buffered page. More... | |
| bf_idx | getRootIndex (StoreID store) const noexcept |
| The buffer pool index of a buffered B-Tree root page. More... | |
| generic_page * | getPage (const bf_idx &index) noexcept |
| A buffered page at a buffer pool index. More... | |
| const generic_page * | getPage (const bf_idx &index) const noexcept |
| A buffered page at a buffer pool index. noexcept More... | |
| bool | isValidIndex (bf_idx index) const noexcept |
| Checks the validity of a buffer pool index in this buffer pool. More... | |
| bool | isActiveIndex (bf_idx index) const noexcept |
| Checks whether a buffer pool frame is used in this buffer pool. More... | |
| bool | upgradeLatchConditional (const generic_page *page) noexcept |
| Upgrade the latch of a page. More... | |
| void | downgradeLatch (const generic_page *page) noexcept |
| Downgrade the latch of a page. More... | |
| bool | unswizzlePagePointer (generic_page *parentPage, general_recordid_t childSlotInParentPage, PageID *childPageID=nullptr) |
| Unswizzle a page pointer in a page's parent page. More... | |
| PageID | normalizePID (const PageID pid) const noexcept |
| Normalize a page ID. More... | |
| bool | isEvictable (const bf_idx indexToCheck, const bool doFlushIfDirty) noexcept |
| Check if a page can be evicted. More... | |
| void | batchPrefetch (PageID startPID, bf_idx numberOfPages) noexcept |
| Prefetches a batch of pages into this buffer pool. More... | |
| void | recoverIfNeeded (bf_tree_cb_t &controlBlock, generic_page *page, bool onlyIfDirty=true) noexcept |
| Recover buffered page if needed. More... | |
| void | fuzzyCheckpoint (chkpt_t &checkpoint) const noexcept |
| Creates a fuzzy checkpoint for this buffer pool. More... | |
| void | sxUpdateChildEMLSN (btree_page_h &parentPage, general_recordid_t childSlotID, lsn_t childEMLSN) const |
| Update the EMLSN of a B-Tree child inside its parent page. More... | |
| void | switchParent (PageID childPID, generic_page *newParentPage) noexcept |
| Switch the parent page of a buffered B-Tree page in this buffer pool. More... | |
| void | setMediaFailure () noexcept |
| MG TODO. More... | |
| void | unsetMediaFailure () noexcept |
| MG TODO. More... | |
| PageID | getMediaFailurePID () const noexcept |
| MG TODO. More... | |
| bool | isMediaFailure () const noexcept |
| bool | isMediaFailure (PageID pid) const noexcept |
| MG TODO. More... | |
| void | debugDump (std::ostream &o) const |
| Dumps some meta data of this buffer pool to an output stream. More... | |
| void | debugDumpPagePointers (std::ostream &o, generic_page *page) const |
| Dumps the pointers stored inside a page to an output stream. More... | |
Private Types | |
| using | RestoreCoord = RestoreCoordinator< std::function< decltype(SegmentRestorer::bf_restore)>> |
| using | BgRestorer = BackgroundRestorer< RestoreCoord, std::function< void(void)>> |
Private Member Functions | |
| bool | _fix (generic_page *parentPage, generic_page *&targetPage, PageID pid, latch_mode_t latchMode, bool conditional, bool virgin, bool onlyIfHit=false, bool doRecovery=true, lsn_t emlsn=lsn_t::null) |
| Fixes a page in this buffer pool. More... | |
| void | _convertToDiskPage (generic_page *page) const noexcept |
| Converts an image of a page with swizzled pointers to one without. More... | |
| void | _readPage (PageID pid, generic_page *targetPage, bool fromBackup=false) |
| Reads a page from database or backup. More... | |
| void | _deletePage (bf_idx index) noexcept |
| Deletes a page from this buffer pool. More... | |
| void | _checkWarmupDone () noexcept |
| Decides if this buffer pool is "warmed up". More... | |
| void | _setWarmupDone () noexcept |
| Sets this buffer pool to "warmed up". More... | |
Private Attributes | |
| bf_idx | _blockCount |
| Maximum number of pages in this buffer pool. More... | |
| std::array< bf_idx, stnode_page::max > | _rootPages |
| Buffer indexes of root pages. More... | |
| std::vector< bf_tree_cb_t, boost::alignment::aligned_allocator< bf_tree_cb_t, sizeof(bf_tree_cb_t)> > | _controlBlocks |
| Array of control blocks. More... | |
| generic_page * | _buffer |
| Array of buffered pages. More... | |
| std::shared_ptr< Hashtable > | _hashtable |
| Allows to locate pages by PageID. More... | |
| std::shared_ptr< FreeListLowContention > | _freeList |
| List of unused buffer frames. More... | |
| std::shared_ptr< page_cleaner_base > | _cleaner |
| Cleans dirty pages. More... | |
| bool | _cleanerDecoupled |
| Use log-based "decoupled" cleaner. More... | |
| std::shared_ptr< PAGE_EVICTIONER > | _evictioner |
| Evicts pages. More... | |
| bool | _asyncEviction |
| Use a dedicated thread for eviction. More... | |
| bool | _maintainEMLSN |
| Maintain EMLSN of B-Tree pages. More... | |
| std::shared_ptr< RestoreCoord > | _restoreCoordinator |
| MG TODO. More... | |
| std::shared_ptr< BgRestorer > | _backgroundRestorer |
| MG TODO. More... | |
| bool | _useWriteElision |
| Use write elision. More... | |
| std::atomic< PageID > | _mediaFailurePID |
| MG TODO. More... | |
| bool | _instantRestore |
| Use instant restore. More... | |
| bool | _noDBMode |
| Use NoDB. More... | |
| bool | _logFetches |
| Log page fetches. More... | |
| size_t | _batchSegmentSize |
| MG TODO. More... | |
| bool | _batchWarmup |
| MG TODO. More... | |
| bool | _warmupDone |
| MG TODO. More... | |
| double | _warmupHitRatio |
| Hit rate of a "warm" buffer pool. More... | |
| unsigned | _warmupMinFixes |
| Minimum number of fixes of a "warm" buffer pool. More... | |
Static Private Attributes | |
| static thread_local SprIterator | _localSprIter |
| Single-page-recovery iterator used for instant restart redo. More... | |
| static thread_local unsigned | _fixCount = 0 |
| MG TODO. More... | |
| static thread_local unsigned | _hitCount = 0 |
| MG TODO. More... | |
Friends | |
| class | ::test_bf_tree |
| class | ::bf_tree_cleaner |
| class | page_cleaner_decoupled |
| class | ::GenericPageIterator |
| class | FreeListLowContention |
| class | FreeListHighContention |
| class | PageEvictioner |
| template<class selector_class , class filter_class , bool filter_early> | |
| class | PageEvictionerSelectAndFilter |
A buffer manager that exploits the tree structure of indexes.
This buffer manager only deals with tree-structured stores such as B-trees.
|
private |
|
private |
| zero::buffer_pool::BufferPool::BufferPool | ( | ) |
Default constructor for a buffer pool.
Constructs an almost completely initialized buffer pool according to the settings set in ss_m::get_options() .
| zero::buffer_pool::BufferPool::~BufferPool | ( | ) |
Default destructor for a buffer pool.
Due to the usage of smart pointers, all this destructor does is implicit.
|
privatenoexcept |
Decides if this buffer pool is "warmed up".
Decides if this buffer pool is "warmed up" by looking at the hit ratio observed for the current thread and the total number of page fixes done by this thread. This is for cases where the dataset fits in main memory and the buffer pool never (or just takes really long to) fill up.
|
privatenoexcept |
Converts an image of a page with swizzled pointers to one without.
Converts an image of a page (buffered in this buffer pool) with swizzled pointers to a disk page without swizzled pointers. This is mainly used to write out dirty pages.
| page | The page with swizzled pointers to convert to a disk page. |
|
privatenoexcept |
Deletes a page from this buffer pool.
Makes the buffer frame which corresponds to the specified buffer index unoccupied.
| index | The buffer index of the buffer pool frame to be freed. |
|
private |
Fixes a page in this buffer pool.
If pointer swizzling is enabled, this receives the requested page's parent page and efficiently fixes the requested page if the pid is already swizzled by inside the parent page. If it is not already swizzled, it will be swizzled after the execution of this. The optimization is transparent for most of the code because the page ID stored in the parent page is automatically (and atomically) changed to a swizzled pointer by the buffer pool.
If pointer swizzling is disabled, this fixes the requested page in this buffer pool.
parentPage set and latched. Otherwise use fixable_page_h.fix_direct(PageID pid, latch_mode_t mode, bool conditional, bool virgin_page, bool only_if_hit, bool do_recovery) .targetPage pointer points to the page which should have been fixed and it is latched in the wanted mode.| [in] | parentPage | This is the parent of the page to be fixed. If the page is either represents a root of a B-Tree or is not a B-Tree page this see the prerequisites. |
| [out] | targetPage | This page should contain the fixed page. |
| [in] | pid | Page ID of the requested page to be fixed (or buffer pool index with swizzledPIDBit set when swizzled). |
| [in] | latchMode | The wanted latch mode for the page that should be fixed (only latch_mode_t::LATCH_SH and latch_mode_t::LATCH_EX are allowed here). |
| [in] | conditional | Whether the fix is conditional (returns immediately even if failed). |
| [in] | virgin | Whether the page is a new page thus does not have to be read from disk. |
| [in] | onlyIfHit | The fix is only performed if the requested page is already buffered in this buffer pool (i.e., a page hit occurs) |
| [in] | doRecovery | Whether recovery should be enabled for this page. |
| [in] | emlsn | The EMLSN of the requested page. |
onlyIfHit is set and it is a page miss false , else true .
|
private |
Reads a page from database or backup.
Reads a page from database or backup into a buffer frame of this buffer pool. The source of the page needs to be selected explicitly.
targetPage in latch_mode_t::LATCH_EX .| pid | The page ID of the page to read. |
| targetPage | The page should be read into this page image. |
| fromBackup | Whether the page should be read from the backup or from the database. |
|
privatenoexcept |
Sets this buffer pool to "warmed up".
Prefetches a batch of pages into this buffer pool.
Prefetches a continuous batch of pages into this buffer pool using preadv . This allows a faster restore process without traversing the B-Tree.
| startPID | The page ID of the first page in the continuous batch of pages to prefetch. |
| numberOfPages | The number of pages to prefetch (page ID of the last prefetched page: startPID + numberOfPages - 1 ). |
| zero::buffer_pool::BufferPool::debugDump | ( | std::ostream & | o | ) | const |
Dumps some meta data of this buffer pool to an output stream.
Dumps some general meta data of this buffer pool and of the first 1000 buffer pool frames to the specified output stream. See the implementation for more details! The data is multi-lined and cannot be manipulated using stream manipulators.
| o | The output stream to which the meta data are printed. |
| zero::buffer_pool::BufferPool::debugDumpPagePointers | ( | std::ostream & | o, |
| generic_page * | page | ||
| ) | const |
Dumps the pointers stored inside a page to an output stream.
Dumps the pointers (accounting for swizzling) of a given page to the specified output stream. See the implementation for more details! The data is single-lined and cannot be manipulated using stream manipulators.
| o | The output stream to which the pointers are printed. |
| page | The page whose contained pointers are printed. |
|
noexcept |
Downgrade the latch of a page.
Downgrade this thread holding the latch of a page in latch_mode_t::LATCH_EX to one holding the latch in latch_mode_t::LATCH_SH .
| page | The latch corresponding to this page should be downgraded. |
| zero::buffer_pool::BufferPool::fixNonRoot | ( | generic_page *& | targetPage, |
| generic_page * | parentPage, | ||
| PageID | pid, | ||
| latch_mode_t | latchMode, | ||
| bool | conditional = false, |
||
| bool | virgin = false, |
||
| bool | onlyIfHit = false, |
||
| bool | doRecovery = true, |
||
| lsn_t | emlsn = lsn_t::null |
||
| ) |
Fixes a non-root B-Tree page in this buffer pool.
If pointer swizzling is enabled, this receives the requested page's parent page and efficiently fixes the requested page if the pid is already swizzled by inside the parent page. If it is not already swizzled, it will be swizzled after the execution of this. The optimization is transparent for most of the code because the page ID stored in the parent page is automatically (and atomically) changed to a swizzled pointer by the buffer pool.
If pointer swizzling is disabled, this fixes the requested page in this buffer pool.
parentPage set and latched. Otherwise use fixable_page_h.fix_direct(PageID pid, latch_mode_t mode, bool conditional, bool virgin_page, bool only_if_hit, bool do_recovery) .targetPage pointer points to the page which should have been fixed and it is latched in the wanted mode.| [out] | targetPage | This page should contain the fixed page. |
| [in] | parentPage | This is the parent of the page to be fixed. If the page is either represents a root of a B-Tree or is not a B-Tree page this see the prerequisites. |
| [in] | pid | Page ID of the requested page to be fixed (or buffer pool index with swizzledPIDBit set when swizzled). |
| [in] | latchMode | The wanted latch mode for the page that should be fixed (only latch_mode_t::LATCH_SH and latch_mode_t::LATCH_EX are allowed here). |
| [in] | conditional | Whether the fix is conditional (returns immediately even if failed). |
| [in] | virgin | Whether the page is a new page thus does not have to be read from disk. |
| [in] | onlyIfHit | The fix is only performed if the requested page is already buffered in this buffer pool (i.e., a page hit occurs) |
| [in] | doRecovery | Whether recovery should be enabled for this page. |
| [in] | emlsn | The EMLSN of the requested page. |
onlyIfHit is set and it is a page miss false , else true . | w_rc_t BufferPool::fixNonRootOldStyleExceptions | ( | generic_page *& | targetPage, |
| generic_page * | parentPage, | ||
| PageID | pid, | ||
| latch_mode_t | latchMode, | ||
| bool | conditional = false, |
||
| bool | virgin = false, |
||
| bool | onlyIfHit = false, |
||
| bool | doRecovery = true, |
||
| lsn_t | emlsn = lsn_t::null |
||
| ) |
| zero::buffer_pool::BufferPool::fixRoot | ( | generic_page *& | targetPage, |
| StoreID | store, | ||
| latch_mode_t | latchMode, | ||
| bool | conditional, | ||
| bool | virgin | ||
| ) |
Fixes a root B-Tree page in this buffer pool.
Fixes an existing (not virgin) root B-Tree page of a given store in this buffer pool.
targetPage pointer points to the page which should have been fixed and it is latched in the wanted mode.| [out] | targetPage | This page should contain the fixed page. |
| [in] | store | Store ID of the store whose root B-Tree page is requested to be fixed. |
| [in] | latchMode | The wanted latch mode for the page that should be fixed (only latch_mode_t::LATCH_SH and latch_mode_t::LATCH_EX are allowed here). |
| [in] | conditional | Whether the fix is conditional (returns immediately even if failed). |
| [in] | virgin | Whether the page is a new page thus does not have to be read from disk. |
| w_rc_t BufferPool::fixRootOldStyleExceptions | ( | generic_page *& | targetPage, |
| StoreID | store, | ||
| latch_mode_t | latchMode, | ||
| bool | conditional, | ||
| bool | virgin | ||
| ) |
|
noexcept |
Creates a fuzzy checkpoint for this buffer pool.
Adds the information required for a fuzzy checkpoint of this buffer pool to the given checkpoint. A fuzzy checkpoint of this buffer pool contains all the page IDs of potentially dirty pages buffered in this buffer pool together with their LSNs.
checkpoint contains a fuzzy checkpoint of this buffer pool.| [in,out] | checkpoint | A fuzzy checkpoint. |
|
inlinenoexcept |
Number of buffer frames of this buffer pool.
|
inlinenoexcept |
Returns the control block corresponding to a buffer pool index.
Returns the control block which corresponds to the buffer frame at the given buffer pool index. Due to the allocation scheme used in _controlBlocks , it is not trivial (but possible in constant time) to find the requested control block.
| index | A buffer pool index corresponding to a buffer frame of this buffer pool. |
|
inlinenoexcept |
Returns the control block corresponding to a buffer pool index. noexcept
Returns the control block which corresponds to the buffer frame at the given buffer pool index. Due to the allocation scheme used in _controlBlocks , it is not trivial (but possible in constant time) to find the requested control block.
| index | A buffer pool index corresponding to a buffer frame of this buffer pool. |
|
inlinenoexcept |
Returns the control block corresponding to a buffered page.
Returns the control block which corresponds to the buffer frame of a given buffered page. Due to the allocation scheme used in _controlBlocks , it is not trivial (but possible in constant time) to find the requested control block.
| page | A page buffered in this buffer pool. |
page is not buffered in this buffer pool!
|
inlinenoexcept |
Returns the free list of this buffer pool.
|
inlinenoexcept |
Returns the hashtable of this buffer pool.
|
inlinenoexcept |
The buffer pool index of a control block.
Returns the buffer pool index to which the given control block corresponds to.
| controlBlock | A control block of this buffer pool. |
controlBlock corresponds to.
|
inlinenoexcept |
The buffer pool index of a buffered page.
Returns the buffer pool index in which the given buffered page is buffered in.
| page | A page buffered in this buffer pool. |
page is buffered in.
|
inlinenoexcept |
MG TODO.
MG TODO
|
inlinenoexcept |
A buffered page at a buffer pool index.
Returns the page which is buffered at a given buffer pool index in this buffer pool.
| index | A buffer index of this buffer pool. |
index .
|
inlinenoexcept |
A buffered page at a buffer pool index. noexcept
Returns the page which is buffered at a given buffer pool index in this buffer pool.
| index | A buffer index of this buffer pool. |
index .
|
inlinenoexcept |
Returns the page cleaner of this buffer pool.
|
noexcept |
Returns the page evictioner of this buffer pool.
|
inlinenoexcept |
The buffer pool index of a buffered B-Tree root page.
Returns the buffer pool index in which a B-Tree root page specified by its Store ID is buffered in.
| store | The Store ID of the requested B-Tree root page. |
0 if it is currently not buffered in this buffer pool. | zero::buffer_pool::BufferPool::hasDirtyFrames | ( | ) |
Whether this buffer pool has dirty buffer frames.
Checks each frame of the buffer pool whether it contains a page and whether this page is dirty inside the buffer pool frame. In NoDB mode, pages cannot be dirty.
true if this buffer pool contains dirty buffer frames, false else.
|
inlinenoexcept |
Checks whether a buffer pool frame is used in this buffer pool.
Whether the given buffer pool index is in the range of valid buffer pool indexes of this buffer pool (0 is invalid and too large indexes are invalid, too) and whether it is occupied by a page.
| index | The buffer pool index to be checked. |
index is a valid buffer pool index in this buffer pool and whether a page is buffered in the corresponding buffer frame.
|
noexcept |
Check if a page can be evicted.
The following conditions make a page unevictable:
== false).== page_tag_t::t_stnode_p).== page_tag_t::t_btree_p && generic_page_h::pid() == btree_page_h::root()).&& generic_page_h::tag() == page_tag_t::t_btree_p && ! btree_page_h::is_leaf() ).&& generic_page_h::tag() == page_tag_t::t_btree_p && btree_page_h::get_foster()) != 0).( doFlushIfDirty || _noDBMode || _useWriteElision ) && bf_tree_cb_t::is_dirty())! bf_tree_cb_t::_used ).! bf_tree_cb_t::_pin_cnt != 0).indexToCheck is latched in latch_mode_t::LATCH_SH or latch_mode_t::LATCH_EX mode by this thread.| indexToCheck | The index of the buffer frame that is supposed to be freed by evicting the contained page. |
| doFlushIfDirty | true if the page gets flushed during the eviction, false else. |
true if the page could be evicted, false else.
|
inlinenoexcept |
|
inlinenoexcept |
MG TODO.
MG TODO
| pid | MG TODO |
|
inlinenoexcept |
Whether this buffer pool is in NoDB mode.
true if this buffer pool is in NoDB mode (_noDBMode ), false else.
|
inlinenoexcept |
Checks the validity of a buffer pool index in this buffer pool.
Whether the given buffer pool index is in the range of valid buffer pool indexes of this buffer pool (0 is invalid and too large indexes are invalid, too).
| index | The buffer pool index to be checked. |
index is a valid buffer pool index in this buffer pool.
|
inlinenoexcept |
Return whether this buffer pool is already "warmed up".
Returns whether this buffer pool is already "warmed up". Further details on the meaning of "warmed up" can be found at _checkWarmupDone() .
|
inlinenoexcept |
Normalize a page ID.
Normalizes the given page ID to an actual page ID (for vol_t ). If the page ID is a buffer pool index (in case of swizzling) then it returns the page ID of the page on disk, otherwise it returns the page ID as it is.
| pid | The page ID to normalize. |
| zero::buffer_pool::BufferPool::pinForRefix | ( | const generic_page * | pinPage | ) |
Pin a page for a cheaper re-fix.
Adds an additional pin count for the given pinPage . This is used to re-fix the page later without parent pointer. See refixDirect(generic_page*& targetPage, bf_idx refixIndex, latch_mode_t latchMode, bool conditional) why we need this feature.
pinPage is already latched by this thread. | [in] | pinPage | The page that is currently latched and will be re-fixed later. |
pinPage in this buffer pool. Use this value for the subsequent calls to refixDirect(generic_page*& targetPage, bf_idx refixIndex, latch_mode_t latchMode, bool conditional) and unpinForRefix(bf_idx unpinIndex) .pinPage will be in this buffer pool forever. | void zero::buffer_pool::BufferPool::postInitialize | ( | ) |
Completes the initialization of this buffer pool.
Completes the initialization of this buffer pool which was started during its construction.
|
noexcept |
Recover buffered page if needed.
Recovers a page—buffered in this buffer pool—if needed using the _localSprIter . It is not needed when recovery is disabled in general or when it is disabled for the particular page. It is possibly needed when it is explicitly requested (onlyIfTrue == false ) or when the page is dirty.
true .| controlBlock | The control block of the page to recover if needed. |
| page | The buffered page to recover if needed. |
| onlyIfDirty | Whether the page should be recovered even though it is not dirty. |
| zero::buffer_pool::BufferPool::refixDirect | ( | generic_page *& | targetPage, |
| bf_idx | refixIndex, | ||
| latch_mode_t | latchMode, | ||
| bool | conditional | ||
| ) |
Re-fix a pinned page.
Re-fixes a page without the parent pointer which was pinned for refix (pinForRefix(const generic_page* pinPage) ) before.
| [out] | targetPage | This page should contain the re-fixed page. |
| [in] | refixIndex | Buffer pool index of the requested page to be re-fixed. |
| [in] | latchMode | The wanted latch mode for the page that should be re-fixed (only latch_mode_t::LATCH_SH and latch_mode_t::LATCH_EX are allowed here). |
| [in] | conditional | Whether the re-fix is conditional (returns immediately even if failed). |
| w_rc_t BufferPool::refixDirectOldSytleExceptions | ( | generic_page *& | targetPage, |
| bf_idx | refixIndex, | ||
| latch_mode_t | latchMode, | ||
| bool | conditional | ||
| ) |
|
noexcept |
MG TODO.
MG TODO
| void zero::buffer_pool::BufferPool::shutdown | ( | ) |
Shuts down this buffer pool.
Stops the threads forked by this buffer pool to allow destruction without leaving those threads running.
|
noexcept |
Switch the parent page of a buffered B-Tree page in this buffer pool.
For each buffered non-root B-Tree page, the buffer pool also stores the buffer pool index of the buffer frame where the corresponding parent page is buffered. Therefore, this information needs to be updated once the parent page of such a page is changed. That is what this function does.
| childPID | The page ID of the B-Tree page whose parent is switched. |
| newParentPage | The new parent page. |
| zero::buffer_pool::BufferPool::sxUpdateChildEMLSN | ( | btree_page_h & | parentPage, |
| general_recordid_t | childSlotID, | ||
| lsn_t | childEMLSN | ||
| ) | const |
Update the EMLSN of a B-Tree child inside its parent page.
Sets the EMLSN of a B-Tree child in the corresponding slot of its parent page. This uses a system transaction for the purpose.
| parentPage | The parent page buffered in this buffer pool. |
| childSlotID | The corresponding slot ID of the child within parentPage . |
| childEMLSN | The new EMLSN of the child page requested to be written in the parent page. |
| zero::buffer_pool::BufferPool::unfix | ( | const generic_page * | unfixPage, |
| bool | evict = false |
||
| ) |
Unfixes a page in this buffer pool.
Unfixes the given page in this buffer pool by releasing its latch, and, if requested, evicting the page.
| [in] | unfixPage | The page that should be unfixed. |
| [in] | evict | Whether the unfixed page should be explicitly evicted if possible. |
| zero::buffer_pool::BufferPool::unpinForRefix | ( | bf_idx | unpinIndex | ) |
Unpin a page for re-fix.
Removes the additional pin count added by the call to pinForRefix(const generic_page* pinPage) from the buffer frame corresponding to the given buffer frame index.
| [in] | unpinIndex | Buffer pool index of the page to be unpin for refix. |
|
noexcept |
MG TODO.
MG TODO
MG TODO
| zero::buffer_pool::BufferPool::unswizzlePagePointer | ( | generic_page * | parentPage, |
| general_recordid_t | childSlotInParentPage, | ||
| PageID * | childPageID = nullptr |
||
| ) |
Unswizzle a page pointer in a page's parent page.
Tries to unswizzle the given child page (childSlotInParentPage ) from the parent page (parentPage ). If, for some reason, unswizzling was impossible or troublesome, gives up and returns false .
| [in] | parentPage | The parent page where to unswizzle the child page. |
| [in] | childSlotInParentPage | The slot within the parent page where to find the swizzled pointer to the child page. |
| [in,out] | childPageID | If it wasn't set to the nullptr, the unswizzled PageID of the child page is returned. |
false if the unswizzling was not successful, else true.
|
noexcept |
Upgrade the latch of a page.
Upgrade this thread holding the latch of a page in latch_mode_t::LATCH_SH to one holding the latch in latch_mode_t::LATCH_EX without waiting.
| page | The latch corresponding to this page should be upgraded. |
true, else false .
|
inlinenoexcept |
Whether this buffer pool uses write elision.
true if this buffer pool uses write elision (_useWriteElision ), false else.
|
inline |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
private |
Use a dedicated thread for eviction.
Set if a dedicated thread should be used for page eviction. If a dedicated thread is used, threads encountering a full buffer pool wakeup this page eviction thread and wait until there is a buffer index of an unoccupied buffer frame available for them in the _freeList . If no dedicated thread is used, the first thread encountering a full buffer pool runs the eviction before it continues with its transaction.
|
private |
MG TODO.
MG TODO
|
private |
MG TODO.
MG TODO
|
private |
MG TODO.
MG TODO
|
private |
Maximum number of pages in this buffer pool.
Number of buffer pool frames available to hold pages in this buffer pool.
|
private |
Array of buffered pages.
A C-array containing up to _blockCount buffered pages, each in a buffer pool frame of this buffer pool. The array index represents the buffer frame index.
|
private |
Cleans dirty pages.
This is responsible to clean dirty pages (write-back changed pages) buffered in this buffer pool.
|
private |
Use log-based "decoupled" cleaner.
Set if the log-based "decoupled" cleaner should be used instead of one that is based on data from the buffer pool.
|
private |
Array of control blocks.
A C-array containing _blockCount control blocks, one for each buffer pool frame of this buffer pool. The array index represents the buffer frame index.
|
private |
Evicts pages.
This is responsible to evict buffered pages from this buffer pool once there are (almost) no more unoccupied buffer frames in this buffer pool while currently not buffered pages should be added to this buffer pool.
|
staticprivate |
MG TODO.
MG TODO
|
private |
List of unused buffer frames.
A queue containing the indexes of currently unoccupied buffer frames of this buffer pool.
|
private |
|
staticprivate |
MG TODO.
MG TODO
|
private |
Use instant restore.
Set if instant restore should be used by this buffer pool. MG TODO
|
staticprivate |
|
private |
Log page fetches.
Set if page fetches from database or from the used recovery mechansim should be logged in the transactional log using log entries of type fetch_page_log .
|
private |
Maintain EMLSN of B-Tree pages.
MG TODO
|
private |
MG TODO.
MG TODO
|
private |
Use NoDB.
Set if this buffer pool should be used for NoDB. MG TODO
|
private |
MG TODO.
MG TODO
|
private |
Buffer indexes of root pages.
This holds for each stnode_t the buffer index of its root page or 0 if it is currently not buffered in this buffer pool.
|
private |
Use write elision.
Set if write elision should be used by this buffer pool. With write elision, a page can be evicted from the buffer pool even though it is dirty because once the page is read again, the changes are retrieved from the log.
|
private |
MG TODO.
MG TODO
|
private |
Hit rate of a "warm" buffer pool.
At least this hit rate needs to be achieved by this buffer pool to be considered warm.
|
private |
Minimum number of fixes of a "warm" buffer pool.
At least this many page fixes need to be performed by this buffer pool to be considered warm.
1.8.12