-
Notifications
You must be signed in to change notification settings - Fork 640
Schedule the next ti request after finishing the handling of request and updating program typing files #1021
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
Conversation
…and updating program typing files This also fixes the flaky test
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.
Pull Request Overview
This PR updates the scheduling logic for the typings installer so that the next request is scheduled after completing both the handling of the current request and the program typing file updates.
- Moved the pending run request scheduling block from an earlier section to after the file update and logging.
- Ensures that state updates complete before processing the next request.
@@ -330,6 +312,24 @@ func (ti *TypingsInstaller) invokeRoutineToInstallTypings( | |||
Status: core.IfElse(success, "Success", "Fail"), | |||
} | |||
} | |||
|
|||
ti.pendingRunRequestsMu.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.
Consider using a defer statement immediately after acquiring the lock (e.g. 'ti.pendingRunRequestsMu.Lock(); defer ti.pendingRunRequestsMu.Unlock()') to improve code safety and clarity.
ti.pendingRunRequestsMu.Lock() | |
ti.pendingRunRequestsMu.Lock() | |
defer ti.pendingRunRequestsMu.Unlock() |
Copilot uses AI. Check for mistakes.
Before:
After:
So, the race is far less prevalent, but still not impossible. |
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.
Approving just since this is a net improvement and I want CI to be cleaner, but I think that there are still some concurrency bugs in the ATA code that might be fixed by a little restructuring / a different kind of request queue.
I dont think there is concurrency issue with project as such as it doesnt access anythin on project thats not handled by mutex.. I am also surprised on the failure you are getting as its specifically testing that installation doesnt start before finishing the first one when the throttle limit is reached. i have run that test lot of times, just it, sometimes all project and sometimes all tests and never ran into it. i will try on a linux vm to see if i can repro it and see whats going on. |
It's definitely a concurrency issue. It's not a data race, but it is a logical race, otherwise the test wouldn't fail. The failure is that there's a different project that succeeds first, which is an ordering problem. All of the use of atomics and a manual work queue is what I think is causing this to happen; I think that if this were instead converted to not have ATA call back into anything in the Project, instead make Projects call a function on ATA that returns info (so, keep the concurrency out of the contract, manage concurrency within ATA for deduping/throttling, and within Project for safely setting things). That sort of model is a lot easier to reason about than passing a Project into ATA, which then does work, and then calls back onto Project with info. |
This also fixes the flaky test (i think)