Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1XpBrh-0006He-B1 for pgsql-hackers@arkaria.postgresql.org; Fri, 14 Nov 2014 08:04:21 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1XpBrg-0005UB-SH for pgsql-hackers@arkaria.postgresql.org; Fri, 14 Nov 2014 08:04:20 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1XpBrf-0005U4-Qe for pgsql-hackers@postgresql.org; Fri, 14 Nov 2014 08:04:19 +0000 Received: from mail-by2on0628.outbound.protection.outlook.com ([2a01:111:f400:fc0c::628] helo=na01-by2-obe.outbound.protection.outlook.com) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1XpBrb-0004h7-8A for pgsql-hackers@postgresql.org; Fri, 14 Nov 2014 08:04:18 +0000 Received: from decina.attlocal.net (2602:306:ce8b:3460:fd63:366:1620:e16a) by BN3PR11MB0179.namprd11.prod.outlook.com (25.160.185.17) with Microsoft SMTP Server (TLS) id 15.1.16.15; Fri, 14 Nov 2014 08:04:08 +0000 Message-ID: <5465B770.70604@BlueTreble.com> Date: Fri, 14 Nov 2014 02:04:00 -0600 From: Jim Nasby User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 MIME-Version: 1.0 To: Andres Freund , Peter Eisentraut , Robert Haas CC: Michael Paquier , Jim Nasby , PostgreSQL mailing lists Subject: Re: REINDEX CONCURRENTLY 2.0 References: <20140827064120.GZ21544@awork2.anarazel.de> <545B8AD2.8030203@gmx.net> <20141112213912.GH13473@awork2.anarazel.de> <20141113003106.GJ13473@awork2.anarazel.de> <5465215D.2060505@gmx.net> <61E955E2-61D7-45E8-BC66-F021EA0CE3CE@2ndquadrant.com> In-Reply-To: <61E955E2-61D7-45E8-BC66-F021EA0CE3CE@2ndquadrant.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [2602:306:ce8b:3460:fd63:366:1620:e16a] X-ClientProxiedBy: BLUPR80CA006.lamprd80.prod.outlook.com (10.255.252.16) To BN3PR11MB0179.namprd11.prod.outlook.com (25.160.185.17) X-Microsoft-Antispam: UriScan:; X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:;SRVR:BN3PR11MB0179; X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:;SRVR:BN3PR11MB0179; X-Forefront-PRVS: 03950F25EC X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6009001)(51704005)(51884002)(377454003)(479174003)(189002)(24454002)(199003)(51444003)(21056001)(83506001)(87976001)(50986999)(54356999)(40100003)(77156002)(107046002)(53416004)(19580395003)(69596002)(19580405001)(77096003)(46102003)(106356001)(15975445006)(105586002)(65816999)(76176999)(62966003)(120916001)(81156004)(23676002)(86362001)(31966008)(122386002)(92566001)(92726001)(64126003)(65956001)(97736003)(20776003)(47776003)(64706001)(65806001)(95666004)(42186005)(101416001)(102836001)(93886004)(4396001)(99396003)(33656002)(15202345003)(36756003)(50466002)(217873001)(85282002)(336755003)(18886065003); DIR:OUT; SFP:1101; SCL:1; SRVR:BN3PR11MB0179; H:decina.attlocal.net; FPR:; MLV:sfv; PTR:InfoNoRecords; MX:1; A:1; LANG:en; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:;SRVR:BN3PR11MB0179; X-OriginatorOrg: bluetreble.com X-Pg-Spam-Score: -0.4 (/) 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 On 11/13/14, 3:50 PM, Andres Freund wrote: > On November 13, 2014 10:23:41 PM CET, Peter Eisentraut wrote: >> On 11/12/14 7:31 PM, Andres Freund wrote: >>> Yes, it sucks. But it beats not being able to reindex a relation with >> a >>> primary key (referenced by a fkey) without waiting several hours by a >>> couple magnitudes. And that's the current situation. >> >> That's fine, but we have, for better or worse, defined CONCURRENTLY := >> does not take exclusive locks. Use a different adverb for an >> in-between >> facility. > > I think that's not actually a service to our users. They'll have to adapt their scripts and knowledge when we get around to the more concurrent version. What exactly CONCURRENTLY means is already not strictly defined and differs between the actions. It also means that if we ever found a way to get rid of the exclusive lock we'd then have an inconsistency anyway. Or we'd also create REINDEX CONCURRENT at that time, and then have 2 command syntaxes to support. > I'll note that DROP INDEX CONCURRENTLY actually already internally acquires an AEL lock. Although it's a bit harder to see the consequences of that. Having been responsible for a site where downtime was a 6 figure dollar amount per hour, I've spent a LOT of time worrying about lock problems. The really big issue here isn't grabbing an exclusive lock; it's grabbing one at some random time when no one is there to actively monitor what's happening. (If you can't handle *any* exclusive locks, that also means you can never do an ALTER TABLE ADD COLUMN either.) With that in mind, would it be possible to set this up so that the time-consuming process of building the new index file happens first, and then (optionally) some sort of DBA action is required to actually do the relfilenode swap? I realize that's not the most elegant solution, but it's WAY better than this feature not hitting 9.5 and people having to hand-code a solution. Possible syntax: REINDEX CONCURRENTLY -- Does what current patch does REINDEX CONCURRENT BUILD -- Builds new files REINDEX CONCURRENT SWAP -- Swaps new files in This suffers from the syntax problems I mentioned above, but at least this way it's all limited to one command, and it probably allows a lot more people to use it. -- Jim Nasby, Data Architect, Blue Treble Consulting Data in Trouble? Get it in Treble! http://BlueTreble.com -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers