Changelog
All notable changes to Macavity are documented in this file.
0.2.0
This release replaces the single armed fault with a per-session event registry. A session can now arm multiple fault events at once. Each event has a stable ID, independent counters, a lifecycle state, and can be re-armed after firing.
Breaking changes. The return types and behavior of
macavity_arm(),macavity_disarm()andmacavity_status()have changed. See Upgrading from 0.1.0.
Added
- Event registry. Events are kept in a backend-local registry until
macavity_reset()is called or the session ends. The registry also serves as the session’s event history. Event IDs are allocated as 1, 2, 3, … in creation order and are never reused until reset. - Multiple armed events. Any number of events can be armed simultaneously, at the same or different fault points. Each event maintains its own counters.
- Event states. Each event is
armed,completed(it fired), ordisarmed(it was cancelled before firing). - Deterministic firing order. When multiple armed events match the same hit, they are evaluated by action in the order
delay>crash>error, then by ascendingevent_id. Adelayreturns and evaluation continues; anerrororcrashends evaluation, so later events are neither counted nor fired. macavity_arm(event_id integer) RETURNS booleanre-arms acompletedordisarmedevent. The event keeps its ID, point, action and occurrence, while its counters are reset. It returnsfalseif the event is already armed. An unknown or NULL ID is an error.- Action-specific shorthands:
macavity_arm_error(point, occurrence),macavity_arm_delay(point, occurrence)andmacavity_arm_crash(point, occurrence). Each returns the new event’s ID. macavity_reset() RETURNS integerclears the registry, restarts event IDs at 1, and returns the number of discarded events.- Added the
macavity_eventsregression suite covering event IDs, concurrent events, state transitions, status output and firing precedence. - Extended session and crash tests to cover multiple concurrent sessions and firing precedence under real crashes.
- Added
sql/macavity--0.1.0--0.2.0.sqlforALTER EXTENSION macavity UPDATE.
Changed
- Breaking:
macavity_arm(point, action, occurrence)now returns the new event’sintegerID instead ofvoid. Breaking:
macavity_disarm(event_id integer DEFAULT NULL) RETURNS booleannow:- disarms the specified event when given an ID;
- disarms all armed events when called with no argument or NULL;
- returns
trueif at least one event changed state; - preserves disarmed and completed events in the registry. Use
macavity_reset()to clear them.
Breaking:
macavity_status()now returns one row per event (SETOF record) with the columnsevent_id,point,action,occurrence,hits,remainingandstate.- The
statecolumn replaces the booleanarmedcolumn. - A session with no events now returns no rows.
- The
- Arming a new event while another is armed is no longer an error.
- The arming-statement skip now applies to each event separately. The statement that arms or re-arms an event does not count toward that event’s own
executor_end,before_commitorbefore_aborthits. - On Windows builds,
macavity_arm()andmacavity_arm_crash()reject thecrashaction withfeature_not_supported. macavity_points()remains granted toPUBLIC. All new functions are revoked fromPUBLIC, like the existing arming functions.- Restructured the README with new “Overview”, “Usage”, “SQL API” and “How events behave” sections.
Fixed
- Fixed an
executor_endevent firing one statement late when the statement that armed it failed. The per-statement skip is now discarded when execution unwinds due to an error, with a transaction-end backstop.
Upgrading from 0.1.0
- Build and install the new version:
make && make install - Run
ALTER EXTENSION macavity UPDATE;in each database that has the extension. The upgrade drops and recreatesmacavity_arm(),macavity_disarm()andmacavity_status()because their return types changed. - Re-issue any
GRANTs you had on those functions. The upgrade revokes the new and recreated functions fromPUBLIC. Update callers:
- Replace checks on
armedwith checks onstate, for exampleWHERE state = 'armed'. - Where you relied on
macavity_disarm()to clear fired state, usemacavity_reset()instead. - Code that expected one row from
macavity_status()must now handle zero or multiple rows.
- Replace checks on
- Existing sessions keep the old library loaded until they reconnect. No fault state is carried across the upgrade because fault state has always lived in backend memory.
0.1.0
Initial release.
- Session-local, one-shot fault injection, with at most one armed fault per session.
- Four fault points:
executor_start,executor_end,before_commitandbefore_abort. - Three actions:
error,delay(fixed at 1 second) andcrash(the backend sendsSIGKILLto itself). macavity_arm(),macavity_disarm(),macavity_status()andmacavity_points(). Thehitsandremainingcounters are updated before the action runs.- The
pg_regresssuitesmacavity_basic,macavity_errors,macavity_countersandmacavity_faults, plustest/session_test.shandtest/crash_test.sh.