Commanded framework, how to recover from {:error, :wrong_expected_version}

I have an application with these Commanded related packages installed,

$mix hex.outdated | grep commanded

commanded                     1.2.0    1.2.0                    
commanded_ecto_projections    1.2.0    1.2.0                    
commanded_eventstore_adapter  1.2.0    1.2.0

Everything worked fine but recently I found a lot of errors like:

Failed to append events to stream "new-quest-xxxxxx:yyyy:20201005004" due to: :wrong_expected_version

and

duplicate key value violates unique constraint \"ix_stream_events\"

I checked the document but still have no idea why it appears and therefore how to recover from it.

Any advice would be appreciated, thanks!

@slashdotdash Do you have any guidance on troubleshooting this issue? Do I need to check something specific?

Are you using :any_version as the expected version argument? There was an issue I fixed (#209) which sounds very similar. That hasn’t yet been released to Hex, but it will be soon!

Thank you for the update and sorry for the delay in response, @slashdotdash !

Where can I get this configuration?