Skip to content

Commit

Permalink
Trigger stop on db write failure (digital-asset#6233)
Browse files Browse the repository at this point in the history
* Stop running trigger under DB write failure

changelog_begin
changelog_end

* Another fix relating to initialization retries

changelog_begin
changelog_end

* Handle the error case directly
  • Loading branch information
shayne-fletcher authored Jun 4, 2020
1 parent 884d4d8 commit 71ff65d
Showing 1 changed file with 16 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -393,26 +393,33 @@ object Server {
server.logTriggerStatus(runningTrigger, "running")
server.addRunningTrigger(runningTrigger) match {
case Left(err) =>
val msg = "Failed to add running trigger to database.\n" + err
ctx.self ! TriggerInitializationFailure(runningTrigger, msg)
// The trigger has just advised it's in the running
// state but updating the running trigger table has
// failed. This error condition is exogenous to the
// runner. We therefore need to tell it explicitly to
// stop.
server.logTriggerStatus(
runningTrigger,
"stopped: initialization failure (db write failure)")
runningTrigger.runner ! TriggerRunner.Stop
Behaviors.same
case Right(()) => Behaviors.same
}
case TriggerInitializationFailure(runningTrigger, cause) =>
// The trigger has failed to start.
// The trigger has failed to start. No need to update the
// running triggers tables since this trigger never made
// it there.
server.logTriggerStatus(runningTrigger, "stopped: initialization failure")
// No need to update the running triggers tables since
// this trigger never made it there.
// Don't send any messages to the runner here (it's under
// the management of a supervision strategy).
Behaviors.same
case TriggerRuntimeFailure(runningTrigger, cause) =>
// The trigger has failed. Remove it from the running
// triggers tables.
server.logTriggerStatus(runningTrigger, "stopped: runtime failure")
server.removeRunningTrigger(runningTrigger)
// Don't send any messages to the runner. Its supervision
// strategy will automatically restart the trigger up to
// some number of times beyond which it will remain
// stopped.
// Don't send any messages to the runner here (it's under
// the management of a supervision strategy).
Behaviors.same
case GetServerBinding(replyTo) =>
replyTo ! binding
Expand Down

0 comments on commit 71ff65d

Please sign in to comment.