Re: [BUG] Error in BRIN summarization
Alvaro Herrera <alvherre@2ndquadrant.com>
From: Alvaro Herrera <alvherre@2ndquadrant.com>
To: Anastasia Lubennikova <a.lubennikova@postgrespro.ru>
Cc: pgsql-hackers@lists.postgresql.org
Date: 2020-08-11T23:43:21Z
Lists: pgsql-hackers
Attachments
- brin-desumm-race.patch (text/x-diff) patch
On 2020-Jul-30, Anastasia Lubennikova wrote: > While testing this fix, Alexander Lakhin spotted another problem. I > simplified the test case to this: Ah, good catch. I think a cleaner way to fix this problem is to just consider the range as not summarized and return NULL from there, as in the attached patch. Running your test case with a telltale WARNING added at that point, it's clear that it's being hit. By returning NULL, we're forcing the caller to scan the heap, which is not great. But note that if you retry, and your VACUUM hasn't run yet by the time we go through the loop again, the same thing would happen. So it seems to me a good enough answer. A much more troubling thought is what happens if the range is desummarized, then the index item is used for the summary of a different range. Then the index might end up returning corrupt results. > At first, I tried to fix it by holding the lock on revmap->rm_currBuf until > we locked the regular page, but it causes a deadlock with brinsummarize(), > It can be easily reproduced with the same test as above. > Is there any rule about the order of locking revmap and regular pages in > brin? I haven't found anything in README. Umm, I thought that stuff was in the README, but it seems I didn't add it there. I think I had a .org file with my notes on that ... must be in an older laptop disk, because it's not in my worktree for that. I'll see if I can fish it out. -- Álvaro Herrera https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
Commits
-
Disable autovacuum for BRIN test table
- b83f1bcca0bb 13.0 landed
- 6e70443edacf 14.0 landed
- 4f47c8e7d438 12.5 landed
- 060e5bd70e4d 11.10 landed
- d4d21490376e 9.6.20 landed
- aa4da2674ca2 9.5.24 landed
- 3a45ac076aab 10.15 landed
-
Handle new HOT chains in index-build table scans
- e5902117dd83 9.6.20 landed
- a811ea5bde2f 14.0 landed
- 704de3739c5b 11.10 landed
- 40bceae7b4de 9.5.24 landed
- 385cbe8e4197 10.15 landed
- 2f29fd4cb252 13.0 landed
- 1122a903e967 12.5 landed
-
BRIN: Handle concurrent desummarization properly
- ce3a8fde8e62 9.5.24 landed
- 8782ea2f36a2 13.0 landed
- 7af39993a47c 11.10 landed
- 7a3c261fbbb4 9.6.20 landed
- 721ef4d28aae 10.15 landed
- 1f42d35a1d61 14.0 landed
- 0426c75e7d1d 12.5 landed