Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bKk6j-0002Ln-Dm for pgsql-bugs@arkaria.postgresql.org; Wed, 06 Jul 2016 10:31:05 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1bKk6j-00069z-0v for pgsql-bugs@arkaria.postgresql.org; Wed, 06 Jul 2016 10:31:05 +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_2) (envelope-from ) id 1bKk6i-00069j-KV for pgsql-bugs@postgresql.org; Wed, 06 Jul 2016 10:31:04 +0000 Received: from ohmu.fi ([2001:1bc8:100:6::f301]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1bKk6f-0001II-3S for pgsql-bugs@postgresql.org; Wed, 06 Jul 2016 10:31:03 +0000 Received: from [127.0.0.1] (localhost [IPv6:::1]) by ohmu.fi (Postfix) with ESMTP id 7DEEC604BF; Wed, 6 Jul 2016 13:30:58 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aiven.io; s=ohmu20151013; t=1467801058; bh=iErum9hLoi7xZvjl6IDbhvgFHKzIrUM3aR6HFgKOz1o=; h=Subject:To:References:Cc:From:Date:In-Reply-To:From; b=e+pJqCBokPPclBlyjdhQDeR19hT6FvIBeWdEK4d5ZAIkkUP92UD05v8PKwhdgcY6H PGWw8hMOfFN0VvA6K1n2see4epFTIGb6Pg4XL34bRnv2DxoByrdMvPdzRBtE9IzCTp mHG3fIlxnDVfaP5Rnj87Kc+08kBx4JF9n5XoALB0= Subject: Re: BUG #14150: Attempted to delete invisible tuple To: Michael Paquier , Peter Geoghegan References: <20160519123338.12513.20271@wrigleys.postgresql.org> <88248a24-47d1-d575-a63f-2b56a09f82e2@aiven.io> Cc: Peter Tripp , Virendra Negi , pgsql-bugs From: Oskari Saarenmaa Message-ID: <62f3793f-13d6-567c-e512-f29d1fd76d00@aiven.io> Date: Wed, 6 Jul 2016 13:30:57 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.1.1 MIME-Version: 1.0 In-Reply-To: <88248a24-47d1-d575-a63f-2b56a09f82e2@aiven.io> Content-Type: multipart/mixed; boundary="------------A6BFF78842EA9A9F2981092C" X-Pg-Spam-Score: -2.0 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org This is a multi-part message in MIME format. --------------A6BFF78842EA9A9F2981092C Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit 06.07.2016, 09:05, Oskari Saarenmaa kirjoitti: > I ran into this yesterday on 9.5.3 and created a test case before > noticing this thread. My test case just inserts a single > toast-requiring row using ON CONFLICT DO NOTHING and typically fails > immediately: > > pgbench -f random.sql -n -T 2 -c 2 > > random.sql: > > -- CREATE TABLE vtest (id INT UNIQUE, blob BYTEA); > TRUNCATE vtest; > INSERT INTO vtest (id, blob) VALUES (1, encrypt(repeat('a', > 8192)::bytea, 'x'::bytea, 'aes')) ON CONFLICT DO NOTHING; > > ISTM this is caused by toast knowing nothing about speculative > insertion: when two backends have executed a speculative heap_insert > with a conflicting key and the latter one tries to abort after receiving > specConflict there's nothing in tqual.c to say that the toast rows > associated with speculative insertion should be visible to that operation. The attached patch against current master allows heap_abort_speculative to delete toast rows created by the same command which makes the above test case and "make check" run without failures. Note that I haven't touched this code before so I don't know how safe my patch is. / Oskari --------------A6BFF78842EA9A9F2981092C Content-Type: text/x-patch; name="0001-Delete-current-command-s-TOAST-when-aborting-specula.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0001-Delete-current-command-s-TOAST-when-aborting-specula.pa"; filename*1="tch"