Исходный код вики Организация блокировок с пропуском заблокированных
Версия 1.2 от Alexandr Fokin на 2024/02/07 21:11
Скрыть последних авторов
author | version | line-number | content |
---|---|---|---|
![]() |
1.1 | 1 | |(% style="width:252px" %) |(% style="width:1202px" %)[[Пессимистичная блокировка>>doc:Архитектура и модели.Блокировки.Пессимистичная блокировка.WebHome]] |
![]() |
1.2 | 2 | |(% style="width:252px" %) |(% style="width:1202px" %)[[https:~~/~~/postgrespro.ru/docs/postgresql/12/functions-admin>>https://postgrespro.ru/docs/postgresql/12/functions-admin]] |
![]() |
1.1 | 3 | |(% style="width:252px" %)Блокировка через основной механизм БД|(% style="width:1202px" %){{code language="sql"}}Begin; |
4 | |||
5 | select * | ||
6 | from table | ||
7 | FOR UPDATE SKIP LOCKED; | ||
8 | |||
9 | --action | ||
10 | |||
11 | Commit;{{/code}} | ||
12 | |(% style="width:252px" %)Рекомендательные блокировки|(% style="width:1202px" %){{code language="sql"}}Begin; | ||
13 | |||
14 | select * | ||
15 | from table | ||
16 | where | ||
17 | -- (table or action key, rowKey) | ||
18 | pg_try_advisory_xact_lock(1, id) | ||
19 | -- or pg_try_advisory_xact_lock(1, uuid_hash(guidId)) | ||
20 | |||
21 | -- action | ||
22 | |||
23 | Commit;{{/code}} | ||
24 | |(% style="width:252px" %) |(% style="width:1202px" %) | ||
25 | |||
26 |