JasperFx / marten

.NET Transactional Document DB and Event Store on PostgreSQL
https://martendb.io
MIT License
2.87k stars 457 forks source link

Archiving streams, snapshots and async projections #3258

Open elexisvenator opened 5 months ago

elexisvenator commented 5 months ago

More of a discussion than an issue.

I've been putting together ideas for how to remodel one of our apps that uses marten events. Currently the main business entity - a versioned document - has its own stream. I see this as a problem as these documents tend to live forever and can have ongoing activity. The new design would split out parts into their own streams - most importantly each "document version" is its own stream. This along with some other changes I think is a good potential design, but it led to me thinking about archiving. So here is what I am considering:

So my questions are:

I think the first question is the most important, as I don't like writing code that is essentially "wait until highwater mark is equal to this event sequence id".

jeremydmiller commented 5 months ago

I don't actually want to do #2982. I don't think that's necessarily a good idea to change the existing behavior. I'll think more on this later though, but this week is awful for me and I'm just trying to hang on til Friday:)

jeremydmiller commented 2 months ago

Think about this as "stream compacting". Two possible ways:

  1. Retain the existing surrogate stream id, but effectively rewrite the stream as an initial event that supplies the initial state
  2. "Re-stream" to a new stream altogether, but archive off the original stream so that it at least gets to the archived partition

Still need more analysis on the rest of the points that @elexisvenator brought up though