vdq.utils
Overview
Row locks on VDQ queue items.
lock_queue_item
Yield the queue item pk locked with SELECT FOR UPDATE inside a transaction. Yields None when the item does not exist, or when skip_locked is true and another transaction holds the lock.
Signature
lock_queue_item(pk, skip_locked)
Parameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
| pk | yes | |||
| skip_locked | no | True |
Returns
contextlib.AbstractContextManager[vueda.vdq.models.QueueItem | None]
Source
server/vueda/vdq/utils.py:34
with_locked_queue_item
Run operation on the locked queue item in its own transaction, and return its result.
operation receives None when the row does not exist. The lock waits for another transaction that holds the row, for at most LOCK_TIMEOUT. At REPEATABLE READ, a transaction that waited for a holder that updated the row fails with a serialization error. A stale read of workflow state fails the same way when it is written. Either failure reruns operation in a new transaction, up to LOCK_ATTEMPTS times, so operation must be safe to run again. Call this outside any transaction: rolling back to a savepoint does not give the rerun a fresh snapshot.
Signature
with_locked_queue_item(pk, operation)
Parameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
| pk | yes | |||
| operation | collections.abc.Callable[[vueda.vdq.models.QueueItem | None], T] | yes |
Returns
T
Source
server/vueda/vdq/utils.py:45
Source
server/vueda/vdq/utils.py