Re: Asymmetry in opening and closing indices for partition routing

From: Ashutosh Bapat <ashutosh(dot)bapat(at)2ndquadrant(dot)com>
To: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Asymmetry in opening and closing indices for partition routing
Date: 2020-06-29 10:03:55
Message-ID: CAG-ACPVEOOrrL_PyUGhYO6xBMQ3tUJ-zwyZHTgeHQdTypP-jkA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, 22 Jun 2020 at 23:22, Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
wrote:

>
> I'm not sure that expecting the relcache entry's refcount drops to zero
> at the right time is a good approach; that may cause leaks some other
> place might have refcounts you're not expecting (say, an open cursor
> that's not fully read).
>

My proposal was to maintain a refcount counting the number of times an
index is opened in ResultRelInfo itself, not to rely on the relcache ref
count. But I think that would be an overkill. Please read ahead

>
> (I'm not terribly worried about refcount leakage as a theoretical
> concern, since the ResourceOwner mechanism will warn us about that if it
> happens.)
>
> > 2. Throw an error in ExecOpenIndices if all the arrays are present. We
> will
> > need to check leaf_part_rri->ri_IndexRelationDescs == NULL in
> > ExecInitPartitionInfo().
>
> This sounds like a job for an assert rather than an error.
>

I agree. Here's a patch to fix to add Assert'ion in ExecOpenIndices(). I
ran make check with this patch and the assertion didn't trip. I think this
will be a good step forward.

--
Best Wishes,
Ashutosh

Attachment Content-Type Size
0001-Assert-if-ExecOpenIndices-is-called-twice-on-same-re.patch application/x-patch 1.2 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Laurenz Albe 2020-06-29 10:13:10 Bug with indexes on whole-row expressions
Previous Message Bharath Rupireddy 2020-06-29 10:02:00 Re: estimation problems for DISTINCT ON with FDW