Re: Injection points: some tools to wait and wake
От
Michael Paquier
Тема
Re: Injection points: some tools to wait and wake
Дата
Msg-id
ZdWqOHkYDfRe646C@paquier.xyz
Ответ на
Re: Injection points: some tools to wait and wake (Michael Paquier)
Список
Дерево обсуждения
Injection points: some tools to wait and wake Michael Paquier <michael@paquier.xyz>
Re: Injection points: some tools to wait and wake "Andrey M. Borodin" <x4mmm@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 "Andrey M. Borodin" <x4mmm@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>
Re: Injection points: some tools to wait and wake Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Re: Injection points: some tools to wait and wake Michael Paquier <michael@paquier.xyz>
Re: Injection points: some tools to wait and wake Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
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>
Re: Injection points: some tools to wait and wake Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Re: Injection points: some tools to wait and wake Michael Paquier <michael@paquier.xyz>
Re: Injection points: some tools to wait and wake Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Re: Injection points: some tools to wait and wake Michael Paquier <michael@paquier.xyz>
Re: Injection points: some tools to wait and wake "Andrey M. Borodin" <x4mmm@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 "Andrey M. Borodin" <x4mmm@yandex-team.ru>
Re: Injection points: some tools to wait and wake Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Re: Injection points: some tools to wait and wake "Andrey M. Borodin" <x4mmm@yandex-team.ru>
Re: Injection points: some tools to wait and wake Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Re: Injection points: some tools to wait and wake Michael Paquier <michael@paquier.xyz>
Re: Injection points: some tools to wait and wake "Andrey M. Borodin" <x4mmm@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 Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Re: Injection points: some tools to wait and wake Michael Paquier <michael@paquier.xyz>
Re: Injection points: some tools to wait and wake Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Re: Injection points: some tools to wait and wake "Andrey M. Borodin" <x4mmm@yandex-team.ru>
Re: Injection points: some tools to wait and wake Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Re: Injection points: some tools to wait and wake "Andrey M. Borodin" <x4mmm@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 Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Re: Injection points: some tools to wait and wake Michael Paquier <michael@paquier.xyz>
Re: Injection points: some tools to wait and wake Jelte Fennema-Nio <postgres@jeltef.nl>
Re: Injection points: some tools to wait and wake "Andrey M. Borodin" <x4mmm@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 Jelte Fennema-Nio <postgres@jeltef.nl>
Re: Injection points: some tools to wait and wake Michael Paquier <michael@paquier.xyz>
Re: Injection points: some tools to wait and wake Jelte Fennema-Nio <postgres@jeltef.nl>
Re: Injection points: some tools to wait and wake Michael Paquier <michael@paquier.xyz>
Re: Injection points: some tools to wait and wake Jelte Fennema-Nio <postgres@jeltef.nl>
Re: Injection points: some tools to wait and wake Michael Paquier <michael@paquier.xyz>
Re: Injection points: some tools to wait and wake Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Re: Injection points: some tools to wait and wake Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Re: Injection points: some tools to wait and wake Michael Paquier <michael@paquier.xyz>
Re: Injection points: some tools to wait and wake Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
On Wed, Feb 21, 2024 at 07:08:03AM +0900, Michael Paquier wrote: > Well, both you and Andrey are asking for it now, so let's do it. The > implementation is simple: > - Store in InjectionPointSharedState an array of wait_counts and an > array of names. There is only one condition variable. > - When a point wants to wait, it takes the spinlock and looks within > the array of names until it finds a free slot, adds its name into the > array to reserve a wait counter at the same position, releases the > spinlock. Then it loops on the condition variable for an update of > the counter it has reserved. It is possible to make something more > efficient, but at a small size it would not really matter. > - The wakeup takes a point name in argument, acquires the spinlock, > and checks if it can find the point into the array, pinpoints the > location of the counter to update and updates it. Then it broadcasts > the change. > - The wait loop checks its counter, leaves its loop, cancels the > sleep, takes the spinlock to unregister from the array, and leaves. > > I would just hardcode the number of points that can wait, say 5 of > them tracked in shmem? Does that look like what you are looking at? I was looking at that, and it proves to work OK, so you can do stuff like waits and wakeups for multiple processes in a controlled manner. The attached patch authorizes up to 32 waiters. I have switched things so as the information reported in pg_stat_activity is the name of the injection point itself. Comments and ideas are welcome. -- Michael
В списке pgsql-hackers по дате отправления
От: Peter Eisentraut
Дата: