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

    • Overview
    • Quartz 4 Quick Start
    • Tutorial
      • Using Quartz
      • Jobs And Triggers
      • More About Jobs & JobDetails
      • Job Data
      • More About Triggers
      • Querying Jobs and Triggers
      • Simple Triggers
      • Cron Triggers
      • RecurrenceTrigger
      • Time and TimeProvider
      • Trigger and Job Listeners
      • Scheduler Listeners
      • Job Execution Middleware
      • Job Stores
      • Configuration, Resource Usage and Building a Scheduler
      • Building a Scheduler Without a Host
      • Clustering
      • Execution Groups
      • Node Affinity (Preferred Node)
      • Testing
      • Compile-Time Checks
      • Declaring Jobs with Attributes
      • Delegate Jobs
    • Configuration Reference
    • JSON Configuration
    • Cron Expression Reference
    • Multi-Tenancy
    • Comparison
    • Frequently Asked Questions
    • Best Practices
    • Before You Go Live
    • Operating a Cluster
    • Log Events
    • Tenancy Patterns
    • Database Schema
    • Database Schema Changes
    • Migration Guide
    • Troubleshooting
    • API Documentation
  • How To's
    • One-Off Job
    • Rescheduling Jobs
    • Backfill
    • Retrying Failed Jobs
    • Pausing with a Reason
    • Job Continuations
    • Overlap Policy
    • Progress and Execution Logs
    • Job Outcomes
    • Multiple Triggers
    • Job Template
    • Running Quartz under Aspire
    • Quartz.NET with Wolverine
    • Coming from Hangfire
    • Coming from TickerQ
    • Embedding Quartz in a Library
    • Running under an External Leader Election
    • Publishing Trimmed and Native AOT
    • Extending Quartz: what is open, what is closed, and how to ask
    • A Job Store of Your Own
    • A Driver Delegate for a New Database
    • Persisting a Custom Trigger Type
    • A Lock Handler of Your Own
  • Packages

    • Quartz Core Additions

      • Jobs
      • Serialization (System.Text.Json)
      • JSON Serialization
      • Plugins
    • Integrations

      • Aspire Integration
      • Aspire Hosting
      • ASP.NET Core Integration
      • HTTP API
      • HTTP Client
      • Dashboard
      • Dashboard Agent
      • Dashboard Host
      • Hosted Services Integration
      • Microsoft DI Integration
      • Multiple Schedulers with Microsoft DI
      • Observability
      • Redis Lock Handler
      • TimeZoneConverter Integration
      • Weasel Schema Management
    • 3rd Party Plugins for Quartz
  • Quartz 3.x

    • Getting Started

      • Quartz 3 Quick Start
      • Tutorial
        • Using Quartz
        • Library Overview
        • Jobs And Triggers
        • More About Jobs
        • More About Triggers
        • Execution Groups
        • Node Affinity (Preferred Node)
        • 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
      • JSON Configuration
      • Multi-Tenancy
      • Frequently Asked Questions
      • Best Practices
      • Tenancy Patterns
      • Troubleshooting
      • API Documentation
      • Database Schema
      • Database Schema Changes
      • 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
  • 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

An ADO.NET job store (usually LocalTransactionJobStore) needs a set of tables.

  • Creating them can be automatic: ProvisionSchema() makes the store run the DDL for its database at startup and create whatever is missing — see Creating the schema. It is opt-in, because creating tables needs a permission production databases often do not grant.
  • Migrating an existing schema is a manual step, unless Weasel manages it: an application on Marten or Wolverine can hand the tables to the db-apply it already runs.
