SETUP
-
Event Store 3.9.3
-
on a VM running Ubuntu Server 14.04 LTS
-
Projections enabled
SCHEMA and PROJECTIONS
We have many Widget-{UUID} streams and a couple projections for creating derivative streams:
One creates a single “Widget.all-changes” stream from certain high-level events for all Widgets:
fromCategory(“Widget”)
.foreachStream()
.when({
WidgetCreated: function(s,e) { linkTo(“Widget.all-changes”, e); },
WidgetAltered: function(s,e) { linkTo(“Widget.all-changes”, e); },
WidgetDeleted: function(s,e) { linkTo(“Widget.all-changes”, e); },
WidgetVersionCompleted: function(s,e) { linkTo(“Widget.all-changes”, e); }
});
``
Another creates a derivative “header” stream for each Widget, capturing same high-level events:
function headerStream(e) {
var id = e.body.id;
var headerStream = “Widget.header-” + id;
return headerStream;
}
fromCategory(“Widget”)
.foreachStream()
.when({
WidgetCreated: function(s,e) { linkTo(headerStream(e), e); },
WidgetAltered: function(s,e) { linkTo(headerStream(e), e); },
WidgetDeleted: function(s,e) { linkTo(headerStream(e), e); },
WidgetVersionCompleted: function(s,e) { linkTo(headerStream(e), e); }
});
``
HOW WE POPULATED IT
Started from brand-new, blank Event Store. Populated Widget streams by running a mass migration script from an older SQL Server database into Event Store. But we first enabled all projections, including the above two. So projections were running when the migration occurred, writing events into all the individual Widget-*** streams.
PROBLEM! MISSING EVENTS in PROJECTED STREAMS!
For many of the Widgets, the initial WidgetCreated event in their stream is straight-up missing from the “header” stream. For example, in stream Widget-e6a4de9d-cfa6-4ab1-97dc-5a3573ef638d, event 0 is (as it ought to be) a WidgetCreated event. In the stream Widget.header-e6a4de9d-cfa6-4ab1-97dc-5a3573ef638d, that WidgetCreated event is just not there. The first event in that projection-created stream is 10853@Widget-e6a4de9d-cfa6-4ab1-97dc-5a3573ef638d, which is a WidgetVersionCompleted event. Based on the projection code, I would have expected that 0@Widget-e6a4de9d-cfa6-4ab1-97dc-5a3573ef638d : WidgetCreated would have/should have been the first event.
Furthermore, this crucial WidgetCreated event is also missing from the unified projection stream Widget.all-changes. It’s just not in the stream; I checked.
SO… WHAT AM I MISSING?
Am I not understanding something about how projections work? Is there an eventual-consistency guarantee - i.e. will those missing events show up later? Or are we looking at a bug? Or are projections not guaranteed to include every event they’re supposed to include?
Obviously the answer to these questions will inform whether we are able to use projections at all in our solution.