Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connecting to restored cluster can be fraught #29

Open
allenap opened this issue Oct 26, 2023 · 0 comments
Open

Connecting to restored cluster can be fraught #29

allenap opened this issue Oct 26, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@allenap
Copy link
Owner

allenap commented Oct 26, 2023

Especially after restoring from a backup, it's important to know a database role to use, otherwise it's not actually possible to connect to the database. For example, a cluster created as system user gavin will have a superuser role, by default, also named gavin. If this cluster is restored in another account, say bobby, then pgdo will not be able to connect to the restored cluster.

A superuser role can be determined in single-user mode like so:

$ postgres --single -D cluster postgres \
>   <<< 'select rolname from pg_roles where rolsuper and rolcanlogin' \
>     2> /dev/null | sed 's/^.*\brolname\s*=\s*"\(.*\)".*/\1/p;d'
gavin

(Update: function that does this added as cluster::determine_superuser_role_names.)

so pgdo could use this to guess, but perhaps something more/different can be done to make it Just Work.

Note, this might all be moot if pg_hba.conf doesn't allow local connections, for example.

@allenap allenap added the bug Something isn't working label Oct 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant