BRIN de-summarize ranges

Started by Alvaro Herreraabout 9 years ago6 messageshackers
Jump to latest
#1Alvaro Herrera
alvherre@2ndquadrant.com

Here's a small patch to make a BRIN page range unsummarized. This is
useful if data has been deleted, and the heap pages are now used for
completely different data.

--
�lvaro Herrera

Attachments:

brin-desummarize-1.patchtext/plain; charset=us-asciiDownload+276-4
#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Alvaro Herrera (#1)
Re: BRIN de-summarize ranges

Alvaro Herrera <alvherre@2ndquadrant.com> writes:

Here's a small patch to make a BRIN page range unsummarized. This is
useful if data has been deleted, and the heap pages are now used for
completely different data.

This seems remarkably, um, manual. Why shouldn't users expect the system
to take care of this for them?

regards, tom lane

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#3Simon Riggs
simon@2ndQuadrant.com
In reply to: Alvaro Herrera (#1)
Re: BRIN de-summarize ranges

On 28 February 2017 at 12:56, Alvaro Herrera <alvherre@2ndquadrant.com> wrote:

Here's a small patch to make a BRIN page range unsummarized. This is
useful if data has been deleted, and the heap pages are now used for
completely different data.

We currently have a manual interface for summarize new values, so it
makes sense to include a manual interface for desummarize also. Since
this adds desummarize_range it would make sense to expose
summarize_range also.

I'd prefer if we had a way to know when the summary is no longer
useful and to do this automatically, but we'd need more info and
research to work out how to do that, so we can only do it this way at
present.

Other than that the patch looks fairly straightforward, so adding a
few tests will be all we need here.

Plus function docs. I'm on the hook to write brin docs anyway, so no
more needed here.

--
Simon Riggs http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#4Seki, Eiji
seki.eiji@jp.fujitsu.com
In reply to: Simon Riggs (#3)
Re: BRIN de-summarize ranges

On 2017-02-28 04:56:43 Alvaro Herrera wrote:

Here's a small patch to make a BRIN page range unsummarized. This is
useful if data has been deleted, and the heap pages are now used for
completely different data.

Hi,

I tried to apply your patch and use it. Applying and "make check" were successed.

However, I found that when calling brin_desummarize_range successively, an assertion is failed. It seems to me that it occurs when desummarizing a revmap page that is already desummarized.

The tried queries and their outputs are the followings:

$ CREATE SCHEMA test_sc;
CREATE SCHEMA
$ CREATE TABLE test_sc.test(a int);
CREATE TABLE
$ INSERT INTO test_sc.test SELECT s FROM generate_series(1, 10000) s;
INSERT 0 10000
$ CREATE INDEX idx_brin ON test_sc.test USING brin(a);
CREATE INDEX
$ SELECT brin_desummarize_range('test_sc.idx_brin', 1);
brin_desummarize_range
------------------------

(1 row)

$ SELECT brin_desummarize_range('test_sc.idx_brin', 1);
psql:check_brin_desum.sql:10: server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
psql:check_brin_desum.sql:10: connection to server was lost

Then, the server log is the following:

TRAP: FailedAssertion("!(!LWLockHeldByMe(((LWLock*) (&(buf)->content_lock))))", File: "bufmgr.c", Line: 1714)
2017-03-22 15:06:12.842 JST [23107] LOG: server process (PID 23186) was terminated by signal 6: Aborted
2017-03-22 15:06:12.842 JST [23107] DETAIL: Failed process was running: SELECT brin_desummarize_range('test_sc.idx_brin', 1);

When assertion is failed, the following brinRevmapTerminate function is called. Then, it tries to release revmap->rm_currBuf by ReleaseBuffer function and it is failed.

+bool
+brinRevmapDesummarizeRange(Relation idxrel, BlockNumber heapBlk)
+{
...
+	if (!ItemPointerIsValid(iptr))
+	{
+		/* no index tuple: range not summarized, we're done */
+		brinRevmapTerminate(revmap);
+		return true;
+	}

--
Regards,
Eiji Seki
Fujitsu

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#5Alvaro Herrera
alvherre@2ndquadrant.com
In reply to: Seki, Eiji (#4)
Re: BRIN de-summarize ranges

Seki, Eiji wrote:

However, I found that when calling brin_desummarize_range
successively, an assertion is failed. It seems to me that it occurs
when desummarizing a revmap page that is already desummarized.

You're right, it's broken for that case. Here's a fixed patch.

--
�lvaro Herrera https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

Attachments:

0001-Support-BRIN-de-summarization.patchtext/plain; charset=iso-8859-1Download+283-5
#6Alvaro Herrera
alvherre@2ndquadrant.com
In reply to: Alvaro Herrera (#5)
Re: BRIN de-summarize ranges

Alvaro Herrera wrote:

However, I found that when calling brin_desummarize_range
successively, an assertion is failed. It seems to me that it occurs
when desummarizing a revmap page that is already desummarized.

You're right, it's broken for that case. Here's a fixed patch.

Pushed.

--
�lvaro Herrera https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers