Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

慢日志统计页面无法展现SQL历史趋势图 #2330

Closed
Grain-Yu opened this issue Oct 13, 2023 · 4 comments · Fixed by #2380
Closed

慢日志统计页面无法展现SQL历史趋势图 #2330

Grain-Yu opened this issue Oct 13, 2023 · 4 comments · Fixed by #2380

Comments

@Grain-Yu
Copy link
Contributor

重现步骤

SQL优化->慢查日志->慢日志统计页面,展开单条语句的详情页面,无法展现SQL历史趋势图

预期外的结果

页面提示“Internal Server Error”

日志文本

archery的日志:
[2023-10-13 09:20:53,089][MainThread:140312554125120][task_id:django.request][log.py:224][ERROR]- Internal Server Error: /slowquery/report/
Traceback (most recent call last):
  File "/opt/venv4archery/lib/python3.9/site-packages/django/core/handlers/exception.py", line 47, in inner
    response = get_response(request)
  File "/opt/venv4archery/lib/python3.9/site-packages/django/core/handlers/base.py", line 181, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/opt/venv4archery/lib/python3.9/site-packages/django/utils/decorators.py", line 130, in _wrapped_view
    response = view_func(request, *args, **kwargs)
  File "/opt/archery/sql/slowlog.py", line 209, in report
    checksum = MySQLdb.escape_string(checksum).decode("utf-8")
AttributeError: module 'MySQLdb' has no attribute 'escape_string'

版本

1.10.0

部署方式

Docker

是否还有其他可以辅助定位问题的信息?比如数据库版本等

No response

@Grain-Yu
Copy link
Contributor Author

Grain-Yu commented Oct 13, 2023

mysqlclient的版本问题,2.1.0以后移除了这个方法:
Remove escape() and escape_string() from MySQLdb package.
https://github.com/PyMySQL/mysqlclient/blob/91c04282eac46ce2e5380be58e262d817faab566/HISTORY.rst#whats-new-in-210

@Grain-Yu
Copy link
Contributor Author

#2331 (comment)
按这个方法处理

@feiazifeiazi
Copy link
Contributor

太坑。方法都没了,得后知后觉。 还是强类型语言好。python语言如何提前发现这个问题呢?

@LeoQuote
Copy link
Collaborator

LeoQuote commented May 8, 2024

这没办法提前发现,只能多写测试

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants