Skip to content

Commit 5e0d056

Browse files
DaedalusGkeegancsmithjdpleiness
authored
chore(release): pg 16 update to docs (#849)
This PR updates some of our surface information about PG upgrades as well as cleans up some eager suggestions of the automatic upgrade upgrade path. It removes references of support for PG12 instead suggesting that we currently only support 16. This was intentional to trim the docs rather than threading out a lot of specific information about Sourcegraph versions. --------- Co-authored-by: Keegan Carruthers-Smith <[email protected]> Co-authored-by: Jacob Pleiness <[email protected]>
1 parent 2de96dc commit 5e0d056

File tree

3 files changed

+20
-103
lines changed

3 files changed

+20
-103
lines changed

docs/admin/external_services/postgres.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ import { CURRENT_VERSION_STRING_NO_V, CURRENT_VERSION_STRING } from 'src/compone
22

33
# Using your own PostgreSQL server
44

5-
You can use your own PostgreSQL v12+ server with Sourcegraph if you wish. For example, you may prefer this if you already have existing backup infrastructure around your own PostgreSQL server, wish to use Amazon RDS, etc.
5+
You can use your own PostgreSQL v16+ server with Sourcegraph if you wish. For example, you may prefer this if you already have existing backup infrastructure around your own PostgreSQL server, wish to use Amazon RDS, etc.
66

77
Please review the [PostgreSQL](/admin/postgres) documentation for a complete list of requirements.
88

9-
<Callout type="note">As of version 3.39.0, codeinsights-db no longer relies on the internal TimescaleDB and can be externalized.</Callout>
9+
<Callout type="note">As of version 6.0.0 The Sourcegraph application will require PostgreSQL v16+, earlier versions worked with 12 or greater.</Callout>
1010

1111
## General recommendations
1212

docs/admin/postgres.mdx

Lines changed: 11 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,11 @@ Sourcegraph uses several PostgreSQL databases to support various functionality.
44

55
- `pgsql` or `primary`: responsible for user data and account information
66
- `codeintel-db`: provides support for lsif data and part of the code-intelligence
7+
- `codeinsights-db`: provides support for code insights data
78

89
## Version requirements
910

10-
We support any version **starting from 12**.
11-
12-
> NOTE: ⚠️ Version **3.26** required only Postgres 9.6. You should check the [upgrade docs for your deployment type](/admin/updates/) as well as the [database upgrade docs](#upgrading-postgresql) below prior to upgrading to 3.27.
11+
We support Postgres 16 and above. Older versions of Sourcegraph supported 12 see our [Postgres 12 deprecation notice](/admin/postgres12_end_of_life_notice) for more details.
1312

1413
## Role requirements
1514

@@ -23,19 +22,23 @@ intarray
2322
pg_stat_statements
2423
pg_trgm
2524
pgcrypto
25+
vector
2626
```
2727

2828
## [Configuring PostgreSQL](/admin/config/postgres-conf)
2929

30-
## Upgrading PostgreSQL
30+
### Upgrading Built-in PostgreSQL
3131

32-
Sourcegraph uses PostgreSQL as its main database and this documentation describes how to upgrade PostgreSQL between major versions.
32+
Sourcegraph deployments come packaged with containers using the `postgresql-16` image for `pgsql` and `codeintel-db` deployments and `postgresql-16-codeinsights` for `codeinsights`. These images contain an entryscript which will detect and upgrade postgres instances at version 12 (our previous images Postgres version). See the (postgres 12 end of life notice)[/admin/prostgres12_end_of_life_notice#] for more details.
3333

3434
> WARNING: Upgrading the PostgreSQL database requires stopping your Sourcegraph deployment which will result in **downtime**.
35+
>
36+
> Additionally, once the upgrade process is started via the database container, interrupting the container before the upgrade is complete could result in corrupting the underlying Postgres database. We strongly advise taking a backup before the upgrade.
3537
38+
The `PG_UPGRADE_EXTRA_ARGS` env var can be set in the built-in `postgresql-16` and `postgresql-16-codeinsights` deployments to provide extra arguments to the `pg_upgrade` command.
3639

40+
Setting the env var `PG_UPGRADE_EXTRA_ARGS=--link` provides the `--link` option to the underlying `pg_update`; creating a hard links between the old and new data directories instead of copying data. This option is faster and requires less disk space, however if the database containers are interrupted during the upgrade process there is a strong possibility of data corruption. This can still be a viable choice for users who are confident in their container scheduling and backups and would like to avoid longer downtimes.
3741

38-
> NOTE: If you running PostgreSQL externally, see [Upgrading external PostgreSQL instances](/admin/postgres#upgrading-external-postgresql-instances)
3942

4043
### Upgrading external PostgreSQL instances
4144

@@ -52,100 +55,11 @@ When running an [external PostgreSQL instance](/admin/external_services/postgres
5255
- [EnterpriseDB](https://www.enterprisedb.com/docs/en/9.6/pg/upgrading.html)
5356
- [Citus](http://docs.citusdata.com/en/v8.1/admin_guide/upgrading_citus.html)
5457
- [Aiven PostgreSQL](https://help.aiven.io/postgresql/operations/how-to-perform-a-postgresql-in-place-major-version-upgrade)
55-
- [Your own PostgreSQL](https://www.postgresql.org/docs/11/pgupgrade.html)
58+
- [Your own PostgreSQL](https://www.postgresql.org/docs/16/pgupgrade.html)
5659
4. Turn Sourcegraph back on connecting to the now-upgraded database.
5760

5861
> WARNING: **Do not allow Sourcegraph to run/connect to the new Postgres database until it has been fully populated with your data.** Doing so could result in Sourcegraph trying to create e.g. a new DB schema and partially migrating. If this happens to you, restore from the backup you previously took or contact us ([email protected])
5962
60-
### Upgrading internal PostgreSQL instances
61-
62-
Many of Sourcegraph's [deployment methods](/admin/deploy/) come with internal PostgreSQL instances that can be deployed as part of a Sourcegraph installation. This section outlines how to upgrade these databases.
63-
64-
#### Sourcegraph with Docker Compose
65-
66-
Generally, no additional steps are required to upgrade the databases shipped alongside [Sourcegraph with Docker Compose](/admin/deploy/docker-compose/).
67-
68-
#### Sourcegraph with Kubernetes
69-
70-
**The upgrade process is different for [Sourcegraph Kubernetes deployments](/admin/deploy/kubernetes/)** because [by default](https://github.com/sourcegraph/sourcegraph-public-snapshot/blob/main/docker-images/postgres-12/build.sh#L10), it uses `sourcegraph/postgres-12` which can be [customized with environment variables](https://github.com/sourcegraph/deploy-sourcegraph/blob/7edcadb/docs/configure#external-postgres).
71-
72-
If you have changed `PGUSER`, `PGDATABASE` or `PGDATA`, then the `PG*OLD` and `PG*NEW` environment variables are
73-
required. Below are the defaults and documentation on what each variable is used for:
74-
75-
- `POSTGRES_PASSWORD=''`: Password of `PGUSERNEW` if it is newly created (i.e when `PGUSERNEW` didn't exist in the old
76-
database).
77-
- `PGUSEROLD=sg`: A user that exists in the old database that can be used to authenticate intermediate upgrade
78-
operations.
79-
- `PGUSERNEW=sg`: A user that must exist in the new database after the upgrade is done (i.e. it'll be created if it
80-
didn't exist already).
81-
- `PGDATABASEOLD=sg`: A database that exists in the old database that can be used to authenticate intermediate upgrade
82-
operations. (e.g `psql -d`)
83-
- `PGDATABASENEW=sg`: A database that must exist in the new database after the upgrade is done (i.e. it'll be created if
84-
it didn't exist already).
85-
- `PGDATAOLD=/data/pgdata-11`: The data directory containing the files of the old PostgreSQL database to be upgraded.
86-
- `PGDATANEW=/data/pgdata-12`: The data directory containing the upgraded PostgreSQL data files, used by the new version
87-
of PostgreSQL.
88-
89-
Additionally, the upgrade process assumes it can write to the parent directory of `PGDATAOLD`.
90-
91-
##### Requirements for upgrading from Postgres 11 to 12 for Kubernetes
92-
93-
**This guide is for the Sourcegraph 3.27 release.** The migration to Postgres 12 using the Sourcegraph provided Postgres images is largely automated.
94-
However, you should take some steps before the migration. For the `3.27` release, these apply to the `pgsql` & `codeintel-db` deployments.
95-
96-
1. Inform your users prior to starting the upgrade that Sourcegraph will take downtime. This downtime scales with the
97-
size and resources allocated to the Postgres database instances.
98-
1. Take snapshots of all Sourcegraph Postgres databases. You can find the backing disk in your cloud by describing the
99-
relevant `PersistentVolumes`.
100-
1. Ensure that the size of the disks backing the databases are under 50% utilization. (You will need *up-to* 2x the size
101-
of your current database to do the migration). In most cases Kubernetes can expand the size of the volume for you,
102-
see the relevant kubernetes
103-
docs [here](https://kubernetes.io/docs/concepts/storage/persistent-volumes/#expanding-persistent-volumes-claims).
104-
105-
You can use `kubectl exec -it $DB_POD_NAME -- df -h`. By default, the database will be mounted under `/data/`.
106-
10763
#### Single-container Sourcegraph
10864

109-
When running a new version of Sourcegraph, [single-container Sourcegraph with Docker instances](/admin/deploy/kubernetes/) will check if the PostgreSQL data needs upgrading upon initialization.
110-
111-
See the following steps to upgrade between major postgresql versions:
112-
113-
**1.** Stop the `sourcegraph/server` container.
114-
115-
**2.** Save this script and give it executable permissions (`chmod + x`).
116-
117-
> NOTE: The script presumes your data is being upgraded from `11` to `12` and your Sourcegraph directory is at `~/.sourcegraph/`. Change the values in the code below if that's not the case.
118-
119-
```bash
120-
#!/usr/bin/env bash
121-
122-
set -xeuo pipefail
123-
124-
export OLD=${OLD:-"11"}
125-
export NEW=${NEW:-"12"}
126-
export SRC_DIR=${SRC_DIR:-"$HOME/.sourcegraph"}
127-
128-
docker run \
129-
-w /tmp/upgrade \
130-
-v "$SRC_DIR/data/postgres-$NEW-upgrade:/tmp/upgrade" \
131-
-v "$SRC_DIR/data/postgresql:/var/lib/postgresql/$OLD/data" \
132-
-v "$SRC_DIR/data/postgresql-$NEW:/var/lib/postgresql/$NEW/data" \
133-
"tianon/postgres-upgrade:$OLD-to-$NEW"
134-
135-
mv "$SRC_DIR/data/"{postgresql,postgresql-$OLD}
136-
mv "$SRC_DIR/data/"{postgresql-$NEW,postgresql}
137-
138-
curl -fsSL -o "$SRC_DIR/data/postgres-$NEW-upgrade/optimize.sh" https://raw.githubusercontent.com/sourcegraph/sourcegraph/master/cmd/server/rootfs/postgres-optimize.sh
139-
140-
docker run \
141-
--entrypoint "/bin/bash" \
142-
-w /tmp/upgrade \
143-
-v "$SRC_DIR/data/postgres-$NEW-upgrade:/tmp/upgrade" \
144-
-v "$SRC_DIR/data/postgresql:/var/lib/postgresql/data" \
145-
"postgres:$NEW" \
146-
-c 'chown -R postgres $PGDATA . && gosu postgres bash /admin/optimize.sh $PGDATA'
147-
```
148-
149-
**3.** Execute the script.
150-
151-
**4.** Start the `sourcegraph/server` container.
65+
Sourcegraph Single-container is not a supported production deployment and currently doesn't support upgrades to Postgres 16. Admins with production data in a single container deployment are advised to reach out to [email protected] for assistance.

docs/admin/updates/index.mdx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ Sourcegraph releases have three digits, for example: `v5.0.3`
2222
| minor | `0` |
2323
| patch | `3` |
2424

25-
For more details on our release cadence, refer to the [Sourcegraph handbook](https://handbook.sourcegraph.com/departments/engineering/dev/process/releases/#sourcegraph-releases).
25+
For more details on previous releases see [Sourcegraph Releases](/releases).
2626

27-
Generally, we ship a new version of Sourcegraph with new features and bug fixes monthly, followed by a patch release later that month. Major and minor releases happen less frequently and contain substantial changes to Sourcegraph.
27+
Generally, we ship a new minor version of Sourcegraph with new features and bug fixes monthly, followed by a patch release later that month.
2828

2929
Check the [Sourcegraph blog](https://about.sourcegraph.com/blog) for release announcements and details on the latest version.
3030

@@ -78,14 +78,16 @@ It is highly recommended to:
7878
Sourcegraph upgrades take the following general form:
7979
1. Determine if your instance is ready to Upgrade (check upgrade notes)
8080
2. Merge the latest Sourcegraph release into your deployment manifests
81-
3. If updating more than a single minor version, perform an [**automatic multi-version upgrade**](/admin/updates/automatic) if targeting **Sourcegraph 5.1 or later**; [manual multi-version upgrades]/admin/updates/migrator/migrator-operations) are required if upgrading to an earlier version, which requires shutting off the instance and invoking the `migrator` container or job to perform the database rewrite and application of unfinished out-of-band migrations
81+
3. Select an upgrade method:
82+
- If updating more than a single minor version, perform a multiversion upgrade with either the migrator [upgrade command](/admin/updates/migrator/migrator-operations#upgrade) or an [automatic upgrade](/admin/updates/automatic). *This method requires downtime.*
83+
- If updating a single minor version, perform a standard upgrade with the [migrator up command](/admin/updates/migrator/migrator-operations#up) or an [automatic upgrade](/admin/updates/automatic). `up` is the default migrator entry command and runs on `frontend` startup.
8284
4. With upstream changes to your manifests merged, start the new instance
8385

8486
> Note: For more explicit steps, specific to your deployment see the operations guides linked below.
8587
8688
### Upgrade Readiness
8789

88-
Starting in v5.0.0, as an admin you are able to check instance upgrade readiness by navigating to the `Site admin > Updates` page. Here you'll be notified if your instance has any **schema drift** or unfinished **out of band migrations**.
90+
Navigate to the `Site admin > Updates` page. Here you'll be notified if your instance has any **schema drift** or unfinished **out of band migrations**.
8991

9092
![Screenshot 2023-05-17 at 1 37 12 PM](https://storage.googleapis.com/sourcegraph-assets/docs/239155807-185fc3e8-0706-4a23-b9fe-e262f9a9e4b3.png)
9193

@@ -117,6 +119,7 @@ If your instance has schema drift or unfinished oob migrations you may need to a
117119
- [**Sourcegraph AWS AMI instances**](/admin/deploy/machine-images/aws-ami#upgrade)
118120

119121
## Other helpful links
122+
- [Postgres 12 End Of Life Notice](admin/postgres12_end_of_life_notice#postgres-12-end-of-life)
120123
- [Migrator operations](/admin/updates/migrator/migrator-operations)
121124
- [Upgrading Early Versions](/admin/updates/migrator/upgrading-early-versions)
122125
- [Troubleshooting upgrades](/admin/updates/migrator/troubleshooting-upgrades)

0 commit comments

Comments
 (0)