Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug? WaitForNonStaleProjectionDataAsync waits for all projections, inline and live, not only Async projections #3166

Closed
Richard87 opened this issue Apr 28, 2024 · 3 comments

Comments

@Richard87
Copy link

When executing WaitForNonStaleProjectionDataAsync, it finds all projections, including Inline, and tries to wait for them to get past initial.EventSequenceNumber

projections.All(x => x.Sequence >= initial.EventSequenceNumber))

In my testing, inline projections doesn't get updated before a new event that is used by the projection is applied, so its almost always lagging. In those cases WaitForNonStaleProjectionDataAsync will fail.

@Richard87
Copy link
Author

Richard87 commented Apr 28, 2024

Probably the most hacky and slow bugfix:

        Dictionary<string,string> shardNames = store.Advanced.AllAsyncProjectionShardNames()
            .ToDictionary(x => x.ProjectionName, x => x.Identity);

        var shardsToCheck = store.Options
            .Events
            .Projections()
            .Where(x => x.Lifecycle == ProjectionLifecycle.Async)
            .Select(x => shardNames[x.ProjectionName]);

///and

            if ((projections.Count >= projectionsCount &&
                 projections.Where(x => shardsToCheck.Contains(x.ShardName)).All(x => x.Sequence >= initial.EventSequenceNumber))
                || cancellationSource.IsCancellationRequested)
            {

@jeremydmiller
Copy link
Member

@Richard87 I'm happy to take a pull request for that, but I'd just fix the AllAsyncProjectionShardNames() in the first place

@jeremydmiller
Copy link
Member

Basically a duplicate with #3165

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants