Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mcPR9-0000pz-5W for pgsql-bugs@arkaria.postgresql.org; Mon, 18 Oct 2021 10:00:08 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mcPR6-0006kL-QP for pgsql-bugs@arkaria.postgresql.org; Mon, 18 Oct 2021 10:00:04 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mcPR6-0006k6-7b for pgsql-bugs@lists.postgresql.org; Mon, 18 Oct 2021 10:00:04 +0000 Received: from lahtoruutu.iki.fi ([185.185.170.37]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mcPR2-0003Uy-Da for pgsql-bugs@postgresql.org; Mon, 18 Oct 2021 10:00:03 +0000 Received: from [192.168.1.113] (dsl-hkibng22-54faa4-119.dhcp.inet.fi [84.250.164.119]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: hlinnaka) by lahtoruutu.iki.fi (Postfix) with ESMTPSA id 3B1F91B000E5; Mon, 18 Oct 2021 12:59:56 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=lahtoruutu; t=1634551196; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=zsq5PHEyM3K9FeAGJt0ezohz4gBCaKZKQB0zSUQANCA=; b=Z12T2CaEBn3Ie+kZetE1LK7xR1R3byAPAs2SjY1LQL2wD9FJEHsuYuJvFZTIBTiFxJTeSd XS3pfMEEMvjtqTWq+z6OT3M5klWX0Bofx+DHVmRoUTHgFSkuFdTUOWCFPyPh4f3Qj2ROkP VWI1e3fSQj9nyjotj7siSI51265PgK4oqLbcFY0KYKxDwP2jt0IFANi2KTFXopH/6eKEgJ Jwjh6nqTQcj5Grj0IhsNza0aYzEEEMm/9s6nyQP3kkLigZAphYnWb7MWNs+d+++tk3DdUK fB4/KCsdGPv1qZMq295tlvet7tT21xnJQT2aFxrGqIUC/7pA6NXIO69XLFLbcw== Subject: Re: Snapshot leak warning with lo_export in subtransaction To: Alvaro Herrera Cc: Pg Bugs , Andrew B References: <202109271233.5zn5bqxn657w@alvherre.pgsql> From: Heikki Linnakangas Message-ID: Date: Mon, 18 Oct 2021 12:59:56 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 MIME-Version: 1.0 In-Reply-To: <202109271233.5zn5bqxn657w@alvherre.pgsql> Content-Type: multipart/mixed; boundary="------------4B67429588ABA6FBAFB00132" Content-Language: en-US ARC-Seal: i=1; s=lahtoruutu; d=iki.fi; t=1634551196; a=rsa-sha256; cv=none; b=XHMITdToKiPaO3L7Lm9F7bSsZKGuGXn6LzABSiQjz8Ml2RnkLjM7eLka/XmSBRGQmbQH7C PHJe7FRNZ20SxEj1KrEIsj1t+RZUf7DGHReoRL8wh2rJwx+GRTqejdDZVcjUbyFg8cce06 AX2b4DnVjJsP8lYdJLDaqOWaz3AFa0BIZn59kRF7ihMaqwMlERB+WO+phtpl16HglVIoyP cL/ovFYU7hGg8w9Oww34VvxPSY7mQ0FH/eSozEkAC2b0kGlLvyTpYIChCKCntoUQGYcdPY 56pXrug/cBSS2Rl2xMy6zVMnkRoKzJvdnMuYtHeqwJlfyHPNwX9z8YmyfbI7qg== ARC-Authentication-Results: i=1; ORIGINATING; auth=pass smtp.auth=hlinnaka smtp.mailfrom=hlinnaka@iki.fi ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=lahtoruutu; t=1634551196; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=zsq5PHEyM3K9FeAGJt0ezohz4gBCaKZKQB0zSUQANCA=; b=QHLWdk6MA+t4t1dUd1jUgA3CyG0r33hWUUTyovm2KlPWAYZG8nKkZ8QSaNb55QCF2IZmcK aRnvTv0HosK3UQZ1KzvuqOi5Dk2KfAFYpycoWZqf/I+LkHDktdc13dDw1DQEEu/qgnvGh8 gHW9Lx15/xvtChgDY3Zeb0YmjzXkg267UDwmskrcYd2F9Q5Tj68Uvr4zUk5Lmn5Fewq8ZT UUEmgGy0gvCKCQHVnyEyxs1PNiPDp2P3rotk6P/Sa/RxgvhNx4Ntt8Rmw0z7FaPSqBj026 Aj+f2oOzftiAqZm5O0DB8J7bIAbe/0mbn6zMyfTIwmR3RjWaIEaD+SL1+KZqyw== List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk This is a multi-part message in MIME format. --------------4B67429588ABA6FBAFB00132 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit On 27/09/2021 15:33, Alvaro Herrera wrote: > On 2021-Sep-27, Heikki Linnakangas wrote: > >> This should be backpatched to all supported versions. This adds an argument >> to 'inv_open' function, but I don't think there are extensions that use the >> inv_*() functions directly. inv_api.c relies on close_lo_relation() being >> called at the end of transaction, so I think an extension would find it hard >> to use those functions correctly, anyway. > > Hmm, but you could also use a new value in its existing 'flags' argument > instead of changing ABI. I tried that, but didn't like the result. It conflated the user-visible INV_READ/WRITE flags with the new internal-only flag. Thinking about this some more, I came up with the attached. It moves the responsibility of registering the snapshot from inv_api.c to the caller. With that change, there's no need for a new option to inv_open(). The division of labor between be-fsstubs.c and inv_api.c has always been a bit blurry, I think that this makes it slightly more clear. With this change, if there is an existing extension out there that calls inv_open(), the returned desc will be short-lived. As I said above, I think that's a reasonable assumption because dealing with a long-lived LO desc correctly would require the caller to jump through some hoops even before this change. - Heikki --------------4B67429588ABA6FBAFB00132 Content-Type: text/x-patch; charset=UTF-8; name="v2-0001-Fix-snapshot-reference-leak-if-lo_export-fails.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="v2-0001-Fix-snapshot-reference-leak-if-lo_export-fails.patch"