Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fdc0T-0006Ef-Jw for pgsql-hackers@arkaria.postgresql.org; Thu, 12 Jul 2018 13:51:41 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fdc0R-0007PI-Ph for pgsql-hackers@arkaria.postgresql.org; Thu, 12 Jul 2018 13:51:39 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fdc0R-0007PB-FL for pgsql-hackers@lists.postgresql.org; Thu, 12 Jul 2018 13:51:39 +0000 Received: from mail-qk0-x241.google.com ([2607:f8b0:400d:c09::241]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1fdc0O-000250-7d for pgsql-hackers@postgresql.org; Thu, 12 Jul 2018 13:51:37 +0000 Received: by mail-qk0-x241.google.com with SMTP id o2-v6so15417033qkc.13 for ; Thu, 12 Jul 2018 06:51:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=from:subject:to:cc:references:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding:content-language; bh=DUuzbKH/8B1dCUm6cA9GbkQ8Z0rV0QAsQFGCPge9+ac=; b=KFVirY+SGOf9K68QgZ/mZJlI2i94wyk+d3sBRVtxc8/hf0wobre/Lz/VJmjO44r+dF XR1Mv7fNVJovNX+WIcpRSxMhMUx9cpcz1j/BuRT1/nbtvDepHwGR41KqZ3ZJA7XxLZfl yvuLilStJI7jjPEyZD7PyyKd/7pUvNyA8FM7tePzgGtFKdUKpEwVftMBw8iLk2smkAyB N4s9SblOdlUoB2rens5PalL04xku0HhYvVj1LaH3eGYBv1q8i0XrDXmipvlLfwHNB0t6 LBhAYCtuoZxHC234nLZrsWVtvJhqglj3UJRxmzN477jZDUf7WmVk3W+/v+1bRp9zUkcB vYpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:subject:to:cc:references:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=DUuzbKH/8B1dCUm6cA9GbkQ8Z0rV0QAsQFGCPge9+ac=; b=DKrni1tJSNlekqBLYUH18/Gv1PNik++39iUXVWwh9kfVJzy1xFaiN18haG0SbZkX+x NzW8u8PJeG0GmJaz7UYU22rCYEGYhtvk7pGB3cbRrbxKjSO6lCHw/EVBvI7UiQ1I1xRO syKeZJYMfpRDSdNFnKOiH16sGLAkHbHh7/GZvZb+STdxFEQ2AHS3diBstMW4FMAs5kq+ W3VGHyy/Wlhjtr/nwEEZE1Sl0p3f7GgORpIutn/sEP0whEocsURoWI7bWZg/aQL8d6do vOGiTZ0tmqfYdWhjfUwD2SiqVlUU6U1w1SQBp6q5vR4c+gywRbGRkke8BAPOg2Bkj+MX dObA== X-Gm-Message-State: AOUpUlG9VkwEijIUqS63w8f2oNeV1xTmMvbjBaHYwaNCIY9eZrZ0wWd2 2S1bHeCGt1BOuGcuBE/Ta7t/mr5/ryBO/gKXq7EcFEylXLSnza5EoooCSktVXwxgbJbo2+0O+EV l8SR5Rwkg9rhIrDQNFDd82WKIiuox9ZkEIFXw2S2QSGPTS/nCGfGdrC8QNrfRH5JwaND2zbE+D1 j3kLBGqmydAxZh X-Google-Smtp-Source: AAOMgpdfDFhuYR3vFuWf4IcpLuTsJbLXZTeVQj+5RxBdhYGlrLQXaQ0CCYNnFWT7TIMSTgFsb2uiVQ== X-Received: by 2002:a37:bb43:: with SMTP id l64-v6mr1825631qkf.414.1531403495155; Thu, 12 Jul 2018 06:51:35 -0700 (PDT) Received: from [192.168.10.146] ([98.122.175.38]) by smtp.gmail.com with ESMTPSA id t6-v6sm1727639qkh.30.2018.07.12.06.51.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 12 Jul 2018 06:51:34 -0700 (PDT) From: Andrew Dunstan X-Google-Original-From: Andrew Dunstan Subject: Re: [HACKERS] WAL logging problem in 9.4.3? To: Michael Paquier , Heikki Linnakangas Cc: pgsql-hackers@postgresql.org References: <20171211.175424.09346818.horiguchi.kyotaro@lab.ntt.co.jp> <20180105041040.GI2416@tamriel.snowman.net> <20180111.170355.123986255.horiguchi.kyotaro@lab.ntt.co.jp> <20180330.100646.86008470.horiguchi.kyotaro@lab.ntt.co.jp> <20180704045912.GG1672@paquier.xyz> <20180711033241.GQ1661@paquier.xyz> Message-ID: Date: Thu, 12 Jul 2018 09:51:33 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: <20180711033241.GQ1661@paquier.xyz> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-MW List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 07/10/2018 11:32 PM, Michael Paquier wrote: > On Tue, Jul 10, 2018 at 05:35:58PM +0300, Heikki Linnakangas wrote: >> Thanks for picking this up! >> >> (I hope this gets through the email filters this time, sending a shell >> script seems to be difficult. I also trimmed the CC list, if that helps.) >> >> On 04/07/18 07:59, Michael Paquier wrote: >>> Hence I propose the patch attached which disables the TRUNCATE and COPY >>> optimizations for two cases, which are the ones actually causing >>> problems. One solution has been presented by Simon here for COPY, which >>> is to disable the optimization when there are no blocks on a relation >>> with wal_level = minimal: >>> https://www.postgresql.org/message-id/CANP8+jKN4V4MJEzFN_iEtdZ+1oM=YETxvmuu1YK4UMXQY2gaGw@mail.gmail.com >>> For back-patching, I find that really appealing. >> This fails in the case that there are any WAL-logged changes to the table >> while the COPY is running. That can happen at least if the table has an >> INSERT trigger, that performs operations on the same table, and the COPY >> fires the trigger. That scenario is covered by the little bash script I >> posted earlier in this thread >> (https://www.postgresql.org/message-id/55AFC302.1060805%40iki.fi). Attached >> is a new version of that script, updated to make it work with v11. > Thanks for the pointer. My tap test has been covering two out of the > three scenarios you have in your script. I have been able to convert > the extra as the attached, and I have added as well an extra test with > TRUNCATE triggers. So it seems to me that we want to disable the > optimization if any type of trigger are defined on the relation copied > to as it could be possible that these triggers work on the blocks copied > as well, for any BEFORE/AFTER and STATEMENT/ROW triggers. What do you > think? > Yeah, this seems like the only sane approach. cheers andrew -- Andrew Dunstan https://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services