From: jkatz (@jkatz) <noreply+jkatz@github.com>
To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>
Subject: Re: [pgvector/pgvector] issue #647: Restoring a backup suddenly breaks with CREATE INDEX ... USING hnsw
Date: Mon, 19 Aug 2024 16:38:00 +0000
Message-ID: <gh-pgvector-pgvector-647-c2296988618@github.com> (raw)
In-Reply-To: <gh-pgvector-pgvector-647@github.com>
References: <gh-pgvector-pgvector-647@github.com>
@itinance Thanks. So a few things here:
1. `pg_dump` is not a backup utility (more on this in a second) - for true backup/restore you'll want to use something like [`pg_basebackup`](https://www.postgresql.org/docs/current/app-pgbasebackup.html) or a utility like [pgBackRest](https://pgbackrest.org/) (there are a variety of tools available here). Effectively these tools take a snapshot of the binary representation of your data, so you can restore it to a similar physical environment. They'll be much more efficient than `pg_dump`/`pg_restore`, which is just recreating the SQL commands used to build your environment.
2. For cases where you do need to use `pg_dump` (e.g. transferring data between non-binary compatible systems), what's likely happening is that your HNSW index build is exceeding the available memory to build the index, and as a result the OOM killer is taking out the process. If you have more resources on the machine, this is likely due to your container settings (limits within the cgroup) that when the process exceeds the container memory threshold, the OOM killer kills the process putting on the most memory pressure (Joe Conway has an [excellent blog on this topic](https://www.crunchydata.com/blog/deep-postgresql-thoughts-the-linux-assassin)). Without knowing more about your setup, if you do need to use the dump/restore method, you likely need to increase the memory limit of your container.