Etherpad-lite: Postgres-Backend - Fehler: Spalte "Wert" ist vom Typ jsonb, aber Ausdruck ist vom Typ Text

Erstellt am 8. Sept. 2020  ·  29Kommentare  ·  Quelle: ether/etherpad-lite

Beschreibe den Fehler
Schema stimmt nicht überein, wenn Einfügungen jeglicher Art ausgeführt werden.

Fehler: Spalte "Wert" ist vom Typ jsonb, aber Ausdruck ist vom Typ Text

Reproduzieren
Verwenden Sie die neuesten Quellen und Postgres. Versucht mit v12 und v13.

Erwartetes Verhalten
Das Einfügen ohne Fehler durchführen.

Screenshots
etherpad_1 | [2020-09-08 20: 37: 50.541] [ERROR] -Konsole - Fehler: Spalte "Wert" ist vom Typ jsonb, aber Ausdruck ist vom Typ Text
etherpad_1 | unter Parser.parseErrorMessage (/opt/etherpad-lite/src/node_modules/pg-protocol/dist/parser.js:278:15)
etherpad_1 | bei Parser.handlePacket (/opt/etherpad-lite/src/node_modules/pg-protocol/dist/parser.js:126:29)
etherpad_1 | at Parser.parse (/opt/etherpad-lite/src/node_modules/pg-protocol/dist/parser.js:39:38)
etherpad_1 | at Socket.stream.on (/opt/etherpad-lite/src/node_modules/pg-protocol/dist/index.js:8:42)
etherpad_1 | bei Socket.emit (events.js: 198: 13)
etherpad_1 | bei Socket.EventEmitter.emit (domain.js: 448: 20)
etherpad_1 | bei addChunk (_stream_readable.js: 288: 12)
etherpad_1 | at readableAddChunk (_stream_readable.js: 269: 11)
etherpad_1 | at Socket.Readable.push (_stream_readable.js: 224: 10)
etherpad_1 | bei TCP.onStreamRead [als onread] (intern / stream_base_commons.js: 94: 17)

Desktop (bitte vervollständigen Sie die folgenden Informationen):
N / A

Smartphone (bitte folgende Angaben machen):
N / A

Zusätzlicher Kontext
Dies wurde mit Docker-Containern getestet.

Serious Bug

Hilfreichster Kommentar

Vielen Dank an @JohnMcLear. Wenn Sie Folgendes

alter table "store" alter column "value" type text;

Alle 29 Kommentare

Dies ist hauptsächlich ein Problem, bei dem ich die neueste Quelle verwendet habe, wenn ich eine Version hätte verwenden sollen.

Ich habe dies mit 1.8.4 versucht und kann bestätigen, dass ich diesen Fehler nicht erhalte. Ich habe das Problem entsprechend aktualisiert.

Außer 1.8.5 enthält diesen Fehler, also whoops.

Behoben in c8361a211a1e6bfbbc006933f48d48ca51857c71

In c8361a2 behoben

Das verstehe ich immer noch.

image

Hast du dann bin / run.sh gezogen?

Sie müssen ueber aktualisieren und bin / run.sh wird dies tun. Verwenden Sie kein Fastrun

Ja, ich habe immer bin/run.sh .
Es wird auf "ueberdb2": "^0.5.2" aktualisiert

Screenshot_20200910_103721

Tests bestehen gut.

Können Sie eine neue pg dB plz versuchen? Ich möchte sehen, ob das vorherige Commit Ihre Datenbank beschädigt hat.

Können Sie eine neue pg dB plz versuchen? Ich möchte sehen, ob das vorherige Commit Ihre Datenbank beschädigt hat.

Klar, lass es mich versuchen.

Können Sie eine neue pg dB plz versuchen? Ich möchte sehen, ob das vorherige Commit Ihre Datenbank beschädigt hat.

Aufgrund meiner Entwicklungsumgebung bekomme ich bei jedem Build eine neue pg-Datenbank.
image
image

Dann Peep Travis config, um zu sehen, wie wir die Datenbank für die ueberdb-Tests erstellen. Sie wollen das ueber dB Repo nicht hier haben

Scheint es, wir sollten das folgende Repo verwenden?
https://github.com/ether/ueberDB#dirtyref

Dirtyref wird in Master zusammengeführt. Verwenden Sie master

