Page MenuHomePhabricator

Make math extension handle no response from restbase
Closed, DuplicatePublic

Description

array(4) { ["request"]=> array(2) { ["method"]=> string(3) "GET" ["url"]=> string(116) "http://physikerwelt.local:8081/wikimedia.org/v1/media/math/render/mml/dea9c7cf5645b42591d3dda979938e95de9e74ac" } ["response"]=> array(10) { ["code"]=> int(0) ["reason"]=> string(0) "" ["headers"]=> array(0) { } ["body"]=> string(0) "" ["error"]=> string(62) "(curl error: 52) Server returned nothing (no headers, no data)" [0]=> int(0) [1]=> string(0) "" [2]=> array(0) { } [3]=> string(0) "" [4]=> string(62) "(curl error: 52) Server returned nothing (no headers, no data)" } ["type"]=> string(3) "mml" ["tex"]=> string(26) "{\displaystyle (A,\cdot )}" }

Event Timeline

Physikerwelt raised the priority of this task from to High.
Physikerwelt updated the task description. (Show Details)
Physikerwelt added projects: Math, RESTBase.
Physikerwelt added a subscriber: Physikerwelt.
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptDec 9 2015, 4:20 PM
{"name":"mathoid","hostname":"physikerwelt.local","pid":4564,"level":50,"message":"500: internal_error","stack":"HTTPError: 500: internal_error\n    at /home/physikerwelt/ms/mathoid-server/lib/util.js:173:22\n    at Layer.handle_error (/home/physikerwelt/ms/mathoid-server/node_modules/express/lib/router/layer.js:71:5)\n    at trim_prefix (/home/physikerwelt/ms/mathoid-server/node_modules/express/lib/router/index.js:310:13)\n    at /home/physikerwelt/ms/mathoid-server/node_modules/express/lib/router/index.js:280:7\n    at Function.process_params (/home/physikerwelt/ms/mathoid-server/node_modules/express/lib/router/index.js:330:12)\n    at next (/home/physikerwelt/ms/mathoid-server/node_modules/express/lib/router/index.js:271:10)\n    at Layer.handle_error (/home/physikerwelt/ms/mathoid-server/node_modules/express/lib/router/layer.js:67:12)\n    at trim_prefix (/home/physikerwelt/ms/mathoid-server/node_modules/express/lib/router/index.js:310:13)\n    at /home/physikerwelt/ms/mathoid-server/node_modules/express/lib/router/index.js:280:7\n    at Function.process_params (/home/physikerwelt/ms/mathoid-server/node_modules/express/lib/router/index.js:330:12)\n    at Immediate.next (/home/physikerwelt/ms/mathoid-server/node_modules/express/lib/router/index.js:271:10)\n    at Immediate.<anonymous> (/home/physikerwelt/ms/mathoid-server/node_modules/express/lib/router/index.js:618:15)\n    at Immediate.immediate._onImmediate (timers.js:435:18)\n    at processImmediate [as _immediateCallback] (timers.js:383:17)","status":500,"type":"internal_error","detail":{},"levelPath":"error/500","request_id":"56d14119-9e8c-11e5-8f1a-227569092c73","msg":"500: internal_error","time":"2015-12-09T15:48:49.431Z","v":0}

It seems that the error was caused, because restbase did not receive a response from mathoid.

Physikerwelt set Security to None.

... and this is caused by

Math Processing Error: Maximum call stack size exceeded

I wonder where this comes from... maybe a console log statement

@Physikerwelt: It sounds like the root cause is in mathoid, but RESTBase should at least return an error. Could you verify whether a correct error response is sent?

@GWicke: Yes it's a mathoid problem. I have a reproducible setup so that I can repeat this problem for debugging and testing pruposes. I would like to use the concrete problem in MathJax to develop a method that the mathoid worker thread kills itself... I found out how, I can detect the problem in MathJax but now how to kill the mathoid worker process.
As far as I can tell, Restbase just waits too long for a response from mathoid. From the restbase perspective a timeout should be sent.

