Re: Issue in GIN fast-insert: XLogBeginInsert + Read/LockBuffer ordering

From: Zhang Mingli <zmlpostgres(at)gmail(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>, Matthias van de Meent <boekewurm+postgres(at)gmail(dot)com>
Subject: Re: Issue in GIN fast-insert: XLogBeginInsert + Read/LockBuffer ordering
Date: 2022-09-30 09:57:32
Message-ID: bf03ff05-d144-493b-b5bd-d344d4b0a52e@Spark
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

HI,

On Sep 8, 2022, 19:08 +0800, Matthias van de Meent <boekewurm+postgres(at)gmail(dot)com>, wrote:
>  In general, this works fine, except that in ginHeapTupleFastInsert we
> call XLogBeginInsert() before the last of the buffers for the eventual
> record was read, thus creating a path where eviction is possible in a
> `begininsert_called = true` context. That breaks our current code by
> being unable to evict (WAL-log) the dirtied hint pages.
Does it break Postgres or Neon?
I look around the codes and as far as I can see, dirty pages could be flushed whether begininsert_called is true or false.
>
> PFA a patch that rectifies this issue, by moving the XLogBeginInsert()
> down to where 1.) we have all relevant buffers pinned and locked, and
> 2.) we're in a critical section, making that part of the code
> consistent with the general scheme for XLog insertion.
+1, Make sense.

Regards,
Zhang Mingli

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Dilip Kumar 2022-09-30 10:06:11 Re: problems with making relfilenodes 56-bits
Previous Message Daniel Gustafsson 2022-09-30 09:35:36 Documentation building fails on HTTPS redirect (again)