Projection in Running/StateLoaded

This has happened twice in the last two days, and the only we can resolve it is by restarting our Event Store (we are running a single instance)

Our projection is sitting in Running/StateLoaded status.
When we click Stop, it stays in “Stopping” status

The Projection itself doesn’t do that much (and funnily enough, we have a few other similar projections that don’t show this behaviour)

Can anyone help?

I tried searching the forums, but couldn’t find something specific to our issue.

Here is our projection (just in case there is a code crime)

var removeTradeFromPending = function (s, e) {

delete s.pendingSettlements[e.data.tradeId];

};

var addTradeToPending = function(s, e)
{
s.pendingSettlements[e.data.tradeId] = {
tradeDateTime : e.data.tradeDateTime
}
};

fromStreams(’$ce-TradeAggregate’, ‘$ce-SettlementAggregate’)
.partitionBy(function (e) { return “ProductTrade-” + e.data.productId.replace(/-/gi, “”); })
.when({
$init: function (s, e) {
return {
pendingSettlements: {}
};
},

    'TradeCompletedEvent': addTradeToPending,
    'SettlementCreatedEvent': removeTradeFromPending
})

``

We are running 4.1.1

For reference, we seem to have fixed the problem.

Two things we changed:

  1. Added some error handling in the partitionBy to check for events which don’t have productId (which were quite a few because we listened to Category stream)

  2. We have some code which automatically updates our projects when a REST endoint restarts (we don’t stop the proejctions, just blindly update if we detect changes)

Assuming one of these changes sorted the issue.

Just for further reference, we opted to remove the listening to category streams, and only listen to the specific event type streams to remove the need for error handling in byPartition.

Hopefully this helps others!