Re: BUG #16329: Valgrind detects an invalid read when building a gist index with buffering

From: Andrey Borodin <x4mmm(at)yandex-team(dot)ru>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Pavel Borisov <pashkin(dot)elfe(at)gmail(dot)com>, Alexander Lakhin <exclusion(at)gmail(dot)com>, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #16329: Valgrind detects an invalid read when building a gist index with buffering
Date: 2020-10-24 16:40:35
Message-ID: ED621F81-B769-4E2F-AB69-6F265C366057@yandex-team.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

> 22 окт. 2020 г., в 19:01, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> написал(а):
>
> Andrey Borodin <x4mmm(at)yandex-team(dot)ru> writes:
>>> 13 окт. 2020 г., в 03:16, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> написал(а):
>>> 2. The test exposed the gistRelocateBuildBuffersOnSplit bug only about
>>> one time in ten for me. I suppose this is due to the random split
>>> choices gistchoose makes for equally-good tuples, so it's not terribly
>>> surprising; but it is problematic for a test that we're hoping to use
>>> to provide reliable code coverage.
>>>
>>> I'm not really sure what we could do about #2. Perhaps, instead of
>>> relying on random(), we could make gistchoose() use our own PRNG and
>>> then invent a debugging function that forces the seed to a known value.
>>> (GEQO already does something similar, although I'd not go as far as
>>> exposing the seed as a GUC. Resetting it via some quick-hack C
>>> function in regress.c would be enough IMO.) Or perhaps gist.sql could
>>> be adjusted so that the test data is less full of equally-good tuples.
>
>> I think we should use not entropy-based tie breaker in GiST. We can extract some randomness from tuples using hash.
>> I'd be much happier if GiST behaviour was deterministic.
>
> If we started using our own PRNG, we could very easily make the "random"
> sequence be the same in every GiST build --- again, see GEQO for prior
> art. I'm a little suspicious of trying to pull some entropy out of the
> tuples themselves: that seems like it'd be tremendously prone to cross-
> platform and cross-version behavioral differences.

PFA copy of GEQO approach to GiST. I haven't found proper place to document this: current random tie breaker seems undocumented.
Will describing GUC here [0] be enough?

Thanks!

Best regards, Andrey Borodin.

[0] https://www.postgresql.org/docs/13/runtime-config-developer.html

Attachment Content-Type Size
0001-Make-GiST-deterministic.patch application/octet-stream 4.1 KB

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2020-10-24 16:54:23 Re: BUG #16685: The ecpg thread/descriptor test fails sometimes on Windows
Previous Message Tom Lane 2020-10-24 15:50:04 Re: BUG #16685: The ecpg thread/descriptor test fails sometimes on Windows