Git Product home page Git Product logo

Comments (3)

volkerstampa avatar volkerstampa commented on July 17, 2024

A possible fix for this bug is to use the combination emitter-id and emitter sequence number as delivery id and store this in a dedicated field of a DurableEvent. So in the example above E1 would be emitted by A with this field set to A-1 and a persistOnEvent request by B would use this as delivery id instead of the local sequence number.

from eventuate.

krasserm avatar krasserm commented on July 17, 2024

This fix sounds reasonable to me as it uses a unique event identifier and not the non-unique local sequence number for referencing events that caused a PersistOnEvent request.

Instead of using the emitterId it is sufficient to use the processId of the event which is also required for extracting the initial local sequence number (i.e. emitter sequence number) from the vectorTimestamp. An additional method on DurableEvent should be added to generate this identifier (or even replace the existing id method as it is not used within Eventuate).

We still need to make sure to preserve the proper emission order of PersistOnEvent requests which is not given any more by the new identifier. Instead of the current SortedMap[Long, PersistOnEventRequest] we could use a plain Seq[PersistOnEventRequest] but this would increase confirmation complexity from O(log n) to O(n) which is not acceptable.

We therefore need to store the new identifier in addition to the currently used persistOnEventSequenceNr and introduce a second mapping Map[A, PersistOnEventRequest] (which allows us to make a lookup and removal in the current SortedMap[Long, PersistOnEventRequest] via the persistOnEventSequenceNr stored in PersistOnEventRequest) with complexity O(log n).

The new identifier must be stored in a new DurableEvent field named persistOnEventReference: Option[A]. We cannot reuse deliveryId because it would prevent us from using events for ConfirmedDelivery that have been generated via persistOnEvent.

For backwards compatibility we have to deal with the following two situations:

  1. confirmation events have set both persistOnEventSequenceNr and persistOnEventReference which allows removal of mapping entries with acceptable complexity i.e O(log n).
  2. confirmation events have only set persistOnEventSequenceNr which requires a removal from Map[A, PersistOnEventRequest] with complexity O(n) for a limited number of outstanding PersistOnEvent requests.

from eventuate.

volkerstampa avatar volkerstampa commented on July 17, 2024

Sounds good to me. A could either be a dedicated type (like case class EventId(processId: String, sequenceNr: Long) or a simple String where processId and sequenceNr are concatenated. The dedicated type might provide better type safety, however the string concatenation pattern is already used in other places in eventuate (e.g. for building a log-id).

from eventuate.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.