Re: Injection points: some tools to wait and wake

Поиск
Список
Период
Сортировка
От Andrey M. Borodin
Тема Re: Injection points: some tools to wait and wake
Дата
Msg-id 48FBD260-D49D-43CA-B05D-BBB03235236E@yandex-team.ru
обсуждение исходный текст
Ответ на Re: Injection points: some tools to wait and wake  (Michael Paquier <michael@paquier.xyz>)
Ответы Re: Injection points: some tools to wait and wake  (Michael Paquier <michael@paquier.xyz>)
Список pgsql-hackers

> On 20 Feb 2024, at 02:21, Michael Paquier <michael@paquier.xyz> wrote:
>
> On Mon, Feb 19, 2024 at 11:54:20AM +0300, Andrey M. Borodin wrote:
>> 1. injection_points_wake() will wake all of waiters. But it's not
>> suitable for complex tests. I think there must be a way to wake only
>> specific waiter by injection point name.
>
> I don't disagree with that, but I don't have a strong argument for
> implementing that until there is an explicit need for it in core.  It
> is also possible to plug in your own module, outside of core, if you
> are looking for something more specific.  The backend APIs allow that.

In [0] I want to create a test for edge case of reading recent multixact. External module does not allow to have a test
withinrepository. 
In that test I need to sync backends in 3 steps (backend 1 starts to wait in injection point, backend 2 starts to sleep
inother point, backend 1 is released and observe 3rd injection point). "wake them all" implementation allows only
2-stepsynchronization. 
I will try to simplify test to 2-step, but it would be much easier to implement if injection points could be awaken
independently.

>> 2. Alexander Korotkov's stopevents could be used in isolation
>> tests. This kind of tests is perfect for describing complex race
>> conditions. (as a side note, I'd be happy if we could have
>> primary\standby in isolation tests too)
>
> This requires plugging is more into src/test/isolation/, with multiple
> connection strings.  This has been suggested in the past.

I think standby isolation tests are just a sugar-on-top feature here.
Wrt injection points, I'd like to see a function to wait until some injection point is observed.
With this function at hand developer can implement race condition tests as an isolation test.

>> 5. In many cases we need to have injection point under critical
>> section. I propose to have a "prepared injection point". See [0] for
>> example in v2-0003-Test-multixact-CV-sleep.patch
>> +   INJECTION_POINT_PREPARE("GetNewMultiXactId-done");
>> +
>>    START_CRIT_SECTION();
>>
>> +   INJECTION_POINT_RUN_PREPARED();
>
> I don't see how that's different from a wait/wake logic?  The only
> thing you've changed is to stop a wait when a point is detached and
> you want to make the stop conditional.  Plugging in a condition
> variable is more flexible than a hardcoded sleep in terms of wait,
> while being more responsive.

No, "prepared injection point" is not about wait\wake logic. It's about having injection point in critical section.
Normal injection point will pstrdup(name) and fail. In [0] I need a test that waits after multixact generation before
WAL-loggingit. It's only possible in a critical section. 

Thanks!


Best regards, Andrey Borodin.

[0] https://www.postgresql.org/message-id/0925F9A9-4D53-4B27-A87E-3D83A757B0E0@yandex-team.ru


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

Предыдущее
От: Robert Haas
Дата:
Сообщение: Re: Have pg_basebackup write "dbname" in "primary_conninfo"?
Следующее
От: Fabrice Chapuis
Дата:
Сообщение: pg_restore problem to load constraints with tables