Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1ioqrN-0001NX-Fw for pgsql-bugs@arkaria.postgresql.org; Tue, 07 Jan 2020 15:33:33 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1ioqrM-0001NP-7S for pgsql-bugs@arkaria.postgresql.org; Tue, 07 Jan 2020 15:33:32 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1ioqrL-0001Kq-S5 for pgsql-bugs@lists.postgresql.org; Tue, 07 Jan 2020 15:33:32 +0000 Received: from mail-lf1-f65.google.com ([209.85.167.65]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1ioqrH-0001iy-CS for pgsql-bugs@lists.postgresql.org; Tue, 07 Jan 2020 15:33:30 +0000 Received: by mail-lf1-f65.google.com with SMTP id n25so48931lfl.0 for ; Tue, 07 Jan 2020 07:33:27 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=gjc9kci+3KIyhSfmzDA+SeI/iOADe0AF9Om6HtRvQkI=; b=eMtDTM3kYktb1gTGsTcIn0JHPiEw1xx0YopqIefK6DLZpI7sVxLcWeSDJzV8J6BxpO 8HlqPW8D4dY87VzJDCZC4u7aiOksbmhlvkUzm+KLqnPFeGVs7nNanUIvazRE+UVs5fB9 rBBfORVLoDmNYcO45bkGWexwJ7fI775O7Mw6K/tA2FvLdyOKXZrL0zrDRp1YqA1CNU50 LXzMNznYPqUlm49PiOJq16b/DRV1McO7pw3didNSq50WBIIYNzTUoGBP3InR/Dm0t3Xz OvgTIsRQqGzasadlkuoThT3+T/nKeacD1/pYKNNKkxbt/j9XmWSso+2s0HwYQ5ztsVqy BdFw== X-Gm-Message-State: APjAAAU9xl8wv6U9fOp0fDj6KJwcYmTfrbhCJ6RZaETPo2qkWAacZ8vx 4yO629/PFv60dycVTi15OepznyLt X-Google-Smtp-Source: APXvYqyMci963SxcQUu73awf7XC3ADqjVDESIjTNViRUwpUbgrupwkxMAU+7CXjdueME18MAM6W8pA== X-Received: by 2002:a05:6512:48c:: with SMTP id v12mr62557lfq.56.1578411205305; Tue, 07 Jan 2020 07:33:25 -0800 (PST) Received: from [192.168.1.10] (dsl-hkibng22-54f980-150.dhcp.inet.fi. [84.249.128.150]) by smtp.gmail.com with ESMTPSA id x84sm9648lfa.97.2020.01.07.07.33.23 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 07 Jan 2020 07:33:24 -0800 (PST) Subject: Re: REINDEX CONCURRENTLY unexpectedly fails To: Michael Paquier , Andres Freund Cc: Tom Lane , Manuel Rigger , PostgreSQL mailing lists References: <20191114080855.GG1910@paquier.xyz> <3808.1573754033@sss.pgh.pa.us> <20191115024512.GE1849@paquier.xyz> <20191115025412.p3beiflrd6bx6wgf@alap3.anarazel.de> <20191115032141.GH1849@paquier.xyz> <20191115080706.GI1849@paquier.xyz> <20191120013649.2xfr2dnznyjgluch@alap3.anarazel.de> <20191120035408.GA4243@paquier.xyz> <20191212213709.neopqccvdo724eha@alap3.anarazel.de> <20191213034536.GD1942@paquier.xyz> <20191223015956.GB34339@paquier.xyz> From: Heikki Linnakangas Message-ID: <8f0bde7b-2d96-fb5c-cd0e-553694c1d376@iki.fi> Date: Tue, 7 Jan 2020 17:33:23 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.3.0 MIME-Version: 1.0 In-Reply-To: <20191223015956.GB34339@paquier.xyz> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 23/12/2019 03:59, Michael Paquier wrote: > +/* > + * RelationSupportsConcurrentIndexing > + * > + * Check if a relation supports concurrent builds or not. This is > + * used as a sanity check prior processing CREATE INDEX, DROP INDEX > + * or REINDEX when using CONCURRENTLY. > + */ > +bool > +RelationSupportsConcurrentIndexing(char relpersistence) > +{ > + /* > + * Build indexes non-concurrently for temporary relations. Such > + * relations only work with the session assigned to them, so they are > + * not subject to concurrent concerns, and a concurrent build would > + * cause issues with ON COMMIT actions triggered by the transactions > + * of the concurrent build. A non-concurrent reindex is also more > + * efficient in this case. > + */ > + if (relpersistence == RELPERSISTENCE_TEMP) > + return false; > + > + return true; > +} > + The comment says "this is used as a sanity check". "Sanity check" implies that it should never happen, but it is perfectly normal for it to return false. The caller in DefineIndex() calls RelationSupportsConcurrentIndexing() only after choosing the lock mode. That's fine for temporary tables, but if wouldn't work right if RelationSupportsConcurrentIndexing() started to return false for some other tables. Maybe it would be clearer to just check "relpersistence == RELPERSISTENCE_TEMP" directly in the callers, and not have the RelationSupportsConcurrentIndexing() function. The new text in drop_index.sgml talks about index creation, copy-pasted from create_index.sgml. - Heikki