etherpad-lite: JSON-PROBLEM shuts server down

A few pads are invalid on my instance and every time these pads are called I get a JSON-PROBLEM-Exception:

[2015-02-18 20:13:48.167] [ERROR] console - JSON-PROBLEM (pad:49Xv36g3re93MSV):{"atext":{"text":"some text\n\n
[2015-02-18 20:13:48.173] [ERROR] console - gracefulShutdown...
[2015-02-18 20:13:48.173] [ERROR] console - Async Stacktrace:
    at /opt/eplite/etherpad-lite-dev/src/node/handler/PadMessageHandler.js:1306:5
    at /opt/eplite/etherpad-lite-dev/src/node/handler/PadMessageHandler.js:1042:16
    at /opt/eplite/etherpad-lite-dev/src/node/db/PadManager.js:171:10
    at Object.callback (/opt/eplite/etherpad-lite-dev/src/node/db/Pad.js:385:8)

SyntaxError: Unexpected end of input
    at Object.parse (native)
    at /opt/eplite/etherpad-lite-dev/src/node_modules/ueberDB/CacheAndBufferLayer.js:164:24
    at Query._callback (/opt/eplite/etherpad-lite-dev/src/node_modules/ueberDB/mysql_db.js:116:5)
    at Query.Sequence.end (/opt/eplite/etherpad-lite-dev/src/node_modules/ueberDB/node_modules/mysql/lib/protocol/sequences/Sequence.js:96:24)
    at Query._handleFinalResultPacket (/opt/eplite/etherpad-lite-dev/src/node_modules/ueberDB/node_modules/mysql/lib/protocol/sequences/Query.js:143:8)
    at Query.EofPacket (/opt/eplite/etherpad-lite-dev/src/node_modules/ueberDB/node_modules/mysql/lib/protocol/sequences/Query.js:127:8)
    at Protocol._parsePacket (/opt/eplite/etherpad-lite-dev/src/node_modules/ueberDB/node_modules/mysql/lib/protocol/Protocol.js:271:23)
    at Parser.write (/opt/eplite/etherpad-lite-dev/src/node_modules/ueberDB/node_modules/mysql/lib/protocol/Parser.js:77:12)
    at Protocol.write (/opt/eplite/etherpad-lite-dev/src/node_modules/ueberDB/node_modules/mysql/lib/protocol/Protocol.js:39:16)
    at Socket.<anonymous> (/opt/eplite/etherpad-lite-dev/src/node_modules/ueberDB/node_modules/mysql/lib/Connection.js:82:28)
    at Socket.emit (events.js:95:17)

After that the instance shutting down. I don’t know how invalid JSON is getting into the DB, but shutting down the server cause of this problem is very bad. Knowing which pads causing this error can lead to a DoS…

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Comments: 37 (26 by maintainers)

Most upvoted comments

@Gared, show table status said 55M rows. It’s InnoDB so that’s an approximation. I am not doing an select count(*), sorry. Hardware is a PowerEdge R510 with 64G of RAM. This is not a dedicated etherpad database, but rather hosted with other projects, but it is a rather idle box. Disks are 15K RPM 300GB drives. Total conversion time with

ALTER TABLE etherpadlite.store 
CHANGE `key` `key` varchar(100) CHARSET utf8mb4 COLLATE utf8mb4_bin NOT NULL DEFAULT '', 
CHANGE `value` `value` longtext CHARSET utf8mb4 COLLATE utf8mb4_bin NOT NULL, 
CHARSET=utf8mb4 COLLATE=utf8mb4_bin;

was about 15 mins. Your milleage will probably vary.

on second thought, it is going to be tricky to find what text is causing the problem, if indeed it is particular text. the problem is that the JSON error is triggered because the database record is truncated. for example:

{"atext":{"text":"blah blah

If I take that text (‘blah blah’ in this example) and paste it into a new pad then it works fine. This leads me to believe that if it is a character(s) that is causing the problem, then whatever that character is is no longer in the database.

and yes, the pads that i have seen this with do tend to have a variety of languages mixed together. the crash today was triggered by a pad with french, english, and arabic. maybe it is a RTL issue?

@Gared can you confirm you are running utf8? mysql> show variables where Variable_name like ‘character_set%’ or Variable_name like ‘collation%’;

If it’s not utf8mb4 you probably experience: https://github.com/ether/etherpad-lite/issues/2516