Re: OOM in spgist insert
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Alvaro Herrera <alvherre@alvh.no-ip.org>
Cc: Pavel Borisov <pashkin.elfe@gmail.com>,
Dilip Kumar <dilipbalaut@gmail.com>,
PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2021-05-13T23:04:19Z
Lists: pgsql-hackers
Alvaro Herrera <alvherre@alvh.no-ip.org> writes: > Hmm, it looks OK to me, but I wonder why you kept the original > CHECK_FOR_INTERRUPTS()s since these would be done once we've broken out > of the loop anyway. I tested Dilip's original test case and while we > still die on OOM, we're able to interrupt it before dying. Hm. My thought was that in the cases where InterruptPending is set for some reason other than a query cancel, we could let ProcessInterrupts service it at less cost than abandoning and retrying the index insertion. On reflection though, that only works for the first CHECK_FOR_INTERRUPTS at the top of the loop, and only the first time through, because during later calls we'll be holding buffer locks. Maybe the best idea is to have one CHECK_FOR_INTERRUPTS at the top of the function, in hopes of clearing out any already-pending interrupts, and then just use the condition test inside the loop. > Not related to this patch -- I was bothered by the UnlockReleaseBuffer > calls at the bottom of spgdoinsert that leave the buffer still set in > the structs. It's not a problem if you look only at this routine, but I > notice that callee doPickSplit does the same thing, so maybe there is > some weird situation in which you could end up with the buffer variable > set, but we don't hold lock nor pin on the page, so an attempt to clean > up would break. Maybe I'm confused, but aren't those just local variables that are about to go out of scope anyway? Clearing them seems more likely to draw compiler warnings about dead stores than accomplish something useful. regards, tom lane
Commits
-
Prevent infinite insertion loops in spgdoinsert().
- e87a0d2e0aa5 10.18 landed
- dc714c120eab 13.4 landed
- d776045eb12a 11.13 landed
- c3c35a733c77 14.0 landed
- 5015d3c35c6b 9.6.23 landed
- 4e046281fb58 12.8 landed
-
Fix query-cancel handling in spgdoinsert().
- eb7a6b922943 14.0 landed
- fe64adc93177 10.18 landed
- f4ee4082f50b 11.13 landed
- c1b72bf04515 13.4 landed
- 4c6cfcc377aa 9.6.23 landed
- 004288d3c0ac 12.8 landed
-
Refactor CHECK_FOR_INTERRUPTS() to add flexibility.
- e47f93f981cc 14.0 landed
- 8274f4517602 11.13 landed
- 63831c16275e 13.4 landed
- 567328989c19 9.6.23 landed
- 4c646b17985c 12.8 landed
- 39b8ccb08619 10.18 landed