Re:Connections hang indefinitely while taking a gin index's LWLock buffer_content lock

chenhj <chjischj@163.com>

From: "chjischj@163.com" <chjischj@163.com>
To: Alexander Korotkov <aekorotkov@gmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>
Cc: Peter Geoghegan <pg@bowt.ie>, Andres Freund <andres@anarazel.de>, Teodor Sigaev <teodor@sigaev.ru>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2018-12-13T15:12:04Z
Lists: pgsql-hackers

Attachments

<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"></head><body><div class="quote" style="line-height: 1.5"><aekorotkov@gmail.com><x4mmm@yandex-team.ru><pg@bowt.ie><andres@anarazel.de><chjischj@163.com><teodor@sigaev.ru><pgsql-hackers@lists.postgresql.org><br><div class="quote" style="line-height: 1.5">hi</div><div class="quote" style="line-height: 1.5">I Have a question. Why the order of unlocking is not adjusted in this patch? like this:</div><div class="quote" style="line-height: 1.5"><br></div><div class="quote" style="line-height: 1.5">if (BufferIsValid(lbuffer))</div><div class="quote" style="line-height: 1.5">UnlockReleaseBuffer(lbuffer);</div><div class="quote" style="line-height: 1.5">if (BufferIsValid(pbuffer))</div><div class="quote" style="line-height: 1.5">UnlockReleaseBuffer(pbuffer);</div><div class="quote" style="line-height: 1.5">if (BufferIsValid(dbuffer))</div><div class="quote" style="line-height: 1.5">UnlockReleaseBuffer(dbuffer);</div><div class="quote" style="line-height: 1.5">==&gt;</div><div class="quote" style="line-height: 1.5">if (BufferIsValid(pbuffer))</div><div class="quote" style="line-height: 1.5">UnlockReleaseBuffer(pbuffer);</div><div class="quote" style="line-height: 1.5">if (BufferIsValid(dbuffer))</div><div class="quote" style="line-height: 1.5">UnlockReleaseBuffer(dbuffer);</div><div class="quote" style="line-height: 1.5">if (BufferIsValid(lbuffer))</div><div class="quote" style="line-height: 1.5">UnlockReleaseBuffer(lbuffer);</div><div class="quote" style="line-height: 1.5"><br></div><br type="attribution"><blockquote class="quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Tue, Dec 11, 2018 at 1:50 AM Alexander Korotkov <aekorotkov@gmail.com> wrote:<br>&gt; On Sun, Dec 9, 2018 at 10:25 PM Alexander Korotkov <aekorotkov@gmail.com> wrote:<br>&gt; &gt; On Sat, Dec 8, 2018 at 12:48 PM Andrey Borodin <x4mmm@yandex-team.ru> wrote:<br>&gt; &gt; &gt; &gt; 8 дек. 2018 г., в 6:54, Alexander Korotkov <aekorotkov@gmail.com> написал(а):<br>&gt; &gt; &gt; &gt;<br>&gt; &gt; &gt; &gt; Yep, please find attached draft patch.<br>&gt; &gt; &gt;<br>&gt; &gt; &gt; Patch seems good to me, I'll check it in more detail.<br>&gt; &gt; &gt; The patch gets posting item at FirstOffsetNumber instead of btree-&gt;getLeftMostChild(). This seem OK, since dataGetLeftMostPage() is doing just the same, but with few Assert()s.<br>&gt; &gt;<br>&gt; &gt; I'd like to evade creating GinBtree for just calling<br>&gt; &gt; getLeftMostChild().  Also, few more places in ginvacuum.c do the same.<br>&gt; &gt; We have the same amount of Assert()s in ginVacuumPostingTreeLeaves().<br>&gt; &gt; So, let's keep it uniform.<br>&gt; &gt;<br>&gt; &gt; I would also like Peter Geoghegan to take a look at this patch before<br>&gt; &gt; committing it.<br>&gt;<br>&gt; I've slightly adjusted commit message.  I'm going to commit this fix<br>&gt; if no objections.<br><br>Please also find patch changing lock order in ginRedoDeletePage()<br>preventing deadlock on standby.  I'm going to commit it too.<br><br>------<br>Alexander Korotkov<br>Postgres Professional: http://www.postgrespro.com<br>The Russian Postgres Company</aekorotkov@gmail.com></x4mmm@yandex-team.ru></aekorotkov@gmail.com></aekorotkov@gmail.com></blockquote><blockquote class="quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br></blockquote><blockquote class="quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br></blockquote></pgsql-hackers@lists.postgresql.org></teodor@sigaev.ru></chjischj@163.com></andres@anarazel.de></pg@bowt.ie></x4mmm@yandex-team.ru></aekorotkov@gmail.com></div></body></html>

Commits

  1. Fix WAL format incompatibility introduced by backpatching of 52ac6cd2d0

  2. Fix wrong backpatching of ginRedoDeletePage() deadlock fix

  3. Fix deadlock in GIN vacuum introduced by 218f51584d5

  4. Prevent GIN deleted pages from being reclaimed too early

  5. Prevent deadlock in ginRedoDeletePage()

  6. Reduce page locking in GIN vacuum

  7. Fix race condition in GIN posting tree page deletion.