-
Notifications
You must be signed in to change notification settings - Fork 79
Job queue, matrix builder, concurrency control #709
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
Merged
thomashoneyman
merged 40 commits into
trh/compilers-in-metadata
from
f-f/concurrent-jobs-2
Jan 8, 2026
Merged
Changes from 5 commits
Commits
Show all changes
40 commits
Select commit
Hold shift + click to select a range
20d6b21
Update database schemas and add job executor loop
thomashoneyman 4b9743c
Split Server module into Env, Router, JobExecutor, and Main
fsoikin 2fe9635
Fix up build
fsoikin a4f1047
Run job executor
fsoikin dfd7e78
Fix integration tests
f-f cdbac72
WIP matrix builds
f-f 253f85c
add missing version to publish fixtures
pacchettibotti 13eaf3a
Add missing packageName and packageVersion to InsertMatrixJob
pacchettibotti 301d348
Fix finishedAt timestamp to capture time after job execution
pacchettibotti 0a13995
Implement matrix jobs, and the recursive enqueuing of new ones
f-f 50cd04b
Reset incomplete jobs so they can be picked up again
f-f 6a57d75
Run matrix jobs for the whole registry when finding a new compiler ve…
f-f 408a46b
Merge branch 'trh/compilers-in-metadata' into f-f/concurrent-jobs-2
thomashoneyman f1a602b
resolve build issues
thomashoneyman f943991
fix smoke test
thomashoneyman ea420fa
Split package jobs into separate tables, return all data from the job…
f-f 9a8d1ba
implement thin client for github issues
thomashoneyman 5ae9449
clean up test failures
thomashoneyman ad6c328
reinstate missing comments
thomashoneyman 6c023cf
Remove COMMENT effect, add NOTIFY log
thomashoneyman e69b875
Implement endpoint for returning jobs
f-f c33a3ad
Check for existing jobs before enqueueing new ones
f-f e524f00
Add E2E test: publishing a package enqueues matrix jobs
f-f 6dc01f0
Add E2E test: run a whole-registry upgrade when detecting a new compiler
f-f bf90252
Don't fail job fetch on unreadable logs
f-f cf91c12
Merge branch 'trh/compilers-in-metadata' into f-f/concurrent-jobs-2
thomashoneyman 96bee58
Fix archive seeder build
thomashoneyman c9bade0
remove effect-4.0.0 from storage in unit tests
thomashoneyman 9ac3531
avoid race condition in initial jobs test
thomashoneyman 4fe219b
format
thomashoneyman 82c6b5a
second test
thomashoneyman c6fc970
Merge remote-tracking branch 'origin/trh/compilers-in-metadata' into …
thomashoneyman 12baa9a
Merge branch 'trh/compilers-in-metadata' into f-f/concurrent-jobs-2
thomashoneyman ab31199
Refactor e2e tests with wiremock scenarios (#713)
thomashoneyman 06ff81f
trim tests down a bit to optimize speed to ~60s
thomashoneyman 198ffcd
Add endpoint for package set jobs + e2e tests for it
f-f 31d247b
tweak unpublish test to verify matrix jobs fail gracefully
thomashoneyman 3e278f4
tweak agents to refer to scratch logs
thomashoneyman f195b37
remove slow archive seeder test
thomashoneyman de4c19e
fix tests by bumping compiler
thomashoneyman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| module Registry.App.Main where | ||
|
|
||
| import Registry.App.Prelude hiding ((/)) | ||
|
|
||
| import Data.DateTime (diff) | ||
| import Data.Time.Duration (Milliseconds(..), Seconds(..)) | ||
| import Effect.Aff as Aff | ||
| import Effect.Class.Console as Console | ||
| import Fetch.Retry as Fetch.Retry | ||
| import Node.Process as Process | ||
| import Registry.App.Server.Env (ServerEnv, createServerEnv) | ||
| import Registry.App.Server.JobExecutor as JobExecutor | ||
| import Registry.App.Server.Router as Router | ||
|
|
||
| main :: Effect Unit | ||
| main = do | ||
| createServerEnv # Aff.runAff_ case _ of | ||
| Left error -> do | ||
| Console.log $ "Failed to start server: " <> Aff.message error | ||
| Process.exit' 1 | ||
| Right env -> do | ||
| case env.vars.resourceEnv.healthchecksUrl of | ||
| Nothing -> Console.log "HEALTHCHECKS_URL not set, healthcheck pinging disabled" | ||
| Just healthchecksUrl -> Aff.launchAff_ $ healthcheck healthchecksUrl | ||
| Aff.launchAff_ $ jobExecutor env | ||
| Router.runRouter env | ||
| where | ||
| healthcheck :: String -> Aff Unit | ||
| healthcheck healthchecksUrl = loop limit | ||
| where | ||
| limit = 10 | ||
| oneMinute = Aff.Milliseconds (1000.0 * 60.0) | ||
| fiveMinutes = Aff.Milliseconds (1000.0 * 60.0 * 5.0) | ||
|
|
||
| loop n = do | ||
| Fetch.Retry.withRetryRequest healthchecksUrl {} >>= case _ of | ||
| Succeeded { status } | status == 200 -> do | ||
| Aff.delay fiveMinutes | ||
| loop n | ||
|
|
||
| Cancelled | n >= 0 -> do | ||
| Console.warn $ "Healthchecks cancelled, will retry..." | ||
| Aff.delay oneMinute | ||
| loop (n - 1) | ||
|
|
||
| Failed error | n >= 0 -> do | ||
| Console.warn $ "Healthchecks failed, will retry: " <> Fetch.Retry.printRetryRequestError error | ||
| Aff.delay oneMinute | ||
| loop (n - 1) | ||
|
|
||
| Succeeded { status } | status /= 200, n >= 0 -> do | ||
| Console.error $ "Healthchecks returned non-200 status, will retry: " <> show status | ||
| Aff.delay oneMinute | ||
| loop (n - 1) | ||
|
|
||
| Cancelled -> do | ||
| Console.error | ||
| "Healthchecks cancelled and failure limit reached, will not retry." | ||
|
|
||
| Failed error -> do | ||
| Console.error $ "Healthchecks failed and failure limit reached, will not retry: " <> Fetch.Retry.printRetryRequestError error | ||
|
|
||
| Succeeded _ -> do | ||
| Console.error "Healthchecks returned non-200 status and failure limit reached, will not retry." | ||
|
|
||
| jobExecutor :: ServerEnv -> Aff Unit | ||
| jobExecutor env = do | ||
| loop initialRestartDelay | ||
| where | ||
| initialRestartDelay = Milliseconds 100.0 | ||
|
|
||
| loop restartDelay = do | ||
| start <- nowUTC | ||
| result <- JobExecutor.runJobExecutor env | ||
| end <- nowUTC | ||
|
|
||
| Console.error case result of | ||
| Left error -> "Job executor failed: " <> Aff.message error | ||
| Right _ -> "Job executor exited for no reason." | ||
|
|
||
| -- This is a heuristic: if the executor keeps crashing immediately, we | ||
| -- restart with an exponentially increasing delay, but once the executor | ||
| -- had a run longer than a minute, we start over with a small delay. | ||
| let | ||
| nextRestartDelay | ||
| | end `diff` start > Seconds 60.0 = initialRestartDelay | ||
| | otherwise = restartDelay <> restartDelay | ||
|
|
||
| Aff.delay nextRestartDelay | ||
| loop nextRestartDelay |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.