-
Notifications
You must be signed in to change notification settings - Fork 0
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
Keep track of PID of process running job #1
Conversation
I know someone wrote a utility to make that happen as well, but I don't remeber what that is called lol. |
This kind of overlaps with sexxi-goose/sexxi-sync#7. I am considering maybe combining both tasks into one PR. |
If this looks good for tracking PID, I will go ahead and merge. This PR does terminate a job if the bot is removed and then re-added, but I decided I will just make a different PR for the conditions that require terminating a job. |
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.
Left some nits for code style. But one thing that confuses me was why are we passing around curr_job
? It seems like it is used to detect if a job is already running for a given head_ref
. I would much prefer we always go to JobRegistry
as the source of truth to fetch the job information. Though that might require some modification of the JobRegistry
to make it fast.
As I mentioned on Discord, |
More testing to be performed tomorrow. |
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.
Awesome work! Just few comments!
have a deadlock. We want to update the JobDesc for the job with the PID of the | ||
running process, but since we have the read lock, we can't acquire the write lock. | ||
|
||
If we want to avoid having to request the read lock everytime we need it, we should |
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.
What about instead of a deep copy we just clone the Arc<RwLock<JobDesc>>
, i know it's a bit boilerplate but we went through all these trouble just so we can avoid deep copy. I think current code works good so it's just my personal preference. Also implementing a macro can probably reduce the repetitive locking/unlocking.
@arora-aman thoughts ?
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.
If we are doing a deep copy then we should probably do it earlier and write some other way of returning the status. But the way code is currently written it makes more sense to just clone the Arc
instead of the cloning the underlying JobDesc
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 am not sure if that really is needed.
Things to keep in mind, why make it more complicated right now when the job is only used for information so far, which should technically not be modified (except for PID, but let's ignore that for now).
Second, the JobRegistry is now being passed around as well as the running job uuid, so technically no need to pass the Arc<RwLock<JobDesc>>
cause we can get it from the JobRegistry
directly.
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.
if u clone the Arc it allows for you to modify the Desc without need to hold lock over the registry. However I don't think it is really need in our case.
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'm not 100% faimilar with this codebase so I could be wrong, but start_build_job(job.clone(), ..) seems simpler, and would work.
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.
hmm no, cloning the Arc still require the read lock
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.
So I am not doing anything about this. Like the comment I left in the code stated, I don't think it is worth adding more concurrency complexity with the read lock when the data of JobDesc is not expected to change. A comment reflects this decision, if we want to change that we should be making a new issue.
have a deadlock. We want to update the JobDesc for the job with the PID of the | ||
running process, but since we have the read lock, we can't acquire the write lock. | ||
|
||
If we want to avoid having to request the read lock everytime we need it, we should |
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.
If we are doing a deep copy then we should probably do it earlier and write some other way of returning the status. But the way code is currently written it makes more sense to just clone the Arc
instead of the cloning the underlying JobDesc
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.
Let's fix the locking issue in #2
This PR is still a work in progress, but so far this is what has been done:
-B
instead of-b
for creating new branch. (-B
create the new branch only if the branch does not exists, otherwise it resets the branch-p
to thegit fetch --all
command, since @arora-aman mentioned it was betterNext to implement:
Closes sexxi-goose/sexxi-sync#6