Re: logical decoding : exceeded maxAllocatedDescs for .spill files
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Amit Kapila <amit.kapila16@gmail.com>
Cc: Noah Misch <noah@leadboat.com>, Amit Khandekar <amitdkhan.pg@gmail.com>, Alvaro Herrera from 2ndQuadrant <alvherre@alvh.no-ip.org>, Andres Freund <andres@anarazel.de>, Juan José Santamaría Flecha <juanjo.santamaria@gmail.com>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>, Robert Haas <robertmhaas@gmail.com>, Thomas Munro <thomas.munro@gmail.com>, Tomas Vondra <tomas.vondra@2ndquadrant.com>
Date: 2020-01-09T23:51:41Z
Lists: pgsql-hackers
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
When a TAP file has non-zero exit status, retain temporary directories.
- 048c7ccd7d6d 9.6.17 landed
- d8efc5900f7c 10.12 landed
- 887657d183fc 11.7 landed
- 78a26c3edd85 12.2 landed
- bf989aaf3561 13.0 landed
-
Fix running out of file descriptors for spill files.
- 1ad47e8757bb 9.4.26 landed
- a6f4f407ada0 9.5.21 landed
- 27b5f48c79f7 10.12 landed
- 3e3a79735235 11.7 landed
- f8a6d8e71b17 12.2 landed
- d20703805383 13.0 landed
- ba5b4e506489 9.6.17 landed
-
Track statistics for spilling of changes from ReorderBuffer.
- 9290ad198b15 13.0 cited
-
Handle ReadFile() EOF correctly on Windows.
- 2189f49c420f 12.2 landed
- 6969deeb8d39 13.0 landed
-
Add logical_decoding_work_mem to limit ReorderBuffer memory usage.
- cec2edfa7859 13.0 cited
-
Generational memory allocator
- a4ccc1cef5a0 11.0 cited
-
Support retaining data dirs on successful TAP tests
- 90627cf98a8e 11.0 cited
Amit Kapila <amit.kapila16@gmail.com> writes:
> On Thu, Jan 9, 2020 at 11:15 AM Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> Noah Misch <noah@leadboat.com> writes:
>>> Even so, a web search for "extend_brk" led to the answer. By default, 32-bit
>>> AIX binaries get only 256M of RAM for stack and sbrk. The new regression test
>>> used more than that, hence this crash.
>> Hm, so
>> (1) Why did we get a crash and not some more-decipherable out-of-resources
>> error? Can we improve that experience?
>> (2) Should we be dialing back the resource consumption of this test?
> In HEAD, we have a guc variable 'logical_decoding_work_mem' by which
> we can control the memory usage of changes and we have used that, but
> for back branches, we don't have such a control.
I poked into this a bit more by running the src/test/recovery tests under
restrictive ulimit settings. I used
ulimit -s 1024
ulimit -v 250000
(At least on my 64-bit RHEL6 box, reducing ulimit -v much below this
causes initdb to fail, apparently because the post-bootstrap process
tries to load all our tsearch and encoding conversion shlibs at once,
and it hasn't got enough VM space to do so. Someday we may have to
improve that.)
I did not manage to duplicate Noah's crash this way. What I see in
the v10 branch is that the new 006_logical_decoding.pl test fails,
but with a clean "out of memory" error. The memory map dump that
that produces fingers the culprit pretty unambiguously:
...
ReorderBuffer: 223302560 total in 26995 blocks; 7056 free (3 chunks); 223295504 used
ReorderBufferByXid: 24576 total in 2 blocks; 11888 free (3 chunks); 12688 used
Slab: TXN: 8192 total in 1 blocks; 5208 free (21 chunks); 2984 used
Slab: Change: 2170880 total in 265 blocks; 2800 free (35 chunks); 2168080 used
...
Grand total: 226714720 bytes in 27327 blocks; 590888 free (785 chunks); 226123832 used
The test case is only inserting 50K fairly-short rows, so this seems
like an unreasonable amount of memory to be consuming for that; and
even if you think it's reasonable, it clearly isn't going to scale
to large production transactions.
Now, the good news is that v11 and later get through
006_logical_decoding.pl just fine under the same restriction.
So we did something in v11 to fix this excessive memory consumption.
However, unless we're willing to back-port whatever that was, this
test case is clearly consuming excessive resources for the v10 branch.
We're not out of the woods either. I also observe that v12 and HEAD
fall over, under these same test conditions, with a stack-overflow
error in the 012_subtransactions.pl test. This seems to be due to
somebody's decision to use a heavily recursive function to generate a
bunch of subtransactions. Is there a good reason for hs_subxids() to
use recursion instead of a loop? If there is, what's the value of
using 201 levels rather than, say, 10?
Anyway it remains unclear why Noah's machine got a crash instead of
something more user-friendly. But the reason why it's only in the
v10 branch seems non-mysterious.
regards, tom lane