-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Fix JournalSpec: AtomicWrite(Seq) instead of Seq(AtomicWrite) #18297
Conversation
Can one of the repo owners verify this patch? |
OK TO TEST |
Test FAILed. |
@@ -58,9 +58,9 @@ abstract class JournalSpec(config: Config) extends PluginSpec(config) { | |||
def writeMessages(fromSnr: Int, toSnr: Int, pid: String, sender: ActorRef, writerUuid: String): Unit = { | |||
val msgs = | |||
if (supportsAtomicPersistAllOfSeveralEvents) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think those two if-else branches were accidentally interchanged. It looks like the test data for persistAll
is located in the else branch, but it should be here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I've just massed up with closing curly braces of map { i => ... }
, moment :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean that the original code was wrong. The fix is to swap places of the if-else
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@patriknw the problem that in both cases of if-else
we have Seq of AtomicWrite
with same persistenceId, and none with AtomicWrite of Seq
PersistentRepr(payload = s"a-$i", sequenceNr = i, persistenceId = pid, sender = sender, | ||
writerUuid = writerUuid) | ||
})) | ||
} else { | ||
(fromSnr to toSnr - 1).map { i ⇒ | ||
if (i == toSnr - 1) | ||
AtomicWrite(List( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@t3hnar isn't this an AtomicWrite(Seq)) ?
I think that was intended to test the persistAll
scenario, unless the journal doesn't support it by setting supportsAtomicPersistAllOfSeveralEvents = false
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this is still wrong;
The first case should be List(AtomicWrite(1,2,3,...))
the second case should be List(AtomicWrite(1), AtomicWrite(2), AtomicWrite(3), ...)
.
The intent is to allow journals to implement handling of AtomicWrite(1,2,3)
by throwing since there's no way it can guarantee it. Such journal should still pass, while it should explicitly document it is not able to provide atomic writes of more than 1 event.
// Yes, it could "store them as one event internally" but we're want to leave this up to the implementation if it does some hack, or says it can not handle this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, it is Seq of AtomicWrite of Seq
... weird, is it an expected behaviour to send
Seq(AtomicWrite(samePersistenceId, xs), AtomicWrite(samePersistenceId, ys))
instead of
Seq(AtomicWrite(samePersistenceId, xs ++ yx))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes because they are not semantically equivalent. It's expected if you use persist()
, only persistAll()
will wrap many events into an Atomic
op.
It's about the guarantees which are expected from these calls - "All" is the atomic one, and atomic ops are opt-in, we never make them up for the user (the assumption being that they're expensive)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since you're in here it would be great if you could pull it through :-)
Let me know if there's something unclear still, happy to help out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, ok, will fix both cases :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is some misunderstanding and it can be on my end. There should not be any AtomicWrite(List(1,2,3)) when supportsAtomicPersistAllOfSeveralEvents == false
.
Why can't we just swap the cases?
val msgs =
if (supportsAtomicPersistAllOfSeveralEvents)
(fromSnr to toSnr - 1).map { i ⇒
if (i == toSnr - 1)
AtomicWrite(List(
PersistentRepr(payload = s"a-$i", sequenceNr = i, persistenceId = pid, sender = sender,
writerUuid = writerUuid),
PersistentRepr(payload = s"a-${i + 1}", sequenceNr = i + 1, persistenceId = pid, sender = sender,
writerUuid = writerUuid)))
else
AtomicWrite(PersistentRepr(payload = s"a-${i}", sequenceNr = i, persistenceId = pid, sender = sender,
writerUuid = writerUuid))
}
else
(fromSnr to toSnr).map { i ⇒
AtomicWrite(PersistentRepr(payload = s"a-$i", sequenceNr = i, persistenceId = pid, sender = sender,
writerUuid = writerUuid))
}
Note that in the supportsAtomicPersistAllOfSeveralEvents == true
case I would like to have a mix of things, i.e.
List(AtomicWrite(1), AtomicWrite(2), AtomicWrite(3, 4))
Test PASSed. |
Test PASSed. |
Test PASSed. |
LGTM, thanks for the cleanup |
Fix JournalSpec: AtomicWrite(Seq) instead of Seq(AtomicWrite)
Would be nice to have it in 2.4.0