fsm_core
fsm_core : Finite state machine toolkit for PostgreSQL
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 2690 | fsm_core | fsm_core | 1.2.0 |
FEAT | Apache-2.0 | SQL |
| Attribute | Has Binary | Has Library | Need Load | Has DDL | Relocatable | Trusted |
|---|---|---|---|---|---|---|
| ----d-- | No | No | No | Yes | no | no |
| Relationships | |
|---|---|
| Schemas | fsm_core |
| Requires | ltree pgmq |
| See Also | pgmq ulak pgmb pg_durable redis pg_task pg_background pgq redis_fdw tcn |
Packages
| Linux / PG | PG19 | PG18 | PG17 | PG16 | PG15 |
|---|---|---|---|---|---|
| el8.x86_64 | N/A | PIGSTY 1.2.0 | PIGSTY 1.2.0 | PIGSTY 1.2.0 | PIGSTY 1.2.0 |
| el8.aarch64 | N/A | PIGSTY 1.2.0 | PIGSTY 1.2.0 | PIGSTY 1.2.0 | PIGSTY 1.2.0 |
| el9.x86_64 | PIGSTY 1.2.0 | PIGSTY 1.2.0 | PIGSTY 1.2.0 | PIGSTY 1.2.0 | PIGSTY 1.2.0 |
| el9.aarch64 | PIGSTY 1.2.0 | PIGSTY 1.2.0 | PIGSTY 1.2.0 | PIGSTY 1.2.0 | PIGSTY 1.2.0 |
| el10.x86_64 | PIGSTY 1.2.0 | PIGSTY 1.2.0 | PIGSTY 1.2.0 | PIGSTY 1.2.0 | PIGSTY 1.2.0 |
| el10.aarch64 | PIGSTY 1.2.0 | PIGSTY 1.2.0 | PIGSTY 1.2.0 | PIGSTY 1.2.0 | PIGSTY 1.2.0 |
| d12.x86_64 | PIGSTY 1.2.0 | PIGSTY 1.2.0 | PIGSTY 1.2.0 | PIGSTY 1.2.0 | PIGSTY 1.2.0 |
| d12.aarch64 | PIGSTY 1.2.0 | PIGSTY 1.2.0 | PIGSTY 1.2.0 | PIGSTY 1.2.0 | PIGSTY 1.2.0 |
| d13.x86_64 | PIGSTY 1.2.0 | PIGSTY 1.2.0 | PIGSTY 1.2.0 | PIGSTY 1.2.0 | PIGSTY 1.2.0 |
| d13.aarch64 | PIGSTY 1.2.0 | PIGSTY 1.2.0 | PIGSTY 1.2.0 | PIGSTY 1.2.0 | PIGSTY 1.2.0 |
| u22.x86_64 | PIGSTY 1.2.0 | PIGSTY 1.2.0 | PIGSTY 1.2.0 | PIGSTY 1.2.0 | PIGSTY 1.2.0 |
| u22.aarch64 | PIGSTY 1.2.0 | PIGSTY 1.2.0 | PIGSTY 1.2.0 | PIGSTY 1.2.0 | PIGSTY 1.2.0 |
| u24.x86_64 | PIGSTY 1.2.0 | PIGSTY 1.2.0 | PIGSTY 1.2.0 | PIGSTY 1.2.0 | PIGSTY 1.2.0 |
| u24.aarch64 | PIGSTY 1.2.0 | PIGSTY 1.2.0 | PIGSTY 1.2.0 | PIGSTY 1.2.0 | PIGSTY 1.2.0 |
| u26.x86_64 | PIGSTY 1.2.0 | PIGSTY 1.2.0 | PIGSTY 1.2.0 | PIGSTY 1.2.0 | PIGSTY 1.2.0 |
| u26.aarch64 | PIGSTY 1.2.0 | PIGSTY 1.2.0 | PIGSTY 1.2.0 | PIGSTY 1.2.0 | PIGSTY 1.2.0 |
Source
github.com/pgfsm/fsm/tree/main/packages/database-src-extension/fsm_core
fsm_core-1.2.0.tar.gz
Install
Make sure PGDG and PIGSTY repo available:
Install this extension with pig:
Create this extension with:
Usage
Sources:
fsm_core 1.2.0 stores finite-state-machine definitions, instances, transitions and event history in PostgreSQL. Its SQL interface loads validated JSON, creates instances by name and version, and submits events through pgmq queues.
Install and Configure
The release requires PostgreSQL 15 or later and was tested on 15–18. Required extensions are ltree 1.2+, pgmq 1.4.4+ and pg_cron 1.5+. Add pg_cron to the existing shared_preload_libraries, restart PostgreSQL if that setting changes, and install into the database selected by cron.database_name.
After installing the matching extension files, a superuser can enable the fixed, nonrelocatable fsm_core schema:
Installation creates fsm_* roles and the fsm_schedule_all_pending scheduler job, which runs every five seconds. Inspect role memberships, queue permissions and the scheduler before granting application access. pg_jsonschema is optional: if its validation helper exists in fsm_core, the loader reports schema problems but does not reject a definition on that check alone.
Load a Definition
Validate the machine with the upstream compiler and set the psql variable fsm_json to that JSON before this call. The 1.2.0 signature has no input_fsm_type argument:
Concurrent loads of the same name and version are serialized by an advisory transaction lock. Identical JSON returns the cached definition; different JSON under an existing name and version raises an error. Use a new version for a changed machine. The optional input_dependent_children argument records child-machine dependencies.
Create an Instance and Send Events
The returned JSON includes fsm_instance_id, queue_created, send_event_result, message and extra_message. Check these before submitting work: queue creation and initial-event failures can be reported in the result. Initial context is shallow-merged with the definition’s static context, with supplied object keys taking precedence.
For this top-level machine, submit an event declared by its definition:
The helper queues the event and writes event history. The old parent-queue parameters are absent from this release’s signature. Queuing an event is not proof that a worker has processed it; monitor scheduler activity, queue backlog and instance state.
Objects and Upgrade Boundaries
fsm_json, fsm_states and fsm_transitions hold definitions; fsm_instance holds instances; fsm_instance_queue_event_logs records queue events. resolve_state_value_v2 and macrostep_v2 expose lower-level state resolution and transition logic. Prefer the verified v2 entry points and restrict access to security-definer functions and underlying tables.
The release notes describe sequential upgrade scripts guarded by require_version, but the reviewed 1.2.0 ZIP contains the full install script and no version-to-version upgrade scripts. Preserve populated databases and obtain a verified upgrade artifact before upgrading an existing installation. Do not rerun the full install or assume ALTER EXTENSION ... UPDATE has an available upgrade path.