Thread: [HACKERS] BRIN de-summarize ranges
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 -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Attachment
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
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
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 occurswhen 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_currBufby 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
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
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