More screenshots

    Works with the AI Agents you already use

    Claude CodeClaude CodeCursorCursorCodex CLICodex CLIDeepSeekDeepSeekMuseMuse+22 more

    Repair Distributed Semaphore Permit Leaks

    1

    Diagnose and repair distributed semaphore permits, ownership, crash recovery, fairness, and bounded concurrency.

    $1

    Secure checkout via Stripe

    Money-back guarantee

    Converts to your local currency at checkout

    Security scanned
    Repair Distributed Semaphore Permit Leaks

    Repair Distributed Semaphore Permit Leaks

    Example session with this skill installed

    Repair Distributed Semaphore Permit Leaks targets production and repository defects around diagnose and repair distributed semaphore permits, ownership, crash recovery, fairness, and bounded concurrency.. It examines permit acquisition identity, owner token and generation binding, release idempotency, TTL/lease renewal semantics, worker crash and abandoned permits, double release and over-release prevention, fairness and configured concurrency caps, reconciliation metrics and recovery, 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.

    • Read your context and instructions
    • Compiled the repair distributed semaphore

    I have analyzed the provided Lua script for your Redis semaphore implementation. The leak occurs because the permit acquisition is not bound to a unique owner ID, and the recovery logic fails to account for heartbeat expiration before the release call.

    Distributed Semaphore Repair Plan

    ComponentCurrent BehaviorIdentified DefectRequired Invariant
    AcquisitionIncrements a global counterNo caller identity stored; cannot verify ownership.Permit[i] must map to OwnerToken.
    RecoveryRelies on 30s Key TTLTTL expires but counter isn't decremented on timeout.Expired(TTL) => Decrement(Counter).
    ReleaseSimple DECR commandDouble-release by late worker drains counter below zero.Release must be idempotent per OwnerToken.

    Implementation Pattern (Atomic Lua)

    -- Proposed Fix: Hash-based semaphore with heartbeat
    local semaphore_key = KEYS[1]
    local owner_id = ARGV[1]
    local limit = tonumber(ARGV[2])
    local ttl_ms = tonumber(ARGV[3])
    
    -- Check if already owned
    if redis.call('HEXISTS', semaphore_key, owner_id) == 1 then
        redis.call('PEXPIRE', semaphore_key, ttl_ms)
        return 1
    end
    
    -- Check capacity
    if redis.call('HLEN', semaphore_key) >= limit then
        return 0
    end
    
    -- Acquire with identity
    redis.call('HSET', semaphore_key, owner_id, ARGV[4]) -- ARGV[4] is timestamp
    redis.call('PEXPIRE', semaphore_key, ttl_ms)
    return 1
    

    Next steps

    1. Implement a background cleanup job to HDEL fields where timestamp + ttl < now.
    2. Add a unique request_id to your client release calls to ensure idempotency.
    3. Deploy the provided Lua script to replace the existing INCR/DECR logic.

    Connects securely to your tools. The creator never sees your data.

    About this skill

    The problem

    Distributed semaphores often fail silently when workers crash or networks partition, leading to permit leaks that permanently exhaust concurrency limits. Debugging these race conditions in production environments like Redis, Etcd, or Postgres is notoriously difficult without a formal state invariant.

    What it does

    • Analyzes permit acquisition identity and owner token binding to detect orphaned locks.
    • Evaluates TTL/lease renewal semantics against worker crash scenarios to prevent deadlocks.
    • Identifies release idempotency failures that cause double-releases or over-release bugs.
    • Generates deterministic test plans using fake clocks and barriers to reproduce race conditions without flaky sleeps.
    • Proposes bounded repairs that restore canonical state invariants while preserving existing retry and security policies.

    Frameworks & tools

    Works with distributed stores like Redis (Redlock), Etcd, PostgreSQL (advisory locks), and DynamoDB. Compatible with Go, Node.js, Python, and Java concurrency primitives.

    Why this beats prompting it yourself

    Generic LLMs often struggle to maintain state consistency across distributed systems, frequently suggesting unsafe "quick fixes" that introduce new race conditions. This skill enforces a rigorous repair method that reconstructs ownership boundaries and defines strict invariants before writing a single line of code.

    Use cases

    • Recovering from permit exhaustion in a Redis-backed task queue after worker OOM events.
    • Implementing idempotent release logic to prevent permit inflation during network retries.
    • Adding observability and reconciliation metrics to legacy distributed locking systems.

    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 logs, architecture notes, or repository access to provide exact diagnosis. Does not perform live production data migrations.

    How to use

    1. 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. 2

      Sign in to Agensi

      Your agent shows a sign-in link. Sign in and click Allow.

    3. 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

    Permissions

    Terminal / Shell
    Listed2 months ago
    Updated9 days ago

    What's inside

    Frequently Asked Questions

    This skill identifies and resolves permit leaks caused by worker crashes or network partitions in distributed stores like Redis, Etcd, and Postgres, ensuring your concurrency limits remain accurate and deadlocks are avoided.

    The skill is compatible with major backend languages including Go, Node.js, Python, and Java, and it integrates seamlessly with agents using tools like Redis (Redlock), Etcd, and DynamoDB.

    Unlike general prompts, this skill enforces formal state invariants and generates deterministic test plans using fake clocks to prove a fix works before deployment, preventing the introduction of new race conditions.

    You receive the production-ready AI agent skill, a suite of deterministic test scenarios for validating repairs, and documentation on implementing observability metrics for permit tracking.

    Setup involves importing the skill into your preferred AI agent framework and providing access to your current locking logic or infrastructure schema for diagnostic analysis.

    Yes, the skill is designed to analyze legacy systems and propose non-breaking, idempotent release logic that can be layered onto existing distributed locking implementations without a full rewrite.

    New in Agents & Orchestration