|
| 1 | +# `pg_crash` |
| 2 | +<!-- |
| 3 | +SPDX-FileCopyrightText: Copyright © contributors to CloudNativePG, established as CloudNativePG a Series of LF Projects, LLC. |
| 4 | +SPDX-License-Identifier: Apache-2.0 |
| 5 | +--> |
| 6 | + |
| 7 | +[pg_crash](https://github.com/cybertec-postgresql/pg_crash) is a PostgreSQL |
| 8 | +extension designed for **fault injection** and **chaos engineering**. It allows |
| 9 | +administrators to simulate various failure scenarios—such as backend crashes |
| 10 | +and signal handling issues—to verify the resilience of High Availability (HA) |
| 11 | +clusters and self-healing mechanisms. |
| 12 | + |
| 13 | +> [!CAUTION] |
| 14 | +> **DO NOT USE THIS IMAGE IN PRODUCTION.** |
| 15 | +> This extension is designed to intentionally destabilize and terminate |
| 16 | +> PostgreSQL processes. Deploying it in production will cause service downtime |
| 17 | +> and potential data availability issues. |
| 18 | +> |
| 19 | +> Only deploy this extension in **dedicated test or staging namespaces**. |
| 20 | +> Consider using Kubernetes admission controllers or OPA/Gatekeeper policies |
| 21 | +> to prevent accidental deployment to production clusters. |
| 22 | +
|
| 23 | +This extension image is maintained by the CNPG project and supersedes the |
| 24 | +[`pgcrash-containers` project](https://github.com/cloudnative-pg/pgcrash-containers). |
| 25 | + |
| 26 | +## Usage |
| 27 | + |
| 28 | +The `pg_crash` extension must be loaded via `shared_preload_libraries`. It |
| 29 | +operates by periodically sending random signals (selected from a user-defined |
| 30 | +list) to PostgreSQL backend processes. |
| 31 | + |
| 32 | +The following example configures a cluster to experience "Chaos" by randomly |
| 33 | +sending signals every 60 seconds. This is ideal for testing how quickly |
| 34 | +CloudNativePG detects a failure and promotes a new primary. |
| 35 | + |
| 36 | +```yaml |
| 37 | +apiVersion: postgresql.cnpg.io/v1 |
| 38 | +kind: Cluster |
| 39 | +metadata: |
| 40 | + name: cluster-pg-crash |
| 41 | +spec: |
| 42 | + imageName: ghcr.io/cloudnative-pg/postgresql:18-minimal-trixie |
| 43 | + instances: 3 |
| 44 | + |
| 45 | + storage: |
| 46 | + size: 1Gi |
| 47 | + |
| 48 | + postgresql: |
| 49 | + extensions: |
| 50 | + - name: pg-crash |
| 51 | + image: |
| 52 | + # renovate: suite=trixie-pgdg depName=postgresql-18-pg-crash |
| 53 | + reference: ghcr.io/cloudnative-pg/pg-crash:0.3-18-trixie |
| 54 | + shared_preload_libraries: |
| 55 | + - pg_crash |
| 56 | + parameters: |
| 57 | + log_min_messages: 'DEBUG1' |
| 58 | + # See https://www.postgresql.org/docs/current/server-shutdown.html |
| 59 | + # SIGHUP (1) - Reload |
| 60 | + # SIGINT (2) - Fast shutdown |
| 61 | + # SIGQUIT (3) - Immediate shutdown |
| 62 | + # SIGTERM (15) - Smart shutdown |
| 63 | + crash.signals: '1 2 3 15' |
| 64 | + crash.delay: '60' |
| 65 | +``` |
| 66 | +
|
| 67 | +--- |
| 68 | +
|
| 69 | +## Licenses and Copyright |
| 70 | +
|
| 71 | +`pg_crash`: |
| 72 | + |
| 73 | +- **Copyright:** (c) 2017, 2025 CYBERTEC PostgreSQL International GmbH |
| 74 | +- **License:** BSD 3-Clause License |
| 75 | + |
| 76 | +All relevant license and copyright information for the `pg-crash` extension |
| 77 | +and its dependencies are bundled within the image at: |
| 78 | + |
| 79 | +```text |
| 80 | +/licenses/ |
| 81 | +``` |
| 82 | + |
| 83 | +By using this image, you agree to comply with the terms of the licenses |
| 84 | +contained therein. |
0 commit comments