citusdata / citusdata/pg_cron

Q: "Must be superuser to create this extension."

Open
#424 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C
Stars
3.9k
Forks
260
Avg merge
5d 5h
Merged PRs (30d)
1

Description

Attempting to install this extension. Added an [init script](https://github.com/haridusministeerium/postgres-docker/blob/master/initdb-cron.sh) to create the pg_cron functions and metadata tables, but still getting a permission error when a db user tries to use it:
```console
2026-04-01 05:20:30.690 CEST [11989] ERROR: permission denied to create extension "pg_cron"
2026-04-01 05:20:30.690 CEST [11989] HINT: Must be superuser to create this extension.
2026-04-01 05:20:30.690 CEST [11989] CONTEXT: SQL statement "CREATE EXTENSION IF NOT EXISTS pg_cron"
PL/pgSQL function inline_code_block line 4 at SQL statement
2026-04-01 05:20:30.690 CEST [11989] STATEMENT: DO $$
BEGIN
IF current_database() NOT LIKE 'prisma_migrate_shadow_db%' THEN
CREATE EXTENSION IF NOT EXISTS pg_cron;
ELSE
CREATE SCHEMA IF NOT EXISTS cron;
CREATE TABLE IF NOT EXISTS cron.job (
jobid BIGINT PRIMARY KEY,
schedule TEXT,
command TEXT,
nodename TEXT,
nodeport INTEGER,
database TEXT,
username TEXT,
active BOOLEAN,
jobname TEXT
);
END IF;
END $$;
```

[This is the initial pgres log](https://gist.github.com/laur89/1f3a684223dfae3bbbbb88163a6d715d) after the initial DB startup that's executing this init script. No idea whether it looks OK or not.

> background worker "pg_cron launcher" (PID 58) exited with exit code 1

does sounds suspicious.

---

Note postrgres was started with `-c shared_preload_libraries=pg_cron -c cron.database_name=postgres` options.

What am I missing. Does that particular application db user need to be granted extra permissions?

Note the error seems to be caused by `split-pro` program's migration logic found [here](https://github.com/oss-apps/split-pro/blob/main/prisma/migrations/20250920192654_recurrence/migration.sql#L54-L55).

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.