-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
feat(server): enable data page checksums #9384
Conversation
The discussion here doesn't seem very positive for this flag. It adds a lot of WAL due to the need to enable hinting and the devs debate on what it would actually catch. |
I did read over that thread. The snippets seemed cherry-picked from the actual discussion, IMO, and the main reason against it was decided against was pg_upgrade not working with changes in defaults from one major release to another. A number of large PG support companies recommend enabling it - whitepaper, source 2 (Amazon RDS uses checksums on all deployments per this source), 3. If |
It isn't enabled currently, so I guess it's fine if we add that too. If we're tuning these then we may as well increase |
I think with the scope of the project and large libraries in use, it's reasonable to provide some sane DB tuning parameters to help improve performance - especially as we get some issues with the large time buckets that have been coming up lately. I think the following would be reasonable:
Some other options that we could consider is |
Of the settings you listed, |
Do we currently specify any custom config for the PG container? Per the docs, we can either pass a custom postgresql.conf (which will conflict with pgvecto.rs) or add It looks like the pgvecto.rs default
|
Yup, that's what I did. |
I just started an instance with the docker-compose.yml in this commit, uploaded an image, and did a test search. Logs look clean.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
Can you apply this change to the dev and prod Compose files as well? It's better if they follow the release file as closely as possible. |
Done. BTW the defaults for those settings were WAL 1GB, buff 128MB, and compression off. |
For anyone reading this, if someone pulls this new docker-compose.yml they will not get the benefit of checksums in an existing install, but they will get the wal_compression and tweaking of WAL size and shared buffers. No breaking changes. |
If anyone is here wondering if you can enable checksumming without recreating the DB and importing an export, this seemed to do the trick to do an offline migration:
Basically I followed the steps from https://www.crunchydata.com/blog/fun-with-pg_checksums but with docker |
Proposal
Currently, the Immich Postgres database container does not use/enable data page checksums. Data page checksums are additional pages stored by Postgres that allow the DB to validate and detect corrupted data within the database tables. They have a minimal performance hit that I believe is more than offset by the ability to detect this type of data damage.
The official Postgres container docs outline how to enable checksums. I have tested deploying this using the pgvecto.rs database image, and it works as described. Adding this to an existing database doesn't do anything, as it's required to be specified on database initialization.
Implications
Importantly, this would not be a breaking change. I believe setting this variable only has an effect during database initialization, and not after. It is possible to restore a pg_dump from a non-checksum DB into a checksum DB, as well.
Healthcheck
This would allow users to add a healthcheck to monitor for corruption in the Postgres container if desired. For example:
Example logs
Checksums:
Current setup PG message:
New PG message:
Adding this to an existing installation does not affect it all, checksums are not enabled: