Skip to content

fix: honor a Worker Group claim batch above 32 - #49

Merged
pdevito3 merged 4 commits into
mainfrom
fix/0306-claim-batch-clamp
Dec 4, 2026
Merged

pdevito3 merged 4 commits into
mainfrom
fix/0306-claim-batch-clamp

Conversation

@pdevito3

@pdevito3 pdevito3 commented Dec 4, 2026

Copy link
Copy Markdown
Contributor

Why

A Worker Group with MaxClaimBatch above 32 claimed at most 32 jobs per call. The store clamped each claim to StoreBounds.MaxClaimBatch, and that bound also defaulted to 32. The group's setting was ignored with no message. This is issue 0306.

Reproduction on main (bf635f8):

  • Hosting test, group MaxClaimBatch 128 and PoolSize 128 on the in-memory store: Expected: 128, Actual: 32.
  • Postgres Conformance clause, claim of 128 with default bounds: Expected: 128, Actual: 32.
  • Real benchmark run, Postgres, --pool-size 128 (group batch 128): the new dial reads claim-batch-ran = largest claim 32 jobs.

What changed

  • StoreBounds.MaxClaimBatch is now a safety ceiling with a default of 256. It keeps one claim statement bounded. It does not set throughput. WorkerGroupOptions.MaxClaimBatch keeps its default of 32.
  • A Worker Group whose claim size, min(MaxClaimBatch, PoolSize), is above the store ceiling logs a warning when it starts (event 2006). The warning names both values and the fix. It does not throw, so every app that starts today still starts.
  • Oracle: page reads use a fixed 32-row LOB fetch window. Before, they borrowed StoreBounds.MaxClaimBatch, so raising the ceiling would have grown every monitor page buffer. The claim uses max(take, 32) rows, so a claim of 32 or fewer reads as before.
  • Oracle: the store rejects MaxClaimBatch above 1,000 when it is created. The claim leases its rows with one IN list, and Oracle accepts at most 1,000 expressions in a list (ORA-01795).
  • SQL Server: tag hydration and the outcome batch's parent lookup send ids in slices of 2,000. SQL Server accepts at most 2,100 parameters in one command (error 8003).
  • Conformance: a new clause certifies that a claim of 128 returns 128, or the store's own ceiling when that is smaller.
  • Benchmarks: a new claim-batch-ran dial reports the largest claim the pump ran, so a result shows the claim size that ran, not only the configured one.
  • Docs: XML docs on both options state how they relate. CONTEXT.md adds the Claim Batch term.

Scope

Not breaking for defaults. A group with MaxClaimBatch 32 or less claims exactly what it claimed before. Only a group set above 32 now gets what it configured.

Two startup changes to note in the release notes:

  • An Oracle store configured with Bounds.MaxClaimBatch above 1,000 now throws when it is created. Before, it started and failed on the first full claim above 1,000.
  • A third-party store that does not override IJobStore.Bounds now reports a ceiling of 256. If it clamps claims lower inside, the new Conformance clause fails for it.

Blast radius

  • Claim SQL, locking, and transaction shape are unchanged on every adapter. A claim can carry more rows in the same statement. I did not run the lease-fencing-model skill for that reason: the model checks statement order and row locks, not batch size. The Oracle change sets only the client fetch size. The SQL Server change splits read-only lists into more commands.
  • Larger claims make larger outcome batches, because MaxOutcomeBatch defaults to the group's MaxClaimBatch. The SQL Server test covers a 2,200-job claim and outcome batch.

Verification

All figures below are from local mode on an M1 Max, and are indicative only.

  • Build: 0 warnings, 0 errors.
  • Tests (Category!=Soak, net10.0): all projects pass. Postgres 323, SQL Server 304, Oracle 359, SQLite 348, Hosting 128, BackWave.Tests 1032, and the rest. One SQLite pool stress test (Concurrent_opens_on_the_store_pool_never_share_a_native_connection) timed out once under machine load and passed alone. It does not touch this change.
  • SQL Server racy tests run alone (SqlServerConcurrentMaintenanceTests): 11 passed.
  • Conformance with every claim helper set to 256 (temporary edit, not committed): InMemory, SQLite, Postgres, SQL Server, and Oracle each 234 of 234 passed.
  • New tests, each failing before its fix:
    • ClaimBatchTests (Hosting): 128 honored; default still 32 with no warning; a ceiling of 64 gives one warning and 64-job claims; no warning when PoolSize keeps the claim under the ceiling.
    • SqlServerLargeClaimTests: a claim and an outcome batch of 2,200 jobs. Before the slicing: The incoming request has too many parameters. The server supports a maximum of 2100 parameters.
    • OracleTagBoundTests: 1,001 rejected, 1,000 accepted.
    • OracleLobPrefetchTests: a raised ceiling does not grow a page read's window. OracleRoundTripBudgetTests still pins the default page window at 4,495,008 bytes and a 32-job claim.
  • Benchmark, Postgres, 1 group, pool 128, group batch 128: claim-batch-ran = largest claim 128 jobs (was 32 on main).
  • Benchmark, drain-noop shape: 1 group, pool 40, UnwrittenOutcomeSlots 40, Max Auto Prepare=64 in the DSN, group batch 128: claim-batch-ran = largest claim 40 jobs. The throughput of this run is not usable (median 1,310, range 1,201 to 7,906 jobs/s), because other work held the machine at a load average above 500.
  • The local workaround branch bench/pg-claim-bound (ac38d82) raised the Postgres store bound in the harness. The fix makes it unnecessary, so I deleted it.

