-
Notifications
You must be signed in to change notification settings - Fork 77
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 merge-conflict notifications #1856
Conversation
Full support for having merge conflict warnings, love it ❤️. On a more technical note, have you been able to test it? |
Yes, here was my test plan:
|
src/handlers/merge_conflict.rs
Outdated
// Spawn since this can trigger a lot of work. | ||
tokio::task::spawn(async move { | ||
// See module note about locking. | ||
let gh = GithubClient::new_from_env(); |
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.
Is there a reason we need a new client vs. using the existing ctx.github client? Seems like that should be Cloneable?
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.
Yea, that sounds good! For some reason I was just assuming it wasn't cloneable (or maybe I was concerned about how the connection pooling would work?).
src/handlers/merge_conflict.rs
Outdated
// row-lock held between the time it is loaded and the save call below. | ||
// The `post_comment` call should normally be pretty fast, so races should | ||
// be rare. If they happen too often, consider adding some locking | ||
// mechanism here. |
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.
I think there is a lock held, actually on the full table? load(...)
starts with LOCK TABLE issue_data
and presumably that's kept until the transaction ends (which happens in save).
triagebot/src/db/issue_data.rs
Line 41 in 742b66b
.execute("LOCK TABLE issue_data", &[]) |
Do we think we need 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.
I don't remember what I was thinking at the time. I saw the LOCK TABLE call, but for some reason was thinking there was something else. I can't think of what it is now, and the lock is clearly held in the IssueData
, so I removed the comment. Thanks for pointing that out!
Generally onboard with landing mostly as-is, a few questions/comments. |
Co-authored-by: Mark Rousskov <[email protected]>
I don't remember what I was thinking at the time. It looks like the transaction is stored in IssueData, so the lock should persist.
The client is already cloneable and should reuse the connection pool.
Personal preference, felt better this way.
90b7023
to
5301321
Compare
This adds a new handler which will post comments on PRs when there is a merge conflict. I have appreciated this feature in homu, and I think it would be helpful for repositories that are not using homu.
A high-level overview:
[merge-conflict]
conflg table to enable the feature. It supports labels just like homu.mergeable
status of a PR is updated both lazily and asynchronously. That is, GitHub doesn't bother computing it until you ask for it, which it then returnsnull
. Then, GitHub has an async background task which computes the value. There is no notification (AFAIK) when that is done, so we just poll again after a delay.