Re: pg15.3: dereference null *plan in CachedPlanIsSimplyValid/plpgsql

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Justin Pryzby <pryzby(at)telsasoft(dot)com>
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: pg15.3: dereference null *plan in CachedPlanIsSimplyValid/plpgsql
Date: 2023-07-20 15:55:32
Message-ID: 584104.1689868532@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Justin Pryzby <pryzby(at)telsasoft(dot)com> writes:
> A production instance crashed like so.

Oh, interesting. Apparently we got past the "Has cache invalidation fired
on this plan?" check:

if (!plansource->is_valid || plan != plansource->gplan || !plan->is_valid)
return false;

because "plan" and "plansource->gplan" were *both* null, which is
a case the code wasn't expecting. plansource.c seems to be paranoid
about gplan possibly being null everywhere else but here :-(

> Note that the prior query seems to have timed out in the same / similar plpgsql
> statement:

Hm. Perhaps that helps explain how we got into this state. It must
be some weird race condition, given the lack of prior reports.
Anyway, adding a check for plan not being null seems like the
obvious fix.

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2023-07-20 16:02:52 Re: remaining sql/json patches
Previous Message Amit Langote 2023-07-20 15:48:06 Re: remaining sql/json patches