Investigate why our application tried to send write queries after a postgres failover

During a recent failover production#637 (closed), our applications continue to try and write data to a read-only instance.

https://sentry.gitlab.net/gitlab/gitlabcom/?query=ReadOnlySqlTransaction

The previous primary postgres node was down at the time of these errors. How did our application decide to send write traffic to postgres? How can we ensure that we do not continue to send write traffic to our read-only replicas?