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

Postgresql-setup script updates #1935

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

rdlrt
Copy link

@rdlrt rdlrt commented Jan 22, 2025

Description

The postgresql-setup script (as well as docker restore functionality) seems to be only used/tested in a standard configuration and old version of postgresql. With the new options available to dbsync configuration, the setup fails over. This PR hopes to add a few minor updates that are hopefully easy to introduce as non-breaking changes and would largely assist us sticking to official images and not have to maintain a fork.

Additionally , there is a bump of references to postgresql 14 to 17 as pg14 is ancient and misses out on lot of value additions (eg: being able to add better compression on tx_cbor, parallel index maintainance without locks)

  • docker.nix: Bump postgresql to 17 (as restore snapshot fails if snapshots are made using postgres 17)
  • docker-compose*.yml: Bump postgresql version to 17, node version to 10.1.4 and dbsync version to 13.6.0.4
  • flake.nix|nix/docker.nix|nix/nixos/tests/services-basic-test.nix: Bump postgresql to 17 <=== Not sure what's the best path ahead for updating external references to add postgresql_17 to nix pkgs, I assume this will have external dependency (eg: for CI?) as well
  • postgresql-setup.sh:
    • Parse psql output using csv instead of manipulating white chars or table seperators
    • Use strict checks for ${PGDATABASE} as there can be another database with a prefix/suffix attached, giving back false outputs
    • When creating/restoring a snapshot, existence of ledger_file should be optional, as there are dbsync config options that don't require lstate files
    • When restoring a snapshot (eg: across postgres versions or for external systems that may have views/stored functions on database being restored), there will be cases where an informational error may be expected. The presence of --exit-on-error flag prevents use of these snapshots, especially when run from docker created by nix-ops (where it isnt as straightforward to override scripts)

Checklist

  • Commit sequence broadly makes sense
  • Commits have useful messages
  • New tests are added if needed and existing tests are updated
  • Any changes are noted in the changelog
  • Code is formatted with fourmolu on version 0.10.1.0 (which can be run with scripts/fourmolize.sh)
  • Self-reviewed the diff

Migrations

  • The pr causes a breaking change of type a,b or c
  • If there is a breaking change, the pr includes a database migration and/or a fix process for old values, so that upgrade is possible
  • Resyncing and running the migrations provided will result in the same database semantically

If there is a breaking change, especially a big one, please add a justification here. Please elaborate
more what the migration achieves, what it cannot achieve or why a migration is not possible.

@rdlrt rdlrt requested review from a team as code owners January 22, 2025 23:24
docker.nix: Bump postgresql to 17 (as restore snapshot fails if snapshots are made using postgres 17), postgres 14 is ancient anyways and there are various improvements (most prominent one being non-locking index maintenance)
docker-compose*.yml: Bump postgresql version to 17, node version to 10.1.4 and dbsync version to 13.6.0.4
flake.nix|nix/docker.nix|nix/nixos/tests/services-basic-test.nix: Bump postgresql client to 17
postgresql-setup.sh:
- Parse psql output using csv instead of manipulating white chars or table seperators
- Use strict checks for ${PGDATABASE} as there can be another database with a prefix/suffix attached
- When creating/restoring a snapshot, existence of ledger_file should be optional, as there are dbsync config options that don't require lstate files, accordingly - make presence of ledger-state-file optional
- When restoring a snapshot (eg: across postgres versions), there will be cases where an informational error may be expected. The presence of exit-on-error prevents use of these snapshots, especially when run from docker created by nix-ops (where it isnt as straightforward to override scripts)
@erikd
Copy link
Contributor

erikd commented Jan 22, 2025

@sgillespie We might need your help on the Nix stuff.

@sgillespie
Copy link
Contributor

@sgillespie We might need your help on the Nix stuff.

I think we just need to update nixpkgs/haskell.nix

@sgillespie
Copy link
Contributor

sgillespie commented Jan 24, 2025

Unfortunately, we will not be able to use postgresql_17 until we update the nixpkgs pin for haskell.nix, currently in progress: input-output-hk/haskell.nix#2307

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants