> On 20 Feb 2024, at 02:21, Michael Paquier <mich...@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 within repository.
In that test I need to sync backends in 3 steps (backend 1 starts to wait in 
injection point, backend 2 starts to sleep in other point, backend 1 is 
released and observe 3rd injection point). "wake them all" implementation 
allows only 2-step synchronization.
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-logging it. It's only possible in a 
critical section.

Thanks!


Best regards, Andrey Borodin.

[0] 
https://www.postgresql.org/message-id/0925f9a9-4d53-4b27-a87e-3d83a757b...@yandex-team.ru

Reply via email to