muoncore / newton

Extend Muon into the world of Spring. Implement Muon apis, especially around events to provide DDD patterns natively in Spring Boot
http://muoncore.io
GNU Lesser General Public License v3.0
12 stars 5 forks source link

Unable to load aggregate even though it exists #40

Closed bobjana closed 7 years ago

bobjana commented 7 years ago

io.muoncore.newton.eventsource.AggregateNotFoundException: Unable to load aggregate with ID 593f988039e08183f26b29d7, it does not exist in the event store

even though the entity exists as part of view:

"_id" : ObjectId("593f988039e08183f26b29d7"), "_class" : "mu.cibecs.core.device.query.view.Device",

This error also occurs inconsistently.

To replicate:

Run Cibecs DeviceSpecification. It fails when trying to create a task for the device. What's really strange is that the same aggregate is loaded for scenarios before 'Add device task', but then fails. Putting in a Thread.sleep(2000) causes it to pass

OR

Run new-sample TaskSpecification - the updateDescription scenario updates the description x25 times. If bug is not reproduced, just rerun spec a couple times

bobjana commented 7 years ago

This bug still occurs. Note: if only a single service is subscribed to stream it seems not to occur (still need to verify), however having 2 or more subscriptions, the bug is reproduced consistently.

In our case trying to delete a customer, with security-service & core-service subscribing to customer events, the usecase fails consistently:

13:36:54.545 [main] DEBUG org.apache.http.wire -  << "{"timestamp":"2017-06-22T11:36:54.542+0000","status":500,"error":"Internal Server Error","exception":"java.lang.RuntimeException","message":"Unable to load aggregate: Customer","path":"/api/customers/594babcf1221a043da4abd07"}"

however if core-service is taken down & the same use-case is run, it is able to delete customer

bobjana commented 7 years ago

Simulated loads are going through. This seems to be resolved

bobjana commented 7 years ago

This re-occured. We suspect that it's an underlying photon memory issue as per issue that might have caused it to occur. Will ask Mark to keep an eye on this

daviddawson commented 7 years ago

Newton currently takes the case where no events are returned as a "no aggregate found" error and reports as that.

In this case, photon was offline due to https://github.com/muoncore/photonlite/issues/9 causing a memory issue. The error should be reported as "eventstore cannot be found" in this case, which would have been correct. @bobjana would you agree this is the correct solution to the case where photon is not able to be contacted? eg, network failures etc.

bobjana commented 7 years ago

Yes, I do agree @daviddawson - Ultimately we'd somehow like to put the client-app in state that blocks any further transactions & report the fact that underlying event-store is offline.