safety-data / akka-persistence-redis

Akka persistence plugin for Redis
Apache License 2.0
27 stars 13 forks source link

Problem with eventsByPersistenceId using large sequence number ranges #11

Closed sidsethupathi closed 7 years ago

sidsethupathi commented 7 years ago

I'm trying to call eventsByPersistenceId(id, 0L, Long.MaxValue) with a single event in my journal that has a score of 600. The reason for this large range is to effectively say I want every event for a given persistenceId.

It appears that the following code makes the zrangebyscore call with a with a min score of 0 and max score of 100 (the default configured max value). Is this intentional?

https://github.com/safety-data/akka-persistence-redis/blob/17563b5f236ee88e57b8cc70b896270fa538c044/src/main/scala/akka/persistence/query/journal/redis/EventsByPersistenceIdSource.scala#L192

satabin commented 7 years ago

Yes, it does not load all events in a range at once because it could blow up the memory. However it should act as a pagination mechanism and if this page is empty, then try the next one and so on until the upper limit.

If it does not try the next page then it is a bug.

sidsethupathi commented 7 years ago

Yes, I don't think it tries the next page if the current page is empty. I will do some more investigating to confirm.

sidsethupathi commented 7 years ago

It looks like this is a bug.

If you add akka-persistence-redis.read-journal.max = 1 to https://github.com/safety-data/akka-persistence-redis/blob/897f31698a9c61fbb19eeef5135dfdd2a090b2b4/src/test/scala/akka/persistence/query/journal/redis/EventsByPersistenceIdSpec.scala#L28-L32 you can reproduce this issue.

satabin commented 7 years ago

I believe this is now fixed. I published a new snapshot version with the fix. I you can confirm it, I will release version 0.3.0 by the end of the week.