Skip to content

Commit 974c537

Browse files
Harden SQL journal and snapshot store against initialization failures (#444)
Port of akkadotnet/akka.net#7325
1 parent 9b67712 commit 974c537

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/Akka.Persistence.Sql/Journal/SqlWriteJournal.cs

+2-3
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,8 @@ private bool Initializing(object message)
134134

135135
case Status.Failure fail:
136136
_log.Error(fail.Cause, "Failure during {0} initialization.", Self);
137-
Context.Stop(Self);
138-
return true;
139-
137+
// trigger a restart so we have some hope of succeeding in the future even if initialization failed
138+
throw new ApplicationException("Failed to initialize SQL Journal.", fail.Cause);
140139
default:
141140
Stash.Stash();
142141
return true;

src/Akka.Persistence.Sql/Snapshot/SqlSnapshotStore.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ private bool WaitingForInitialization(object message)
6262

6363
case Status.Failure msg:
6464
_log.Error(msg.Cause, "Error during {0} initialization", Self);
65-
Context.Stop(Self);
65+
// trigger a restart so we have some hope of succeeding in the future even if initialization failed
66+
throw new ApplicationException("Failed to initialize SQL SnapshotStore.", msg.Cause);
6667
return true;
6768

6869
default:

0 commit comments

Comments
 (0)