-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CurrentEventsByTag query does not guarantee ordering of events #214
Comments
Hi @pepite - There's a bunch of discussion on this in #37. Implementing a global sequence number (#95 maybe) should solve the issue.
The problem with |
thanks I will have a look at what I can do and submit a PR. |
Would a solution then be to group by persistence id and then sort by sequence number? Or do I miss something? |
I think you really end up needing a sequence number either at the tag level or at the global level to accomplish ordering. Maybe for some use cases of the plugin the suggested approach of group by persistence id then sort by sequence number could work well enough, but in general for a concurrent set of The case of batched inserts could be fixed by sorting on |
First version is there https://github.com/pepite/akka-persistence-mongo/tree/fix-ordering-event . PR to follow (I still need a migration feature, some extra tests and maybe some explanation). However the tests are not all passing on my Mac (this branch and master). I started test_container but some of them fails, especially the Akka test kit. Is there anything I should be aware of? |
I will take a deeper look soon - but in quickly looking at this, I'm concerned that it may not be backward compatible. It could be that I just haven't looked at it deep enough yet. Just need to tread carefully since this code has been in production for a while (write side for several years, read side less). The tests have a couple of race conditions in them, so do not always pass. I use a minimum of |
Yes I did not implement the backward compatibility yet. It is on my todo list. This is why there is no PR yet ;)
…Sent from my iPhone
On 3 Jan 2019, at 16:09, Brian Scully ***@***.***> wrote:
I will take a deeper look soon - but in quickly looking at this, I'm concerned that it may not be backward compatible. It could be that I just haven't looked at it deep enough yet. Just need to tread carefully since this code has been in production for a while (write side for several years, read side less).
The tests have a couple of race conditions in them, so do not always pass. I use a minimum of akka.test.timefactor=3. With this, the test suite passes on travis for most combinations of (scala + mongo) on the first attempt.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
|
We are experiencing this issue occasionally. The main problem it seems is that the I have one idea that should work for Mongo version >= 3.6. It will change the read side setup though, but shouldn't require migration since the journal collection is the source of truth anyway.
@scullxbones what do you think? I'm not sure about the performance implications of this approach but it sounds like a robust solution that should guarantee consistency between the write and the read sides |
Yep no doubt the 3.6 I'd be interested though in the workarounds you mentioned in (1). Especially for #238 - it would be good to make the 3 drivers as consistent as possible. Or at least the 2 that are actively developed. |
The current
CurrentEventsByTag
object query the events sorted by Id. However, there is no guarantee an id is greater than the other when inserted in the journal.An object ID is encoded with the following specification:
This means that if two events is inserted at the same second we have no guarantee one is inserted before the other.
The relevant code is:
with
BSONDocument(ID -> BSONDocument("$gt" -> id))
and.sort(BSONDocument(ID -> 1))
being the issue I suppose. I believe it should be.sort(BSONDocument(SEQUENCE_NUMBER -> 1))
The text was updated successfully, but these errors were encountered: