Skip to content

Add client option FetchOnlyKnownKinds - #1396

Merged
brandur merged 1 commit into
masterfrom
brandur-fetch-only-known-kinds
Sep 28, 2026
Merged

brandur merged 1 commit into
masterfrom
brandur-fetch-only-known-kinds

Conversation

@brandur

@brandur brandur commented Sep 27, 2026

Copy link
Copy Markdown
Contributor

Here, add a client option for FetchOnlyKnownKinds which modifies
producer queries to only fetch job kinds that are registered with the
client.

While not generally needed, I was thinking that this might be useful for
users who are trying to do cross-language migrations within River. e.g.
Trying to move from Go to Rust and needing a clean way to make the
changeover. The target language could handle all job kinds, while the
source language would use FetchOnlyKnownKinds and fetch a dwindling
number of job kinds as they're incrementally moved over and verified.

I benchmarked performance on this and there's very little difference
unless you have large numbers of unknown jobs, and even then, in SQLite
only.

Database / workload Disabled Enabled Difference
PostgreSQL: all known, 1 kind 1.10 ms 1.05 ms Within noise
PostgreSQL: all known, 100 kinds 1.19 ms 1.34 ms +13%
PostgreSQL: 1% known 1.33 ms 1.35 ms +2%
SQLite: all known, 100 kinds 1.07 ms 1.10 ms +3%
SQLite: 50% known 1.05 ms 1.19 ms +13%
SQLite: 1% known 1.11 ms 6.39 ms 5.8×

@brandur
brandur requested a review from bgentry September 27, 2026 19:26

@bgentry bgentry left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Awesome! My main concern here is making sure that this performs well both in OSS and Pro and that the latter maintains support for this as well. Can you make sure to add support on the Pro side as well so we can ship it at the same time, and run similar benchmarks over there? We have a solid benchmark foundation over there that your agent should be able to pick up and run with easily.

Comment thread CHANGELOG.md Outdated

### Added

- Added `Config.FetchOnlyKnownKinds` to restrict job fetching to registered worker kinds, including aliases. Clients with different workers can share a queue while leaving unknown jobs available without consuming attempts. Disabled by default; leader election and stuck-job rescue behavior are unchanged.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

missing PR number

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

@brandur
brandur force-pushed the brandur-fetch-only-known-kinds branch from 34703b5 to 65f7671 Compare September 28, 2026 16:56
Here, add a client option for `FetchOnlyKnownKinds` which modifies
producer queries to only fetch job kinds that are registered with the
client.

While not generally needed, I was thinking that this might be useful for
users who are trying to do cross-language migrations within River. e.g.
Trying to move from Go to Rust and needing a clean way to make the
changeover. The target language could handle all job kinds, while the
source language would use `FetchOnlyKnownKinds` and fetch a dwindling
number of job kinds as they're incrementally moved over and verified.

I benchmarked performance on this and there's very little difference
unless you have large numbers of unknown jobs, and even then, in SQLite
only.

| Database / workload | Disabled | Enabled | Difference |
|---|---:|---:|---:|
| PostgreSQL: all known, 1 kind | 1.10 ms | 1.05 ms | Within noise |
| PostgreSQL: all known, 100 kinds | 1.19 ms | 1.34 ms | +13% |
| PostgreSQL: 1% known | 1.33 ms | 1.35 ms | +2% |
| SQLite: all known, 100 kinds | 1.07 ms | 1.10 ms | +3% |
| SQLite: 50% known | 1.05 ms | 1.19 ms | +13% |
| SQLite: 1% known | 1.11 ms | 6.39 ms | **5.8×** |
@brandur
brandur force-pushed the brandur-fetch-only-known-kinds branch from 65f7671 to fa33a7b Compare September 28, 2026 18:48
@brandur

brandur commented Sep 28, 2026

Copy link
Copy Markdown
Contributor Author

Thanks! Okay I opened another PR over on the Pro side to add support there, with a planned release at the same time this next version of River goes out. Benchmarks confirm no major performance regression.

@brandur
brandur merged commit 208e40b into master Sep 28, 2026
15 checks passed
@brandur
brandur deleted the brandur-fetch-only-known-kinds branch September 28, 2026 20:13
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.

2 participants