Skip to content

UseOptimizedProjectionRebuilds not working for customprojection since no eventypes are know. And why do we change the type of the stream for a rebuild? #3691

Open
@schadowfax

Description

@schadowfax

Issue1: CustomProjection(s) like the documentation example (custom-aggregate) does not working with UseOptimizedProjectionRebuilds true.

the issue seems to be in the in the 'BackfillStreamTypeOperation'

_eventTypeNames = projection.AllEventTypes.Select(x => events.EventMappingFor((Type)x).EventTypeName).ToArray();

AllEventTypes are null at this point and give a exception.

Issue2: Also the logic that is executed here in the 'BackfillStreamTypeOperation' i find bit wierd.

update public.mt_streams s set type = $1 from public.mt_events e where s.id = e.stream_id and s.tenant_id = e.tenant_id and s.type is NULL and e.type = ANY($2) and s.is_archived = FALSE and e.seq_id > $3 and e.seq_id <= $4",

Why would I want to change the type of my stream? From what I understand, this is done to populate the mt_aggregate_rebuild table based on stream type information. However, this approach can introduce significant and unexpected issues.

Consider this scenario:

You have Aggregate1 and a SingleStreamViewProjection1, which subscribes to a subset of events from Aggregate1.
If you attempt to rebuild both simultaneously, concurrency issues are likely to occur, potentially leading to significant data loss.

Wouldn't it be better to use an intermediary table like mt_aggregate_rebuild to handle this behavior explicitly? This would also avoid incorrectly setting the original stream as a 'SingleStreamViewProjection1', which is inherently problematic.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions