Skip to content

Friendly Inquiry: Are there plans to support Auto-Renewal for Distributed Locks in StackExchange.Redis? #2904

@Misaka11693

Description

@Misaka11693

Hi StackExchange.Redis Team,

First, sincere thanks for this exceptional library – it's fundamental to our Redis implementation in .NET.

We've encountered a specific challenge with distributed locks:
When setting an initial lock timeout (e.g., 30 seconds), occasional extended execution times (e.g., 35 seconds) due to third-party latency or network fluctuations can cause:
1️⃣ At 30s: Automatic lock release (by Redis design)
2️⃣ 30-35s: Original process continues critical operations (e.g., inventory updates)
3️⃣ At 31s: Another process acquires the same resource lock
4️⃣ At 35s: Original process releases the lock (inadvertently terminating the new holder's lock)

This creates risks of premature lock release and cross-process accidental release, potentially causing data inconsistencies in sensitive workflows like financial transactions.

While researching solutions, we observed Java's Redisson mitigates this elegantly via its "Watchdog" mechanism:

  • Initial 30s timeout set
  • Automatically renews to 30s at 20s (when 10s remain)
  • Ensures continuous validity during extended execution

We'd be grateful for your perspective:

  1. Future Direction
    Is graceful lock renewal under consideration for StackExchange.Redis?

  2. Implementation Guidance
    If not planned, could you advise on:

    • Mitigating this risk with current features
    • Recommended patterns for lock lifecycle management
      (We've tried background renewal but seek expert insight on edge cases)

Your guidance would be invaluable. Regardless, we deeply appreciate your work on this critical library!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions