Eventuous / eventuous

Event Sourcing library for .NET
https://eventuous.dev
Apache License 2.0
447 stars 71 forks source link

Npgsql.PostgresException: 23505: duplicate key value violates unique constraint "pk_checkpoints" #232

Closed alex91352 closed 1 year ago

alex91352 commented 1 year ago

PostgresCheckpointStore.GetLastCheckpoint throws 'duplicate key value violates unique constraint "pk_checkpoints"' when the stream is empty.

When GetLastCheckpoint executes the first time, it creates a checkpoint with a null position. The second time, it loads the checkpoint from the database, but discards it because checkpoint.IsEmpty is true and tries to create a new checkpoint with the same checkpointId. This causes the duplicate key exception.

We are using eventuous version "0.14.1-alpha.0.32".

alexeyzimarev commented 1 year ago

Sounds like an easy fix, mind opening a PR?