From f57a002dae8bb16694b9f05f3944ac4639476fb3 Mon Sep 17 00:00:00 2001 From: Salar Rahmanian Date: Sun, 28 Jul 2024 11:13:41 -0700 Subject: [PATCH 1/2] add TIL for postgresql collation mismatch --- .../postgresql-collation-version-mismatch.md | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 content/til/postgresql-collation-version-mismatch.md diff --git a/content/til/postgresql-collation-version-mismatch.md b/content/til/postgresql-collation-version-mismatch.md new file mode 100644 index 0000000..1326529 --- /dev/null +++ b/content/til/postgresql-collation-version-mismatch.md @@ -0,0 +1,56 @@ ++++ +title = "PostgreSQL: collation version mismatch" +date = 2024-07-28 + +[taxonomies] +tags = ["PostgreSQL", "Databases"] +categories = [ "TIL" ] + +[extra] +toc = true +keywords = ["PostgreSQL", "Database", "Collation", "Mismatch"] ++++ + +I run my own instance of PeerTube which uses PostgreSQL as its database. When I tried to record my latest video, I got an error message that said: + +``` +[3397851] WARNING: database "peertube" has a collation version mismatch +``` + +I had never seen this error before, so I did some research to figure out what was going on. It turns out that this error occurs when the collation version of the database does not match the collation version of the server. In my case, the collation version of the database was 2.38, while the collation version of the server was 2.39. + +I run NixOS, so this probably occured after I updated the system. + +To resolve this issue, I logged into my NixOS server and did the following: + +- Logged into the PostgreSQL database using the `psql` command: + +```bash +psql -h localhost -d postgres -U postgres +``` + +- connected to my `peertube` database: + +``` +\c peertube +``` + +- Ran the following command: + +```sql +REINDEX DATABASE peertube; ALTER DATABASE peertube REFRESH COLLATION VERSION; +``` + +- Logged out of psql: + +``` +\q +``` + +- Restarted the PostgreSQL service: + +```bash +systemctl restart postgresql +``` + +Note: use `sudo` if you are not logged in as the `root` user. -- 2.46.1 From 05cfaf975812919bc6b296cf6e0ff2a5deebe751 Mon Sep 17 00:00:00 2001 From: Salar Rahmanian Date: Sun, 28 Jul 2024 11:42:44 -0700 Subject: [PATCH 2/2] correction --- content/til/postgresql-collation-version-mismatch.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/content/til/postgresql-collation-version-mismatch.md b/content/til/postgresql-collation-version-mismatch.md index 1326529..d30a52b 100644 --- a/content/til/postgresql-collation-version-mismatch.md +++ b/content/til/postgresql-collation-version-mismatch.md @@ -47,10 +47,10 @@ REINDEX DATABASE peertube; ALTER DATABASE peertube REFRESH COLLATION VERSION; \q ``` -- Restarted the PostgreSQL service: +- Restarted the peertube service: ```bash -systemctl restart postgresql +systemctl restart peertube ``` Note: use `sudo` if you are not logged in as the `root` user. -- 2.46.1