JasperFx / marten

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

Async deamon Query after event archive #3245

Closed asoeters closed 4 months ago

asoeters commented 4 months ago

After archiving the projection is still queryable after archiving.

    await using (var session = store.LightweightSession())
    {
        id = session.Events.StartStream<ValueDto>(new Add("test"), new Edit("edit")).Id;
        session.SaveChanges();
    }

    await store.WaitForNonStaleProjectionDataAsync(20.Seconds());
    await using (var session = store.QuerySession())
    {
        var state = session.Query<ValueDto>().FirstOrDefault(x => x.Id == id);
    }

    await using (var session = store.LightweightSession())
    {
        session.Events.ArchiveStream(id);
    }
    await store.WaitForNonStaleProjectionDataAsync(20.Seconds());
    await using (var session = store.QuerySession())
    {
       var currentState = await session.Events.FetchStreamStateAsync(id); //This returns a true for archive
        var state = session.Query<ValueDto>().FirstOrDefault(x => x.Id == id); //This return the full object. 
    }

I created a small repro project: https://github.com/asoeters/MartenArchive

jeremydmiller commented 4 months ago

Archiving a stream is just a marker in the system. It has impact on projection rebuilds, and will hopefully be part of future plans to shard the events table. What you're seeing is as designed.