【问题标题】:Slow exception report in Kemal凯末尔的缓慢异常报告
【发布时间】:2020-02-07 18:01:59
【问题描述】:

我使用水晶 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

【问题讨论】:

    标签: crystal-lang kemal


    【解决方案1】:

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-05-23
      • 2018-02-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-02-27
      • 2023-04-02
      相关资源
      最近更新 更多