Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1ZLHHm-0006pY-6A for pgsql-hackers@arkaria.postgresql.org; Fri, 31 Jul 2015 20:52:10 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1ZLHHl-0007DF-N1 for pgsql-hackers@arkaria.postgresql.org; Fri, 31 Jul 2015 20:52:09 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1ZLHHi-0007Bm-OK for pgsql-hackers@postgresql.org; Fri, 31 Jul 2015 20:52:06 +0000 Received: from smtp-auth.no-ip.com ([8.23.224.61] helo=out.smtp-auth.no-ip.com) by magus.postgresql.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84) (envelope-from ) id 1ZLHHd-0003eS-0R for pgsql-hackers@postgresql.org; Fri, 31 Jul 2015 20:52:05 +0000 X-No-IP: alvh.no-ip.org@noip-smtp X-Report-Spam-To: abuse@no-ip.com Received: from alvin.alvh.no-ip.org (unknown [186.37.24.123]) (Authenticated sender: alvh.no-ip.org@noip-smtp) by smtp-auth.no-ip.com (Postfix) with ESMTPA id 71A024009CA; Fri, 31 Jul 2015 13:51:53 -0700 (PDT) Received: by alvin.alvh.no-ip.org (Postfix, from userid 1000) id 3D10288C; Fri, 31 Jul 2015 17:51:51 -0300 (CLT) Date: Fri, 31 Jul 2015 17:51:51 -0300 From: Alvaro Herrera To: Kevin Grittner Cc: PostgreSQL-development Subject: Re: brin index vacuum versus transaction snapshots Message-ID: <20150731205151.GD2441@postgresql.org> References: <20150731194524.GB2441@postgresql.org> <64199124.3265995.1438374075160.JavaMail.yahoo@mail.yahoo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <64199124.3265995.1438374075160.JavaMail.yahoo@mail.yahoo.com> User-Agent: Mutt/1.5.23 (2014-03-12) X-Pg-Spam-Score: -2.6 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org Kevin Grittner wrote: > Alvaro Herrera wrote: > > >> I think the real solution to this problem is to avoid use of > >> GetTransactionSnapshot(), and instead use GetLatestSnapshot(). As far > >> as I can see, that should completely close the hole. This requires > >> patching IndexBuildHeapRangeScan() to allow for that. > > > > Actually I think there's another problem: if a transaction starts and > > inserts a tuple into the page range, then goes to sleep, and then > > another session does the summarization of the page range, session 1 is > > seen as "in progress" by session 2 (so the scan does not see the new > > tuple), but the placeholder tuple was not modified either because it was > > inserted later than the snapshot. So the update is lost. > > > > I think the only way to close this hole is to have summarize_range() > > sleep until all open snapshots are gone after inserting the placeholder > > tuple and before acquiring the snapshot, similarly to how CREATE INDEX > > CONCURRENTLY does it. > > Please excuse my naiveté on the topic, but could you explain (or > point me to the documented explanation) of why we don't scan using > a non-MVCC snapshot and build the page range based on all non-dead > tuples? Because I don't know of any mechanism to lock insertion into the block range while the scan takes place. If you can suggest something workable, that might be better than what I'm proposing. Note that in my proposal, we would have to wait for all snapshots to go away *for every page range*, which seems very troublesome. A better answer might be to insert all placeholder tuples first, then wait for concurrent snapshots to go away, then do each scan. But this is a larger rework of code. > I understand that the range being scanned would need to be > locked, but we're OK with doing that for creation of other indexes. That might be so, but this is not index creation; it's not acceptable to lock the table during vacuuming. Do we have anything with finer granularity than locking the entire table? (I don't think holding buffer lock on all the pages in the range is acceptable.) > (There is no mention of snapshots or locks in the BRIN README....) Um. -- Álvaro Herrera http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers