backendkiller

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 29, 2026 License: BSD-3-Clause Imports: 10 Imported by: 0

Documentation

Overview

Package backendkiller defines implementation of workload which deliberately drives a single PostgreSQL backend towards an out-of-memory condition.

A single dedicated connection (not a pool) issues, in a single-threaded rate-limited loop, unique literal server-side prepared statements of the form "PREPARE noisia_bk_<i> AS SELECT 0 AS c0, 1 AS c1, …" and immediately EXECUTEs each one once. PREPARE caches the statement's parse/rewrite tree; the first EXECUTE builds and caches its generic plan as well, so each pair grows the backend's plan cache (and RSS) faster than PREPARE alone. The statements are never DEALLOCATEd, so the plan cache (and the backend's RSS) grows without bound. Eventually the OOM killer reaps the backend and the postmaster restarts the whole instance.

The workload self-reports: it keeps an in-process counter of created statements and prints an escalation panel every report-interval via logger.Infof. When its own connection is lost after at least one successful PREPARE (the target was likely OOM-restarted), it logs a climax line and returns nil. Workload duration is controlled by a context created outside and passed to Run.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewWorkload

func NewWorkload(config Config, logger log.Logger) (noisia.Workload, error)

NewWorkload creates a new workload with specified config.

Types

type Config

type Config struct {
	// Conninfo defines connection string used for connecting to Postgres.
	// It is a secret and must never be logged.
	Conninfo string
	// Rate defines PREPARE statements rate per second; 0 means unlimited (rate.Inf).
	Rate float64
	// PlanSize defines the target-list width per PREPARE (plan heaviness).
	PlanSize int
	// ShowMemory enables appending the own-backend memory estimate to the panel.
	ShowMemory bool
	// ReportInterval defines the escalation panel print cadence.
	ReportInterval time.Duration
}

Config defines configuration settings for backend-killer workload.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL