More screenshots

    Works with the AI tools you already use

    Claude CodeClaude CodeCursorCursorCodex CLICodex CLIGitHub CopilotGitHub CopilotGemini CLIGemini CLI+20 more

    Repair Distributed Semaphore Permit Leaks

    1

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

    $8.99

    Secure checkout via Stripe

    30-day refund guarantee

    Converts to your local currency at checkout

    0 installsSecurity 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.

    What you get

    Detect permit leaks caused by worker crashes or network partitions.Fix double-release bugs in distributed locks and task queues.Design idempotent lease renewal and heartbeat mechanisms.Create deterministic test suites for concurrency-sensitive code.

    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.

    How to install

    Works the same in every agent - Claude, Cursor, Codex, Copilot and 20+ more.

    ~30 seconds
    1. 1

      Download the ZIP

      Free skills download straight away. Paid skills unlock right after purchase.

    2. 2

      Unzip into your skills folder

      Every agent reads skills from one folder on your machine. Drop the unzipped folder in there.

    3. 3

      Ask your agent to use it

      Restart the agent if it was already running. It picks the skill up automatically - no config needed.

    Skills folder by agent

    Click the path to copy it. Create the folder if it does not exist yet.

    Reviews

    No reviews yet

    Be one of the first to try it. Every listed skill passes our trust checks below.

    Security scanned

    Passed our 8-point scan before listing

    Fresh listing

    Recently published to Agensi

    30-day refund

    Not a fit? Get your money back

    Trust & safety

    Security scanned

    Verified clean 23 days ago

    • Passed all security checks, Safe to install

    Listed23 days ago

    What's inside

    Frequently Asked Questions