... btw, I believe the reason for the failure here:
http://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=jaguarundi&dt=2015-08-06%2011%3A52%3A17
is that brin_page_items() is unsafe. It's accessing
state->bdesc->bd_tupdesc, which is pointing at the tupdesc of an index
Relation that it no longer has open; not only directly, but via
brin_deform_tuple(). All you need is a relcache flush to be accessing
garbage. I haven't dug down thoroughly, but I'd not be surprised if there
were also some dereferences of bd_index, which is equally a dangling
pointer.
regards, tom lane