Projection wired as synchronous and asynchronous


Marten1008 Warning

Cause

A projection is wired as synchronous and asynchronous through the EventGraph of the document store.

Reason for rule

Projections wired both as synchronous and asynhcronous can race, leading to data loss.

Note: analyzers run at project scope (and against open files, if Full Solution Analysis is not enabled). For solution-wide analysis, run Marten.AnalyzerTool.

Remarks

Synchronous single stream projections can safely be wired in multiple store instances (e.g. in separate processes), as long as versioned methods of the IEvenStore are used (see Marten docs).

How to fix violations

Either have a dedicated asynchronous projection or see that the projection is applicable to be wired as synchronous in multiple store instances.

Examples

Violates

storeOptions.Events.InlineProjections.Add(new MyProjection());
storeOptions.Events.AsyncProjections.AggregateStreamsWith<MyProjection>();

Does not violate

storeOptions.Events.AsyncProjections.AggregateStreamsWith<MyProjection>();