Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bW1FC-0005RS-Pp for pgsql-hackers@arkaria.postgresql.org; Sat, 06 Aug 2016 13:02:26 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1bW1FC-00035I-Cv for pgsql-hackers@arkaria.postgresql.org; Sat, 06 Aug 2016 13:02:26 +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.84_2) (envelope-from ) id 1bW1Do-0001Tv-OI for pgsql-hackers@postgresql.org; Sat, 06 Aug 2016 13:01:00 +0000 Received: from lungold.riddles.org.uk ([82.68.208.19]) by makus.postgresql.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1bW1Dh-0000ou-Oz for pgsql-hackers@postgresql.org; Sat, 06 Aug 2016 13:00:59 +0000 Received: from localhost ([127.0.0.1]:43672 helo=caithnard.riddles.org.uk) by lungold.riddles.org.uk with esmtp (Exim 4.84 (FreeBSD)) (envelope-from ) id 1bW1Df-000EcB-GZ; Sat, 06 Aug 2016 13:00:51 +0000 From: Andrew Gierth To: Amit Kapila Cc: Andreas Seltenreich , pgsql-hackers Subject: Re: [sqlsmith] Crash in GetOldestSnapshot() In-Reply-To: (Amit Kapila's message of "Sat, 6 Aug 2016 18:03:47 +0530") Message-ID: <87zioqcbbv.fsf@news-spur.riddles.org.uk> References: <87vazemeda.fsf@credativ.de> <874m6ydrna.fsf@news-spur.riddles.org.uk> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (berkeley-unix) Date: Sat, 06 Aug 2016 14:00:51 +0100 MIME-Version: 1.0 Content-Type: text/plain X-Pg-Spam-Score: -3.1 (---) 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 >>>>> "Amit" == Amit Kapila writes: Amit> Sure, that is the reason of crash, but even if we do that it will Amit> lead to an error "no known snapshots". Here, what is going on is Amit> that we initialized toast snapshot when there is no active Amit> snapshot in the backend, so GetOldestSnapshot() won't return any Amit> snapshot. Hmm. So this happens because RETURNING queries run to completion immediately and populate a tuplestore with the results, and the portal then fetches from the tuplestore to send to the destination. The assumption is that the tuplestore output can be processed without needing a snapshot, which obviously is not true now if it contains toasted data. In a similar case in the past involving holdable cursors, the solution was to detoast _before_ storing in the tuplestore (see PersistHoldablePortal). I guess the question now is, under what circumstances is it now allowable to detoast a datum with no active snapshot? (Wouldn't it be necessary in such a case to know what the oldest snapshot ever used in the transaction was?) Amit> I think for such situations, we need to initialize the lsn and Amit> whenTaken of ToastSnapshot as we do in GetSnapshotData() [1]. Would that not give a too-recent LSN, resulting in possibly failing to fetch the toast rows? -- Andrew (irc:RhodiumToad) -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers