Re: Bug in batch tuplesort memory CLUSTER case (9.6 only)

Поиск
Список
Период
Сортировка
От Peter Geoghegan
Тема Re: Bug in batch tuplesort memory CLUSTER case (9.6 only)
Дата
Msg-id CAM3SWZS_1F=ut+CtOt7inai_6qYdytzhxvZqR3uRDOj0qASEEQ@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Bug in batch tuplesort memory CLUSTER case (9.6 only)  (Robert Haas <robertmhaas@gmail.com>)
Ответы Re: Bug in batch tuplesort memory CLUSTER case (9.6 only)  (Peter Geoghegan <pg@heroku.com>)
Список pgsql-hackers
On Fri, Jul 1, 2016 at 12:10 PM, Robert Haas <robertmhaas@gmail.com> wrote:
>> I could give you steps to reproduce the bug, but they involve creating
>> a large table using my gensort tool [1]. It isn't trivial. Are you
>> interested?
>
> The bug can't very well be so simple that you need not include a set
> of steps to reproduce it and, at the same time, so complex that even
> so much as reading the list of steps to reproduce it might be more
> than I want to do.

Reading and following are two different things. I don't think reading
alone will do much good with the following steps, but here they are:

Checkout my gensort tool from github. Build the C tool with "make".
Then, from the working directory:

./postgres_load.py -m 250 --skew --logged
psql -c "CREATE INDEX segfaults on sort_test_skew(sortkey);"
psql -c "CLUSTER sort_test_skew USING segfaults;"

That test case isn't at all minimal, but that's how I happened upon
the bug. I didn't tell you this before now because I assumed that
you'd just accept that there was an omission made based on a quick
reading of the code. This is not a complicated bug; the pointer
HeapTuple.t_data needs to be updated when tuples are moved around in
memory, but isn't. readtup_cluster() initializes that field like this:

/* Reconstruct the HeapTupleData header */
tuple->t_data = (HeapTupleHeader) ((char *) tuple + HEAPTUPLESIZE);

More or less the same process needs to occur following any movement of
the tuple. Whereas, in all other cases there is no need to do
something similar, as it happens.

-- 
Peter Geoghegan



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Andres Freund
Дата:
Сообщение: Re: Reviewing freeze map code
Следующее
От: Andreas Seltenreich
Дата:
Сообщение: [sqlsmith] ERROR: plan should not reference subplan's variable