Re: segmentation fault using currtid and partitioned tables

2020-05-31 Thread Michael Paquier
On Sun, May 31, 2020 at 10:26:54PM -0400, Tom Lane wrote: > Ugh. Aside from the stale-pointer-deref problem, once we drop the lock > we can't even be sure the table still exists. +1 for back-patch. Thanks. Fixed down to 9.5 then to make prion happier. -- Michael signature.asc Description:

Re: segmentation fault using currtid and partitioned tables

2020-05-31 Thread Tom Lane
Michael Paquier writes: > Woah. This one is old, good catch from -DRELCACHE_FORCE_RELEASE. It > happens that since its introduction in a3519a2 from 2002, > currtid_for_view() in tid.c closes the view and then looks at a RTE > from it. I have reproduced the issue and the patch attached takes >

Re: segmentation fault using currtid and partitioned tables

2020-05-31 Thread Michael Paquier
On Mon, Jun 01, 2020 at 10:57:29AM +0900, Michael Paquier wrote: > Applied this one then. I also got to check the ODBC driver in more > details, and I am indeed not seeing those functions getting used. > One extra thing to know is that the ODBC driver requires libpq from at > least 9.2, which may

Re: segmentation fault using currtid and partitioned tables

2020-05-31 Thread Michael Paquier
On Fri, May 29, 2020 at 03:48:40PM +0900, Michael Paquier wrote: > Okay, I have switched the patch to do that. Any comments or > objections? Applied this one then. I also got to check the ODBC driver in more details, and I am indeed not seeing those functions getting used. One extra thing to

Re: segmentation fault using currtid and partitioned tables

2020-05-29 Thread Michael Paquier
On Thu, May 28, 2020 at 05:55:59PM -0700, Andres Freund wrote: > And there only for very old servers (< 8.2), according to Hiroshi > Inoue. Found that out post 12 freeze. I was planning to drop them for > 13, but I unfortunately didn't get around to do so :( [... digging ...] Ah, I think I see

Re: segmentation fault using currtid and partitioned tables

2020-05-28 Thread Tom Lane
Andres Freund writes: > On 2020-04-05 12:51:56 -0400, Tom Lane wrote: >> I think it might be a good idea to make relations-without-storage >> set up rd_tableam as a vector of dummy functions that will throw >> some suitable complaint about "relation lacks storage". NULL is >> a horrible default

Re: segmentation fault using currtid and partitioned tables

2020-05-28 Thread Andres Freund
Hi, On 2020-04-05 12:51:56 -0400, Tom Lane wrote: > (2) The proximate cause of the crash is that rd_tableam is zero, > so that the interface functions in tableam.h just crash hard. > This seems like a pretty bad thing; does anyone want to promise > that there are no other oversights of the same

Re: segmentation fault using currtid and partitioned tables

2020-05-28 Thread Andres Freund
Hi, On 2020-05-22 19:32:57 -0400, Alvaro Herrera wrote: > On 2020-Apr-09, Michael Paquier wrote: > > > Playing more with this stuff, it happens that we have zero code > > coverage for currtid() and currtid2(), and the main user of those > > functions I can find around is the ODBC driver: > >

Re: segmentation fault using currtid and partitioned tables

2020-05-27 Thread Alvaro Herrera
On 2020-May-26, Michael Paquier wrote: > On Mon, May 25, 2020 at 06:29:10PM +0900, Michael Paquier wrote: > > Perhaps you are right though, and that we don't need to spend this > > much energy into improving the error messages so I am fine to discard > > this part. At the end, in order to remove

Re: segmentation fault using currtid and partitioned tables

2020-05-27 Thread Michael Paquier
On Wed, May 27, 2020 at 12:29:39AM -0500, Jaime Casanova wrote: > so, currently the patch just installs protections on both currtid_* > functions and adds some tests... therefore we can consider it as a bug > fix and let it go in 13? actually also backpatch in 12... Yes, and it has the advantage

Re: segmentation fault using currtid and partitioned tables

2020-05-26 Thread Jaime Casanova
On Mon, 25 May 2020 at 22:01, Michael Paquier wrote: > > On Mon, May 25, 2020 at 06:29:10PM +0900, Michael Paquier wrote: > > Perhaps you are right though, and that we don't need to spend this > > much energy into improving the error messages so I am fine to discard > > this part. At the end, in

Re: segmentation fault using currtid and partitioned tables

2020-05-25 Thread Michael Paquier
On Mon, May 25, 2020 at 06:29:10PM +0900, Michael Paquier wrote: > Perhaps you are right though, and that we don't need to spend this > much energy into improving the error messages so I am fine to discard > this part. At the end, in order to remove the crashes, you just need > to keep around the

Re: segmentation fault using currtid and partitioned tables

2020-05-25 Thread Michael Paquier
On Fri, May 22, 2020 at 07:32:57PM -0400, Alvaro Herrera wrote: > I don't know, but this stuff is so unused that your patch seems > excessive ... and I think we'd rather not backpatch something so large. > I propose we do something less invasive in the backbranches, like just > throw elog() errors

Re: segmentation fault using currtid and partitioned tables

2020-05-22 Thread Alvaro Herrera
On 2020-Apr-09, Michael Paquier wrote: > Playing more with this stuff, it happens that we have zero code > coverage for currtid() and currtid2(), and the main user of those > functions I can find around is the ODBC driver: > https://coverage.postgresql.org/src/backend/utils/adt/tid.c.gcov.html

Re: segmentation fault using currtid and partitioned tables

2020-04-09 Thread Michael Paquier
On Wed, Apr 08, 2020 at 04:13:31PM +0900, Michael Paquier wrote: > I have been looking at the tree and the use of the table AM APIs, and > those TID lookups are really a particular case compared to the other > callers of the table AM callbacks. Anyway, I have not spotted similar > problems, so I

Re: segmentation fault using currtid and partitioned tables

2020-04-08 Thread Michael Paquier
On Sun, Apr 05, 2020 at 12:51:56PM -0400, Tom Lane wrote: > I think it might be a good idea to make relations-without-storage > set up rd_tableam as a vector of dummy functions that will throw > some suitable complaint about "relation lacks storage". NULL is > a horrible default for this. Yeah,

Re: segmentation fault using currtid and partitioned tables

2020-04-05 Thread Tom Lane
Jaime Casanova writes: > Another one caught by sqlsmith, on the regression database run this > query (using any non-partitioned table works fine): > select currtid('pagg_tab'::regclass::oid, '(0,156)'::tid) >= '(1,158)'::tid; Hm, so (1) currtid_byreloid and currtid_byrelname lack any check to

segmentation fault using currtid and partitioned tables

2020-04-05 Thread Jaime Casanova
Hi, Another one caught by sqlsmith, on the regression database run this query (using any non-partitioned table works fine): """ select currtid('pagg_tab'::regclass::oid, '(0,156)'::tid) >= '(1,158)'::tid; """ This works on 11 (well it gives an error because the file doesn't exists) but crash