TableHolds
qrtz_calendarsnon-standard calendars
qrtz_job_detailsIJobDetail data
qrtz_locksthe locks Quartz takes
qrtz_scheduler_stateIScheduler data
qrtz_triggersITrigger data
qrtz_cron_triggersthe cron expression of a cron trigger
qrtz_fired_triggerstriggers that are currently running
qrtz_blob_triggerstriggers stored as binary blob data
qrtz_simple_triggerssimple repeat triggers
qrtz_simprop_triggerscustom triggers; ICalendarIntervalTrigger, IDailyTimeIntervalTrigger and IRecurrenceTrigger use it
qrtz_paused_trigger_grpsIScheduler.PauseTriggerGroups data
qrtz_paused_job_grpsIScheduler.PauseJobGroups data — one row per paused job group, so an empty group is still reported as paused

The scripts for each database are in database/tables.

The ADO.NET driver is a package the application references: see the method-to-package table and A missing driver package.

Upgrading an existing database? See Database Schema Changes. Upgrading from 3.x to 4.x is mandatory, because 4.x no longer probes for the optional 3.x columns.

Creating it, and why migrating it is different

A store can create a missing schema but never upgrades an existing one; the Quartz.Weasel packages can. Quartz's tables carry no version marker, so a guarded CREATE TABLE skips a table that exists without checking which columns it should have by now, and adding a marker would itself be a migration. A deployment pipeline runs database/migrations/, whose folder names are the version numbers.

For comparison: Hangfire records its schema version and migrates at startup by default, holding its heaviest 1.8 migrations behind an opt-in switch; TickerQ leaves both steps to the application's EF Core migrations.

Columns 4.x requires

These four columns are optional on 3.x, which probes for them at startup and disables the matching feature when one is missing. 4.x has no probes and requires all four.

ColumnTable(s)Added as optional in
MISFIRE_ORIG_FIRE_TIMEQRTZ_TRIGGERS3.17
EXECUTION_GROUPQRTZ_TRIGGERS, QRTZ_FIRED_TRIGGERS3.18
PREFERRED_NODEQRTZ_TRIGGERS3.19
PREFERRED_NODE_AUTOQRTZ_TRIGGERS3.19

4.x also needs what 3.x never had: the columns RETRY_POLICY and RETRY_ATTEMPT on QRTZ_TRIGGERS, and the table QRTZ_PAUSED_JOB_GRPS, which lets an empty job group be paused and a job group listing report paused correctly.

Apply database/migrations/4.0/ to add whichever are missing, table included. Every statement is guarded, so it is safe on a database that already has some of them. Database Schema Changes lists the whole 3.x → 4.x set.

Text columns that count bytes: Oracle and Firebird

Oracle and Firebird can count a VARCHAR column's width in bytes rather than characters. A character outside ASCII is two to four bytes of UTF-8, so such a column holds fewer of them.

DatabaseCounts bytesCounts characters
OracleNLS_LENGTH_SEMANTICS is BYTE, the defaultthe column was created under CHAR semantics
Firebirdthe database has no default character set (NONE)the database was created with DEFAULT CHARACTER SET UTF8

Quartz cannot tell which one a database uses. On these two dialects it cuts these texts by bytes too, always at a whole character:

ColumnCut to (characters)Oracle width (bytes)Firebird width (bytes)
PAUSE_REASON2501,0001,000
PAUSED_BY200800800
PROGRESS_MESSAGE2501,000250
ERROR_MESSAGE (execution history)1,0004,0001,000
SUMMARY (execution history)1,0004,0001,000
LAST_SUMMARY, LAST_FAILURE_MESSAGE (job status)1,0004,0001,000
  • A width four times the length never shortens a text: UTF-8 is at most three bytes a UTF-16 code unit. Oracle's are all four times.
  • Firebird's PROGRESS_MESSAGE and its 1,000-character texts are not. A message of é keeps 125 or 500 characters, one of 日 83 or 333, whatever the database's character set.
  • No other text is cut. Names, groups, DESCRIPTION and CALENDAR_NAME are refused when they do not fit. Counted in bytes, 250 characters of é are 500, so a VARCHAR(250) DESCRIPTION refuses them: ORA-12899 on Oracle, string right truncation on Firebird.
  • The widths are fixed for 4.x. A 4.x migration only adds columns.

Firebird

Create the database with a character set, and connect with the same one:

CREATE DATABASE 'localhost:/data/quartz.fdb' USER 'SYSDBA' PASSWORD 'masterkey'
  DEFAULT CHARACTER SET UTF8;
DataSource=localhost;Database=/data/quartz.fdb;User=SYSDBA;Password=masterkey;Charset=UTF8
  • A database's character set is fixed by CREATE DATABASE, so tables_firebird.sql cannot set it.
  • Its columns take the database's default. On a NONE database, VARCHAR(250) holds 250 bytes.
  • SELECT RDB$CHARACTER_SET_NAME FROM RDB$DATABASE answers UTF8 or NONE.

Oracle

  • SELECT COLUMN_NAME, CHAR_USED FROM USER_TAB_COLUMNS WHERE TABLE_NAME = 'QRTZ_TRIGGERS' answers B for a column that counts bytes, C for characters.
  • To have names and descriptions hold their width in characters, run tables_oracle.sql after ALTER SESSION SET NLS_LENGTH_SEMANTICS = CHAR. A VARCHAR2 still holds at most 4,000 bytes while MAX_STRING_SIZE is STANDARD.
  • Use an AL32UTF8 database character set. A single-byte one replaces a character it cannot encode.

SQL Server: READ_COMMITTED_SNAPSHOT

Turn it on for lock-free firing rounds on SQL Server, which run only in a cluster of two or more live 4.7 nodes, because that is where they help. Without it, every firing round takes TRIGGER_ACCESS, as in 4.5. A single node keeps 4.5's rounds either way.

What it isA database option: read committed reads a row's last committed version instead of taking a shared lock
Why rounds need itWithout it, a round's read waits on, and can deadlock with, another node's claim
DefaultOff on SQL Server and Azure SQL Managed Instance; on in Azure SQL Database
When Quartz reads itOnce, at scheduler startup

Turn it on, then restart the schedulers:

ALTER DATABASE CURRENT SET READ_COMMITTED_SNAPSHOT ON WITH ROLLBACK IMMEDIATE;

Check it:

SELECT is_read_committed_snapshot_on FROM sys.databases WHERE database_id = DB_ID();
  • The ALTER needs the database to itself. WITH ROLLBACK IMMEDIATE rolls back and disconnects every other session. Stop the schedulers and run it in a maintenance window.
  • It changes reads for the whole database, not only Quartz's tables. A read under read committed no longer waits for a writer; it sees each row as of the start of its statement. Check the other applications on the database first.
  • Row versions take space. They live in tempdb, or in the database itself under accelerated database recovery.
  • A setting changed while a scheduler runs is not seen until that scheduler restarts.

Without it, every round is locked with reason read_committed_snapshot_off, and event 3056 says so once at startup, naming the ALTER DATABASE statement. A store that cannot read the setting counts it as off. Exactly-once holds either way.

The QRTZ_TRIGGERS table

Holds the data shared by all trigger types. Type-specific data is in QRTZ_CRON_TRIGGERS, QRTZ_SIMPLE_TRIGGERS, QRTZ_SIMPROP_TRIGGERS or QRTZ_BLOB_TRIGGERS, as TRIGGER_TYPE says.

ColumnHolds
SCHED_NAMEThe Scheduler:InstanceName the row belongs to. On every table, so one database can hold several schedulers.
TRIGGER_NAME, TRIGGER_GROUPThe TriggerKey. With SCHED_NAME, the primary key.
JOB_NAME, JOB_GROUPThe JobKey of the job this trigger fires.
DESCRIPTIONITrigger.Description.
NEXT_FIRE_TIME, PREV_FIRE_TIMEFire times, as UTC ticks; null when there is none.
PRIORITYITrigger.Priority, which breaks ties between triggers due at the same instant.
TRIGGER_STATEThe stored state — see below.
TRIGGER_TYPECRON, SIMPLE, CAL_INT, DAILY_I, RECUR or BLOB: which sibling table holds the rest.
START_TIME, END_TIMEWhen the schedule is in force, as UTC ticks.
CALENDAR_NAMEThe QRTZ_CALENDARS entry that excludes times from the schedule, if any.
MISFIRE_INSTRThe misfire instruction's numeric value.
MISFIRE_ORIG_FIRE_TIMEThe fire time a misfire handler moved the trigger away from, so a job can see what it missed.
EXECUTION_GROUPThe trigger's execution group.
PREFERRED_NODE, PREFERRED_NODE_AUTONode affinity: which node should acquire the trigger, and whether it claimed the pin itself.
RETRY_POLICY, RETRY_ATTEMPTThe retry policy in stored string form, and how many retries of the current occurrence have run. See below.
PAUSE_REASON, PAUSED_BY, PAUSED_ATFrom 4.3: why, by whom and when (UTC ticks) the trigger was paused. Read only while it is paused. The paused-group tables carry the same three.
JOB_DATAThe trigger's own JobDataMap, serialized.

RETRY_POLICY is NULL on a trigger that does not retry, the default. RETRY_ATTEMPT is 0 on a row 4.x wrote and NULL on one an upgrade brought across; the store reads both as "no retries so far".

Trigger states

TRIGGER_STATE holds the stored vocabulary, StoredTriggerState in Quartz.Extensibility — not the enum an application sees.

TRIGGER_STATEMeaning
WAITINGReady to be picked up when due. The ordinary resting state.
ACQUIREDA node has taken the trigger and is about to fire it.
EXECUTINGIts job is running.
COMPLETEIt will not fire again.
BLOCKEDIts job is [DisallowConcurrentExecution] and another firing of it is running.
PAUSEDPaused until resumed.
PAUSED_BLOCKEDPaused, and blocked by a running firing of the same job.
ERRORThe trigger could not fire: its job type could not be built, or its fire failed MaxConsecutiveFireFailures times in a row. IScheduler.ResetTriggerFromErrorState clears it.
DELETEDA transient marker while a trigger is being removed.

IScheduler.GetTriggerState returns TriggerState: Normal, Paused, Complete, Error, Blocked, Executing, and None for a trigger that does not exist.

  • WAITING and ACQUIRED read as Normal; PAUSED_BLOCKED as Paused; DELETED as None.
  • A trigger whose job is running reads as Executing, unless the row says deleted, error or paused — those are reported as they are.
  • TriggerStateResolver.Resolve is that mapping, for code of your own.

Indexes, and the acquisition index in particular

Four indexes ship on QRTZ_TRIGGERS, the same four on every dialect:

  • three key lookups — (SCHED_NAME, JOB_NAME, JOB_GROUP), (SCHED_NAME, TRIGGER_GROUP, TRIGGER_NAME) and (SCHED_NAME, CALENDAR_NAME);
  • IDX_QRTZ_T_NFT_ST, which both trigger sweeps read: acquisition, and misfire recovery with the counting peek before it. It is the only index whose shape differs by dialect:
-- SQL Server, PostgreSQL, MySQL, Oracle, SQLite
(SCHED_NAME, TRIGGER_STATE, NEXT_FIRE_TIME ASC, PRIORITY DESC, MISFIRE_INSTR)

-- Firebird
(SCHED_NAME, TRIGGER_STATE, NEXT_FIRE_TIME)

