Re: Hot standby and GiST page splits (was Re: WIP: Fast GiST index build)
От | Heikki Linnakangas |
---|---|
Тема | Re: Hot standby and GiST page splits (was Re: WIP: Fast GiST index build) |
Дата | |
Msg-id | 4E368387.5020307@enterprisedb.com обсуждение исходный текст |
Ответ на | Re: Hot standby and GiST page splits (was Re: WIP: Fast GiST index build) (Simon Riggs <simon@2ndQuadrant.com>) |
Ответы |
Re: Hot standby and GiST page splits (was Re: WIP: Fast
GiST index build)
Re: Hot standby and GiST page splits (was Re: WIP: Fast GiST index build) Re: Hot standby and GiST page splits (was Re: WIP: Fast GiST index build) |
Список | pgsql-hackers |
On 01.08.2011 13:13, Simon Riggs wrote: > On Mon, Aug 1, 2011 at 10:38 AM, Heikki Linnakangas > <heikki.linnakangas@enterprisedb.com> wrote: >> Attached is a patch for that for 9.1/master. The 9.0 GiST replay code was >> quite different, it will require a separate patch. > > Hmm, I was assured no changes would be required for Hot Standby for > GIST and GIN. Perhaps we should check GIN code also. Yeah, we probably should. > Does the order of locking of the buffers matter? I'm sure it does. Yep. > Did you want me to write the patch for 9.0? I'm looking at it now. > And what does NSN stand for? :-) Hmm, I don't know actually know what NSN is an acronym for :-). But in case you want an explanation of what it does: The NSN is field in the GiST page header, used to detect concurrent page splits. Whenever a page is split, its NSN is set to the LSN of the page split record. To be precise: the NSN of the resulting left page(s) is set, the resulting rightmost half keeps the NSN of the original page. When you scan a parent page and decide to move down, it's possible that the child page is split before you read it, but after you read the parent page. So you didn't see the downlink for the right half when you scanned the parent page. To reach the right half, you need to follow the rightlink from the left page, but first you need to detect that the page was split. To do that, when you scan the parent page you remember the LSN on the parent. When you scan the child, you compare the parent's LSN you saw with the NSN of the child. If the child's NSN > parent's LSN, the page was split after you scanned the parent, so you need to follow the rightlink. The B-tree code has similar move-right logic, but it uses the "high" key on each page to decide when it needs to move right. There's no high key on GiST pages, so we rely on the NSN for that. In 9.1, I added the F_FOLLOW_RIGHT flag to handle the case of an incomplete split correctly. If the flag is set on a page, its rightlink needs to be followed regardless of the NSN. -- Heikki Linnakangas EnterpriseDB http://www.enterprisedb.com
В списке pgsql-hackers по дате отправления: