Skip to content

Commit

Permalink
fix: Wrong VersionVector when migrated from non-replicated (#1304)
Browse files Browse the repository at this point in the history
* fix: Wrong VersionVector when migrated from non-replicated

* it should be replicaId and not persistenceId

* adjust test
  • Loading branch information
patriknw authored Jan 24, 2025
1 parent b0741d8 commit 6ec48a0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -258,13 +258,15 @@ class EventProducerServiceSpec
.withReplicatedEventMetadataTransformation(
env =>
if (env.eventMetadata.isDefined) None
else
else {
// migrated from non-replicated, fill in metadata
Some(
ReplicatedEventMetadata(
originReplica = ReplicaId.empty,
originSequenceNr = env.sequenceNr,
version = VersionVector(env.persistenceId, env.sequenceNr),
concurrent = false))))
version = VersionVector(ReplicaId.empty.id, env.sequenceNr),
concurrent = false))
}))

private val eventProducerService =
new EventProducerServiceImpl(
Expand Down Expand Up @@ -611,14 +613,14 @@ class EventProducerServiceSpec
protoAnySerialization.deserialize(out1.getEvent.metadata.get) shouldBe ReplicatedEventMetadata(
originReplica = ReplicaId.empty,
originSequenceNr = env1.sequenceNr,
version = VersionVector(env1.persistenceId, env1.sequenceNr),
version = VersionVector(ReplicaId.empty.id, env1.sequenceNr),
concurrent = false)

val out2 = probe.expectNext()
protoAnySerialization.deserialize(out2.getEvent.metadata.get) shouldBe ReplicatedEventMetadata(
originReplica = ReplicaId.empty,
originSequenceNr = env2.sequenceNr,
version = VersionVector(env2.persistenceId, env2.sequenceNr),
version = VersionVector(ReplicaId.empty.id, env2.sequenceNr),
concurrent = false)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ private[akka] object ReplicationImpl {
ReplicatedEventMetadata(
originReplica = settings.selfReplicaId,
originSequenceNr = env.sequenceNr,
version = VersionVector(env.persistenceId, env.sequenceNr),
version = VersionVector(settings.selfReplicaId.id, env.sequenceNr),
concurrent = false))
})

Expand Down Expand Up @@ -367,7 +367,7 @@ private[akka] object ReplicationImpl {
ReplicatedEventMetadata(
originReplica = settings.selfReplicaId,
originSequenceNr = env.sequenceNr,
version = VersionVector(env.persistenceId, env.sequenceNr),
version = VersionVector(settings.selfReplicaId.id, env.sequenceNr),
concurrent = false))
})

Expand Down

0 comments on commit 6ec48a0

Please sign in to comment.