1

我使用水晶 32.1 和凯末尔。如果我有运行时异常,打印回溯需要 21 秒。知道为什么需要这么长时间吗?

500 GET /chats/by_sale/1 21280.52ms

回溯:

web_1     | I, [2020-02-07 17:57:33 +00:00 #1]  INFO -- : [1]
web_1     | Exception: Expected string for object name (JSON::Error)
web_1     |   from /usr/share/crystal/src/json/builder.cr:308:16 in 'start_scalar'
web_1     |   from /usr/share/crystal/src/json/builder.cr:295:11 in 'start_scalar'
web_1     |   from /usr/share/crystal/src/json/builder.cr:194:5 in 'start_object'
web_1     |   from src/service/json.cr:220:5 in 'object'
web_1     |   from src/controller/chat.cr:37:5 in '->'
web_1     |   from lib/kemal/src/kemal/route.cr:255:3 in '->'
web_1     |   from lib/kemal/src/kemal/route_handler.cr:255:3 in 'process_request'
web_1     |   from lib/kemal/src/kemal/route_handler.cr:17:7 in 'call'
web_1     |   from /usr/share/crystal/src/http/server/handler.cr:26:7 in 'call_next'
web_1     |   from lib/kemal/src/kemal/websocket_handler.cr:13:14 in 'call'
web_1     |   from /usr/share/crystal/src/http/server/handler.cr:26:7 in 'call_next'
web_1     |   from lib/kemal/src/kemal/filter_handler.cr:21:7 in 'call'
web_1     |   from /usr/share/crystal/src/http/server/handler.cr:26:7 in 'call_next'
web_1     |   from src/middleware/authenticate.cr:17:7 in 'call'
web_1     |   from /usr/share/crystal/src/http/server/handler.cr:26:7 in 'call_next'
web_1     |   from lib/kemal/src/kemal/static_file_handler.cr:68:9 in 'call'
web_1     |   from /usr/share/crystal/src/http/server/handler.cr:26:7 in 'call_next'
web_1     |   from lib/kemal/src/kemal/exception_handler.cr:8:7 in 'call'
web_1     |   from /usr/share/crystal/src/http/server/handler.cr:26:7 in 'call_next'
web_1     |   from lib/kemal/src/kemal/log_handler.cr:8:37 in 'call'
web_1     |   from /usr/share/crystal/src/http/server/handler.cr:26:7 in 'call_next'
web_1     |   from lib/kemal/src/kemal/init_handler.cr:12:7 in 'call'
web_1     |   from /usr/share/crystal/src/http/server/request_processor.cr:48:11 in 'process'
web_1     |   from /usr/share/crystal/src/http/server/request_processor.cr:22:3 in 'process'
web_1     |   from /usr/share/crystal/src/http/server.cr:497:5 in 'handle_client'
web_1     |   from /usr/share/crystal/src/http/server.cr:463:13 in '->'
web_1     |   from /usr/share/crystal/src/fiber.cr:255:3 in 'run'
web_1     |   from /usr/share/crystal/src/fiber.cr:47:34 in '->'
web_1     |   from ???
web_1     |
web_1     | 2020-02-07 17:57:54 UTC 500 GET /chats/by_sale/1 21280.52ms
4

1 回答 1

1

很大的评论,所以让它成为一个答案。

我将如何处理这个问题是通过在 gdb 中运行你的服务器,然后在“21 秒暂停的中间”你在你的服务器中点击 ctrl+c。它会让你进入 gdb。然后运行 ​​gdbbacktrace命令,看看它是否告诉你什么。另一种选择可能是在其上运行分析器,这里提到了一些:甚至 gdb “穷人的分析器”也适用于水晶(在 OS X 中,该sample命令执行类似 FWIW 的操作),并在减速期间运行它有问题。

于 2020-02-21T13:46:44.000 回答