Re: GIN non-intrusive vacuum of posting tree

From: Andrew Borodin <borodin(at)octonica(dot)com>
To: Vladimir Borodin <root(at)simply(dot)name>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>, Евгений Ефимкин <efimkin(at)yandex-team(dot)ru>, Teodor Sigaev <teodor(at)postgrespro(dot)ru>
Subject: Re: GIN non-intrusive vacuum of posting tree
Date: 2016-11-30 16:38:54
Message-ID: CAJEAwVE4UAmm8fr+NW8XTnKV6M--ACoNhL3ES8yoKL2sKhbaiw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Here is v1 of the patch. Now it has changes for README and contains
more comments clarifying changes of locking model.

Also I will elaborate some more on what is patched. Main portion of
changes is made to function ginVacuumPostingTreeLeaves(). Before the
patch it was traversing tree in depth-first fashion, acquiring
exclusive lock on each page and removing dead tuples from leafs. Also
this function used to hold cleanup lock. Now this function is doing
same DFS, but without cleanup lock, acquiring only read locks on inner
pages and exclusive lock on leafs before eliminating dead tuples. If
this function finds empty leafs, it computes minimal subtree,
containing only empty pages and start scan for empty pages from parent
page pointing to found subtree.

This scan acquires cleanup lock on root of scan (not necessarily root
of posting tree). Cleanup lock ensures no inserts are inside subtree.
Scan traverses subtree DF taking exclusive locks from left to right.
For any page being deleted all leftmost pages were locked and unlocked
before. New reads cannot enter subtree, all old readscans were
excluded by lock\unlock. Thus there shall not be deadlocks with
ginStepRight().

We get lock on page being deleted, then on a left page.
ginStepRight() takes lock on left page, than on right page. But it’s
presence is excluded by cleanup lock and DFS scan with locks of upper
and left parts of tree.

Thank you for reading this. Concurrency bothers me a lot. If you see
that anything is wrong or suspicious, please do not hesitate to post
your thoughts.

Best regards, Andrey Borodin.

Attachment Content-Type Size
gin_nonintrusive_vacuum_v1.diff text/plain 11.2 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2016-11-30 17:30:09 Re: Re: [COMMITTERS] pgsql: Build HTML documentation using XSLT stylesheets by default
Previous Message xu jian 2016-11-30 16:33:06 postgres 1 个(共 2 个) can pg 9.6 vacuum freeze skip page on index?