mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-12 01:47:33 +00:00
feat(eventstore): add row locking option (#8939)
# Which Problems Are Solved We need a reliable way to lock events that are being processed as part of a job queue. For example in the notification handlers. # How the Problems Are Solved Allow setting `FOR UPDATE [ NOWAIT | SKIP LOCKED ]` to the eventstore query builder using an open transaction. - NOWAIT returns an errors if the lock cannot be obtained - SKIP LOCKED only returns row which are not locked. - Default is to wait for the lock to be released. # Additional Changes - none # Additional Context - [Locking docs](https://www.postgresql.org/docs/17/sql-select.html#SQL-FOR-UPDATE-SHARE) - Related to https://github.com/zitadel/zitadel/issues/8931
This commit is contained in:
@@ -14,6 +14,8 @@ type SearchQuery struct {
|
||||
|
||||
SubQueries [][]*Filter
|
||||
Tx *sql.Tx
|
||||
LockRows bool
|
||||
LockOption eventstore.LockOption
|
||||
AllowTimeTravel bool
|
||||
AwaitOpenTransactions bool
|
||||
Limit uint64
|
||||
@@ -130,6 +132,7 @@ func QueryFromBuilder(builder *eventstore.SearchQueryBuilder) (*SearchQuery, err
|
||||
AwaitOpenTransactions: builder.GetAwaitOpenTransactions(),
|
||||
SubQueries: make([][]*Filter, len(builder.GetQueries())),
|
||||
}
|
||||
query.LockRows, query.LockOption = builder.GetLockRows()
|
||||
|
||||
for _, f := range []func(builder *eventstore.SearchQueryBuilder, query *SearchQuery) *Filter{
|
||||
instanceIDFilter,
|
||||
|
Reference in New Issue
Block a user