Repository navigation
Add a Where escape hatch to JobDeleteManyParams - #1570
Merged
Merged
Conversation
JobListParams has Where for predicates its filters can't express, but JobDeleteManyParams doesn't, so deleting queued jobs by a value in their args (for example every job naming a customer whose data is erased) meant listing the jobs first and deleting them by ID, or going around River. JobDeleteManyParams.Where mirrors JobListParams.Where and goes through the same dblist path, so it works with every driver. A Where predicate counts as a filter, so params with only a Where don't need UnsafeAll. Each predicate is wrapped in parentheses: JobDeleteMany appends its `state != 'running'` guard with AND, so an unparenthesized OR would widen the deletion past the other filters and to running jobs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
mokevnin
force-pushed
the
delete-many-where
branch
from
October 31, 2026 20:18
087b780 to
fa44467
Compare
Contributor
|
Thanks @mokevnin! Do you think you could sign our https://github.com/riverqueue/rivercla? I'll take a look at this in a bit. |
Contributor
Author
|
Thanks @brandur! Signed the CLA in riverqueue/rivercla#41. |
A few tweaks for riverqueue#1570: * Add a set of shared driver tests to verify wide compatibility for predicates, `OR` safety, trailing comments, and skipped locked jobs. * Docs clarifying batch limits and skipped lock jobs. * Some method and test ordering cleanup (largely for alphabetical order which is our internal convention for organizing things).
brandur
approved these changes
Nov 1, 2026
Contributor
|
Ty! Pushed one more commit here with:
|
Contributor
|
Released v0.51.0 |
mokevnin
added a commit
to getsphericon/sphericon
that referenced
this pull request
Nov 1, 2026
…, drop the ent mapping of river_job River v0.51.0 adds JobDeleteManyParams.Where (riverqueue/river#1570), so Erasure's purge deletes the jobs that name an erased Contact through River on the erasure transaction instead of an ent entity over River's table. River deletes a batch at a time, so the purge repeats until a batch comes back short. A job a fetch holds locked is skipped as a running one is: its worker re-checks that what it refers to still exists. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
mokevnin
added a commit
to getsphericon/sphericon
that referenced
this pull request
Nov 1, 2026
… on River v0.51.0 (#905) * chore(deps): update River to v0.51.0 Picks up the fixes for a lost cancellation notification, the notifier run loop that could block Client.Stop forever, and InsertManyFast/QueueUpdate without a listener. The release carries no database migration. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * refactor(erasure): delete queued jobs through River's JobDeleteManyTx, drop the ent mapping of river_job River v0.51.0 adds JobDeleteManyParams.Where (riverqueue/river#1570), so Erasure's purge deletes the jobs that name an erased Contact through River on the erasure transaction instead of an ent entity over River's table. River deletes a batch at a time, so the purge repeats until a batch comes back short. A job a fetch holds locked is skipped as a running one is: its worker re-checks that what it refers to still exists. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
3 tasks
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
JobListParamshasWhere(sql, NamedArgs)for predicates its filters can't express, butJobDeleteManyParamsdoesn't. We need to delete queued jobs by a value in their args: when erasing a customer's personal data (GDPR), every non-running job whose args name that customer has to go, in the same transaction as the erasure. Today that means listing the jobs first and deleting them by ID, or going around River to theriver_jobtable, which we'd rather not do.This adds
JobDeleteManyParams.Where(sql string, namedArgs ...NamedArgs), mirroringJobListParams.Whereand built on the samedblistpath, so it works with every driver:Two details:
Wherepredicate counts as a filter, so params with only aWheredon't needUnsafeAll(and callingUnsafeAllafterWherepanics, like after any other filter).JobDeleteManyappends itsstate != 'running'guard withAND, so an unparenthesizedORwould widen the deletion past the other filters and to running jobs. The closing parenthesis goes on its own line so a trailing--comment in the predicate can't comment it out.Named args are merged into a fresh map, so the caller's maps aren't modified.
The other ports have no raw predicate on their list either, so this is Go-only, like
JobListParams.Where.Tests
delete_many_params_test.go:Wherecounts forfiltersEmptyand makesUnsafeAllpanic; the generated where clause wraps each predicate (including one with a trailing comment); named args merge without mutating the caller's maps; the receiver isn't modified.client_test.go(Test_Client_JobDeleteMany): deleting byargs->>'customer_id'together withKinds; aWherealone withoutUnsafeAll; and anORpredicate that must not delete a running job or a job of another kind. That last test fails with the parentheses removed (it then deletes all three jobs).riverdriver/riverdrivertest/job_delete.goalready coversJobDeleteManywith a rawWhereClauseand named args on every driver.🤖 Generated with Claude Code