Error: relation "task_result" does not exist

Hello,
I have a new installation of onlyoffice on a virtualmachine. I followed this doc : Installer ONLYOFFICE Docs sur Debian, Ubuntu et ses dérivés - ONLYOFFICE
It’ a Debian GNU/Linux 12 (bookworm)

I can reach the welcome/ page. I started the test and go to the example/ page.
I created a new Document.
The i got this error :

Error
You are trying to perform an action you do not have rights for. Please contact your Document Server administrator.
Press "OK" to return to document list.

in /var/log/onlyoffice/documentserver/docservice/out.log, i got:

[2024-01-10T15:09:03.035] [WARN] [localhost] [10.0.2.2new.docx1704815924806] [uid-1] nodeJS - sqlQuery error sqlCommand: INSERT INTO task_result (tenant, id, status, statu: error: la relation « task_result » n'existe pas
    at /snapshot/server/build/server/DocService/node_modules/pg-pool/index.js:45:11
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
[2024-01-10T15:09:03.035] [ERROR] [localhost] [10.0.2.2new.docx1704815924806] [uid-1] nodeJS - auth error: error: la relation « task_result » n'existe pas
    at /snapshot/server/build/server/DocService/node_modules/pg-pool/index.js:45:11
    at processTicksAndRejections (internal/process/task_queues.js:95:5)

I noticed that in onlyoffice database there is no structure (no table).

A file new.docx has been created but whatever i want to do with (except download) i get the same issue.

Do you you what is the problem ?
Thanks

Hello,

This means the database wasn’t configured properly. Have you executed all the steps related to PostgreSQL configuration in the guide?

sudo -i -u postgres psql -c "CREATE DATABASE onlyoffice;"
sudo -i -u postgres psql -c "CREATE USER onlyoffice WITH password 'onlyoffice';"
sudo -i -u postgres psql -c "GRANT ALL privileges ON DATABASE onlyoffice TO onlyoffice;"

Hello Carl,
Yes, the onlyoffice database and user exist. But the database seems empty.

Hello @evamed,
Please specify the version of PostgreSQL you have installed: psql -V
Also attach your config file /etc/onlyoffice/documentserver/local.json

psql (PostgreSQL) 15.5 (Debian 15.5-0+deb12u1)

/etc/onlyoffice/documentserver/local.json:

{
  "services": {
    "CoAuthoring": {
      "sql": {
        "type": "postgres",
        "dbHost": "localhost",
        "dbPort": "5432",
        "dbName": "onlyoffice",
        "dbUser": "onlyoffice",
        "dbPass": "SECRET1"
      },
      "token": {
        "enable": {
          "request": {
            "inbox": true,
            "outbox": true
          },
          "browser": true
        },
        "inbox": {
          "header": "Authorization"
        },
        "outbox": {
          "header": "Authorization"
        }
      },
      "secret": {
        "inbox": {
          "string": "SECRET2"
        },
        "outbox": {
          "string": "SECRET2"
        },
        "session": {
          "string": "SECRET2"
        }
      }
    }
  },
  "rabbitmq": {
    "url": "amqp://guest:guest@localhost"
  },
  "storage": {
    "fs": {
      "secretString": "SECRET3"
    }
  }
}

Please create a zip archive of /var/log/onlyoffice/documentserver/ and attach it here.

Here it is: /var/log/onlyoffice/documentserver/

Thank you, now please connect to PostgreSQL:
psql -h localhost -U onlyoffice -d onlyoffice
Then execute these two commands and provide the output:

SELECT *
  FROM information_schema.role_table_grants
 WHERE grantee = 'onlyoffice';

SELECT *
  FROM pg_tables
 WHERE tableowner = 'onlyoffice';
onlyoffice=> SELECT *
  FROM information_schema.role_table_grants
 WHERE grantee = 'onlyoffice';
 grantor | grantee | table_catalog | table_schema | table_name | privilege_type | is_grantable | with_hierarchy 
---------+---------+---------------+--------------+------------+----------------+--------------+----------------
(0 ligne)

onlyoffice=> SELECT *
  FROM pg_tables
 WHERE tableowner = 'onlyoffice';
 schemaname | tablename | tableowner | tablespace | hasindexes | hasrules | hastriggers | rowsecurity 
------------+-----------+------------+------------+------------+----------+-------------+-------------
(0 ligne)

Thanks, please try to re-create the database by executing the script:
/var/www/onlyoffice/documentserver/server/schema/postgresql/createdb.sql

#psql -h localhost -U onlyoffice -d onlyoffice -f /var/www/onlyoffice/documentserver/server/schema/postgresql/createdb.sql
Mot de passe pour l'utilisateur onlyoffice : 

psql:/var/www/onlyoffice/documentserver/server/schema/postgresql/createdb.sql:21: ERREUR:  droit refusé pour le schéma public
LIGNE 1 : CREATE TABLE IF NOT EXISTS "public"."doc_changes" (
                                     ^
psql:/var/www/onlyoffice/documentserver/server/schema/postgresql/createdb.sql:41: ERREUR:  droit refusé pour le schéma public
LIGNE 1 : CREATE TABLE IF NOT EXISTS "public"."task_result" (
                                     ^
psql:/var/www/onlyoffice/documentserver/server/schema/postgresql/createdb.sql:73: ERREUR:  droit refusé pour le schéma public

FYI:

onlyoffice=> \l
                                                      Liste des bases de données
    Nom     | Propriétaire | Encodage | Collationnement | Type caract. | Locale ICU | Fournisseur de locale |     Droits d'accès      
------------+--------------+----------+-----------------+--------------+------------+-----------------------+-------------------------
 onlyoffice | postgres     | UTF8     | fr_FR.UTF-8     | fr_FR.UTF-8  |            | libc                  | =Tc/postgres           +
            |              |          |                 |              |            |                       | postgres=CTc/postgres  +
            |              |          |                 |              |            |                       | onlyoffice=CTc/postgres
 postgres   | postgres     | UTF8     | fr_FR.UTF-8     | fr_FR.UTF-8  |            | libc                  | 
 template0  | postgres     | UTF8     | fr_FR.UTF-8     | fr_FR.UTF-8  |            | libc                  | =c/postgres            +
            |              |          |                 |              |            |                       | postgres=CTc/postgres
 template1  | postgres     | UTF8     | fr_FR.UTF-8     | fr_FR.UTF-8  |            | libc                  | =c/postgres            +
            |              |          |                 |              |            |                       | postgres=CTc/postgres
(4 lignes)

onlyoffice=> \d
Aucune relation n'a été trouvée.
onlyoffice=> \du
                                              Liste des rôles
 Nom du rôle |                                    Attributs                                    | Membre de 
-------------+---------------------------------------------------------------------------------+-----------
 onlyoffice  |                                                                                 | {}
 postgres    | Superutilisateur, Créer un rôle, Créer une base, Réplication, Contournement RLS | {}

onlyoffice=> \dn+
                                      Liste des schémas
  Nom   |   Propriétaire    |             Droits d'accès             |      Description       
--------+-------------------+----------------------------------------+------------------------
 public | pg_database_owner | pg_database_owner=UC/pg_database_owner+| standard public schema
        |                   | =U/pg_database_owner                   | 
(1 ligne)

thanks for your help

Please try this:
GRANT USAGE, CREATE ON SCHEMA public TO onlyoffice;

onlyoffice=> GRANT USAGE, CREATE ON SCHEMA public TO onlyoffice;
ATTENTION:  aucun droit n'a été accordé pour « public »
GRANT
onlyoffice=> \du
                                              Liste des rôles
 Nom du rôle |                                    Attributs                                    | Membre de 
-------------+---------------------------------------------------------------------------------+-----------
 onlyoffice  |                                                                                 | {}
 postgres    | Superutilisateur, Créer un rôle, Créer une base, Réplication, Contournement RLS | {}

Please specify the version of the Document Server you have installed:
apt list --installed | grep onlyoffice

onlyoffice-documentserver/squeeze,now 7.5.1-23 amd64 [installé]

Please specify if PostgreSQL 15 was already installed and used on this server before you installed Document Server? I’m asking this because I’ve tested a clean installation of the Document Server and sudo apt-get install postgresql installs PostgreSQL 16.

I’d recommend to perform a clean installation. You could also try installing with the script:
https://helpcenter.onlyoffice.com/fr/installation/docs-community-install-script.aspx
Let me know if this helps.

Hi Carl,
Paostgresql has been installed just before onlyoffice installation like in documentation. So installation of postresql 15 was new. Never tried with v16 as v15 is last version proposed by repository of Debian.
As i can’t give rights to onlyoffice user on onlyoffice database, i changed the owner of the database from postgresql to only office:

onlyoffice=> \l
                                                      Liste des bases de données
    Nom     | Propriétaire | Encodage | Collationnement | Type caract. | Locale ICU | Fournisseur de locale |     Droits d'accès      
------------+--------------+----------+-----------------+--------------+------------+-----------------------+-------------------------
 onlyoffice | postgres     | UTF8     | fr_FR.UTF-8     | fr_FR.UTF-8  |            | libc                  | =Tc/postgres           +
            |              |          |                 |              |            |                       | postgres=CTc/postgres  +
            |              |          |                 |              |            |                       | onlyoffice=CTc/postgres
 postgres   | postgres     | UTF8     | fr_FR.UTF-8     | fr_FR.UTF-8  |            | libc                  | 
 template0  | postgres     | UTF8     | fr_FR.UTF-8     | fr_FR.UTF-8  |            | libc                  | =c/postgres            +
            |              |          |                 |              |            |                       | postgres=CTc/postgres
 template1  | postgres     | UTF8     | fr_FR.UTF-8     | fr_FR.UTF-8  |            | libc                  | =c/postgres            +
            |              |          |                 |              |            |                       | postgres=CTc/postgres
(4 lignes)

postgres=# ALTER DATABASE onlyoffice OWNER TO onlyoffice;

postgres=# \l
                                                       Liste des bases de données
    Nom     | Propriétaire | Encodage | Collationnement | Type caract. | Locale ICU | Fournisseur de locale |      Droits d'accès       
------------+--------------+----------+-----------------+--------------+------------+-----------------------+---------------------------
 onlyoffice | onlyoffice   | UTF8     | fr_FR.UTF-8     | fr_FR.UTF-8  |            | libc                  | =Tc/onlyoffice           +
            |              |          |                 |              |            |                       | onlyoffice=CTc/onlyoffice
 postgres   | postgres     | UTF8     | fr_FR.UTF-8     | fr_FR.UTF-8  |            | libc                  | 
 template0  | postgres     | UTF8     | fr_FR.UTF-8     | fr_FR.UTF-8  |            | libc                  | =c/postgres              +
            |              |          |                 |              |            |                       | postgres=CTc/postgres
 template1  | postgres     | UTF8     | fr_FR.UTF-8     | fr_FR.UTF-8  |            | libc                  | =c/postgres              +
            |              |          |                 |              |            |                       | postgres=CTc/postgres
(4 lignes)

with the result i can’t execute the script createdb.sql with no error:

psql -h localhost -U onlyoffice -d onlyoffice -f /var/www/onlyoffice/documentserver/server/schema/postgresql/createdb.sql
Mot de passe pour l'utilisateur onlyoffice : 
CREATE TABLE
CREATE TABLE
CREATE FUNCTION

When I create a new document, or try to open a document, i have this new error:

[2024-01-15T15:36:34.481] [ERROR] [localhost] [10.0.2.2new.docx1704815924806] [uid-1] nodeJS - postData error: url = http://127.0.0.1:8181/example/track?filename=new.docx&useraddress=10.0.2.2;data = {"key":"10.0.2.2new.docx1704815924806","status":1,"users":["uid-1"],"actions":[{"type":1,"userid":"uid-1"}],"token":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJrZXkiOiIxMC4wLjIuMm5ldy5kb2N4MTcwNDgxNTkyNDgwNiIsInN0YXR1cyI6MSwidXNlcnMiOlsidWlkLTEiXSwiYWN0aW9ucyI6W3sidHlwZSI6MSwidXNlcmlkIjoidWlkLTEifV0sImlhdCI6MTcwNTMyOTM5NCwiZXhwIjoxNzA1MzI5Njk0fQ.SagFjz8mK5yx5R2sM1yeNMYnMkBOOPeE6ArJUmc-5uo"} Error: connect ECONNREFUSED 127.0.0.1:8181
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1159:16)

Please try accessing the Example by the IP address of the server instead of localhost and let me know the results.

It’s work with a static IP!
Thanks a lot Carl.

To resume my problem was that

GRANT ALL privileges ON DATABASE onlyoffice TO onlyoffice;

hadn’t work for me, I had to change the owner:

ALTER DATABASE onlyoffice OWNER TO onlyoffice;

it’s what’s done in the script you proposed me.

1 Like