hazard pointer in Wired Tiger

150 views
Skip to first unread message

Alex

unread,
Jul 3, 2019, 8:21:58 PM7/3/19
to wiredtiger-users
I recently leant the hazard pointer algorithm and then check how does WT use them.  

In a normal (as many articles),  during the write path,  there is a copy-on-update and use a retired-list to record the old copies so that they can be scanned and reclaim later. 

But I didn't see it in WT source code.    does it has something with in-place update in memory?   if so,  what is look like before the in-place update?   any function in source code would be better.  


thanks

Alex

unread,
Jul 3, 2019, 9:00:50 PM7/3/19
to wiredtiger-users
and another questions is:  suppose 1 session can access 1 page at most at the same time,  but I see the HP list is initialized to 250 and may be increase later.    why it is necessary? Per my understand it just need be a 1 size array and no need to grow. 

Keith Bostic

unread,
Jul 3, 2019, 9:15:50 PM7/3/19
to wiredtiger-users


On Wednesday, July 3, 2019 at 5:21:58 PM UTC-7, Alex wrote:
I recently leant the hazard pointer algorithm and then check how does WT use them.  

In a normal (as many articles),  during the write path,  there is a copy-on-update and use a retired-list to record the old copies so that they can be scanned and reclaim later.

WiredTiger uses hazard pointers for page eviction, not for the purpose of reference counting memory chunks. (In summary, worker threads acquire hazard pointers on pages in order to access them, and the eviction manager reviews the list of hazard pointers to ensure a page can be safely evicted.)

The WiredTiger hazard pointer functions are in the src/support/hazard.c source file: https://github.com/wiredtiger/wiredtiger/blob/master/src/support/hazard.c.

Keith Bostic

unread,
Jul 3, 2019, 9:17:26 PM7/3/19
to wiredtiger-users


On Wednesday, July 3, 2019 at 6:00:50 PM UTC-7, Alex wrote:
and another questions is:  suppose 1 session can access 1 page at most at the same time,  but I see the HP list is initialized to 250 and may be increase later.    why it is necessary? Per my understand it just need be a 1 size array and no need to grow. 

A session can have any number of open cursors, an open cursor can access multiple pages at a time, and the cursor will need a hazard pointer on each of those pages to ensure the page is not evicted out from under it.

Alex

unread,
Jul 3, 2019, 9:26:36 PM7/3/19
to wiredtiger-users
Thanks. 

> an open cursor can access multiple pages at a time
1.  in which case it can access more than 1 page?
Reply all
Reply to author
Forward
0 new messages