Re: BUG #19355: Attempt to insert data unexpectedly during concurrent update
| От | Amit Langote |
|---|---|
| Тема | Re: BUG #19355: Attempt to insert data unexpectedly during concurrent update |
| Дата | |
| Msg-id | CA+HiwqGpeG2jo51o6XoXfFYpoXGg=NM2Byj0Yjk7G1rzr=0mJw@mail.gmail.com обсуждение исходный текст |
| Ответ на | Re: BUG #19355: Attempt to insert data unexpectedly during concurrent update (Bernice Southey <bernice.southey@gmail.com>) |
| Ответы |
Re: BUG #19355: Attempt to insert data unexpectedly during concurrent update
|
| Список | pgsql-bugs |
Hi Bernice, On Fri, Jan 2, 2026 at 6:58 AM Bernice Southey <bernice.southey@gmail.com> wrote: > > > Dean Rasheed wrote: > > >> I'm somewhat conflicted as to which approach is better. I think maybe > > >> there is less chance of other unintended side-effects if the set of > > >> RTEs included in PlannerGlobal.allRelids, unprunableRelids, and > > >> es_unpruned_relids is not changed. However, as it stands, > > >> PlannerGlobal.allRelids is misnamed (it should probably have been > > >> called "relationRelids", in line with the "relationOids" field). > > >> Making it actually include all RTEs would solve that. > > I did some more digging (postgres source code is addictive). > > Up until v56-0004-Defer-locking-of-runtime-prunable-relations-to-e.patch > [1], the existing unfiltered rtable is used to create > unprunableRelids. > > +++ b/src/backend/optimizer/plan/planner.c > @@ -555,6 +555,8 @@ standard_planner(Query *parse, const char > *query_string, int cursorOptions, > result->planTree = top_plan; > result->partPruneInfos = glob->partPruneInfos; > result->rtable = glob->finalrtable; > + result->unprunableRelids = bms_difference(bms_add_range(NULL, 1, > list_length(result->rtable)), > + glob->prunableRelids); > > In v56 [2], the filtered allRelids was added. I think this is when the > bug was introduced, because the three places from Dean's patch are in > both versions. > > I've looked much harder at the code (I'm still at > stumbling-around-in-the-dark-with-a-match level) and AFAICT, the two > approaches are very similar. I think equal effort is required to check > that PlannerGlobal.allRelids, unprunableRelids, and es_unpruned_relids > are correct, whichever approach is used. I can't find any missed cases > in either approach - with my matchlight. Good catch on the history -- that's exactly when the bug was introduced. I'd say Dean's approach is easier to verify since it's a simple check at the point of use, rather than ensuring allRelids is built correctly across all planner code paths. > Sorry for my ignorance: does a relId refer to a range table index and > a relation to a...for lack of a better word...table+? Depends on the context, but "relid" in the planner internal data structures refer to RT index. In the planner output data structures (plan nodes, etc.), we typically use "rti" or "rtindex". -- Thanks, Amit Langote
В списке pgsql-bugs по дате отправления: