porsager / porsager/postgres

Issue with auto failover with unresponsive host

Open
#815 5 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
8.7k
Forks
374
Avg merge
11d 16h
Merged PRs (30d)
1

Description

We have 2 DB instances: a primary instance host1:5432 and a read replica host2:5432

Here is my config:

client = postgres({
            host: "host1:5432,host2:5432",
            database: "postgres",
            username: "",
            password: "",
            target_session_attrs: "prefer-standby",
}

What I found is that it does not auto failover to the primary when the read replica can not be connected (Host exist but not respond). It will just print out error write CONNECT_TIMEOUT host2:5432 and stuck

same issue with primary

client = postgres({
            host: "unresponsive-host:5432,host1:5432",
            database: "postgres",
            username: "",
            password: "",
            target_session_attrs: "primary",
}

it will suck on error write CONNECT_TIMEOUT unresponsive-host:5432

Auto failover seems only work if host does not exist or host refuse connection

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No source file, test, or entry point is named in the report. Reproduce the two configurations with an unreachable host and inspect the connection timeout and host-selection flow; done means the client proceeds to the eligible primary or standby instead of remaining stuck on CONNECT_TIMEOUT.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, postgresql
Domain
backend, databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
32/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.