- Home
- Skills
- Agents & Orchestration
- Repair Multi-Region Failover Races
More screenshots
Works with the AI Agents you already use
Repair Multi-Region Failover Races
Diagnose and repair multi-region failover, routing authority, stale regional writers, and recovery coordination.
$1
Repair Multi-Region Failover Races
Example session with this skill installed
We are seeing 'stale write' errors after failing over from us-east-1 to us-west-2. It seems the old primary in east is still processing queued messages. How do we fence it?
- Read your context and instructions
- Compiled the repair multi-region failover
I have analyzed the failover race condition between us-east-1 and us-west-2. The issue stems from a lack of generation identity in your worker heartbeats, allowing the 'degraded' region to continue processing the task queue without verifying its current authority status.
Regional Write Fencing Implementation
To resolve this, we must implement a monotonic generation counter (fence token) stored in a global consensus layer (like DynamoDB or Consul). Every write must include this token, and the storage layer must reject writes with a lower generation than the current global maximum.
// Proposed Fencing Logic for Task Workers
interface TaskMetadata {
id: string;
generation: number; // The fencing token
region: string;
}
async function processTask(task: TaskMetadata) {
const currentAuthority = await authorityService.getGlobalGeneration();
// 1. Pre-flight check
if (task.generation < currentAuthority.generation) {
console.error(`Fencing violation: Task gen ${task.generation} < Current ${currentAuthority.generation}`);
return; // Drop task, it belongs to a stale region
}
// 2. Atomic Write with Condition Expression
try {
await db.update({
TableName: 'RegionalTasks',
Key: { id: task.id },
UpdateExpression: 'SET val = :val, gen = :gen',
// Ensure the write only happens if no newer generation has taken over
ConditionExpression: 'attribute_not_exists(gen) OR gen <= :gen',
ExpressionAttributeValues: {
':val': task.data,
':gen': task.generation
}
});
} catch (err) {
if (err.code === 'ConditionalCheckFailedException') {
// Logic for handling a write that arrived after a newer region took over
await handleStaleWrite(task);
}
}
}
Deterministic Test Plan
- Initialize Authority: Set global generation to
10. - Simulate Lag: Start a worker in
us-east-1withgeneration: 10. - Trigger Failover: Update global generation to
11(simulatingus-west-2takeover). - Execute Stale Write: Attempt the
us-east-1write. - Verify Invariant: Assert the database rejects the write and the
us-east-1worker enters a 'dormant' state.
Next steps
- Audit the
authorityServiceto ensure it uses a strongly consistent read for generation checks. - Update the CI/CD pipeline to increment the global generation counter during regional traffic shifts.
- Implement a 'drain' signal for workers that detects generation mismatches via heartbeats.
Connects securely to your tools. The creator never sees your data.
About this skill
Repair Multi-Region Failover Races targets production and repository defects around diagnose and repair multi-region failover, routing authority, stale regional writers, and recovery coordination.. It examines active/active versus active/passive ownership, routing and failover authority, regional write fencing or generation identity, replication lag and read/write locality, health signals and traffic withdrawal, background workers during failover, session/cache affinity across regions, recovery, failback, and observability, then establishes one explicit repair contract and focused deterministic validation.
The skill works from repository access or partial evidence such as snippets, logs, configuration, traces, and architecture notes. It preserves existing product/security policy, avoids invented execution claims, and keeps production systems, real credentials, and deployment outside the validation path.
Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Skills for Agents & Orchestration.
Requires specific architecture details or logs to be effective. Cannot perform actual network-level failover tests without environment access or mocked infrastructure.
How to use
- 1
Connect your agent to the Agensi MCP
Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup
- 2
Sign in to Agensi
Your agent shows a sign-in link. Sign in and click Allow.
- 3
Ask for what you need
Your agent loads this skill and uses it on your task. It always asks before buying a skill.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill goes through the trust checks below.
Security scanned
Checked by our 8-point scan before listing
Fresh listing
Recently published to Agensi
Money-back guarantee
Doesn't do what its page promises? You get your money back.
Trust & safety
Security scan
Security scan passed 2 months ago