Follow-ups

  • backwave-site: authoring-a-storage-adapter.mdx still lists MaxClaimBatch | 32. throughput-model.mdx and node-driver.mdx describe the group option only and are still correct.
  • Earlier benchmark results that report "batch 128" ran at 32 (for example, the seven-way report in backwave-admin).
  • The benchmark's claim-size listener turns on the process span path for each job during the measured run. The cost is likely small for no-op jobs, but it is not zero.

The claim-strategy dial states the group's MaxClaimBatch, but the pool
size and the store's claim bound can both cut the batch that runs. The
seven-way report said "up to 128" while each claim returned at most 32.

A new claim-batch-ran dial records the largest claimed count off the
BackWave claim span during the last run. The recorder samples only the
claim span, so the job spans stay off.
A Worker Group with MaxClaimBatch 128 and PoolSize 128 claims at most 32
jobs per call, because every store clamps the claim to
StoreBounds.MaxClaimBatch, which defaults to 32. The hosting test reads
the claimed count off the claim span. The conformance clause asks a
store with the default bounds for 128 jobs. Both fail with 32.
Every store clamped each claim to StoreBounds.MaxClaimBatch, which
defaulted to 32. A group set to MaxClaimBatch 128 claimed at most 32
jobs per call, and nothing reported it.

StoreBounds.MaxClaimBatch is now a safety ceiling with a default of 256.
It keeps one claim statement bounded and does not set throughput. The
group default stays 32, so a group that does not set MaxClaimBatch
claims as before. A group whose full claim (the smaller of
MaxClaimBatch and PoolSize) is above the store ceiling logs warning
2006 when it starts. It names both values and the setting to change.

The Oracle page reads took their fetch window from the claim bound.
They now use a fixed window of 32 rows, the value they had by default,
so a raised ceiling does not grow the buffer of a monitor page. An
Oracle claim sizes its window to the rows it can return, so a claim
reads in one fetch trip up to the 8 MB window ceiling.
…SQL Server

A raised StoreBounds.MaxClaimBatch could pass two database limits. The
Oracle claim leases its jobs with one IN list, and Oracle accepts at
most 1,000 expressions in a list (ORA-01795). SQL Server accepts at most
2,100 parameters in one command (error 8003). Its claim reads the tags
of its jobs in one command, after the claim commits, and an outcome
batch of the same size looks up parents in one command.

The Oracle store now rejects a MaxClaimBatch above 1,000 when it is
created, as it does for a tag bound wider than its column. The SQL
Server store sends those id lists in slices of 2,000.
@pdevito3

pdevito3 commented Dec 4, 2026

Copy link
Copy Markdown
Contributor Author

Review gate: two rounds. These findings were accepted without a code change:

  • The startup warning logs once per Pump, so a group with several Pumps logs it more than once. It is a startup message, so I kept the simpler code.
  • SQL Server can pick a different plan for a 256-row claim. The concurrency tests (SqlServerConcurrentMaintenanceTests) pass when run alone at the default claim size, and Conformance passes at a claim of 256. No contention test runs at 256 yet.
  • The benchmark claim-size listener turns on the per-job process span path during the measured run. The cost is likely small for no-op jobs, but it is not zero.
  • Release notes: an Oracle store with Bounds.MaxClaimBatch above 1,000 now throws when it is created. A third-party store that does not override IJobStore.Bounds now reports a ceiling of 256.

@pdevito3
pdevito3 merged commit 51c7424 into main Dec 4, 2026
2 checks passed
@pdevito3
pdevito3 deleted the fix/0306-claim-batch-clamp branch December 4, 2026 01:10
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.

1 participant