Find Primary #918
-
HI Is there away to just get the ip of the primary from a single command to pg_autoctl ? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
See #875 and also the blog post at https://www.citusdata.com/blog/2021/02/12/reconnecting-your-app-after-a-postgres-failover/ which addresses the same question. The idea is to use multi-hosts connection strings, and use the If the following connection string snippet makes sense when using Django (I just don't know), then I think it would make sense to allow for a specific switch such as DATABASES = {
'default': {
'ENGINE': _db_engine,
'NAME': environment.DB,
'USER': environment.DB_USER,
'PASSWORD': environment.DB_PASSWD,
'HOST': environment.DB_HOSTS,
'CONN_MAX_AGE': 0,
'PORT': environment.DB_PORTS,
'OPTIONS': {
'application_name': f'applicationname',
'options': f'-c search_path={environment.DB_SCHEMA}',
'target_session_attrs': 'read-write',
'connect_timeout': '30',
'keepalives_idle': '300',
'keepalives_interval': '75'
},
'ATOMIC_REQUESTS': True
}
} |
Beta Was this translation helpful? Give feedback.
See #875 and also the blog post at https://www.citusdata.com/blog/2021/02/12/reconnecting-your-app-after-a-postgres-failover/ which addresses the same question. The idea is to use multi-hosts connection strings, and use the
target-session-attrs=read-write
to ensure that if connected first to a standby, then the connection is dropped and attempted again with the next host on the list, until a primary is reached.If the following connection string snippet makes sense when using Django (I just don't know), then I think it would make sense to allow for a specific switch such as
pg_autoctl show uri --django
that would output just that: