Re: BRIN indexes - TRAP: BadArgument

From: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
To: Greg Stark <stark(at)mit(dot)edu>
Cc: Heikki Linnakangas <hlinnakangas(at)vmware(dot)com>, Michael Paquier <michael(dot)paquier(at)gmail(dot)com>, David Rowley <dgrowleyml(at)gmail(dot)com>, Jeff Janes <jeff(dot)janes(at)gmail(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Erik Rijkers <er(at)xs4all(dot)nl>, Emanuel Calvo <3manuek(at)esdebian(dot)org>, Simon Riggs <simon(at)2ndquadrant(dot)com>, Nicolas Barbier <nicolas(dot)barbier(at)gmail(dot)com>, Claudio Freire <klaussfreire(at)gmail(dot)com>, Josh Berkus <josh(at)agliodbs(dot)com>, Andres Freund <andres(at)2ndquadrant(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: BRIN indexes - TRAP: BadArgument
Date: 2014-11-11 12:12:38
Message-ID: 20141111121238.GN1791@alvin.alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Greg Stark wrote:
> On Tue, Nov 11, 2014 at 2:14 AM, Alvaro Herrera
> <alvherre(at)2ndquadrant(dot)com> wrote:
> > I'm not sure why you say opaque is not associated with the specific
> > scan. Are you thinking we could reuse opaque for a future scan? I
> > think we could consider that opaque *is* the place to cache things such
> > as the hashed value of the qual constants or whatever.
>
> Oh. I guess this goes back to my original suggestion that the API docs
> need to explain some sense of when OpcInfo is called. I didn't realize
> it was tied to a specific scan. This does raise the question of why
> the scan information isn't available in OpcInfo though. That would let
> me build the hash value in a natural place instead of having to do it
> lazily which I find significantly more awkward.

Hmm. OpcInfo is also called in contexts other than scans, though, so
passing down scan keys into it seems wrong. Maybe we do need another
amproc that "initializes" the scan for the opclass, which would get
whatever got returned from opcinfo as well as scankeys. There you would
have the opportunity to run the hash and store it into the opaque.

> Is it possible for scan keys to change between calls for nested loop
> joins or quirky SQL with volatile functions in the scan or anything? I
> guess that would prevent the index scan from being used at all. But I
> can be reassured the Opcinfo call will be called again when a cached
> plan is reexecuted? Stable functions might have new values in a
> subsequent execution even if the plan hasn't changed at all for
> example.

As far as I understand, the scan keys don't change within any given
scan; if they do, the rescan AM method is called, at which point we
should reset whatever is cached about the previous scan.

> > That's to test the Union procedure; if you look at the code, it's just
> > used in assert-enabled builds. Now that I think about it, perhaps this
> > can turn out to be problematic for your bloom filter opclass. I
> > considered the idea of allowing the opclass to disable this testing
> > procedure, but it isn't done (yet.)
>
> No, it isn't a problem for my opclass other than performance, it was
> quite helpful in turning up bugs early in fact. It was just a bit
> confusing because I was trying to test things one by one and it turned
> out the assertion checks meant a simple insert turned up bugs in Union
> which I hadn't expected. But it seems perfectly sensible in an
> assertion check.

Great, thanks.

--
Álvaro Herrera http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Greg Stark 2014-11-11 12:38:23 Re: BRIN indexes - TRAP: BadArgument
Previous Message Fujii Masao 2014-11-11 12:11:54 Re: PENDING_LIST_CLEANUP_SIZE - maximum size of GIN pending list Re: HEAD seems to generate larger WAL regarding GIN index