EventStore / EventStore

EventStoreDB, the event-native database. Designed for Event Sourcing, Event-Driven, and Microservices architectures
https://eventstore.com
Other
5.31k stars 643 forks source link

Projection fails when selecting events from streams with maxAge set #1333

Closed jeer007 closed 7 years ago

jeer007 commented 7 years ago

Regarding EventStore 4.0.1.0. for Windows

My continuous projection code looks like this:

fromStreams('CC1-teservice-1', 'CC1-teservice-2').when({'te-status' : function(s, e) {linkTo('teccapi-apa5-stream', e);}})

This works fine as long as the events in the input streams ('CC1-teservice-1', 'CC1-teservice-2') persists for ever.

The problem occurs when I set the maxAge on the input streams to any value that causes old events to be deleted from the streams.

The EventStore logs then says:


[PID:09264:017 2017.06.07 14:56:23.874 INFO  ProjectionManager   ] 'TestAPA5' projection source has been written
[PID:09264:017 2017.06.07 14:56:23.874 DEBUG MultiStreamMessageWr] PROJECTIONS: Scheduling the writing of $start to $projections-$74aa7753-ae1a-4c3c-87c6-1c2d7d0ea183. Current status of Writer: Busy: False
[PID:09264:017 2017.06.07 14:56:23.890 DEBUG MultiStreamMessageWr] PROJECTIONS: Finished writing events to $projections-$74aa7753ae1a4c3c87c61c2d7d0ea183: $start
[PID:09264:018 2017.06.07 14:56:23.890 DEBUG ProjectionCoreServic] PROJECTIONS: Command received: 121@$start
[PID:09264:018 2017.06.07 14:56:23.890 DEBUG ResponseWriter      ] PROJECTIONS: Scheduling the writing of $started to $projections-$master. Current status of Writer: Busy: True
[PID:09264:018 2017.06.07 14:56:23.890 ERROR QueuedHandlerMRES   ] Error while processing message EventStore.Projections.Core.Messaging.UnwrapEnvelopeMessage in queued handler 'Projection Core #0'.
System.InvalidOperationException: Event number 0 was expected in the stream CC1-teservice-1, but event number 13 was received
   at EventStore.Projections.Core.Services.Processing.MultiStreamEventReader.DeliverEvent(ResolvedEvent pair, Single progress)
   at EventStore.Projections.Core.Services.Processing.MultiStreamEventReader.ProcessBuffers()
   at EventStore.Projections.Core.Services.Processing.MultiStreamEventReader.Handle(ReadStreamEventsForwardCompleted message)
   at EventStore.Core.Messaging.SendToThisEnvelope.ReplyWith[T](T message)
   at EventStore.Core.Bus.MessageHandler`1.TryHandle(Message message)
   at EventStore.Core.Bus.InMemoryBus.Publish(Message message)
   at EventStore.Core.Bus.QueuedHandlerMRES.ReadFromQueue(Object o)

...and no event links will be added to the output stream (in this case 'teccapi-apa5-stream').

What is really strange is if I only select one (e.g. 'CC1-teservice-1') input stream in the fromStreams() the projection works fine without any errors.

Regards Jens Eriksson

jeer007 commented 7 years ago

As long as we don't utilizes checkpoints in our implementation, I've tried to just remove the "throw new InvalidOperationException" in MultiStreamEventReader.DeliverEvent (row 329) as a workaround. This seems to work fine for us. It has been running for a week now. But maybe it can pose some other consequences that I cannot foresee?