Proletarian requires PostgreSQL 9.5 or later. The minimum version is enforced by Proletarian’s use of theDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/msolli/proletarian/llms.txt
Use this file to discover all available pages before exploring further.
SELECT ... FOR UPDATE SKIP LOCKED feature, which was introduced in PostgreSQL 9.5 and enables multiple worker threads to poll the job queue concurrently without blocking each other.
The install script creates a dedicated proletarian PostgreSQL schema containing two tables — proletarian.job (the live queue) and proletarian.archived_job (the finished-job record) — plus a composite index on the job table that is critical for efficient queue polling.
Schema and Table Definitions
The full DDL is reproduced below exactly as shipped in the repository. Copy this into a migration file or run it directly against your database.database/postgresql/tables.sql
Column Reference
proletarian.job
| Column | Type | Description |
|---|---|---|
job_id | UUID | Primary key. Generated by Proletarian and returned by proletarian.job/enqueue!. |
queue | TEXT | Queue name. Defaults to :proletarian/default when not specified. |
job_type | TEXT | Clojure keyword identifying the job type, e.g. ::send-confirmation-email. |
payload | TEXT | Transit-encoded job data — the map passed as the third argument to enqueue!. |
attempts | INTEGER | Number of processing attempts so far. Starts at 0 and increments each time the job is picked up. |
enqueued_at | TIMESTAMPTZ | Timestamp when the job was first enqueued. Never updated. |
process_at | TIMESTAMPTZ | Earliest timestamp at which the job should be executed. Updated on each retry according to the retry strategy’s delay. |
proletarian.archived_job
All columns from proletarian.job are copied verbatim when a job is finished. Two additional columns record the outcome:
| Column | Type | Description |
|---|---|---|
status | TEXT | Either success or failure. Set to failure after all configured retries are exhausted. |
finished_at | TIMESTAMPTZ | Timestamp when the job finished (successfully or after final failure). |
The job_queue_process_at Index
- Filters rows by
queuename. - Orders the matching rows by
process_atascending to pick the oldest due job. - Skips any rows already locked by a sibling worker thread (
SKIP LOCKED).
proletarian.job table. With it, PostgreSQL resolves the query using an index-only scan over a tiny slice of the B-tree regardless of how many jobs are waiting.
Installing the Schema
Using the Provided Script
The repository ships a Bash install script atdatabase/postgresql/install.sh. It creates the proletarian role, optionally creates the database, applies tables.sql, and grants the necessary privileges.
If you are working inside the Proletarian repository itself, the bundled Makefile exposes two convenience targets:
proletarian. You can also invoke the script directly for more control:
psql environment variables (PGHOST, PGPORT, PGUSER, PGPASSWORD, etc.) for connecting to the server.
The roles and privileges applied by the script are:
database/postgresql/roles.sql
database/postgresql/privileges.sql
Quick Local Database with Docker
To spin up a throwaway PostgreSQL instance for local development or running the bundled examples:jdbc:postgresql://localhost:55432/postgres and run the install script (or apply tables.sql directly with psql).
Integrating with Migration Tools
If you are already managing schema changes with Flyway or Migratus, simply copy the SQL above into a new migration file. No special configuration is required — Proletarian has no awareness of how the tables were created. Flyway example — createsrc/main/resources/db/migration/V1__proletarian_tables.sql and paste the contents of tables.sql into it.
Migratus example — create resources/migrations/20240101000000-proletarian-tables.up.sql and paste the SQL there.
Customizing Table and Schema Names
Theproletarian schema and table names are entirely configurable. Pass the :proletarian/job-table and :proletarian/archived-job-table options to both proletarian.job/enqueue! and proletarian.worker/create-queue-worker using the fully-qualified table name as a string.
The schema and table names can be anything you like, but they must be identical in the options passed to
enqueue! and create-queue-worker. If they differ, workers will poll a different table than the one jobs are written to and no jobs will ever be processed.Uninstalling
To drop the database and theproletarian role entirely, use the make target (when inside the repository) or call the uninstall script directly:
DROP ROLE IF EXISTS proletarian; against the postgres maintenance database.