mirror of
https://github.com/andwati/zitadel.git
synced 2026-10-18 05:52:51 +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
|
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 {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user