Skip to content

Commit

Permalink
handle task failure properly and reenable write
Browse files Browse the repository at this point in the history
  • Loading branch information
an-tex committed Nov 29, 2023
1 parent 8a3a054 commit 4646003
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions elastic/core/src/main/scala/Evolver.scala
Original file line number Diff line number Diff line change
Expand Up @@ -240,13 +240,7 @@ object Evolver extends ClusterComponent.Singleton {
IndexMigrated
}

context.pipeToSelf(eventualCommand)(_.fold(e => {
setReadOnly(oldIndexName, readOnly = false).onComplete {
case Failure(exception) => log.errorT("reEnablingWriteAfterIndexMigrationFailureFailed", s"on $index due to $exception")
}

IndexMigrationFailed(index, e)
}, identity))
context.pipeToSelf(eventualCommand)(_.fold(IndexMigrationFailed(index, _), identity))

migratingIndex(index, oldIndexName, newIndexName, pendingIndices)

Expand Down Expand Up @@ -286,6 +280,9 @@ object Evolver extends ClusterComponent.Singleton {
case IndexMigrationFailed(index, exception) =>
timerScheduler.cancelAll()
log.errorT("indexMigrationFailed", s"of ${index.name -> "index"} with $exception")
setReadOnly(oldIndexName, readOnly = false).onComplete {
case Failure(exception) => log.errorT("reEnablingWriteAfterIndexMigrationFailureFailed", s"on $index due to $exception")
}
idle

case CheckTaskCompletion(nodeId, taskId) =>
Expand All @@ -305,7 +302,8 @@ object Evolver extends ClusterComponent.Singleton {
getTaskResponse.error match {
case Some(error) =>
log.errorT("taskFailed", s"of ${index.name -> "index"} with $error, aborting")
idle
context.self ! IndexMigrationFailed(index, new Exception(error.toString))
Behaviors.same
case None =>
if (getTaskResponse.completed) context.self ! IndexMigrated
Behaviors.same
Expand Down

0 comments on commit 4646003

Please sign in to comment.