Skip to content

macavity

Deterministic session-local fault injection for PostgreSQL test clusters

Overview

PackageVersionCategoryLicenseLanguage
macavity0.2.0ADMINMITC
IDExtensionBinLibLoadCreateTrustRelocSchema
5215macavityNoYesNoYesNoYes-

Testing release; destructive crash action affects the entire instance. Disposable test clusters only.

Version

TypeRepoVersionPG VerPackageDeps
EXTPIGSTY0.2.01817161514macavity-
RPMPIGSTY0.2.01817161514macavity_$v-
DEBPIGSTY0.2.01817161514postgresql-$v-macavity-
OS / PGPG18PG17PG16PG15PG14
el8.x86_64N/AN/A
el8.aarch64N/AN/A
el9.x86_64N/AN/A
el9.aarch64N/AN/A
el10.x86_64N/AN/A
el10.aarch64N/AN/A
d12.x86_64N/AN/A
d12.aarch64
PIGSTY 0.2.0
PIGSTY 0.2.0
PIGSTY 0.2.0
N/AN/A
d13.x86_64
PIGSTY 0.2.0
PIGSTY 0.2.0
PIGSTY 0.2.0
N/AN/A
d13.aarch64
PIGSTY 0.2.0
PIGSTY 0.2.0
PIGSTY 0.2.0
N/AN/A
u22.x86_64
PIGSTY 0.2.0
PIGSTY 0.2.0
PIGSTY 0.2.0
N/AN/A
u22.aarch64
PIGSTY 0.2.0
PIGSTY 0.2.0
PIGSTY 0.2.0
N/AN/A
u24.x86_64
PIGSTY 0.2.0
PIGSTY 0.2.0
PIGSTY 0.2.0
N/AN/A
u24.aarch64
PIGSTY 0.2.0
PIGSTY 0.2.0
PIGSTY 0.2.0
N/AN/A
u26.x86_64N/AN/A
u26.aarch64
PIGSTY 0.2.0
PIGSTY 0.2.0
PIGSTY 0.2.0
N/AN/A

Build

You can build the RPM / DEB packages for macavity using pig build:

pig build pkg macavity         # build RPM / DEB packages

Install

You can install macavity directly. First, make sure the PGDG and PIGSTY repositories are added and enabled:

pig repo add pgsql -u          # Add repo and update cache

Install the extension using pig or apt/yum/dnf:

Install
pig install macavity;          # Install for current active PG version
pig
pig ext install -y macavity -v 18  # PG 18
pig ext install -y macavity -v 17  # PG 17
pig ext install -y macavity -v 16  # PG 16
dnf
dnf install -y macavity_18       # PG 18
dnf install -y macavity_17       # PG 17
dnf install -y macavity_16       # PG 16
apt
apt install -y postgresql-18-macavity   # PG 18
apt install -y postgresql-17-macavity   # PG 17
apt install -y postgresql-16-macavity   # PG 16

Create Extension:

CREATE EXTENSION macavity;

Usage

Sources:

macavity 0.2.0 provides deterministic fault injection for disposable PostgreSQL test clusters. Upstream tests PostgreSQL 16–18 on Linux; PostgreSQL 19+ and other platforms are not validated, and Windows crash injection is unsupported. The crash action can disconnect every session and force crash recovery.

Event workflow

CREATE EXTENSION macavity;
SELECT * FROM macavity_points();
SELECT macavity_arm('executor_start', 'error', 1);
SELECT 1; -- expected injected error
SELECT * FROM macavity_status();
SELECT macavity_disarm();
SELECT macavity_reset();

Registry and upgrade

Each session keeps multiple events with stable IDs, separate counters and states armed, completed or disarmed. macavity_arm returns an integer event ID; its single-ID overload re-arms a completed or disarmed event. macavity_status returns zero or more event rows. macavity_disarm retains event history; macavity_reset clears it and restarts IDs.

Points are executor_start, executor_end, before_commit and before_abort; actions are error, delay and crash. Delay lasts one second. Abort-time error injection is rejected. At a shared hit, delay precedes crash, then error, with IDs breaking ties.

Creation requires a superuser; no shared preload is needed. Only point enumeration is granted to PUBLIC. Upgrading with ALTER EXTENSION macavity UPDATE recreates functions with changed signatures: restore explicit grants, update callers and reconnect old sessions. Current Pigsty package fields still refer to 0.1.0.

Was this page helpful?