Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fAxDK-0004V7-V2 for pgsql-bugs@arkaria.postgresql.org; Tue, 24 Apr 2018 12:38:31 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fAxDJ-0005je-IX for pgsql-bugs@arkaria.postgresql.org; Tue, 24 Apr 2018 12:38:29 +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.89) (envelope-from ) id 1fAxDJ-0005jP-8g for pgsql-bugs@lists.postgresql.org; Tue, 24 Apr 2018 12:38:29 +0000 Received: from forward4p.cmail.yandex.net ([77.88.31.19]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fAxDA-00053Q-Is for pgsql-bugs@lists.postgresql.org; Tue, 24 Apr 2018 12:38:28 +0000 Received: from mxback5o.mail.yandex.net (mxback5o.mail.yandex.net [IPv6:2a02:6b8:0:1a2d::1f]) by forward4p.cmail.yandex.net (Yandex) with ESMTP id 6FA8620E6E; Tue, 24 Apr 2018 15:38:17 +0300 (MSK) Received: from localhost (localhost [::1]) by mxback5o.mail.yandex.net (nwsmtp/Yandex) with ESMTP id yk6j6lK7Fu-cGKCdtum; Tue, 24 Apr 2018 15:38:16 +0300 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zsrv.org; s=mail; t=1524573496; bh=eyGf9hqcreB+MKhhWJy4Q4mB58gFEo5gNkqETuSnMTM=; h=From:To:In-Reply-To:References:Subject:Message-Id:Date; b=sePTTOfN4HS5V+p+fz1+exio6WsZeHdI+uJhABlZpOd+PBBVWbI51/1XPpJwRaokb BEXp56fc6Hfh9cgdniFyiQzXsWUAmvdyYJSSjIaMDbRegzHFgyU7+QuUWALnGTQYxj /CkiApVqXHM2oltPnzemqvb2uBZ2Z9QekhBlohb4= Authentication-Results: mxback5o.mail.yandex.net; dkim=pass header.i=@zsrv.org Received: by web23g.yandex.ru with HTTP; Tue, 24 Apr 2018 15:38:16 +0300 From: Sergei Kornilov To: "digoal@126.com" , "pgsql-bugs@lists.postgresql.org" In-Reply-To: <152457298745.19804.5702434604866048036@wrigleys.postgresql.org> References: <152457298745.19804.5702434604866048036@wrigleys.postgresql.org> Subject: Re: BUG #15169: create index CONCURRENTLY conflict with other table's COPY MIME-Version: 1.0 Message-Id: <1204731524573496@web23g.yandex.ru> X-Mailer: Yamail [ http://yandex.ru ] 5.0 Date: Tue, 24 Apr 2018 15:38:16 +0300 Content-Transfer-Encoding: 7bit Content-Type: text/plain List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hello This works as documented: https://www.postgresql.org/docs/current/static/sql-createindex.html#SQL-CREATEINDEX-CONCURRENTLY > PostgreSQL must perform two scans of the table, and in addition it must wait for all existing transactions that could potentially modify or use the index to terminate > Before each table scan, the index build must wait for existing transactions that have modified the table to terminate. After the second scan, the index build must wait for any transactions that have a snapshot (see Chapter 13) predating the second scan to terminate. Then finally the index can be marked ready for use, and the CREATE INDEX command terminates So create index concurrently waiting your transaction. regards, Sergei