Hi! On Wed, Aug 9, 2017 at 6:30 PM, Shubham Barai <shubhambara...@gmail.com> wrote:
> Please find the updated patch for predicate locking in gin index here. > > There was a small issue in the previous patch. I didn't consider the case > where only root page exists in the tree, and there is a predicate lock on > it, > and it gets split. > > If we treat the original page as a left page and create a new root and > right > page, then we just need to copy a predicate lock from the left to the > right > page (this is the case in B-tree). > > But if we treat the original page as a root and create a new left and right > page, then we need to copy a predicate lock on both new pages (in the case > of rum and gin). > > link to updated code and tests: https://github.com/ > shubhambaraiss/postgres/commit/6172639a104785f051cb4aa0d511c58f2bae65a6 > I've assigned to review this patch. First of all I'd like to understand general idea of this patch. As I get, you're placing predicate locks to both entry tree leaf pages and posting tree leaf pages. But, GIN implements so called "fast scan" technique which allows it to skip some leaf pages of posting tree when these pages are guaranteed to not contain matching item pointers. Wherein the particular order of posting list scan and skip depends of their estimated size (so it's a kind of coincidence). But thinking about this more generally, I found that proposed locking scheme is redundant. Currently when entry has posting tree, you're locking both: 1) entry tree leaf page containing pointer to posting tree, 2) leaf pages of corresponding posting tree. Therefore conflicting transactions accessing same entry would anyway conflict while accessing the same entry tree leaf page. So, there is no necessity to lock posting tree leaf pages at all. Alternatively, if entry has posting tree, you can skip locking entry tree leaf page and lock posting tree leaf pages instead. ------ Alexander Korotkov Postgres Professional: http://www.postgrespro.com The Russian Postgres Company