From a85e5b4b6ec75a1bf537fbfeea1db16e7a480c61 Mon Sep 17 00:00:00 2001 From: Yardena Meymann Date: Wed, 25 Apr 2018 12:50:17 +0300 Subject: [PATCH 1/3] rxmongo 0.13.0 --- build.sbt | 6 +++--- .../mongodb/RxMongoPersistenceExtension.scala | 13 +++++++++++-- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/build.sbt b/build.sbt index 6afd0a56..a97ba385 100644 --- a/build.sbt +++ b/build.sbt @@ -1,4 +1,4 @@ -val releaseV = "2.0.8" +val releaseV = "2.0.8-ffm1" val scalaV = "2.11.8" @@ -88,10 +88,10 @@ lazy val `akka-persistence-mongo-rxmongo` = (project in file("rxmongo")) .settings(commonSettings:_*) .settings( libraryDependencies ++= Seq( - ("org.reactivemongo" %% "reactivemongo" % "0.12.3" % "provided") + ("org.reactivemongo" %% "reactivemongo" % "0.13.0" % "provided") .exclude("com.typesafe.akka","akka-actor_2.11") .exclude("com.typesafe.akka","akka-actor_2.12"), - ("org.reactivemongo" %% "reactivemongo-akkastream" % "0.12.3" % "provided") + ("org.reactivemongo" %% "reactivemongo-akkastream" % "0.13.0" % "provided") .exclude("com.typesafe.akka","akka-actor_2.11") .exclude("com.typesafe.akka","akka-actor_2.12") ), diff --git a/rxmongo/src/main/scala/akka/contrib/persistence/mongodb/RxMongoPersistenceExtension.scala b/rxmongo/src/main/scala/akka/contrib/persistence/mongodb/RxMongoPersistenceExtension.scala index 218b5104..198d72dc 100755 --- a/rxmongo/src/main/scala/akka/contrib/persistence/mongodb/RxMongoPersistenceExtension.scala +++ b/rxmongo/src/main/scala/akka/contrib/persistence/mongodb/RxMongoPersistenceExtension.scala @@ -193,12 +193,21 @@ class RxMongoDriver(system: ActorSystem, config: Config, driverProvider: RxMongo private[mongodb] override def ensureIndex(indexName: String, unique: Boolean, sparse: Boolean, keys: (String, Int)*)(implicit ec: ExecutionContext) = { collection => val ky = keys.toSeq.map { case (f, o) => f -> (if (o > 0) IndexType.Ascending else IndexType.Descending) } - collection.flatMap(c => c.indexesManager.ensure(Index( + def ensureIndex(c: BSONCollection) = c.indexesManager.ensure(Index( key = ky, background = true, unique = unique, sparse = sparse, - name = Some(indexName))).map(_ => c)) + name = Some(indexName))) + + collection.flatMap(c => + ensureIndex(c).recoverWith { + case CommandError.Code(26) => //no collection + c.create().recover { + case CommandError.Code(48) => //name exists (race condition) + () + }.flatMap(_ => ensureIndex(c)) + }.map(_ => c)) } override private[mongodb] def cappedCollection(name: String)(implicit ec: ExecutionContext) = { From 3149b3ab8358c41e1bad3e9d0b187d96ea3fa20d Mon Sep 17 00:00:00 2001 From: Yardena Meymann Date: Wed, 25 Apr 2018 12:53:56 +0300 Subject: [PATCH 2/3] change version to 2.0.9-SNAPSHOT --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index a97ba385..6f06d3b3 100644 --- a/build.sbt +++ b/build.sbt @@ -1,4 +1,4 @@ -val releaseV = "2.0.8-ffm1" +val releaseV = "2.0.9-SNAPSHOT" val scalaV = "2.11.8" From f240300d823b348b433e9f38d4beb85d585590ca Mon Sep 17 00:00:00 2001 From: Yardena Meymann Date: Mon, 30 Apr 2018 14:41:28 +0300 Subject: [PATCH 3/3] change version back to 2.0.8 for PR --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 6f06d3b3..adf97159 100644 --- a/build.sbt +++ b/build.sbt @@ -1,4 +1,4 @@ -val releaseV = "2.0.9-SNAPSHOT" +val releaseV = "2.0.8" val scalaV = "2.11.8"