Hi,
We are evaluating whether we can migrate the calculation of our average of incoming measurement events to projections in EventStore. I up-gradate today to the latest version (coming from 0.9), and I can’t remeber I had the problem in the past with the same projections…
What we do, as test, is writing measurement values for 50 meters. And we have 4 projections calculating averages. After a while we get following exception. This can be some seconds to minutes depending on how hard we stress the writing of the events…
Emitted event caused position before last handled position
The projections looks like this:
fromAll()
.foreachStream()
.when( {
MeasurementRead : function (previousState, measurementEvent) {
if (measurementEvent.body == null) return previousState;
var timestamp = measurementEvent.body.Timestamp;
var reading = measurementEvent.body.Reading;
if (previousState.total == null) {
return createState(reading, 1, timestamp);
}
if (isDifferentTimeSlot(timestamp, previousState.lastTimestamp)) {
var name = eventStreamId(measurementEvent.streamId, previousState.lastTimestamp);
var event = createEvent(formatTimeSlot(previousState.lastTimestamp), previousState.total, previousState.count);
emit(name, "MeasurementPeriod", event);
return createState(reading, 1, timestamp);
} else {
return createState(previousState.total + reading, previousState.count + 1, timestamp);
}
};
});
The helper methods implementations are omitted for verbosity…
Any idea on how to prevent this? I can upload the sample project if this helps…