From: | Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org> |
---|---|
To: | Michael Paquier <michael(dot)paquier(at)gmail(dot)com> |
Cc: | Asim Praveen <apraveen(at)pivotal(dot)io>, Jacob Champion <pchampion(at)pivotal(dot)io>, Robert Haas <robertmhaas(at)gmail(dot)com>, PostgreSQL mailing lists <pgsql-hackers(at)postgresql(dot)org>, Kevin Grittner <kgrittn(at)gmail(dot)com> |
Subject: | Re: [HACKERS] [PATCH] Assert that the correct locks are held when calling PageGetLSN() |
Date: | 2018-01-09 18:26:24 |
Message-ID: | 20180109182624.khjdclnzkevekm2a@alvherre.pgsql |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
So ... gistdoinsert can sometimes hold an exclusive lock, so we could do
this instead:
diff --git a/src/backend/access/gist/gist.c b/src/backend/access/gist/gist.c
index 0e499598a4..2ea19d2683 100644
--- a/src/backend/access/gist/gist.c
+++ b/src/backend/access/gist/gist.c
@@ -566,7 +566,8 @@ gistdoinsert(Relation r, IndexTuple itup, Size freespace, GISTSTATE *giststate)
}
stack->page = (Page) BufferGetPage(stack->buffer);
- stack->lsn = PageGetLSN(stack->page);
+ stack->lsn = xlocked ?
+ PageGetLSN(stack->page) : BufferGetLSNAtomic(stack->buffer);
Assert(!RelationNeedsWAL(state.r) || !XLogRecPtrIsInvalid(stack->lsn));
I suppose it doesn't really hurt all that much. I admit I'm a bit
nervous about the fact that code is uncovered.
--
Álvaro Herrera https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
From | Date | Subject | |
---|---|---|---|
Next Message | Pavel Stehule | 2018-01-09 18:46:19 | Re: to_timestamp TZH and TZM format specifiers |
Previous Message | Peter Eisentraut | 2018-01-09 18:08:07 | Re: [HACKERS] SQL procedures |