mirror of
https://github.com/zitadel/zitadel.git
synced 2025-12-25 23:16:29 +00:00
fix(projection): locking behavior based on configuration (#11014)
Ensure projections await running status if configured, improving synchronization during event processing.
This commit is contained in:
@@ -559,7 +559,12 @@ func (h *Handler) processEvents(ctx context.Context, config *triggerConfig) (add
|
||||
}()
|
||||
|
||||
var hasLocked bool
|
||||
err = tx.QueryRowContext(ctx, "SELECT pg_try_advisory_xact_lock(hashtext($1), hashtext($2))", h.ProjectionName(), authz.GetInstance(ctx).InstanceID()).Scan(&hasLocked)
|
||||
if config.awaitRunning {
|
||||
_, err = tx.ExecContext(ctx, "SELECT pg_advisory_xact_lock(hashtext($1), hashtext($2))", h.ProjectionName(), authz.GetInstance(ctx).InstanceID())
|
||||
hasLocked = true
|
||||
} else {
|
||||
err = tx.QueryRowContext(ctx, "SELECT pg_try_advisory_xact_lock(hashtext($1), hashtext($2))", h.ProjectionName(), authz.GetInstance(ctx).InstanceID()).Scan(&hasLocked)
|
||||
}
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user