Hallo, ich habe dieses Problem auch auf 1.8.5. Können Sie dieses Problem erneut öffnen, bis eine Lösung gefunden wurde? (so ist es einfacher, es zu finden!)
Vielen Dank!

cc @Gared

Ich habe immer noch dieses Problem geändert, um https://github.com/ether/ueberDB (Master) zu repo

image

Hier gilt das gleiche:

  • Pads werden nicht geladen (entweder ewiges "Laden ..." oder 502)
  • Der Server fällt mit dieser Ausnahme stündlich aus:
[2020-09-11 11:36:24.449] [ERROR] console - error: column "value" is of type jsonb but expression is of type text
    at Parser.parseErrorMessage (/usr/local/var/etherpad/repo/src/node_modules/pg-protocol/dist/parser.js:278:15)
    at Parser.handlePacket (/usr/local/var/etherpad/repo/src/node_modules/pg-protocol/dist/parser.js:126:29)
    at Parser.parse (/usr/local/var/etherpad/repo/src/node_modules/pg-protocol/dist/parser.js:39:38)
    at Socket.<anonymous> (/usr/local/var/etherpad/repo/src/node_modules/pg-protocol/dist/index.js:8:42)
    at Socket.emit (events.js:315:20)
    at Socket.EventEmitter.emit (domain.js:483:12)
    at addChunk (_stream_readable.js:295:12)
    at readableAddChunk (_stream_readable.js:271:9)
    at Socket.Readable.push (_stream_readable.js:212:10)
    at TCP.onStreamRead (internal/stream_base_commons.js:186:23)
[2020-09-11 11:36:24.463] [ERROR] console - TypeError: Cannot read property 'name' of null
    at Client._handleParseComplete (/usr/local/var/etherpad/repo/src/node_modules/pg/lib/client.js:358:26)
    at Connection.emit (events.js:315:20)
    at Connection.EventEmitter.emit (domain.js:483:12)
    at /usr/local/var/etherpad/repo/src/node_modules/pg/lib/connection.js:109:12
    at Parser.parse (/usr/local/var/etherpad/repo/src/node_modules/pg-protocol/dist/parser.js:40:17)
    at Socket.<anonymous> (/usr/local/var/etherpad/repo/src/node_modules/pg-protocol/dist/index.js:8:42)
    at Socket.emit (events.js:315:20)
    at Socket.EventEmitter.emit (domain.js:483:12)
    at addChunk (_stream_readable.js:295:12)
    at readableAddChunk (_stream_readable.js:271:9)
  • Betriebssystem: Ubuntu 18.04
  • settings.json :
{
  "dbSettings" : {
                   "user"    : "etherpad",
                   "host"    : "localhost",
                   "port"    : 5432,
                   "password": "xxx",
                   "database": "etherpad",
                 },
  "padOptions": {
    "noColors":         false,
    "showControls":     true,
    "showChat":         true,
    "showLineNumbers":  true,
    "useMonospaceFont": false,
    "userName":         false,
    "userColor":        false,
    "rtl":              false,
    "alwaysShowChat":   false,
    "chatAndUsers":     false,
    "lang":             "de-de"
  },
  "suppressErrorsInPadText": false,
  "requireSession": false,
  "editOnly": true,
  "sessionNoPassword": false,
  "minify": true,
  "maxAge": 21600,
  "abiword": null,
  "soffice": null,
  "tidyHtml": null,
  "allowUnknownFileEnds": true,
  "requireAuthentication": false,
  "requireAuthorization": false,
  "trustProxy": true,
  "disableIPlogging": true,
  "automaticReconnectionTimeout": 5,
  "users": {
    "admin": {
      "hash": "xxx",
      "is_admin": true
    }
  },
  "socketTransportProtocols" : ["xhr-polling", "jsonp-polling", "htmlfile"],
  "loadTest": false,
  "exposeVersion": false,
  "loglevel": "WARN",
  "logconfig" :
    { "appenders": [
        { "type": "console" }
      ]
    }
}
  • DB: postgresql 10 + 190ubuntu0.1
  • DB-Schema:
