Eventuous / eventuous

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

Postgres subscription does not automatically reconnect after database server restart #225

Closed oakie closed 1 year ago

oakie commented 1 year ago

I have an issue when my subscription drops when the postgres server restarts (during scaling in azure), and does not reconnect when the server comes back online. It seems that the EventStoreDB-subscription has code to handle dropped connections, but that the Postgres subscriptions are just rethrowing the exception:

            try {
               // ...
            }
               // ...
            catch (Exception e) {
                IsDropped = true;
                Log.WarnLog?.Log(e, "Dropped");
                throw;
            }

Couldn't the postgres subscription utilize the same handler in the base class? Something like this:

            catch (Exception e) {
                Dropped(PostgresMappings.AsDropReason(e), e);
                break;
            }
oakie commented 1 year ago

I tried my proposed solution and it works great! :) I'll see if I can create a PR.