-
Notifications
You must be signed in to change notification settings - Fork 13
Force write journal to initialize when read journal is started #423
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Detailed my changes
|
||
namespace Akka.Persistence.Sql.Tests.Common.Query | ||
{ | ||
public abstract class Bugfix344Spec<T> : Akka.TestKit.Xunit2.TestKit, IAsyncLifetime where T : ITestContainer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Abstract spec to validate that this issue has been resolved, and that the ReadJournal
will automatically start up the write journal and wait for it to initialize.
@@ -59,6 +59,11 @@ public class SqlReadJournal : | |||
_system = system; | |||
|
|||
var connFact = new AkkaPersistenceDataConnectionFactory(_readJournalConfig); | |||
|
|||
// Fix for https://github.com/akkadotnet/Akka.Persistence.Sql/issues/344 | |||
var writeJournal = Persistence.Instance.Apply(system).JournalFor(writePluginId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Start the SqlWriteJournal
if it has not been started already - technically the _eventAdapters = Persistence.Instance.Apply(system).AdaptersFor(writePluginId);
also does this implicitly.
// Fix for https://github.com/akkadotnet/Akka.Persistence.Sql/issues/344 | ||
var writeJournal = Persistence.Instance.Apply(system).JournalFor(writePluginId); | ||
// we want to block, we want to crash if the journal is not available | ||
var started = writeJournal.Ask<Initialized>(IsInitialized.Instance, TimeSpan.FromSeconds(5)).Result; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Block and wait until startup is complete - this should cover any cases of this issue where queries still get executed before the write journal fully finishes initializing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Got the error to occur:
|
Changes
close #344
Checklist
For significant changes, please ensure that the following have been completed (delete if not relevant):