Skip to content

Conversation

@f-f
Copy link
Member

@f-f f-f commented Dec 9, 2025

WIP, should fix #696, fix #649

@f-f
Copy link
Member Author

f-f commented Dec 9, 2025

Main chunks of work to be done at this point:

  • enqueuing/running matrix jobs, need to settle on a design for this. Current direction is "build plan is fixed at submission time, and we dynamically add jobs for dependent packages after a job is completed"
  • enqueing/running package set jobs, need to figure out auth story for that
  • return jobs from the API; need to spec it more:
    • do we keep backwards compatibility? Spago should keep working
    • what details do we return?
    • when returning a list we should allowing selecting queued/done/in progress jobs

@f-f f-f mentioned this pull request Dec 9, 2025
@fsoikin
Copy link
Contributor

fsoikin commented Dec 9, 2025

But the first two bullets can be implemented as separate changes, right? They're not needed for strict parity.

@f-f
Copy link
Member Author

f-f commented Dec 11, 2025

@fsoikin the overall goal is to merge #669 ASAP, so that we can reupload the whole registry.
That can't be merged until we have guaranteed single job execution (#696, this PR, and #649, not yet in this PR but soon), because jobs would otherwise take too long and likely conflict. Splitting off compilation for different compilers is part of making the jobs faster and support keeping the compiler information up to date.

We could be doing all these changes in separate PRs but I don't see the point since they will all need to end up in the compilers-in-metadata branch since we can't merge to trunk until we have the whole package.

Comment on lines +100 to +105
insertPackageJob :: PackageOperation -> ContT Response (Run _) Response
insertPackageJob operation = do
lift $ Log.info $ "Enqueuing job for package " <> PackageName.print (Operation.packageName operation)
jobId <- newJobId
lift $ Db.insertPackageJob { jobId, payload: operation }
jsonOk V1.jobCreatedResponseCodec { jobId }
Copy link
Member

Choose a reason for hiding this comment

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

The old code checked for running jobs before creating new ones:

lift (Db.runningJobForPackage packageName) >>= case _ of
  Right { jobId, jobType: runningJobType } -> ...

Looks like the duplicate checking is no longer there, is that intentional?

JOIN ${JOB_INFO_TABLE} info ON job.jobId = info.jobId
WHERE info.finishedAt IS NULL
AND info.startedAt IS NULL
ORDER BY info.createdAt DESC
Copy link
Member

Choose a reason for hiding this comment

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

Why DESC here? Don't we want the oldest job to go out first (FIFO), like it previously was? Same for the other selectNext* functions.

@thomashoneyman
Copy link
Member

Also the tests are failing because of a missing version field in the fixtures, see:
5afab58

Comment on lines +151 to +153
DeleteIncompleteJobs next -> do
Run.liftEffect $ SQLite.deleteIncompleteJobs env.db
pure next
Copy link
Member

Choose a reason for hiding this comment

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

Are we sure we want to just delete incomplete jobs? Should they instead be re-inserted into the queue? For example, reset startedAt to NULL so the job is picked up again.

We may also want to put more effort into making partially-completed jobs more recoverable, such as making operations as close to idempotent as possible and having a way to sweep through and catch any only partially-complete operations and decide whether to roll them back or to retry and complete them.

@thomashoneyman
Copy link
Member

Main chunks of work to be done at this point:

In addition to your list (some responses to that below), the other point that I'm not seeing here is that we need to ensure that the github issue module only proxies requests over to the server API and writes comments on 'notify' logs but does not actually execute e.g. the publish operation itself. Otherwise we've defeated the purpose of the pull request, as we can't enforce a lock on the git commits anymore.

  • enqueuing/running matrix jobs, need to settle on a design for this. Current direction is "build plan is fixed at submission time, and we dynamically add jobs for dependent packages after a job is completed"

This makes sense to me: start with no-dependency packages, and on completion we queue dependents that are satisfied by this package existing, propagate outwards.

  • enqueing/running package set jobs, need to figure out auth story for that

What do we need to do beyond what we have today? Today, we open an issue, pacchettibotti signs the payload via the GitHub Actions setup, and then the job is executed by the action. With the server, the only difference would be that this payload is submitted to the server API. I'm not sure I'm seeing what the additional auth issues are. We can also have a daily GitHub Action cron job that kicks off the daily package set updater, so as far as the server is concerned it's just receiving an authenticated package set update.

The same approach is used for transfers or unpublishing: open the issue as a purescript/packaging maintainer and it will be auto-signed by pacchettibotti. I like this because it's public.

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.

4 participants