fix(mirror): skip notification projections (#9878)

# Which Problems Are Solved

During the mirror command execution we saw high wait times for
notification projections.

# How the Problems Are Solved

As the events are skipped anyways because the notifications are sent out
by the source Zitadel we skip the projections and just set the current
state.
This commit is contained in:
Silvan
2025-05-12 15:58:23 +02:00
committed by GitHub
parent e302591f09
commit 5331841675
4 changed files with 43 additions and 6 deletions

View File

@@ -59,6 +59,26 @@ func Start(ctx context.Context) {
}
}
func SetCurrentState(ctx context.Context, es *eventstore.Eventstore) error {
if len(projections) == 0 {
return nil
}
position, err := es.LatestSequence(ctx, eventstore.NewSearchQueryBuilder(eventstore.ColumnsMaxSequence).InstanceID(authz.GetInstance(ctx).InstanceID()).OrderDesc().Limit(1))
if err != nil {
return err
}
for i, projection := range projections {
logging.WithFields("name", projection.ProjectionName(), "instance", authz.GetInstance(ctx).InstanceID(), "index", fmt.Sprintf("%d/%d", i, len(projections))).Info("set current state of notification projection")
_, err = projection.Trigger(ctx, handler.WithMinPosition(position))
if err != nil {
return err
}
logging.WithFields("name", projection.ProjectionName(), "instance", authz.GetInstance(ctx).InstanceID(), "index", fmt.Sprintf("%d/%d", i, len(projections))).Info("current state of notification projection set")
}
return nil
}
func ProjectInstance(ctx context.Context) error {
for i, projection := range projections {
logging.WithFields("name", projection.ProjectionName(), "instance", authz.GetInstance(ctx).InstanceID(), "index", fmt.Sprintf("%d/%d", i, len(projections))).Info("starting notification projection")