Upgrading Paperless-ngx: nothing is easy (ever)
Irgendwas mit Gartenbau...
Before Paperless-ngx comes with a major release, I figured I’d update from 2.10.x to the latest 2.20.x. Having already lost an initial installation/db when trying it out, I decided to be more careful. But still, bare-metal upgrade-instructions remain a hot mess.
Issues I had to solve after grabbing the new release:
- systemd-service needed to be moved from
gunicorntogranian. The shipped systemd-sample fails to take into acount the Pythonvenv, so you want to tweakpaperless-webserver.serviceto:
ExecStart=/bin/sh -c '\
...
exec /opt/paperless/venv/bin/python3 /opt/paperless/venv/bin/granian --interface asginl --ws "paperless.asgi:application"'
That way it picks up the right Python. Probably I had something like this in the original service as well before I overwrote it ;-)
- After that that UI failed with an error, and the log greeted me with an ominous issue in my MariaDB:
django.db.utils.OperationalError: (1267, "Illegal mix of collations
(utf8mb4_unicode_ci,IMPLICIT) and (utf8mb4_general_ci,IMPLICIT) for operation '='")
After reading up on the blame-game on various GitHub-issues here and there (“bare-metal: your personal problem”), it occurred to me to go back to its Django roots before I start messing with db collation. Turns out you just need to nail it to your collation in the options!
src/paperless/settings.py:
if os.getenv("PAPERLESS_DBENGINE") == "mariadb":
engine = "django.db.backends.mysql"
# Contrary to Postgres, Django does not natively support connection pooling for MariaDB.
# However, since MariaDB uses threads instead of forks, establishing connections is significantly faster
# compared to PostgreSQL, so the lack of pooling is not an issue
options = {
"read_default_file": "/etc/mysql/my.cnf",
"charset": "utf8mb4",
"collation": "utf8mb4_unicode_ci", # <- NEW!
Off to the woods now for some screaming…
Trackback: https://mastodon.social/@fm_volker/116708353655011099