Skip to content
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

Merged
merged 1 commit into from
Sep 3, 2015

Conversation

t3hnar
Copy link
Contributor

@t3hnar t3hnar commented Aug 22, 2015

Would be nice to have it in 2.4.0

@akka-ci
Copy link

akka-ci commented Aug 22, 2015

Can one of the repo owners verify this patch?

@ktoso
Copy link
Member

ktoso commented Aug 24, 2015

OK TO TEST

@akka-ci akka-ci added validating PR is currently being validated by Jenkins needs-attention Indicates a PR validation failure (set by CI infrastructure) and removed validating PR is currently being validated by Jenkins labels Aug 24, 2015
@akka-ci
Copy link

akka-ci commented Aug 24, 2015

Test FAILed.
Refer to this link for build results (access rights to CI server needed):
https://jenkins.akka.io/job/pr-validator-per-commit-jenkins/3501/

@@ -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)
Copy link
Member

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.

Copy link
Contributor Author

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 :)

Copy link
Member

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

Copy link
Contributor Author

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

@akka-ci akka-ci added validating PR is currently being validated by Jenkins and removed needs-attention Indicates a PR validation failure (set by CI infrastructure) labels Aug 24, 2015
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(
Copy link
Member

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

Copy link
Member

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.

Copy link
Contributor Author

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))

Copy link
Member

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)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@patriknw @ktoso are you going to fix the second case ?

Copy link
Member

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.

Copy link
Contributor Author

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 :)

Copy link
Member

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))

@akka-ci akka-ci added tested PR that was successfully built and tested by Jenkins and removed validating PR is currently being validated by Jenkins labels Aug 24, 2015
@akka-ci
Copy link

akka-ci commented Aug 24, 2015

Test PASSed.
Refer to this link for build results (access rights to CI server needed):
https://jenkins.akka.io/job/pr-validator-per-commit-jenkins/3502/

@akka-ci akka-ci added validating PR is currently being validated by Jenkins tested PR that was successfully built and tested by Jenkins and removed tested PR that was successfully built and tested by Jenkins validating PR is currently being validated by Jenkins labels Aug 31, 2015
@akka-ci
Copy link

akka-ci commented Aug 31, 2015

Test PASSed.
Refer to this link for build results (access rights to CI server needed):
https://jenkins.akka.io/job/pr-validator-per-commit-jenkins/3552/

@akka-ci akka-ci added the tested PR that was successfully built and tested by Jenkins label Aug 31, 2015
@akka-ci
Copy link

akka-ci commented Aug 31, 2015

Test PASSed.
Refer to this link for build results (access rights to CI server needed):
https://jenkins.akka.io/job/pr-validator-per-commit-jenkins/3553/

@patriknw
Copy link
Member

patriknw commented Sep 3, 2015

LGTM, thanks for the cleanup

patriknw added a commit that referenced this pull request Sep 3, 2015
Fix JournalSpec: AtomicWrite(Seq) instead of Seq(AtomicWrite)
@patriknw patriknw merged commit 5592e2f into akka:master Sep 3, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tested PR that was successfully built and tested by Jenkins
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants