Quartz.NETQuartz.NET
Home
Features
Discussions
NuGet
GitHub
Home
Features
Discussions
NuGet
GitHub
  • Getting Started

    • Quartz 3 Quick Start
    • Tutorial
      • Using Quartz
      • Library Overview
      • Jobs And Triggers
      • More About Jobs
      • More About Triggers
      • Simple Triggers
      • Cron Triggers
      • RecurrenceTrigger
      • Trigger and Job Listeners
      • Scheduler Listeners
      • Job Stores
      • Tuning the Scheduler
      • Configuration, Resource Usage and SchedulerFactory
      • Advanced (Enterprise) Features
    • Configuration Reference
    • Frequently Asked Questions
    • Best Practices
    • Troubleshooting
    • API Documentation
    • Database Schema
    • Migration Guide
    • Miscellaneous Features
  • How To's

    • One-Off Job
    • Multiple Triggers
    • Job Template
    • Using the CronTrigger
    • Rescheduling Jobs
  • Packages

    • Quartz Core Additions

      • Dashboard
      • Jobs
      • Serialization (System.Text.Json)
      • Serialization (Newtonsoft Json.NET)
      • Plugins
    • Integrations

      • ASP.NET Core Integration
      • Hosted Services Integration
      • Microsoft DI Integration
      • Multiple Schedulers with Microsoft DI
      • OpenTelemetry Integration
      • OpenTracing Integration
      • Redis Lock Handler
      • TimeZoneConverter Integration
    • 3rd Party Plugins for Quartz
  • Unreleased Releases

    • Quartz 4.x
      • Quartz 4 Quick Start
      • Tutorial
        • Using Quartz
        • Jobs And Triggers
        • More About Jobs & JobDetails
        • More About Triggers
        • Simple Triggers
        • Cron Triggers
        • RecurrenceTrigger
        • Trigger and Job Listeners
        • Scheduler Listeners
        • Job Stores
        • Configuration, Resource Usage and SchedulerFactory
        • Advanced (Enterprise) Features
        • Miscellaneous Features
        • CronTrigger Tutorial
      • Configuration Reference
      • Migration Guide
      • Troubleshooting
      • API Documentation
      • How To's

        • One-Off Job
        • Multiple Triggers
        • Job Template
        • Using the CronTrigger
      • Packages

        • Quartz Core Additions

          • Dashboard
          • Jobs
          • JSON Serialization
          • Plugins
        • Integrations

          • ASP.NET Core Integration
          • HTTP API
          • Hosted Services Integration
          • Microsoft DI Integration
          • Multiple Schedulers with Microsoft DI
          • OpenTelemetry Integration
          • OpenTracing Integration
          • Redis Lock Handler
          • TimeZoneConverter Integration
        • 3rd Party Plugins for Quartz
  • Old Releases

    • Quartz 2.x
      • Quartz 2 Quick Start
      • Tutorial
        • Lesson 1: Using Quartz
        • Lesson 2: Jobs And Triggers
        • Lesson 3: More About Jobs & JobDetails
        • Lesson 4: More About Triggers
        • Lesson 5: SimpleTrigger
        • Lesson 6: CronTrigger
        • Lesson 7: TriggerListeners and JobListeners
        • Lesson 8: SchedulerListeners
        • Lesson 9: JobStores
        • Lesson 10: Configuration, Resource Usage and SchedulerFactory
        • Lesson 11: Advanced (Enterprise) Features
        • Lesson 12: Miscellaneous Features of Quartz
        • CronTrigger Tutorial
      • Configuration Reference
      • Migration Guide
      • API Documentation
    • Quartz 1.x
      • Tutorial
        • Lesson 1: Using Quartz
        • Lesson 2: Jobs And Triggers
        • Lesson 3: More About Jobs & JobDetails
        • Lesson 4: More About Triggers
        • Lesson 5: SimpleTrigger
        • Lesson 6: CronTrigger
        • Lesson 7: TriggerListeners and JobListeners
        • Lesson 8: SchedulerListeners
        • Lesson 9: JobStores
        • Lesson 10: Configuration, Resource Usage and SchedulerFactory
        • Lesson 11: Advanced (Enterprise) Features
        • Lesson 12: Miscellaneous Features of Quartz
      • API Documentation
  • License

Quartz.Redis provides a Redis-based distributed lock handler (ISemaphore) that replaces database row locks in clustered Quartz.NET setups.

Tips

Useful when database row locks (the default for clustered setups) cause deadlocks or performance issues under heavy scheduling load.

Tips

Quartz 4.0 or later required.

Installation

Install-Package Quartz.Redis

Why Redis Locks?

The default StdRowLockSemaphore uses SELECT ... FOR UPDATE database row locks to coordinate trigger acquisition across cluster nodes. Under heavy scheduling load this can lead to:

  • Table deadlocks in certain database engines
  • Connection timeouts when obtaining locks is slow
  • Performance degradation from lock contention on the QRTZ_LOCKS table

The Redis lock handler replaces these database locks with Redis SET NX PX distributed locks while keeping all job and trigger data in your relational database.

Configuring

Using SchedulerBuilder (recommended)

var schedulerFactory = SchedulerBuilder.Create()
    .UsePersistentStore(store =>
    {
        store.UseSqlServer(connectionString);
        store.UseSystemTextJsonSerializer();
        store.UseClustering();
        store.UseRedisLockHandler(redis =>
        {
            redis.RedisConfiguration = "redis-server:6379";
        });
    })
    .Build();

Using properties

var properties = new NameValueCollection
{
    ["quartz.jobStore.type"] = "Quartz.Impl.AdoJobStore.JobStoreTX, Quartz",
    ["quartz.jobStore.clustered"] = "true",
    ["quartz.jobStore.lockHandler.type"] = "Quartz.Impl.AdoJobStore.RedisSemaphore, Quartz.Redis",
    ["quartz.jobStore.lockHandler.redisConfiguration"] = "redis-server:6379"
};

Configuration Properties

PropertyDefaultDescription
redisConfigurationlocalhost:6379StackExchange.Redis connection string
keyPrefixquartz:lock:Prefix for Redis lock keys
lockTtlMilliseconds30000Lock TTL in milliseconds (auto-expires after this duration)
lockRetryIntervalMilliseconds100Polling interval between SET NX retry attempts

All properties are set under quartz.jobStore.lockHandler.*. The schedName and tablePrefix properties are injected automatically.

How It Works

The lock handler uses a two-tier locking strategy:

  1. Local tier — A SemaphoreSlim per lock name prevents redundant Redis round-trips when the same process already holds the lock.

  2. Redis tier — SET key value NX PX timeout provides the cross-node distributed lock. The key includes the scheduler name for multi-scheduler isolation (e.g., quartz:lock:MyScheduler:TRIGGER_ACCESS).

Lock release uses a Lua script for atomic check-and-delete, preventing a node from accidentally releasing a lock that has already expired and been re-acquired by another node.

Considerations

  • Lock TTL: The default 30-second TTL provides ample margin for typical scheduling operations (milliseconds to low seconds). If your database is very slow, increase the TTL. If a node crashes, the lock auto-expires after the TTL.
  • Redis availability: If Redis is unreachable, ObtainLock throws a LockException which the scheduler handles via its standard retry mechanism.
  • Single-instance Redis: This implementation uses simple SET NX locks, not the Redlock algorithm. For most Quartz.NET deployments a single Redis instance (or replica set with Sentinel) is sufficient since the locks are advisory and short-lived.
Help us by improving this page!
Last Updated: 4/4/26, 1:40 PM
Contributors: Marko Lahma, Claude Opus 4.6 (1M context)
Prev
OpenTracing Integration
Next
TimeZoneConverter Integration