Skip to content
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

A new event is created even though all past events have not been applied #130

Closed
tksugimoto opened this issue Feb 21, 2022 · 0 comments · Fixed by #131
Closed

A new event is created even though all past events have not been applied #130

tksugimoto opened this issue Feb 21, 2022 · 0 comments · Fixed by #131

Comments

@tksugimoto
Copy link
Contributor

tksugimoto commented Feb 21, 2022

TODO: Translate to English

期待する振る舞い

過去に発行したイベントを全て適用した状態で新たな決定(イベントの発行)を行うことが期待されるため、コミットされていないイベントがある時は Entity はコマンドを処理しない。

問題(期待する振る舞いとのギャップ)

未コミットのイベントがある状態でも Entity がコマンドを処理し、過去に発行したイベントが全て適用されていない状態で新たなイベントを発行してしまうケースがある。

イベントをレプリケーション中に Leader 側の RaftActor がクラッシュすると、新しい Leader に属する Entity が未コミットのイベントが存在する状態で ProcessCommand を処理してしまう場合がある。

例) (TODO: use mermaid )
replicationsucceeded2 drawio

発生条件

次の 3 つの条件を全て満たす場合に発生します。

  1. イベントをレプリケーション中に Leader が移動する(クラッシュ、ネットワーク分断)
  2. イベントのレプリケーションが完了する前に ProcessCommand が Entity に届く
  3. ProcessCommand が完了した後にイベントのレプリケーションが完了する
@tksugimoto tksugimoto changed the title Entity processes the command in the presence of uncommitted events A new event is created even though all past events have not been applied Feb 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant