Re: Extension Enhancement: Buffer Invalidation in pg_buffercache

From: jian he <jian(dot)universality(at)gmail(dot)com>
To: Japin Li <japinli(at)hotmail(dot)com>
Cc: Palak Chaturvedi <chaturvedipalak1911(at)gmail(dot)com>, Thomas Munro <thomas(dot)munro(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Extension Enhancement: Buffer Invalidation in pg_buffercache
Date: 2023-07-04 11:53:39
Message-ID: CACJufxFWPQS6_OHjV6Vk2pd9Ff+=xRWtdvyR97WjpbGfBfjAYA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Jul 4, 2023 at 5:45 PM Japin Li <japinli(at)hotmail(dot)com> wrote:

>
> On Tue, 04 Jul 2023 at 17:00, jian he <jian(dot)universality(at)gmail(dot)com> wrote:
> > the following will also crash. no idea why.
> > begin;
> > select count(*) from onek;
> > select relpages from pg_class where relname = 'onek'; --queryA
> >
> > SELECT count(*) FROM pg_buffercache WHERE relfilenode =
> > pg_relation_filenode('onek'::regclass); --queryB
> >
> > insert into onek values(default);
> >
> > select count(pg_buffercache_invalidate(bufferid)) from
> > pg_buffercache where relfilenode =
> > pg_relation_filenode('onek'::regclass);
> >
> > ---------------------------------
> > queryA returns 35, queryB returns 37.
> > ----------------------------------
> > crash info:
> > test_dev=*# insert into onek values(default);
> > INSERT 0 1
> > test_dev=*# select count(pg_buffercache_invalidate(bufferid)) from
> > pg_buffercache where relfilenode =
> > pg_relation_filenode('onek'::regclass);
> > TRAP: failed Assert("resarr->nitems < resarr->maxitems"), File:
> >
> "../../Desktop/pg_sources/main/postgres/src/backend/utils/resowner/resowner.c",
> > Line: 275, PID: 1533312
>
> According to the comments of ResourceArrayAdd(), the caller must have
> previously
> done ResourceArrayEnlarge(). I tried to call ResourceOwnerEnlargeBuffers()
> before
> PinBuffer_Locked(), so it can avoid this crash.
>
> if ((buf_state & BM_DIRTY) == BM_DIRTY)
> {
> + /* make sure we can handle the pin */
> + ResourceOwnerEnlargeBuffers(CurrentResourceOwner);
> +
> /*
> * Try once to flush the dirty buffer.
> */
> PinBuffer_Locked(bufHdr);
>
> --
> Regrads,
> Japin Li.
>

thanks. tested flush pg_catalog, public schema, now, both works as pitched.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tomas Vondra 2023-07-04 11:59:21 Re: brininsert optimization opportunity
Previous Message Yuya Watari 2023-07-04 11:24:08 Re: Making empty Bitmapsets always be NULL