SET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SELECT pg_catalog.set_config('search_path', '', false);
SET check_function_bodies = false;
SET xmloption = content;
SET client_min_messages = warning;
SET row_security = off;
CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog;
COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language';
CREATE FUNCTION public.ueberdb_insert_or_update(character varying, text) RETURNS void
    LANGUAGE plpgsql
    AS $_$ BEGIN   IF EXISTS( SELECT * FROM store WHERE key = $1 ) THEN     UPDATE store SET value = $2 WHERE key = $1;   ELSE     INSERT INTO store(key,value) VALUES( $1, $2 );   END IF;   RETURN; END; $_$;
ALTER FUNCTION public.ueberdb_insert_or_update(character varying, text) OWNER TO etherpad;
CREATE FUNCTION public.ueberdb_insert_or_update_jsonb(character varying, jsonb) RETURNS void
    LANGUAGE plpgsql
    AS $_$ BEGIN   IF EXISTS( SELECT * FROM store WHERE key = $1 ) THEN     UPDATE store SET value = $2 WHERE key = $1;   ELSE     INSERT INTO store(key,value) VALUES( $1, $2 );   END IF;   RETURN; END; $_$;
ALTER FUNCTION public.ueberdb_insert_or_update_jsonb(character varying, jsonb) OWNER TO etherpad;
SET default_tablespace = '';
SET default_with_oids = false;
CREATE TABLE public.store (
    key character varying(100) NOT NULL,
    value jsonb NOT NULL
);
ALTER TABLE public.store OWNER TO etherpad;
ALTER TABLE ONLY public.store
    ADD CONSTRAINT store_pkey PRIMARY KEY (key);

Ich nahm den Rollback Road. Ich habe versucht, nur Etherpad auf 1.8.4 zurückzusetzen, aber es hat nicht funktioniert:

[2020-09-11 20:55:44.494] [ERROR] console - JSON-PROBLEM:[object Object]
[2020-09-11 20:55:44.495] [ERROR] console - (node:1) UnhandledPromiseRejectionWarning: SyntaxError: Unexpected token o in JSON at position 1
    at JSON.parse (<anonymous>)
    at /opt/etherpad-lite/src/node_modules/ueberdb2/CacheAndBufferLayer.js:169:24
    at Query.<anonymous> (/opt/etherpad-lite/src/node_modules/ueberdb2/postgres_common.js:99:5)
    at Query.handleReadyForQuery (/opt/etherpad-lite/src/node_modules/pg/lib/query.js:128:10)
    at Connection.<anonymous> (/opt/etherpad-lite/src/node_modules/pg/lib/client.js:247:19)
    at Connection.emit (events.js:198:13)
    at Connection.EventEmitter.emit (domain.js:448:20)
    at Socket.<anonymous> (/opt/etherpad-lite/src/node_modules/pg/lib/connection.js:134:12)
    at Socket.emit (events.js:198:13)
    at Socket.EventEmitter.emit (domain.js:448:20)
[2020-09-11 20:55:44.496] [ERROR] console - (node:1) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
[2020-09-11 20:55:44.496] [ERROR] console - (node:1) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Also habe ich auch einen pgsql-Dump wiederhergestellt und jetzt funktioniert 1.8.4 wieder (was nicht wirklich überraschend ist, da es gut funktioniert hat).

Grund: Von 1.8.4 auf 1.8.5 wird der Spaltenwert von Typ Text in jsonb geändert.
Sollte eine Hauptversion sein ...

Gibt es ein Migrationsskript, das angewendet werden kann?

Ich werde diese Commits einfach zurücksetzen. Dies wurde meiner Meinung nach alles schlecht gehandhabt.

Das Änderungsprotokoll lautet "WICHTIG: Dies behebt ein schwerwiegendes Problem mit postgresql in 1.8.5" für 1.8.6, aber ich habe ein Upgrade durchgeführt und erhalte immer noch die oben genannten Ausnahmen. Ich habe jetzt auch diese Ausnahmen bemerkt, die unmittelbar nach dem Neustart des Dienstes ausgegeben werden:

