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

Add archive notify #2852

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

woshiyanghai
Copy link
Contributor

添加归档任务通知

Copy link

codecov bot commented Oct 30, 2024

Codecov Report

Attention: Patch coverage is 28.91566% with 59 lines in your changes missing coverage. Please review.

Project coverage is 78.31%. Comparing base (69ddfd0) to head (e5e2c71).

Files with missing lines Patch % Lines
sql/archiver.py 2.17% 45 Missing ⚠️
sql/notify.py 61.29% 12 Missing ⚠️
sql/binlog.py 66.66% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2852      +/-   ##
==========================================
- Coverage   78.37%   78.31%   -0.07%     
==========================================
  Files         124      124              
  Lines       17573    17605      +32     
==========================================
+ Hits        13773    13787      +14     
- Misses       3800     3818      +18     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

# 假设 my2sql.execute_cmd 返回一个包含 user 和 path 的元组
my2sql.execute_cmd(cmd_args)
return user, path, error_info
except Exception as e:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不建议这样简单的捕获所有异常, 这个函数是给异步 worker 调用的, 捕获异常后, worker 会认为这个任务正常执行了, 后续的逻辑判断会不对

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我是想在最后my2sql通知时,还是通过错误内容来判断my2sql 执行成功与否,比如设置一个错误的my2sql目录

Comment on lines +479 to +480
except Exception as e:
return src_db_name, src_table_name, str(e)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里同样, 不建议这样捕获异常, 会造成任务状态和实际不一致

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

在最后通知阶段根据是否有报错信息来区分成功还是失败,这样的话,不管是pt-archiver 执行失败了,还是说pt-archiver 执行成功了,但是删除行数和插入行数不对应,都应该报错,提示归档存在问题。这样try 可能就是在def archive(archive_id) 这个函数内部任何任何报错,比如最后记录归档日志失败,都报错,这个时候可能归档是成功的只是记录日志失败了。也报错了。这样是否合理?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

可以通过 raise exception 来实现相同的目的

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

最终报错抛到前端页面么?还是继续发送通知?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

如果 raise exception 我记得 django-q 会自动记录的

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 this pull request may close these issues.

2 participants