4.0 drops IDX_QRTZ_T_NFT_ST_MISFIRE (#3656), a fifth index over (SCHED_NAME, MISFIRE_INSTR, NEXT_FIRE_TIME, TRIGGER_STATE) on SQL Server, MySQL, Oracle and Firebird (PostgreSQL and SQLite never had it). It led with MISFIRE_INSTR, which both misfire statements compare with <> -1 and no B-tree can seek past. Measured on all four engines (#3608, #3656), no optimizer picks it for either misfire statement; MySQL only appeared to because MySQLDelegate forced it by name, and that hint now names the acquisition index. An upgrade from 3.x drops it in schema_30_to_40_indexes_<dialect>.sql, a separate file because 3.x does sweep from it, so it waits for the last 3.x node to shut down.

The last two columns of the acquisition index serve the plan, not a predicate (#3510). SelectNextTriggerToAcquire orders by NEXT_FIRE_TIME ASC, PRIORITY DESC and every dialect puts its row limit into that statement, so the ORDER BY picks the highest-priority trigger of a tied set, as RAMJobStore does. With matching index directions the engine takes the first entry instead of reading and sorting every candidate:

100,000 triggers, 5,000 due, one acquisitionSQL Server 2022MySQL 8.0PostgreSQL 15Firebird 4
p50, three columns21.6 ms11.8 ms0.89 ms14.8 ms
p50, shipped shape0.59 ms0.69 ms0.74 ms14.8 ms
reads, three columns20,39515,5171,52610,025
reads, shipped shape8962410,025
index size+6.2 %+13 %+0.4 %unchanged

MISFIRE_INSTR is the fifth column for misfire backlogs. The ordered seek starts at the oldest waiting trigger, and the statement's lower bound on NEXT_FIRE_TIME is inside an OR with MISFIRE_INSTR, so it cannot narrow the seek. Without the column, every backlogged row the seek walks costs a table lookup. With it, those rows are skipped inside the index: against a 5,000-row backlog, 20,401 logical reads become 84 on SQL Server, and 15,071 buffer reads become 117 on MySQL.

The one case where it is slower than the three-column index: several thousand misfired triggers below the window and only a handful due costs about 3 ms against 1.5 ms. With several thousand due it is 3 ms against 30 ms, and backlogs drain.

Before you diff an index definition:

  • Firebird keeps the three-column index. Its indexes are ascending or descending as a whole, so CREATE INDEX rejects ASC, and a computed column with the negated priority cannot be indexed either (attempt to index COMPUTED BY column). Acquisition there still sorts its candidates — the 10,025 reads above. Ordering by NEXT_FIRE_TIME alone measures 3.2× faster and 345× cheaper there, but changes which trigger of a tied set fires first; if this costs you, open an issue with numbers rather than patching your schema.
  • MySQL before 8.0.1 and MariaDB before 10.8 parse DESC in an index and ignore it. Harmless; it buys nothing.
  • Oracle turns a descending key column into a function-based index, so USER_IND_COLUMNS shows a hidden SYS_NC000nn$ column with DESC at that position. Expected.

PREFERRED_NODE is in no index, measured on PostgreSQL 15, SQL Server 2022 and MySQL 8.0 against 100,000 triggers (#3426); AcquisitionIndexBenchmark prints the plans on demand.

  • It does nothing for acquisition. The node-affinity filter is a disjunction (unpinned, pinned here, or pinned to a node that stopped checking in), and no B-tree serves an OR; the plan is unchanged on all three engines. Adding it to the acquisition index buys nothing over MISFIRE_INSTR on SQL Server and MySQL, and makes PostgreSQL's backlog case worse — 660 shared buffers against 408.
  • It helps only the failover re-pin, the one UPDATE ClusterRecover issues per dead node: from a full scan (PostgreSQL 8.4 ms, SQL Server 4,319 logical reads, MySQL around 88 ms) to a seek of two or three pages. That runs once per node failure, which does not justify a permanent write cost on the busiest table.
  • If you add one anyway, use (SCHED_NAME, PREFERRED_NODE, PREFERRED_NODE_AUTO), for a cluster that fails over often enough for a multi-second recovery to hurt. Measure first: below a few thousand triggers every plan reads a handful of pages whatever the indexes are.
Help us by improving this page!
Last Updated: 11/13/26, 10:10 AM
Contributors: Daniel Nordström
Prev
Tenancy Patterns
Next
Database Schema Changes