Re: GIN index fast list search may become un-interruptible for long time.

From: shihao zhong <zhong950419(at)gmail(dot)com>
To: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>
Cc: Kirill Reshke <reshkekirill(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: GIN index fast list search may become un-interruptible for long time.
Date: 2026-09-15 03:45:28
Message-ID: CAGRkXqQzZZ+S-Lidf5VYnA4_b3y83M7Q+DhvE40uq5+Jnizzag@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Kirill,

Thanks for posting this patch. We have seen this happen in production
a few times this year.

This still reproduces on current master. With your test case and 900k
keys, the query did not respond to pg_cancel_backend for more than 3
minutes. Stack samples show almost all of the time in
collectMatchesForHeapRow, with the pending list page locked. The
numbers are from a cassert build.

> The reason that the loop takes so long is that we look up every key item
> individually on the pending list. In your example, the key has about
> 900000 items. With such a large number of key items, it would be much
> faster to sort the key items, and do a "merge join" of the key items and
> the item on the page. That's a bigger patch though, and not
> backpatchable. But aside from the interrupt issue, it would make it much
> faster.

I would like to know if you plan to post a v2 along the lines Heikki
suggested. If so, I am happy to review and test it. If not, I can work
on it, unless you prefer otherwise.

Thanks,
Shihao

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Ashutosh Bapat 2026-09-15 04:15:21 Re: Use-after-free of a shared Path in add_path()/add_partial_path()
Previous Message Nikolay Samokhvalov 2026-09-15 03:32:22 Re: Add wait events for server logging destination writes