2023-06-22: Correct installation of pgvector extension on embedding database nodes
Production Change
Change Summary
When initially setting up the embedding databases with the pgvector
extension, there was no .deb
package available, and it was installed using make install
. This is not ideal. Now that an appropriate package is available, this CR will swap the manual install with the packaged installation.
We know that during the time when the extension's library file is not on the disk, we will get errors for any queries that use it. ERROR: could not access file "$libdir/vector": No such file or directory
Since we have 3 nodes, we can manually roll out the change to the secondaries and then switch one of them to be the primary while we roll the change out to the original primary node. We can't just merge the change to chef and have it roll out normally, since that will result in errors.
The risk on this is fairly low, but because it is a database change, it is a C2 - If it goes badly, the impact will be that we will see errors in the AI chat bot until we restore the previous state.
We should not need to restart any of the database instances, since the extensions are dynamically loaded.
Change Details
- Services Impacted - ServicePatroniEmbedding
-
Change Technician -
@devin
- Change Reviewer - @ayeung
- Time tracking - 30 minutes
- Downtime Component - none
Detailed steps for the change
Change Steps - steps to take to execute the change
Estimated Time to Complete (mins) - Estimated Time to Complete in Minutes
-
Set label changein-progress /label ~change::in-progress
-
Disable Chef on all Patroni Embedding nodes: knife ssh 'roles:gprd-base-db-patroni-embedding' 'sudo chef-client-disable "Fixing pgvector installation - see: https://gitlab.com/gitlab-com/gl-infra/production/-/issues/15906"'
-
Merge https://gitlab.com/gitlab-com/gl-infra/chef-repo/-/merge_requests/3680 -
Check which node is currently master: ssh patroni-embedding-01-db-gprd.c.production.internal sudo gitlab-patronictl list
-
Verify that the pgvector
tar package is still in/tmp/
usingknife ssh 'roles:gprd-base-db-patroni-embedding' 'ls /tmp/pgvector'
- we will do this instead of taking a backup, since this should be the same, and easier to restore. If it does not exist:cd /tmp; git clone --branch v0.4.4 https://github.com/pgvector/pgvector.git
-
On each of the secondaries -
-
Enable Chef on this node: ssh patroni-embedding-02-db-gprd.c.gitlab-production.internal sudo chef-client-enable
-
-
-
Run chef client ssh patroni-embedding-02-db-gprd.c.gitlab-production.internal sudo chef-client
-
-
-
Verify: ssh patroni-embedding-02-db-gprd.c.gitlab-production.internal dpkg -l | grep pgvector
-
- Switch over the master node to one of the secondaries
ssh patroni-embedding-01-db-gprd.c.gitlab-production.internal sudo gitlab-patronictl switchover gprd-patroni-embedding
-
On the original primary node -
-
Enable Chef on this node: ssh patroni-embedding-01-db-gprd.c.gitlab-production.internal sudo chef-client-enable
-
-
-
Run chef client ssh patroni-embedding-01-db-gprd.c.gitlab-production.internal sudo chef-client
-
-
-
Verify: ssh patroni-embedding-01-db-gprd.c.gitlab-production.internal dpkg -l | grep pgvector
-
- Optionally switch the primary back to the original node
ssh patroni-embedding-01-db-gprd.c.gitlab-production.internal sudo gitlab-patronictl switchover gprd-patroni-embedding
-
Set label changecomplete /label ~change::complete
Rollback
Rollback steps - steps to be taken in the event of a need to rollback this change
Estimated Time to Complete (mins) - Estimated Time to Complete in Minutes
If rolling back before installing the package on the primary node, simply switch the primary back
-
ssh patroni-embedding-01-db-gstg.c.gitlab-staging-1.internal sudo gitlab-patronictl switchover gprd-patroni-embedding
If rolling back after the package is installed, remove it and reinstall the old extension
-
dpkg -r postgresql-14-pgvector
-
cd /tmp/pgvector; PG_CONFIG=/usr/lib/postgresql/14/bin/pg_config make install
Then address the issue or re-enable chef if we're not going to
-
Enable Chef on all Patroni Embedding nodes: knife ssh 'roles:gprd-base-db-patroni-embedding' 'sudo chef-client-enable'
-
Set label changeaborted /label ~change::aborted
Monitoring
Key metrics to observe
- Metric: Database Errors
- Location: https://log.gprd.gitlab.net/goto/4ec06eb0-113f-11ee-8afc-c9851e4645c0
- What changes to this metric should prompt a rollback: A large increase in errors which does not resolve quickly
Change Reviewer checklist
-
Check if the following applies: - The scheduled day and time of execution of the change is appropriate.
- The change plan is technically accurate.
- The change plan includes estimated timing values based on previous testing.
- The change plan includes a viable rollback plan.
- The specified metrics/monitoring dashboards provide sufficient visibility for the change.
-
Check if the following applies: - The complexity of the plan is appropriate for the corresponding risk of the change. (i.e. the plan contains clear details).
- The change plan includes success measures for all steps/milestones during the execution.
- The change adequately minimizes risk within the environment/service.
- The performance implications of executing the change are well-understood and documented.
- The specified metrics/monitoring dashboards provide sufficient visibility for the change.
- If not, is it possible (or necessary) to make changes to observability platforms for added visibility?
- The change has a primary and secondary SRE with knowledge of the details available during the change window.
- The change window has been agreed with Release Managers in advance of the change. If the change is planned for APAC hours, this issue has an agreed pre-change approval.
- The labels blocks deployments and/or blocks feature-flags are applied as necessary.
Change Technician checklist
-
Check if all items below are complete: - The change plan is technically accurate.
- This Change Issue is linked to the appropriate Issue and/or Epic
- Change has been tested in staging and results noted in a comment on this issue.
- A dry-run has been conducted and results noted in a comment on this issue.
- The change execution window respects the Production Change Lock periods.
- For C1 and C2 change issues, the change event is added to the GitLab Production calendar.
- For C1 and C2 change issues, the SRE on-call has been informed prior to change being rolled out. (In #production channel, mention
@sre-oncall
and this issue and await their acknowledgement.) - For C1 and C2 change issues, the SRE on-call provided approval with the eoc_approved label on the issue.
- For C1 and C2 change issues, the Infrastructure Manager provided approval with the manager_approved label on the issue.
- Release managers have been informed prior to any C1, C2, or blocks deployments change being rolled out. (In #production channel, mention
@release-managers
and this issue and await their acknowledgment.) - There are currently no active incidents that are severity1 or severity2
- If the change involves doing maintenance on a database host, an appropriate silence targeting the host(s) should be added for the duration of the change.