requarks / wiki-v1

Legacy version (1.x) of Wiki.js
https://wiki.js.org
GNU Affero General Public License v3.0
101 stars 75 forks source link

server stop work when save large table #63

Open chenyuango opened 6 years ago

chenyuango commented 6 years ago

Actual behavior

Expected behavior

Steps to reproduce the behavior

when I save a large table(about 50 lines), I can not save success. Then the server stop work and CPU load up to 100%. image

ru-kontrol commented 5 years ago

The same behavior while trying to save 56KB md-document. Document is successfully saved to disk (into ./repo directory) but CPU load goes to 100% and Wiki page stops responding in broswer. Less size documents are saved successfully and Wiki continues working.

Ubuntu 16.04, Wiki.js 1.0.102, Node v8.11.4.

ru-kontrol commented 5 years ago

I caught conditions when CPU rises to 100% and Wiki stops. When you add table with huge quantity of REPEATED spaces and minuses - it falls. Decrease number of spaces and minuses if possible, like this: | ----------- |:----------------------------------------------------:| :------------------------------------------------------------------------------------------------------------:| - falls

| ----------- |:------------------------------------------:| :-------------------------------------------------------:| - works

ivangan-convertium commented 5 years ago

@ru-kontrol thanks for your effort on catching this! Was pulling my hair trying to figure the issue regarding the sudden surge of CPU usage on saving change.

NGPixel commented 5 years ago

Try disabling mathjax in your config.yml.

ivangan-convertium commented 5 years ago

@NGPixel This doesn't seems to work though. :)

Went to do some research, it has some relation to the table as mentioned by @ru-kontrol Reference to https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet#tables

If aesthetic does not matter, we only require a minimal of 3 dashes for each header cell, as well as reducing the number of spaces just to make it align. This reduces the load time greatly. Which was the main issue I faced

However, regarding the 100% CPU usage, it doesn't seem to fix it. :(

dirkjanfaber commented 5 years ago

I second this issue

@NGPixel This doesn't seems to work though. :)

Went to do some research, it has some relation to the table as mentioned by @ru-kontrol Reference to https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet#tables

If aesthetic does not matter, we only require a minimal of 3 dashes for each header cell, as well as reducing the number of spaces just to make it align. This reduces the load time greatly. Which was the main issue I faced

However, regarding the 100% CPU usage, it doesn't seem to fix it. :(

I can second this. The node process always takes 100%. The fix in reducing the spaces and dashes helps in saving a markdown file.

Turom commented 5 years ago

I'm facing the same issue. When using MD tables I use this generator: https://www.tablesgenerator.com/markdown_tables

I was able to "fix" the issue using "compact mode" in my tables, when using standard mode the server process would skyrocket and timeout, leaving agent.js with 100% CPU, when using compact mode it behaves normally for now.

NGPixel commented 5 years ago

Would someone be willing to post an example which results in the server timing out? I want to make sure the issue isn't present in 2.0.

dirkjanfaber commented 5 years ago

Would someone be willing to post an example which results in the server timing out? I want to make sure the issue isn't present in 2.0.

This gist makes saving the page take a long while, about 15 seconds on my system, though it does come through in the end. Saving the same file as a gist on GitHub took less than a second.

koallen commented 5 years ago

For me, the CPU issue happens every time the agent runs (I think it's once per day?).

I looked at the source code. Isn't the agent just syncing with remote git repo? Why would this cause 100% CPU usage?