Bringing over another home-grown postgresql replication check

since the upstream one is kinda broken right now and works different-like.