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:
Silvan
2025-10-31 12:10:02 +01:00
committed by GitHub
parent c913904df3
commit 345480faeb

View File

@@ -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
}