Creation Concurrency with CQRS and EventStore
**Baseline info:**
I'm using an external OAuth provider for login.  If the user logs into the external OAuth, they are OK to enter my system.  However this user may not yet exist in my system.  It's not really a technology issue, but I'm using JOliver EventStore for what it's worth.

**Logic:**
1) I'm not given a guid for new users.  I just have an email address.
2) I check my read model before sending a command, if the user email exists, I issue a Login command with the ID, if not I issue a CreateUser command with a generated ID.  This case is a new user.
3) A save occurs in the event store with the new ID.

**Issue:**
Assume two create commands are somehow issued before the read model is updated due to browser refresh or some other anomaly that occurs before consistency with the read model is achieved. That's OK that's not my problem.

**What Happens:**
Because the new ID is generated an is a Guid comb, there's no chance the event store will know that these two commands represent the same user.  By the time they get to the read model, the read model will know and can merge the two records.  But now my read model is out of sync with the event store which still thinks these are two separate entities.

**Perhaps it doesn't matter because:**

 1. Replaying the events will have the same effect on the read model
    so that should be OK. 
 2. Because both commands are "New Object" commands, they should contain identical information, so it's not like I'm losing anything in the event store.

Can anybody illuminate how they handled similar issues?  If some compensating action needs to occur does the read model service issue some kind of compensation command when it realizes it's got a duplicate entry?  Is there a simpler methodology I'm not considering?

Thanks!


Creation Concurrency with CQRS and EventStore
===

**Baseline info:**
I'm using an external OAuth provider for login.  If the user logs into the external OAuth, they are OK to enter my system.  However this user may not yet exist in my system.  It's not really a technology issue, but I'm using JOliver EventStore for what it's worth.

**Logic:**
1) I'm not given a guid for new users.  I just have an email address.
2) I check my read model before sending a command, if the user email exists, I issue a Login command with the ID, if not I issue a CreateUser command with a generated ID.  This case is a new user.
3) A save occurs in the event store with the new ID.

**Issue:**
Assume two create commands are somehow issued before the read model is updated due to browser refresh or some other anomaly that occurs before consistency with the read model is achieved. That's OK that's not my problem.

**What Happens:**
Because the new ID is generated an is a Guid comb, there's no chance the event store will know that these two commands represent the same user.  By the time they get to the read model, the read model will know and can merge the two records.  But now my read model is out of sync with the event store which still thinks these are two separate entities.

**Perhaps it doesn't matter because:**

 1. Replaying the events will have the same effect on the read model
    so that should be OK. 
 2. Because both commands are "New Object" commands, they should contain identical information, so it's not like I'm losing anything in the event store.

Can anybody illuminate how they handled similar issues?  If some compensating action needs to occur does the read model service issue some kind of compensation command when it realizes it's got a duplicate entry?  Is there a simpler methodology I'm not considering?

Thanks!

