Update to 3.1.0 - failed to find conversion function from unknown to text

Hi,

Just followed the manual upgrade instructions for peertube on my freebsd box. After restarting I’m seeing the following error:

Mar 24 14:23:13 bns-normandy postgres[29039]: [3-1] ERROR: failed to find conversion function from unknown to text
Mar 24 14:23:13 bns-normandy postgres[29039]: [3-2] STATEMENT: UPDATE « videoFile » SET « torrentUrl » = t.« serverUrl » || ‹ /static/torrents/ › || « videoFile ».« torrentFilename », « fileUrl » = t.« serverUrl » || t.« filePath » || « videoFile ».« filename » FROM (SELECT ‹ https:// › || server.host AS « serverUrl », ‹ /static/webseed/ › AS « filePath », « videoFile ».id FROM video INNER JOIN « videoChannel » ON « videoChannel ».id = video.« channelId » INNER JOIN actor ON actor.id = « videoChannel ».« actorId » INNER JOIN server ON server.id = actor.« serverId » INNER JOIN « videoFile » ON « videoFile ».« videoId » = video.id WHERE video.remote IS TRUE) AS t WHERE t.id = « videoFile ».« id » AND « videoFile ».« fileUrl » IS NULL

It looks like I’ve botched something along the way. Any troubleshooting help is appreciated!

Including output in peertube.log here too:

[video.berocs.com:443] 2021-03-25 00:13:09.938 info: Begin migrations.
[video.berocs.com:443] 2021-03-25 00:13:09.944 info: Executing 0595-remote-url.js migration script.
[video.berocs.com:443] 2021-03-25 00:13:09.966 error: Cannot execute migration 0595. {
« err »: {
« stack »: « SequelizeDatabaseError: failed to find conversion function from unknown to text\n at Query.formatError (/var/www/peertube/versions/peertube-v3.1.0/node_modules/sequelize/lib/dialects/postgres/query.js:386:16)\n at Query.run (/var/www/peertube/versions/peertube-v3.1.0/node_modules/sequelize/lib/dialects/postgres/query.js:87:18)\n at processTicksAndRejections (internal/process/task_queues.js:93:5)\n at async /var/www/peertube/versions/peertube-v3.1.0/node_modules/sequelize/lib/sequelize.js:619:16 »,
« message »: « failed to find conversion function from unknown to text »,
« name »: « SequelizeDatabaseError »,
« parent »: {
« stack »: « error: failed to find conversion function from unknown to text\n at Parser.parseErrorMessage (/var/www/peertube/versions/peertube-v3.1.0/node_modules/pg-protocol/dist/parser.js:278:15)\n at Parser.handlePacket (/var/www/peertube/versions/peertube-v3.1.0/node_modules/pg-protocol/dist/parser.js:126:29)\n at Parser.parse (/var/www/peertube/versions/peertube-v3.1.0/node_modules/pg-protocol/dist/parser.js:39:38)\n at Socket. (/var/www/peertube/versions/peertube-v3.1.0/node_modules/pg-protocol/dist/index.js:10:42)\n at Socket.emit (events.js:315:20)\n at addChunk (internal/streams/readable.js:309:12)\n at readableAddChunk (internal/streams/readable.js:284:9)\n at Socket.Readable.push (internal/streams/readable.js:223:10)\n at TCP.onStreamRead (internal/stream_base_commons.js:188:23) »,
« message »: « failed to find conversion function from unknown to text »,
« length »: 117,
« name »: « error »,
« severity »: « ERROR »,
« code »: « XX000 »,
« file »: « parse_coerce.c »,
« line »: « 514 »,
« routine »: « coerce_type »,
« sql »: « UPDATE "videoFile" SET "torrentUrl" = t."serverUrl" || ‹ /static/torrents/ › || "videoFile"."torrentFilename", "fileUrl" = t."serverUrl" || t."filePath" || "videoFile"."filename" FROM (SELECT ‹ https:// › || server.host AS "serverUrl", ‹ /static/webseed/ › AS "filePath", "videoFile".id FROM video INNER JOIN "videoChannel" ON "videoChannel".id = video."channelId" INNER JOIN actor ON actor.id = "videoChannel"."actorId" INNER JOIN server ON server.id = actor."serverId" INNER JOIN "videoFile" ON "videoFile"."videoId" = video.id WHERE video.remote IS TRUE) AS t WHERE t.id = "videoFile"."id" AND "videoFile"."fileUrl" IS NULL »
},
« sql »: « UPDATE "videoFile" SET "torrentUrl" = t."serverUrl" || ‹ /static/torrents/ › || "videoFile"."torrentFilename", "fileUrl" = t."serverUrl" || t."filePath" || "videoFile"."filename" FROM (SELECT ‹ https:// › || server.host AS "serverUrl", ‹ /static/webseed/ › AS "filePath", "videoFile".id FROM video INNER JOIN "videoChannel" ON "videoChannel".id = video."channelId" INNER JOIN actor ON actor.id = "videoChannel"."actorId" INNER JOIN server ON server.id = actor."serverId" INNER JOIN "videoFile" ON "videoFile"."videoId" = video.id WHERE video.remote IS TRUE) AS t WHERE t.id = "videoFile"."id" AND "videoFile"."fileUrl" IS NULL »
}
}

Following from here: Database error during start peertube - #3 par shvonder

Restoring the database fails:

# pg_restore -U postgres -c -C -d postgres "sql-peertube_prod-21-03-24.sql"
pg_restore: [archiver (db)] Error while PROCESSING TOC:
pg_restore: [archiver (db)] Error from TOC entry 3221; 1262 16385 DATABASE peertube_prod peertube
pg_restore: [archiver (db)] could not execute query: ERROR:  database "peertube_prod" does not exist
    Command was: DROP DATABASE peertube_prod;

WARNING: errors ignored on restore: 1

Hi,

What is your postgresql version?

I had an update error too. I just deleted the directory from Peertube /var/www/peertube/versions/peertube-v3.1.0-rc1
and reinstalled. Then I replaced the config files and fixed all paths and passwords in them. Everything works great. But still there was a problem with the update.

PostgreSQL 11.10 (Debian 11.10-0+deb10u1)

I’m using postgresql 9.6 through freebsd’s pkg installer.

# pkg info | grep -i postgresql
postgresql96-client-9.6.20     PostgreSQL database (client)
postgresql96-contrib-9.6.20    The contrib utilities from the PostgreSQL distribution
postgresql96-server-9.6.20     PostgreSQL is the most advanced open-source database available anywhere

Thanks @alterak! I’ll give that a shot when I have some time today.

I found the bug in our migration that only affects PostgreSQL 9.6. Please try to upgrade and migrate your peertube database to PostgreSQL >= 10.

1 « J'aime »

Hi,
I’m also having trouble with latest upgrade…

I also had error « « failed to find conversion function from unknown to text » »
I was using a postgres 9.6 database, so I migrated to 11 following instructions from https://blog.codetitans.pl/post/howto-migrate-postgresql-9-6-to-11-5/

But now i have errors like it’s trying to make a fresh install and i have duplicate entry for my main user error
cf. https://paste.mrflos.pw/?7e468846732d9fae#Be9pcL7WL6gzkaur9zgb8j5oPW3TwZiUmE5zHkxtW2w5

Could you enable debug log? We should not create the admin because we do a SELECT COUNT(*) FROM "user" first to check if we already have users.

So it’s really weird that peertube tries to create a user, if the index already contains a user :thinking:
Seems like a broken db?

Check also this PG upgrade guide https://wiki.fiat-tux.fr/books/administration-systèmes/page/migration-d’une-version-majeure-de-postgresql-à-une-autre

1 « J'aime »

Thank you @Chocobozzz, I switched to postgresql 13 and the upgrade appears to have worked!

@mrflos I haven’t seen that upgrade path before, this is the process I used:

# pkg install postgresql13-server postgresql13-client postgresql13-contrib
Updating FreeBSD repository catalogue...
FreeBSD repository is up to date.
All repositories are up to date.
The following 5 package(s) will be affected (of 0 checked):

New packages to be INSTALLED:
	llvm11: 11.0.1
	lua52: 5.2.4
	postgresql13-client: 13.1
	postgresql13-contrib: 13.1_1
	postgresql13-server: 13.1_1

Number of packages to be installed: 5

The process will require 765 MiB more space.
123 MiB to be downloaded.

Proceed with this action? [y/N]: y
[bns-normandy] [1/5] Fetching postgresql13-server-13.1_1.txz: 100%   13 MiB  13.3MB/s    00:01    
[bns-normandy] [2/5] Fetching postgresql13-client-13.1.txz: 100%    3 MiB   2.8MB/s    00:01    
[bns-normandy] [3/5] Fetching postgresql13-contrib-13.1_1.txz: 100%  487 KiB 498.6kB/s    00:01    
[bns-normandy] [4/5] Fetching llvm11-11.0.1.txz: 100%  107 MiB   4.0MB/s    00:28    
[bns-normandy] [5/5] Fetching lua52-5.2.4.txz: 100%  175 KiB 178.7kB/s    00:01    
Checking integrity... done (4 conflicting)
  - postgresql13-server-13.1_1 conflicts with postgresql96-server-9.6.20 on /usr/local/bin/initdb
  - postgresql13-client-13.1 conflicts with postgresql96-client-9.6.20 on /usr/local/bin/clusterdb
  - postgresql13-client-13.1 conflicts with postgresql96-client-9.6.20 on /usr/local/bin/clusterdb
  - postgresql13-contrib-13.1_1 conflicts with postgresql96-contrib-9.6.20 on /usr/local/bin/oid2name
Checking integrity... done (0 conflicting)
Conflicts with the existing packages have been found.
One more solver iteration is needed to resolve them.
The following 8 package(s) will be affected (of 0 checked):

Installed packages to be REMOVED:
	postgresql96-client: 9.6.20
	postgresql96-contrib: 9.6.20
	postgresql96-server: 9.6.20

New packages to be INSTALLED:
	llvm11: 11.0.1
	lua52: 5.2.4
	postgresql13-client: 13.1
	postgresql13-contrib: 13.1_1
	postgresql13-server: 13.1_1

Number of packages to be removed: 3
Number of packages to be installed: 5

The process will require 731 MiB more space.

Proceed with this action? [y/N]: y
[bns-normandy] [1/8] Deinstalling postgresql96-server-9.6.20...
[bns-normandy] [1/8] Deleting files for postgresql96-server-9.6.20: 100%
==> You should manually remove the "postgres" user. 
==> You should manually remove the "postgres" group 
[bns-normandy] [2/8] Deinstalling postgresql96-contrib-9.6.20...
[bns-normandy] [2/8] Deleting files for postgresql96-contrib-9.6.20: 100%
[bns-normandy] [3/8] Deinstalling postgresql96-client-9.6.20...
[bns-normandy] [3/8] Deleting files for postgresql96-client-9.6.20: 100%
[bns-normandy] [4/8] Installing lua52-5.2.4...
[bns-normandy] [4/8] Extracting lua52-5.2.4: 100%
[bns-normandy] [5/8] Installing postgresql13-client-13.1...
[bns-normandy] [5/8] Extracting postgresql13-client-13.1: 100%
[bns-normandy] [6/8] Installing llvm11-11.0.1...
[bns-normandy] [6/8] Extracting llvm11-11.0.1: 100%
[bns-normandy] [7/8] Installing postgresql13-server-13.1_1...
===> Creating groups.
Using existing group 'postgres'.
===> Creating users
Using existing user 'postgres'.
===> Creating homedir(s)

  =========== BACKUP YOUR DATA! =============
  As always, backup your data before
  upgrading. If the upgrade leads to a higher
  major revision (e.g. 9.6 -> 10), a dump
  and restore of all databases is
  required. This is *NOT* done by the port!
  See https://www.postgresql.org/docs/current/upgrading.html
  ===========================================
[bns-normandy] [7/8] Extracting postgresql13-server-13.1_1: 100%
[bns-normandy] [8/8] Installing postgresql13-contrib-13.1_1...
[bns-normandy] [8/8] Extracting postgresql13-contrib-13.1_1: 100%
=====
Message from postgresql13-client-13.1:

--
The PostgreSQL port has a collection of "side orders":

postgresql-docs
  For all of the html documentation

p5-Pg
  A perl5 API for client access to PostgreSQL databases.

postgresql-tcltk 
  If you want tcl/tk client support.

postgresql-jdbc
  For Java JDBC support.

postgresql-odbc
  For client access from unix applications using ODBC as access
  method. Not needed to access unix PostgreSQL servers from Win32
  using ODBC. See below.

ruby-postgres, py-psycopg2
  For client access to PostgreSQL databases using the ruby & python
  languages.

postgresql-plperl, postgresql-pltcl & postgresql-plruby
  For using perl5, tcl & ruby as procedural languages.

postgresql-contrib
  Lots of contributed utilities, postgresql functions and
  datatypes. There you find pg_standby, pgcrypto and many other cool
  things.

etc...
=====
Message from postgresql13-server-13.1_1:

--
For procedural languages and postgresql functions, please note that
you might have to update them when updating the server.

If you have many tables and many clients running, consider raising
kern.maxfiles using sysctl(8), or reconfigure your kernel
appropriately.

The port is set up to use autovacuum for new databases, but you might
also want to vacuum and perhaps backup your database regularly. There
is a periodic script, /usr/local/etc/periodic/daily/502.pgsql, that
you may find useful. You can use it to backup and perform vacuum on all
databases nightly. Per default, it performs `vacuum analyze'. See the
script for instructions. For autovacuum settings, please review
~pgsql/data/postgresql.conf.

If you plan to access your PostgreSQL server using ODBC, please
consider running the SQL script /usr/local/share/postgresql/odbc.sql
to get the functions required for ODBC compliance.

Please note that if you use the rc script,
/usr/local/etc/rc.d/postgresql, to initialize the database, unicode
(UTF-8) will be used to store character data by default.  Set
postgresql_initdb_flags or use login.conf settings described below to
alter this behaviour. See the start rc script for more info.

To set limits, environment stuff like locale and collation and other
things, you can set up a class in /etc/login.conf before initializing
the database. Add something similar to this to /etc/login.conf:
---
postgres:\
	:lang=en_US.UTF-8:\
	:setenv=LC_COLLATE=C:\
	:tc=default:
---
and run `cap_mkdb /etc/login.conf'.
Then add 'postgresql_class="postgres"' to /etc/rc.conf.

======================================================================

To initialize the database, run

  /usr/local/etc/rc.d/postgresql initdb

You can then start PostgreSQL by running:

  /usr/local/etc/rc.d/postgresql start

For postmaster settings, see ~pgsql/data/postgresql.conf

NB. FreeBSD's PostgreSQL port logs to syslog by default
    See ~pgsql/data/postgresql.conf for more info

NB. If you're not using a checksumming filesystem like ZFS, you might
    wish to enable data checksumming. It can only be enabled during
    the initdb phase, by adding the "--data-checksums" flag to
    the postgres_initdb_flags rcvar.  Check the initdb(1) manpage
    for more info and make sure you understand the performance
    implications.

======================================================================

To run PostgreSQL at startup, add
'postgresql_enable="YES"' to /etc/rc.conf
=====
Message from postgresql13-contrib-13.1_1:

--
The PostgreSQL contrib utilities have been installed. Please see
/usr/local/share/doc/postgresql/contrib/README
for more information.
root@bns-normandy:/var/www/peertube # /usr/local/etc/rc.d/postgresql initdb
The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.

The database cluster will be initialized with locale "C".
The default text search configuration will be set to "english".

Data page checksums are disabled.

creating directory /var/db/postgres/data13 ... ok
creating subdirectories ... ok
selecting dynamic shared memory implementation ... posix
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
selecting default time zone ... US/Central
creating configuration files ... ok
running bootstrap script ... ok
performing post-bootstrap initialization ... ok
syncing data to disk ... ok

initdb: warning: enabling "trust" authentication for local connections
You can change this by editing pg_hba.conf or using the option -A, or
--auth-local and --auth-host, the next time you run initdb.

Success. You can now start the database server using:

    /usr/local/bin/pg_ctl -D /var/db/postgres/data13 -l logfile start

root@bns-normandy:/var/www/peertube # service postgresql start
2021-03-25 09:39:48.368 CDT [63446] LOG:  ending log output to stderr
2021-03-25 09:39:48.368 CDT [63446] HINT:  Future log output will go to log destination "syslog".
 
root@bns-normandy:/var/www/peertube # sudo -u postgres createuser -P peertube
Enter password for new role: 
Enter it again: 


# sudo -u postgres createdb -O peertube -E UTF8 -T template0 peertube_prod
root@bns-normandy:/var/www/peertube # sudo -u postgres psql -c "CREATE EXTENSION pg_trgm;" peertube_prod
CREATE EXTENSION
root@bns-normandy:/var/www/peertube # sudo -u postgres psql -c "CREATE EXTENSION unaccent;" peertube_prod
CREATE EXTENSION
root@bns-normandy:/var/www/peertube # 
root@bns-normandy:/var/www/peertube # 
root@bns-normandy:/var/www/peertube # sudo -u postgres pg_restore -c -C -d postgres backup/sql-peertube_prod-21-03-24.sql
pg_restore: while PROCESSING TOC:
pg_restore: from TOC entry 5; 2615 2200 SCHEMA public postgres
pg_restore: error: could not execute query: ERROR:  schema "public" already exists
Command was: CREATE SCHEMA public;


pg_restore: warning: errors ignored on restore: 1
root@bns-normandy:/var/www/peertube # service peertube start
1 « J'aime »

Just in case there should be a discussion about this, the dependencies document still lists postgresql 9.6.

https://docs.joinpeertube.org/dependencies?id=freebsd

Yes, I’ll update the links.