-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
base: master
Are you sure you want to change the base?
Add archive notify #2852
Conversation
Codecov ReportAttention: Patch coverage is
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. |
# 假设 my2sql.execute_cmd 返回一个包含 user 和 path 的元组 | ||
my2sql.execute_cmd(cmd_args) | ||
return user, path, error_info | ||
except Exception as e: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
不建议这样简单的捕获所有异常, 这个函数是给异步 worker 调用的, 捕获异常后, worker 会认为这个任务正常执行了, 后续的逻辑判断会不对
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
我是想在最后my2sql通知时,还是通过错误内容来判断my2sql 执行成功与否,比如设置一个错误的my2sql目录
except Exception as e: | ||
return src_db_name, src_table_name, str(e) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里同样, 不建议这样捕获异常, 会造成任务状态和实际不一致
There was a problem hiding this comment.
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) 这个函数内部任何任何报错,比如最后记录归档日志失败,都报错,这个时候可能归档是成功的只是记录日志失败了。也报错了。这样是否合理?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
可以通过 raise exception 来实现相同的目的
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
最终报错抛到前端页面么?还是继续发送通知?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
如果 raise exception 我记得 django-q 会自动记录的
添加归档任务通知