A customer completes a purchase. Your API adds a background job to generate an invoice, and a worker processes it. Everything looks fine until the customer receives two invoices.
You check the logs. There is only one job ID, but the worker appears to have processed it twice.
Was the queue broken? Did Redis lose something? Did someone accidentally start a second worker?
All are tempting explanations, but there is a more fundamental issue: receiving a job, performing its work and recording its completion are separate operations. A failure between those operations can make a perfectly legitimate job run again.
This article uses Node.js, BullMQ and MongoDB to explore that problem. The same principles apply to many other background job systems.
1. A completed business operation is not necessarily a completed job
Consider a worker that creates an invoice and sends a notification.
import { Worker } from 'bullmq';
const connection = { host: 'redis', port: 6379 };
const worker = new Worker('invoices', async job => {
const invoice = await createInvoice(job.data.orderId);
await sendInvoiceEmail(invoice);
return invoice.id;
}, { connection });
The two business functions are application-specific. The important part is what happens when the worker finishes: BullMQ still needs to record successful completion in the queue.
Imagine that the invoice and email have both been created successfully, but the process is killed before the queue records the result. The next worker cannot infer from the queue alone whether the previous worker finished its business operation.
BullMQ uses locks to track active jobs. When a worker loses its lock and a stalled job is recovered, that job may be processed again. This recovery behaviour is intentional: otherwise a worker crash could leave work unfinished indefinitely. See the [BullMQ stalled jobs guide][stalled].
SVG source
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 760 230" width="760" height="230" role="img" aria-label="The job completion gap">
<rect width="760" height="230" rx="8" fill="#f6f4ee"/>
<text x="24" y="34" font-family="Arial, sans-serif" font-size="20" font-weight="600" text-anchor="start" fill="#242b25">The job completion gap</text>
<rect x="24" y="80" width="166" height="62" rx="7" fill="#fffef9" stroke="#d9ddd2"/><text x="107.0" y="116.0" font-family="Arial, sans-serif" font-size="14" font-weight="600" text-anchor="middle" fill="#242b25">Worker starts</text><line x1="190" y1="111" x2="206" y2="111" stroke="#6d7268" stroke-width="1.5"/><polygon points="206.00,111.00 197.00,107.00 197.00,115.00" fill="#6d7268"/><rect x="206" y="80" width="166" height="62" rx="7" fill="#e6eadd" stroke="#d9ddd2"/><text x="289.0" y="116.0" font-family="Arial, sans-serif" font-size="14" font-weight="600" text-anchor="middle" fill="#242b25">Invoice saved</text><line x1="372" y1="111" x2="388" y2="111" stroke="#ab4932" stroke-width="1.5"/><polygon points="388.00,111.00 379.00,107.00 379.00,115.00" fill="#ab4932"/><rect x="388" y="80" width="166" height="62" rx="7" fill="#fffef9" stroke="#ab4932"/><text x="471.0" y="116.0" font-family="Arial, sans-serif" font-size="14" font-weight="600" text-anchor="middle" fill="#242b25">Worker crashes</text><line x1="554" y1="111" x2="570" y2="111" stroke="#6d7268" stroke-width="1.5"/><polygon points="570.00,111.00 561.00,107.00 561.00,115.00" fill="#6d7268"/><rect x="570" y="80" width="166" height="62" rx="7" fill="#fffef9" stroke="#d9ddd2"/><text x="653.0" y="116.0" font-family="Arial, sans-serif" font-size="14" font-weight="600" text-anchor="middle" fill="#242b25">Job recovered</text><text x="389" y="66" font-family="Arial, sans-serif" font-size="13" font-weight="400" text-anchor="middle" fill="#ab4932">Completion not recorded</text><text x="380" y="180" font-family="Arial, sans-serif" font-size="15" font-weight="400" text-anchor="middle" fill="#242b25">The next worker may repeat the business operation.</text><text x="380" y="205" font-family="Arial, sans-serif" font-size="13" font-weight="400" text-anchor="middle" fill="#6d7268">Queue state and business state are separate.</text>
</svg>The key distinction is between execution and effect. A job might execute more than once, but our business operation should produce the intended effect only once when that is required.
This is the practical implication of at-least-once processing under failure conditions. It is not a promise that every job will eventually succeed: retry limits, persistence failures and operational errors can still prevent completion.
Rather than trying to prove that a worker can never run twice, design the worker so that running twice does not corrupt the application.
2. You might be creating duplicate jobs before a worker even sees them
Not every duplicate operation comes from a retry. Sometimes two separate jobs represent the same business action.
Suppose your checkout endpoint enqueues an invoice job:
await invoiceQueue.add('generate', { orderId: 'order-123' });
A user double-clicks the checkout button, or an API client retries after a timeout. The same line executes twice. Without a stable identifier, BullMQ can assign different job IDs to the two submissions.
We can use a deterministic job ID instead.
import { Queue } from 'bullmq';
const invoiceQueue = new Queue('invoices', {
connection: { host: 'redis', port: 6379 }
});
export async function queueInvoice(orderId) {
return invoiceQueue.add(
'generate',
{ orderId },
{
jobId: `invoice-${orderId}`,
attempts: 4,
backoff: { type: 'exponential', delay: 1000 },
removeOnComplete: { age: 86400, count: 10000 },
removeOnFail: { age: 604800, count: 10000 }
}
);
}
This assumes the order ID is a validated, safe identifier without colons. BullMQ reserves colons in custom job IDs.
While the job with that ID exists in the queue, adding another job with the same ID does not create a second job. This is useful when a producer might submit the same operation repeatedly.
But there is a catch. When a completed or failed job is removed, its ID can be used again. The retention settings above therefore do not constitute permanent business-level deduplication. See [job IDs][ids] and [auto-removal][removal].
BullMQ also provides a deduplication option. Its simple mode suppresses additional submissions with the same deduplication ID until the existing job finishes or fails. Other modes address time-window suppression and debounce-like workloads. See [deduplication][dedup].
Choose the identifier according to the business action. An invoice for one order can use the order ID. A recurring monthly report needs the reporting period as well. A user's profile synchronization may need different semantics from generating a new invoice.
SVG source
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 760 310" width="760" height="310" role="img" aria-label="Submission is not execution">
<rect width="760" height="310" rx="8" fill="#f6f4ee"/>
<text x="24" y="34" font-family="Arial, sans-serif" font-size="20" font-weight="600" text-anchor="start" fill="#242b25">Submission is not execution</text>
<rect x="24" y="65" width="180" height="60" rx="7" fill="#fffef9" stroke="#d9ddd2"/><text x="114.0" y="100.0" font-family="Arial, sans-serif" font-size="14" font-weight="600" text-anchor="middle" fill="#242b25">Producer retries</text><line x1="204" y1="95" x2="276" y2="95" stroke="#6d7268" stroke-width="1.5"/><polygon points="276.00,95.00 267.00,91.00 267.00,99.00" fill="#6d7268"/><rect x="276" y="65" width="210" height="60" rx="7" fill="#e6eadd" stroke="#242b25"/><text x="381.0" y="100.0" font-family="Arial, sans-serif" font-size="14" font-weight="600" text-anchor="middle" fill="#242b25">Same stable job ID</text><line x1="486" y1="95" x2="556" y2="95" stroke="#6d7268" stroke-width="1.5"/><polygon points="556.00,95.00 547.00,91.00 547.00,99.00" fill="#6d7268"/><rect x="556" y="65" width="180" height="60" rx="7" fill="#e6eadd" stroke="#242b25"/><text x="646.0" y="100.0" font-family="Arial, sans-serif" font-size="14" font-weight="600" text-anchor="middle" fill="#242b25">One queued job</text><text x="24" y="155" font-family="Arial, sans-serif" font-size="14" font-weight="600" text-anchor="start" fill="#6d7268">Submission deduplication</text><line x1="24" y1="172" x2="736" y2="172" stroke="#d9ddd2"/><rect x="24" y="195" width="180" height="60" rx="7" fill="#fffef9" stroke="#ab4932"/><text x="114.0" y="230.0" font-family="Arial, sans-serif" font-size="14" font-weight="600" text-anchor="middle" fill="#242b25">Worker failure</text><line x1="204" y1="225" x2="276" y2="225" stroke="#ab4932" stroke-width="1.5"/><polygon points="276.00,225.00 267.00,221.00 267.00,229.00" fill="#ab4932"/><rect x="276" y="195" width="210" height="60" rx="7" fill="#fffef9" stroke="#d9ddd2"/><text x="381.0" y="230.0" font-family="Arial, sans-serif" font-size="14" font-weight="600" text-anchor="middle" fill="#242b25">Same job recovered</text><line x1="486" y1="225" x2="556" y2="225" stroke="#6d7268" stroke-width="1.5"/><polygon points="556.00,225.00 547.00,221.00 547.00,229.00" fill="#6d7268"/><rect x="556" y="195" width="180" height="60" rx="7" fill="#fffef9" stroke="#ab4932"/><text x="646.0" y="230.0" font-family="Arial, sans-serif" font-size="14" font-weight="600" text-anchor="middle" fill="#242b25">Runs again</text><text x="24" y="286" font-family="Arial, sans-serif" font-size="15" font-weight="400" text-anchor="start" fill="#242b25">Execution safety requires business-level idempotency.</text>
</svg>A stable job ID protects the queue from duplicate submissions during its retention lifetime. It does not stop the same job from being recovered after a worker failure.
3. A retry can repeat work that already succeeded
A common mistake is putting several independent side effects inside one retryable job.
async function processOrder(orderId) {
await deductInventory(orderId);
await createInvoice(orderId);
await sendConfirmationEmail(orderId);
}
Suppose the first two operations succeed, but the email service returns an error. If the entire job is retried, the inventory deduction runs again.
It is easy to reach for a boolean flag:
if (!(await hasProcessed(orderId))) {
await deductInventory(orderId);
await markProcessed(orderId);
}
Unfortunately, the check and update are separate operations. Two workers could both see an unprocessed order, or a worker could crash after deducting inventory but before setting the flag.
Moving markProcessed() before the deduction is not a solution either. A crash after setting the flag could prevent the deduction from ever happening.
Make the database enforce the invariant
For an invoice that must exist at most once per order, MongoDB can enforce the rule with a unique index.
// Run during database migration, before accepting jobs.
await db.collection('invoices').createIndex(
{ orderId: 1 },
{ unique: true }
);
Then use an upsert that creates the document only when it does not exist.
export async function ensureInvoice(db, order) {
const invoices = db.collection('invoices');
try {
await invoices.updateOne(
{ orderId: order.id },
{
$setOnInsert: {
orderId: order.id,
amountCents: order.amountCents,
currency: order.currency,
createdAt: new Date()
}
},
{ upsert: true }
);
} catch (error) {
// A competing upsert may have inserted the invoice.
// Only suppress a duplicate on the intended index.
if (error.code !== 11000 ||
error.keyPattern?.orderId !== 1 ||
Object.keys(error.keyPattern).length !== 1) {
throw error;
}
}
const invoice = await invoices.findOne({ orderId: order.id });
if (!invoice) throw new Error('Invoice not found');
return invoice;
}
This example assumes a single tenant or globally unique order IDs, a standard unsharded collection, and authoritative, immutable invoice inputs. In a multi-tenant application, use the appropriate compound unique index and include the tenant in every lookup.
The first execution creates the invoice. Subsequent executions retrieve the existing document without replacing the original invoice details.
If your application supports invoice revisions, model those as separate business operations. Do not silently reuse an old identifier for changed financial terms.
MongoDB guarantees atomicity at the single-document write level; unique indexes enforce uniqueness. See [atomicity][atomicity] and [unique indexes][unique].
What about updating multiple documents?
Suppose a job must both decrement inventory and record the fact that the deduction took place. A unique invoice index cannot protect that separate operation.
One approach is to record a unique operation ID and perform the inventory change within the same database transaction.
// processedOperations uses MongoDB's unique _id index.
export async function reserveStock(client, db, operation) {
const session = client.startSession();
const operations = db.collection('processedOperations');
const inventory = db.collection('inventory');
try {
await session.withTransaction(async () => {
const existing = await operations.findOne(
{ _id: operation.id }, { session }
);
if (existing) return;
await operations.insertOne({
_id: operation.id,
sku: operation.sku,
quantity: operation.quantity,
createdAt: new Date()
}, { session });
const result = await inventory.updateOne(
{
_id: operation.sku,
available: { $gte: operation.quantity }
},
{ $inc: { available: -operation.quantity } },
{ session }
);
if (result.matchedCount !== 1) {
throw new Error('Insufficient stock');
}
});
} finally {
await session.endSession();
}
}
The example assumes a validated positive integer quantity and a stable operation ID bound to immutable parameters. If competing transactions cause an error, let the job retry or reconcile rather than treating every duplicate-key error as success.
MongoDB transactions require a replica set or sharded deployment. A standalone MongoDB container is not enough. See [transactions][transactions].
Keep external HTTP requests outside the transaction callback: transaction helpers may rerun the callback, and an external service cannot be rolled back by MongoDB.
SVG source
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 760 290" width="760" height="290" role="img" aria-label="Make the business effect atomic">
<rect width="760" height="290" rx="8" fill="#f6f4ee"/>
<text x="24" y="34" font-family="Arial, sans-serif" font-size="20" font-weight="600" text-anchor="start" fill="#242b25">Make the business effect atomic</text>
<rect x="24" y="68" width="170" height="60" rx="7" fill="#fffef9" stroke="#d9ddd2"/><text x="109.0" y="103.0" font-family="Arial, sans-serif" font-size="14" font-weight="600" text-anchor="middle" fill="#242b25">Operation ID</text><line x1="194" y1="98" x2="254" y2="98" stroke="#6d7268" stroke-width="1.5"/><polygon points="254.00,98.00 245.00,94.00 245.00,102.00" fill="#6d7268"/><rect x="254" y="58" width="482" height="155" rx="7" fill="#e6eadd" stroke="#242b25"/><text x="495" y="83" font-family="Arial, sans-serif" font-size="16" font-weight="600" text-anchor="middle" fill="#242b25">One database transaction</text><rect x="274" y="103" width="205" height="65" rx="7" fill="#fffef9" stroke="#d9ddd2"/><text x="376.5" y="131.0" font-family="Arial, sans-serif" font-size="14" font-weight="600" text-anchor="middle" fill="#242b25">Record operation</text><text x="376.5" y="150.0" font-family="Arial, sans-serif" font-size="14" font-weight="400" text-anchor="middle" fill="#242b25">Unique identifier</text><rect x="511" y="103" width="205" height="65" rx="7" fill="#fffef9" stroke="#d9ddd2"/><text x="613.5" y="131.0" font-family="Arial, sans-serif" font-size="14" font-weight="600" text-anchor="middle" fill="#242b25">Update inventory</text><text x="613.5" y="150.0" font-family="Arial, sans-serif" font-size="14" font-weight="400" text-anchor="middle" fill="#242b25">Conditional write</text><text x="495" y="193" font-family="Arial, sans-serif" font-size="14" font-weight="400" text-anchor="middle" fill="#242b25">Commit both changes or neither</text><text x="380" y="244" font-family="Arial, sans-serif" font-size="15" font-weight="400" text-anchor="middle" fill="#242b25">A retry checks the durable operation record.</text><text x="380" y="267" font-family="Arial, sans-serif" font-size="13" font-weight="400" text-anchor="middle" fill="#ab4932">External calls do not belong inside this transaction.</text>
</svg>4. External side effects need their own protection
Database transactions are useful when all the changes belong to the same database. They cannot undo a successfully sent email, a payment accepted by an external provider or a webhook already delivered to another system.
Consider a payment request. The provider accepts it, but the network connection fails before the worker receives the response. The worker sees an error and retries. Without an idempotency contract, that could create another payment.
Some providers support an idempotency key. Stripe is a documented example. Reusing the same key and parameters allows a caller to repeat a logical request according to the provider's idempotency rules. Retention periods and response semantics still apply; see [Stripe idempotency][stripe].
async function submitPayment(stripe, payment) {
return stripe.paymentIntents.create(
{
amount: payment.amountCents,
currency: payment.currency,
metadata: { orderId: payment.orderId }
},
{
idempotencyKey: payment.operationId
}
);
}
This example creates a PaymentIntent; it does not by itself confirm or capture a payment. The operation ID must be generated and persisted before the first attempt, not generated inside each retry.
A provider without idempotency support presents a different problem. A local sent flag cannot eliminate the gap between the external action and recording its outcome. For such a provider, decide whether duplicates are acceptable, whether a reconciliation API exists, or whether a different provider is needed.
The transactional outbox
There is a similar gap when an API writes an order to MongoDB and then submits a BullMQ job. A crash between those steps can leave a saved order without its background job.
The transactional outbox pattern addresses this by storing the order and an outbox event in the same database transaction. A separate dispatcher publishes pending events to the queue.
The dispatcher might publish an event successfully and crash before marking it published. Consequently, the dispatcher itself must tolerate repeated publication, and the consumer still needs idempotency.
SVG source
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 760 310" width="760" height="310" role="img" aria-label="Transactional outbox">
<rect width="760" height="310" rx="8" fill="#f6f4ee"/>
<text x="24" y="34" font-family="Arial, sans-serif" font-size="20" font-weight="600" text-anchor="start" fill="#242b25">Transactional outbox</text>
<rect x="24" y="65" width="310" height="155" rx="7" fill="#e6eadd" stroke="#242b25"/><text x="179" y="90" font-family="Arial, sans-serif" font-size="16" font-weight="600" text-anchor="middle" fill="#242b25">MongoDB transaction</text><rect x="42" y="109" width="130" height="65" rx="7" fill="#fffef9" stroke="#d9ddd2"/><text x="107.0" y="146.5" font-family="Arial, sans-serif" font-size="14" font-weight="600" text-anchor="middle" fill="#242b25">Save order</text><rect x="186" y="109" width="130" height="65" rx="7" fill="#fffef9" stroke="#d9ddd2"/><text x="251.0" y="146.5" font-family="Arial, sans-serif" font-size="14" font-weight="600" text-anchor="middle" fill="#242b25">Save event</text><text x="179" y="201" font-family="Arial, sans-serif" font-size="13" font-weight="400" text-anchor="middle" fill="#6d7268">Both commit together</text><line x1="334" y1="142" x2="374" y2="142" stroke="#6d7268" stroke-width="1.5"/><polygon points="374.00,142.00 365.00,138.00 365.00,146.00" fill="#6d7268"/><rect x="374" y="112" width="150" height="60" rx="7" fill="#fffef9" stroke="#d9ddd2"/><text x="449.0" y="147.0" font-family="Arial, sans-serif" font-size="14" font-weight="600" text-anchor="middle" fill="#242b25">Dispatcher</text><line x1="524" y1="142" x2="566" y2="142" stroke="#6d7268" stroke-width="1.5"/><polygon points="566.00,142.00 557.00,138.00 557.00,146.00" fill="#6d7268"/><rect x="566" y="112" width="170" height="60" rx="7" fill="#fffef9" stroke="#d9ddd2"/><text x="651.0" y="147.0" font-family="Arial, sans-serif" font-size="14" font-weight="600" text-anchor="middle" fill="#242b25">BullMQ queue</text><line x1="651" y1="172" x2="651" y2="221" stroke="#6d7268" stroke-width="1.5"/><polygon points="651.00,221.00 655.00,212.00 647.00,212.00" fill="#6d7268"/><rect x="566" y="221" width="170" height="60" rx="7" fill="#e6eadd" stroke="#242b25"/><text x="651.0" y="246.5" font-family="Arial, sans-serif" font-size="14" font-weight="600" text-anchor="middle" fill="#242b25">Idempotent</text><text x="651.0" y="265.5" font-family="Arial, sans-serif" font-size="14" font-weight="400" text-anchor="middle" fill="#242b25">worker</text><text x="24" y="256" font-family="Arial, sans-serif" font-size="14" font-weight="400" text-anchor="start" fill="#ab4932">Dispatcher retries may publish twice.</text><text x="24" y="279" font-family="Arial, sans-serif" font-size="13" font-weight="400" text-anchor="start" fill="#6d7268">The consumer must remain safe to rerun.</text>
</svg>The outbox makes the intent to publish durable alongside the business change. It does not magically provide exactly-once delivery to every external system.
For a small application, the extra infrastructure may not be necessary. For workflows involving orders, money, inventory or critical notifications, it can be well worth considering.
5. Your worker may be losing its lock
Now imagine a job that generates a large report. It performs several seconds of intensive synchronous computation on the Node.js event loop.
BullMQ workers need to renew their job locks while processing. If the event loop is blocked for long enough, the worker may fail to renew its lock. The job can then be recovered as stalled, even if the original processor is still running.
This is one reason why increasing worker concurrency is not a universal performance improvement. I/O-heavy workloads often benefit from concurrency; CPU-heavy workloads may need isolated processors or separate processes instead.
BullMQ's [stalled jobs][stalled] documentation specifically discusses lock renewal and CPU-intensive processing. Its [sandboxed processors][sandbox] guide describes a way to isolate processing from queue bookkeeping.
import { Worker } from 'bullmq';
import { fileURLToPath } from 'node:url';
const processor = fileURLToPath(
new URL('./report-processor.js', import.meta.url)
);
const worker = new Worker('reports', processor, {
connection: { host: 'redis', port: 6379 },
concurrency: 2
});
The separate processor file should export the actual report-generation function. Adjust concurrency to measured CPU and memory capacity.
Do not immediately increase lock duration just because jobs stall. A longer lock can delay recovery from a genuine crash, while doing nothing to correct a blocked event loop. Investigate the cause first.
Deployments can trigger the same problem
If you run workers in Docker, stopping a container while it is processing a job can interrupt it halfway through its work.
Handle shutdown signals and let BullMQ finish active jobs before closing the worker.
let shuttingDown = false;
async function shutdown() {
if (shuttingDown) return;
shuttingDown = true;
try {
await worker.close();
} catch (error) {
console.error('Worker shutdown failed', error);
process.exitCode = 1;
}
// Close any other owned database or Redis connections here.
}
process.once('SIGTERM', shutdown);
process.once('SIGINT', shutdown);
An illustrative Compose configuration gives the worker more time to finish:
services:
worker:
image: myapp-worker:stable
stop_grace_period: 60s
init: true
Choose the grace period according to real job durations and deployment constraints. Ensure the container entrypoint forwards signals to Node.js. BullMQ's worker.close() waits for active work and has no built-in timeout, so an unresponsive job still needs an operational shutdown policy. See [graceful shutdown][shutdown] and [production guidance][production].
Even graceful shutdown cannot prevent sudden crashes, forced termination or machine failure. It reduces unnecessary reprocessing; it does not replace idempotency.
Bonus: How to find out why a job ran twice
Before changing configuration, collect enough information to distinguish duplicate submissions from repeated processing of a single job.
worker.on('active', job => {
console.info('job started', {
jobId: job.id,
jobName: job.name,
operationId: job.data.operationId ?? job.data.orderId,
attemptsMade: job.attemptsMade,
workerPid: process.pid
});
});
worker.on('stalled', jobId => {
console.warn('job stalled', { jobId });
});
worker.on('failed', (job, error) => {
console.error('job failed', {
jobId: job?.id,
attemptsMade: job?.attemptsMade,
message: error.message
});
});
worker.on('error', error => {
console.error('worker error', error);
});
In production, also log an application instance ID and a correlation ID, while excluding secrets and sensitive payloads. Worker event listeners are local; centralized logs or queue-wide events are useful when several workers are running.
| Symptom | First thing to investigate |
|---|---|
| Different job IDs, same order | Producer retries, duplicate submissions, missing stable job ID |
| Same job ID, repeated failure | Retry policy and partially completed work |
| Stalled events | Lock renewal, CPU usage, event-loop delay, Redis connectivity |
| Duplicates around deployments | Shutdown signals, grace period, interrupted jobs |
| Same operation after job removal | Job retention versus durable business deduplication |
| One job, two external requests | SDK retries or ambiguous external outcomes |
Check the Redis deployment too. Queue data is not disposable cache data. BullMQ recommends a noeviction policy for its Redis instance; using the same Redis instance for a memory-evicting cache and critical queues can create conflicting requirements. See [production guidance][production].
A useful test plan is to submit an identical job twice, force a failure after a database write, invoke the business handler concurrently, and terminate a test worker after an external operation succeeds. Verify the resulting business state, not merely the number of times the processor started. Run destructive fault-injection tests only against isolated test infrastructure.
Final thoughts
The instinct to prevent a background job from running twice is understandable. But retries and stalled-job recovery exist because distributed applications cannot assume that every process will finish cleanly.
A more reliable design asks what happens when the job runs again.
Use deterministic job IDs to reduce duplicate submissions. Use database constraints and transactions to protect business state. Use provider-supported idempotency for external operations. Give workers enough room to renew locks and shut down gracefully.
These techniques address different failure boundaries. None is a universal replacement for the others.
The real goal is not necessarily to make the processor execute exactly once. It is to make repeated execution safe.
THE CONVERSATION
Comments
Questions, useful examples and different approaches are welcome. Keep the discussion thoughtful and on topic.
Loading comments…