Claimed rows and dispatch
- Find the failure window between committing a row claim and sending work to the broker.
Diagram phase
Select a component to trace its direct connections. Drag to pan · Ctrl + wheel or pinch to zoom.
- I marks rows chosen for synchronous work in a local pool. C marks rows chosen for asynchronous dispatch to Solace. Both markers are written to Oracle during the claim.
- A worker can exit after committing C and before publishing the batch. The row is claimed, even though a queue consumer may have received nothing.
- The proposed SQL commits a row claim and its pending message in one Oracle transaction. A relay can then reconstruct exactly which batch to publish after a restart.
- A crash after broker acceptance can still publish twice. The consumer commits a unique operation receipt with the offer changes so a redelivery can reuse the result.
Reading
- The named lock serializes claiming, while two previously claimed slices may execute concurrently.
- Synchronous I work stays in the local JVM pool. C work crosses the broker boundary.
- Inspect C-claim recovery and DB/JMS enlistment before deciding whether existing infrastructure closes this crash window.
- Keep the existing file lock for the first migration. Consider row-level picking only if measurements show the claim section limits throughput.
- A committed receipt must share the transaction with the local business effect. An irreversible remote effect needs an independent recovery contract.
Physical file pickup and release
FileUpload work scheduling and Oracle row ownership
One registration, one loader winner
- A participating servlet starts a scan immediately. Its scheduled task begins after one second and runs at 100-second intervals.
- An available local worker reserves execution capacity. The poller locks the Oracle file-master row, checks it is still pending, records initiation and commits. A competing poller rechecks and skips a registration already taken.
- The winning worker launches the standard SQL*Loader child process. On success the file awaits authorization. Manual or scheduled authorization releases its staged records for offer creation.
- With two FileUpload members, both pollers may see the same pending registration. Only the worker that commits initiation launches SQL*Loader.
Recover the gap before and after child launch
| File-master state | What can still be true | Safe next decision |
|---|---|---|
| Initiation committed | Worker died before launching the loader, or the child is still running | Establish the original attempt’s status before reloading. A missed heartbeat alone cannot prove absence. |
| Staging rows exist | A child left partial output or completed while its parent was unavailable | Verify source identity, control totals and the applicable reject policy. |
| Staged and awaiting authorization | Loading succeeded and the business release decision is outstanding | Recover that decision without rerunning the physical load. |
Proposed attempt-scoped staging
- Retain the existing file claim lock. Record an attempt ID and immutable input identity at initiation. Scope output to that attempt so a late child cannot contaminate a replacement load.
- Publish the validated attempt with a conditional update on the current owner and attempt ID. Authorization must select only this published set. Inspect the loader control file and downstream readers before changing the schema.
- Compare the proposed control totals with the existing authorization decision before enabling enforcement. Test crashes immediately before child launch and after the final row. Cut over one upload type after both paths converge on the same authorized set.
- On rollback, stop new attempts, drain or quarantine unfinished attempts, and reconcile their staged rows before restoring the earlier reader.
Illustrative loader interruption casesjson
{
"kind": "IllustrativeLoaderRecoveryCases",
"registration": "DEMO-F",
"attempt": 1,
"proposedPrerequisites": [
"Recorded input identity and expected control totals for this registration",
"Staging rows scoped to registration and load attempt",
"One elected attempt may publish its staged output",
"Authorization selects only that published attempt"
],
"cases": [
{"failure": "Owner exits after initiation commits, before child creation", "evidence": "Attempt has no confirmed terminal outcome", "recovery": "Fence prior ownership; establish child absence or isolate a fresh attempt before retry"},
{"failure": "Child finishes after its parent loses ownership", "evidence": "Staging bytes exist under the old attempt", "recovery": "Reject old completion using a conditional owner/attempt update; keep old rows outside the authorized set"},
{"failure": "Loader reports success with rejects or a count mismatch", "evidence": "Loader outcome and expected totals disagree", "recovery": "Hold for reconciliation under the file's reject policy"},
{"failure": "Retry arrives after the staged attempt was published", "evidence": "Published attempt and validated input identity already match", "recovery": "Reuse the recorded result; retain the separate authorization decision"}
]
}
Staged row claims and Solace handoff
Staged row claims and Solace handoff
FileUpload work scheduling and Oracle row ownership
Two lock lifetimes during row pickup
- Two processors can work on different slices of one authorized file. Each first requests an exclusive Oracle application lock keyed by file ID.
- The procedure marks eligible records I for synchronous work or C for asynchronous dispatch, then commits. That ends its row locks. The file-level application lock survives this commit until explicit release or session end.
- Acquisition wait defaults to one second for this lock request. The 100-second setting retains the lock-name mapping. A blocked acquisition can time out without evicting the current owner.
- After releasing file ownership, the sync path schedules local workers. The async path sends batches to Solace for an MDB. Both eventually invoke offer creation.
Close the async commit-to-send gap
- A process can exit after C is committed but before Java sends a message. A send exception presents a second case where the broker might already have accepted the message.
- First inspect the deployed resource adapter, transaction enlistment, retry jobs and C-claim recovery. An XA-style destination name alone cannot establish this particular atomic handoff.
- If no equivalent durable dispatcher exists, change the procedure boundary. Commit the claim, its generation and a unique dispatch intent in the same Oracle transaction. A relay can reconstruct pending work.
- Use a stable operation ID across repeated deliveries. At the consumer, check the generation and commit the business receipt with the Oracle effect. A broker redelivery after commit should find that receipt.
Illustrative claim and dispatch transaction fragmentsql
-- Illustrative Oracle transaction contract. Table and column names are proposed.
-- Supply one stable operation ID for an immutable business group. Membership,
-- input version and expected row count must already be recorded together.
-- The caller holds the existing file claim lock. All statements below use ONE
-- DB transaction. Remove the legacy internal commit before using this boundary.
BEGIN
IF :operation_id IS NULL OR :input_version IS NULL OR
:expected_positive_count IS NULL OR :expected_positive_count <= 0 OR
:expected_generation IS NULL OR :expected_generation < 0 THEN
RAISE_APPLICATION_ERROR(-20000, 'Invalid claim identity, count, or generation');
END IF;
UPDATE demo_stage
SET claim_state = 'DISPATCH_PENDING', generation = :expected_generation + 1
WHERE operation_id = :operation_id AND input_version = :input_version
AND generation = :expected_generation AND claim_state = 'ELIGIBLE';
IF SQL%ROWCOUNT <> :expected_positive_count THEN
RAISE_APPLICATION_ERROR(-20001, 'Claim membership changed');
END IF;
-- Unique key: (operation_id, generation). Store exact input/membership
-- references so recovery can reconstruct this message after a restart.
INSERT INTO demo_dispatch (operation_id, generation, input_version, send_state)
VALUES (:operation_id, :expected_generation + 1, :input_version, 'PENDING');
COMMIT;
EXCEPTION WHEN OTHERS THEN
ROLLBACK;
RAISE;
END;
/
-- Relay after commit. Broker acceptance followed by relay failure can resend.
-- Consumer in a separate DB transaction:
-- 1. Lock the operation, validate generation and input membership.
-- 2. If the unique business receipt for operation_id exists, return its result.
-- 3. Apply all Oracle business effects and record the receipt in THIS transaction.
-- 4. Commit before acknowledging delivery. Separate remote effects require their
-- own idempotency or authoritative reconciliation contract.
Keep the lock until contention justifies replacement
| Option | When it helps | Cost and acceptance test |
|---|---|---|
| Existing named lock plus atomic intent | Broker crash gap dominates while claims remain fast | Add relay backlog and duplicate checks. Kill the relay on both sides of broker acceptance. |
| Bounded row pickup with SKIP LOCKED | Measured claim-lock waiting delays otherwise available workers | Add fairness, file completion checks and owner fencing. Test an old worker returning after takeover. |
| Shorter polling interval only | Healthy pending registrations wait for the next scan | More empty scans; a shorter interval cannot recover C rows with no durable dispatch. |
- Activate a single dispatch writer per upload cohort. Disable the old Java sender only when parity checks pass. To roll back, pause new claims, settle acknowledged or ambiguous intents and transfer pending work to one owner.
- Oracle row skipping supports competing consumers. Test the deployed SQL version, execution plan and file ordering before selecting it.
Worker budgets and replay scope
FileUpload work scheduling and Oracle row ownership
Size each execution stage
- Loader workers limit physical files. JVM-local synchronous workers limit concurrent sync batches. Asynchronous batches wait on Solace and execute through the MDB and its WebLogic Work Manager.
- Both branches call the creation service and need Oracle capacity. SQL claim size, message batch size and concurrent DB transactions control different resources.
- An illustrative 30,000 rows at 75 rows per batch yields 400 batches. With 20 free workers, 20 batches can start and 380 remain outstanding. Completion rate depends on service time, DB contention and failures.
A valid row can share a failed transaction
- If one create call fails before batch commit, earlier calls in the same transaction can roll back. The async path records rejects and republishes eligible retry work. A separate file-status poller reconciles the totals.
- In the example, rows A and B form one indivisible business group, while C is independent. Invalid B holds A and B. C can commit separately only after the business owner confirms that independence.
- The selected LOADOFFER timeout procedure considers file status 7 or 9. Both file update and I-row processing start must be older than 30 minutes for the selected I-to-R transition with code 4000. The servlet leaves its timeout analyser unscheduled. This procedure only recovers I rows. Give pending C claims a separate reconciliation path.
Executable example of retry scope and fleet demandjavascript
// Synthetic planning fixture. Run with Node. No broker or database is needed.
'use strict';
const assert = require('node:assert/strict');
// A and B form one indivisible business group. C may commit independently.
const records = [
{id: 'A', group: 'one', valid: true},
{id: 'B', group: 'one', valid: false},
{id: 'C', group: 'two', valid: true}
];
const wholeBatchReplayed = records.length;
const invalidGroups = new Set(records.filter(r => !r.valid).map(r => r.group));
const held = records.filter(r => invalidGroups.has(r.group)).map(r => r.id);
const eligible = records.filter(r => !invalidGroups.has(r.group)).map(r => r.id);
assert.deepEqual(held, ['A', 'B']);
assert.deepEqual(eligible, ['C']);
// Illustrative fleet limits. Each active creation transaction borrows one
// DB connection throughout. Other application users need their reserved share.
const consumers = {synchronous: 12, normalMdb: 16, retryMdb: 8};
const dbBudget = 40 - 12;
const demand = Object.values(consumers).reduce((total, n) => total + n, 0);
assert.equal(demand, 36);
assert.equal(demand - dbBudget, 8);
console.log({wholeBatchReplayed, held, eligible, demand, dbBudget,
excessConcurrentTransactions: demand - dbBudget});
Bound replay before adding consumers
- Prevalidate deterministic data errors. Keep checks that depend on current offer/customer state inside the creation transaction. Group updates by the actual business invariant and use a stable receipt for each committed unit.
- Put permanent or exhausted groups in a review queue with the input identity and error class. Limit normal and retry execution against the same DB budget. Reserve capacity for inquiries and live transactions.
- Worked limit across all replicas: 12 sync + 16 normal MDB + 8 retry transactions can demand 36 connections. If 28 are available to uploads and each holds one, eight can contend at saturation. Monitor DB borrow time, oldest ready batch and successful commits before raising concurrency.
- Validate with mixed good/bad groups, duplicate deliveries, commit-before-ack crashes and same-customer conflicts. Compare committed unique outcomes, file totals and replayed rows. Roll back batch sizing independently of retaining the deduplication receipts.