Re: bulk_multi_insert infinite loops with large rows and small fill factors

From: Andres Freund <andres(at)2ndquadrant(dot)com>
To: David Gould <daveg(at)sonic(dot)net>
Cc: pgsql-hackers(at)postgresql(dot)org, Anand Ranganathan <arangana(at)adobe(dot)com>, Alex Eulenberg <aeulenbe(at)adobe(dot)com>, Ashokraj M <ashokraj(at)adobe(dot)com>, Hari <hari(at)adobe(dot)com>, Elein Mustain <mustain(at)adobe(dot)com>
Subject: Re: bulk_multi_insert infinite loops with large rows and small fill factors
Date: 2012-12-12 11:27:11
Message-ID: 20121212112711.GD8027@awork2.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2012-12-12 03:04:19 -0800, David Gould wrote:
>
> COPY IN loops in heap_multi_insert() extending the table until it fills the
> disk when trying to insert a wide row into a table with a low fill-factor.
> Internally fill-factor is implemented by reserving some space space on a
> page. For large enough rows and small enough fill-factor bulk_multi_insert()
> can't fit the row even on a new empty page, so it keeps allocating new pages
> but is never able to place the row. It should always put at least one row on
> an empty page.

Heh. Nice one. Did you hit that in practice?

> One more point, in the case where we don't insert any rows, we still do all the
> dirtying and logging work even though we did not modify the page. I have tried
> skip all this if no rows are added (nthispage == 0), but my access method foo
> is sadly out of date, so someone should take a skeptical look at that.
>
> A test case and patch against 9.2.2 is attached. It fixes the problem and passes
> make check. Most of the diff is just indentation changes. Whoever tries this will
> want to test this on a small partition by itself.

ISTM this would be fixed with a smaller footprint by just making

if (PageGetHeapFreeSpace(page) < MAXALIGN(heaptup->t_len) + saveFreeSpace)

if (!PageIsEmpty(page) &&
PageGetHeapFreeSpace(page) < MAXALIGN(heaptup->t_len) + saveFreeSpace)

I think that should work?

Greetings,

Andres Freund

--
Andres Freund http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Heikki Linnakangas 2012-12-12 11:56:08 Re: Re: bulk_multi_insert infinite loops with large rows and small fill factors
Previous Message Andres Freund 2012-12-12 11:20:11 Re: Logical decoding & exported base snapshot