The restbase error message... might not be very useful... but at least it might help if someone, who has a similar problem uses a search engine...

{"name":"restbase","hostname":"physikerwelt-2.local","pid":14027,"level":50,"message":"504: internal_http_error","req":{"method":"get","uri":"/wikimedia.org/v1/media/math/render/mml/dea9c7cf5645b42591d3dda979938e95de9e74ac","headers":{"content-length":"0","user-agent":"wikimedia/multi-http-client v1.0","x-client-ip":"::ffff:130.149.225.108","x-request-id":"20ece208-9e90-11e5-82b5-3d45ed1c845a"}},"res":{"name":"HTTPError","message":"504: internal_http_error","status":504,"body":{"type":"internal_http_error","description":"Error: ETIMEDOUT","error":{"cause":{"code":"ETIMEDOUT","connect":false},"isOperational":true,"code":"ETIMEDOUT","connect":false},"stack":"Error: ETIMEDOUT\n    at null._onTimeout (/home/physikerwelt-user/ms/restbase/node_modules/preq/node_modules/request/request.js:761:15)\n    at Timer.listOnTimeout (timers.js:92:15)","uri":"http://localhost:10042/complete","method":"post"},"requestName":"mathoid","headers":{"cache-control":"private, max-age=0, s-maxage=0, must-revalidate","access-control-allow-origin":"*","access-control-allow-methods":"GET","access-control-allow-headers":"accept, content-type","access-control-expose-headers":"etag","x-content-type-options":"nosniff","x-frame-options":"SAMEORIGIN","x-xss-protection":"1; mode=block","content-security-policy":"default-src 'none'; frame-ancestors 'none'","x-content-security-policy":"default-src 'none'; frame-ancestors 'none'","x-webkit-csp":"default-src 'none'; frame-ancestors 'none'","x-request-id":"20ece208-9e90-11e5-82b5-3d45ed1c845a"}},"stack":"Error: ETIMEDOUT\n    at null._onTimeout (/home/physikerwelt-user/ms/restbase/node_modules/preq/node_modules/request/request.js:761:15)\n    at Timer.listOnTimeout (timers.js:92:15)","levelPath":"error/request","request_id":"20ece208-9e90-11e5-82b5-3d45ed1c845a","msg":"504: internal_http_error","time":"2015-12-09T16:17:56.959Z","v":0}

That does not help at all... https://github.com/physikerwelt/mathoid-server/commit/18f791029ea15a100dc1fc9a35e2c3d106e39ef7 The only option that I could find is that MathJax-node kills itself.

The worker committing suicide seems like a bad choice. Can't MathJax-node return an error itself?

In my tests it could... but in practice the error returned never arrives at the mathoid level. Maybe that is connected to this specific error:

Maximum call stack size exceeded
Physikerwelt lowered the priority of this task from High to Medium.Dec 9 2015, 9:50 PM

Letting MathJax-node die it at leat an option, which solves the urgency of the problem.

And the first 40k formulae perform quite well

1/2nd rendering	time in ms	items processed
1-getMathM	37.88873511873259	19363
1-getSvg	38.01941206706523	19649
2-getMathM	4.0958816267781675	19649
2-getSvg	4.146319702571658	19361
checkTeX	15.00948109577863	39097

Waiting for a timeout to happen on the RB side hurts performance. Perhaps see with the MathJax folks why is it committing suicide and whether that can be avoided somehow?

I found one input that causes the problem

{"q":"=nf(x)\\left({n-1 \\choose k-1}F(x)^{k-1}(1-F(x))^{(n-1)-(k-1)}-\\underbrace {{n-1 \\choose n}F(x)^{n}(1-F(x))^{(n-1)-n}} \\right)","type":"inline-tex"}

tested with
mathoid 1.0.0-alpha.6