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

Store assigned PRs in memory #1906

Merged
merged 2 commits into from
Mar 6, 2025
Merged

Conversation

Kobzol
Copy link
Contributor

@Kobzol Kobzol commented Feb 18, 2025

This PR stops using assigned_prs column in the review_prefs table, and remembers PR assignments in-memory instead.

@Kobzol Kobzol marked this pull request as ready for review February 18, 2025 17:34
@Kobzol Kobzol force-pushed the assigned-prs-in-memory branch from 1a93fe6 to 3fde3dd Compare February 18, 2025 17:34
@Kobzol Kobzol requested a review from jackh726 February 20, 2025 08:36
@Kobzol Kobzol force-pushed the assigned-prs-in-memory branch from 3fde3dd to d64caa6 Compare February 21, 2025 16:13
@Kobzol
Copy link
Contributor Author

Kobzol commented Feb 21, 2025

Rebased.

@@ -348,4 +349,7 @@ pub struct Context {
pub db: crate::db::ClientPool,
pub username: String,
pub octocrab: Octocrab,
/// Represents the workqueue (assigned open PRs) of individual reviewers.
/// tokio's RwLock is used to avoid deadlocks, since we run on a single-threaded tokio runtime.
pub workqueue: Arc<tokio::sync::RwLock<ReviewerWorkqueue>>,
Copy link
Member

Choose a reason for hiding this comment

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

So, I don't quite like storing this state like this - I'd rather have some (Handler, HandlerState) somewhere. But this is fine for now.

Copy link
Contributor Author

@Kobzol Kobzol Feb 22, 2025

Choose a reason for hiding this comment

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

The problem is that this state has to be available across handlers. It is populated in pull_requests_assignment_update.rs, updated in pr_tracking.rs and it will be read in the future in assign.rs. Thus it's pretty much global state, hence it being stored in Context.

// .await?;
// return Ok(());
}
// let work_queue = has_user_capacity(&db_client, &name).await;
Copy link
Member

Choose a reason for hiding this comment

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

Why is this disabled? We definitely want this logging.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

These functions that I commented were using the assigned_prs column in the DB, which is no longer used after this PR. So these functions simply do not work anymore (in fact I removed them in this PR).

I'm planning to further work on assigning PR capacity limit, and then refactor the way PRs are assigned, and add back logging (and then we can hopefully enable the new assignment logic again).

I did not want to do all that in this PR, hence I commented this code.

issue.number,
filtered_candidates
);
// let filtered_candidates = filter_by_capacity(db, &candidates)
Copy link
Member

Choose a reason for hiding this comment

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

Similar here.

@Kobzol Kobzol force-pushed the assigned-prs-in-memory branch from d64caa6 to b7c8cd8 Compare February 22, 2025 17:36
@Kobzol
Copy link
Contributor Author

Kobzol commented Mar 3, 2025

Let me know if you want further changes :)

@jackh726
Copy link
Member

jackh726 commented Mar 4, 2025

@Kobzol I'm holding off merging, since I think we should make sure to merge when we can quickly revert if there are problems.

@Kobzol Kobzol force-pushed the assigned-prs-in-memory branch from b7c8cd8 to fc3b6f9 Compare March 6, 2025 08:52
Kobzol added 2 commits March 6, 2025 09:55
Assignment based on review preferences is not working currently.
@Kobzol Kobzol force-pushed the assigned-prs-in-memory branch from fc3b6f9 to c4a6179 Compare March 6, 2025 08:55
@Kobzol
Copy link
Contributor Author

Kobzol commented Mar 6, 2025

I rebased the PR and went through the changes again. I hope that this shouldn't break stuff, but one never knows. After merging, I'll monitor the logs and triagebot's state. The bors queue is borked anyway 😆

@Kobzol Kobzol merged commit fd32535 into rust-lang:master Mar 6, 2025
3 checks passed
@Kobzol Kobzol deleted the assigned-prs-in-memory branch March 6, 2025 09:11
@Kobzol
Copy link
Contributor Author

Kobzol commented Mar 6, 2025

Hmm, off to a good start.

HTTP status server error (504 Gateway Timeout) for url (https://api.github.com/graphql))

While loading the initial list of PRs. I only renamed that function in this PR though, so pretty sure that it is a GH problem (maybe because we have more open PRs now due to the bors queue being stuck?). Maybe we should load the PRs through the REST API in batches, rather than loading all at once using GraphQL. Nevermind, the GQL query is already paged, so that probably wouldn't help.

Otherwise it seems to work though.

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