[2020-09-19 17:47:45.482] [ERROR] console - JSON-PROBLEM:[object Object]                                    
[2020-09-19 17:47:45.496] [ERROR] console - (node:30613) UnhandledPromiseRejectionWarning: SyntaxError: Unexpected token o in JSON at position 1
    at JSON.parse (<anonymous>)                                                                         
    at /usr/local/var/etherpad/repo/src/node_modules/ueberdb2/lib/CacheAndBufferLayer.js:169:24
    at Query.<anonymous> (/usr/local/var/etherpad/repo/src/node_modules/ueberdb2/databases/postgres_common.js:99:5)
    at Query.handleReadyForQuery (/usr/local/var/etherpad/repo/src/node_modules/pg/lib/query.js:122:12)
    at Client._handleReadyForQuery (/usr/local/var/etherpad/repo/src/node_modules/pg/lib/client.js:281:19)
    at Connection.emit (events.js:315:20)               
    at Connection.EventEmitter.emit (domain.js:483:12)          
    at /usr/local/var/etherpad/repo/src/node_modules/pg/lib/connection.js:109:12          
    at Parser.parse (/usr/local/var/etherpad/repo/src/node_modules/pg-protocol/dist/parser.js:40:17)      
    at Socket.<anonymous> (/usr/local/var/etherpad/repo/src/node_modules/pg-protocol/dist/index.js:8:42)
[2020-09-19 17:47:45.497] [ERROR] console - (node:30613) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)    
[2020-09-19 17:47:45.497] [ERROR] console - (node:30613) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

@ c7hm4r hat sich deine Datenbank geändert oder so? Wenn Sie eine neue Tarble / Datenbank starten, sind die Dinge in Ordnung?

@JohnMcLear Beim Neustart von Etherpad 1.8.6 mit einer leeren Datenbank wird ein neues Schema erstellt, das ausnahmslos zu funktionieren scheint.

Wenn ich das neue Schema mit dem alten vergleiche, erhalte ich Folgendes:

diff --git a/etherpad_schema.sql b/etherpad_schema_new.sql
index 9baf5f4..ad3c08b 100644
--- a/etherpad_schema.sql
+++ b/etherpad_schema_new.sql
@@ -41,17 +41,6 @@ CREATE FUNCTION public.ueberdb_insert_or_update(character varying, text) RETURNS

 ALTER FUNCTION public.ueberdb_insert_or_update(character varying, text) OWNER TO etherpad;

---
--- Name: ueberdb_insert_or_update_jsonb(character varying, jsonb); Type: FUNCTION; Schema: public; Owner: etherpad
---
-
-CREATE FUNCTION public.ueberdb_insert_or_update_jsonb(character varying, jsonb) RETURNS void
-    LANGUAGE plpgsql
-    AS $_$ BEGIN   IF EXISTS( SELECT * FROM store WHERE key = $1 ) THEN     UPDATE store SET value = $2 WHERE key = $1;   ELSE     INSERT INTO store(key,value) VALUES( $1, $2 );   END IF;   RETURN; END; $_$;
-
-
-ALTER FUNCTION public.ueberdb_insert_or_update_jsonb(character varying, jsonb) OWNER TO etherpad;
-
 SET default_tablespace = '';

 SET default_with_oids = false;
@@ -62,7 +51,7 @@ SET default_with_oids = false;

 CREATE TABLE public.store (
     key character varying(100) NOT NULL,
-    value jsonb NOT NULL
+    value text NOT NULL
 );

Die Frage ist also: Wann hat sich der Typ der Spalte geändert und wie kann man das migrieren / zurücksetzen?

Ich habe automatische Updates für meine Etherpad-Instanz über den Hauptzweig konfiguriert.

@ c7hm4r @qsuscs war der Autor der beleidigenden Commits. Ich hoffe er übernimmt hier etwas Verantwortung und hilft aus :)

https://github.com/ether/ueberDB/commit/b9e786e2c8753f4cbbe09d3695a92a1a03904ead#diff -f1b8245dd259fa912c33cb2db527f609R31 ist die alter-Anweisung.

  var updateValueColumnType = "ALTER TABLE store " +
    "ALTER COLUMN value " +
    "TYPE jsonb " +
    "USING value::jsonb";

Man würde annehmen, dass das Ändern von jsonb in Text dies tun würde?

Vielen Dank an @JohnMcLear. Wenn Sie Folgendes

alter table "store" alter column "value" type text;

@ c7hm4r keine Sorge, hoffentlich finden die wenigen Betroffenen diesen Thread und führen diesen Befehl aus., Danke fürs Schreiben und Testen! :) Ich würde gerne eine PR machen, um das Problem zu beheben, wenn Sie oder der ursprüngliche Autor dies wünschen. Ich habe im Moment andere Aufgaben, die Priorität haben.

War diese Seite hilfreich?
0 / 5 - 0 Bewertungen