Skip to content

Configurable eid generation strategy. #191

Open
@Chuburashka

Description

At this moment we have hardcoded logic for generating new eid value - link

There are following advantages for this solution:

  1. We have a guarantee that every event sent from this application (or rather, using this same eventlog table/eid sequence) has only one unique eid. If we republish this event it will be republished with the same eid.
  2. Sequential eid generation – the eid can be used as an ordering key to restore the event creation order.

But also we have some disadvantages:

  1. The ID generated here is formatted as an UUID (as this is how the field is declared at Nakadi), but actually doesn't provide the uniqueness guarantees expected from UUIDs
  2. If you have multiple producers (with separate databases) submitting to the same event type, each has their own sequence running in parallel, which will produce duplicates.

In some cases it topics with multiple producers are needed (or at least very nice to have), and we should have a uniqueness guarantee of eids at least per event type for them.

I see the these possible solutions:

  1. Based on configuration, use different strategy for convertToUUID method: current (by default) or UUID.randomUUID().
    The main changes are needed in mapToNakadiEvent and tryToPublishBatch.
    But in this case we lose all advantages of the current solution with randomUUID generation.

  2. Add additional eid column with generated eid to event_log table.
    Before persisting the event, event generate randomUUID in createEventLog and persist the EventLog entity with already generated eid.
    When we try to send event to nakadi, we can choose the different strategy based on eid field. If there is data there, then use eid field, if not, then id with default strategy. (Again don't forget about failed events resolving in tryToPublishBatch).
    In this case we have guarantee for repulishing, but lose sequential eid generation logic (possibly we can use spanCtx and add id field as key here).

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions