autovacuum launcher crash: assert in pgstat_count_io_op (IOOP_EXTEND on pg_database's VM)

First seen: 2026-05-31 04:36:45+00:00 · Messages: 1 · Participants: 1

Latest Update

2026-06-01 · claude-opus-4-6

Autovacuum Launcher Crash: Assert in pgstat_count_io_op (IOOP_EXTEND on pg_database's VM)

Technical Problem

This thread reports a crash in the autovacuum launcher triggered by an assertion failure in pgstat_count_io_op when performing an IOOP_EXTEND operation on the visibility map (VM) of pg_database. The crash was discovered during stress testing on master (commit e2b35735b00) with assertions enabled, using a workload involving rapid creation and dropping of databases in a tight loop.

Root Cause Analysis

The core issue lies at the intersection of several PostgreSQL subsystems:

  1. Visibility Map Extension: When autovacuum processes pg_database (a shared catalog), it may need to extend the visibility map. The VM is a fork of the relation that tracks which pages are known to contain only tuples visible to all transactions.

  2. I/O Statistics Tracking: The pgstat_count_io_op function tracks I/O operations for the statistics subsystem. It contains assertions that validate the combination of I/O operation type, backend type, and I/O object being operated on.

  3. The Assertion Failure: The autovacuum launcher (as distinct from autovacuum workers) is apparently performing or triggering an I/O operation (IOOP_EXTEND on a relation fork) that the statistics subsystem does not expect from that particular backend type. The pgstat I/O statistics infrastructure has a matrix of valid combinations of (BackendType, IOObject, IOContext, IOOp), and the autovacuum launcher extending a VM file likely falls outside the expected valid combinations.

Architectural Significance

This bug exposes a subtle design tension:

Proposed Solutions

Given this is a single-message thread (initial bug report), no formal patches have been proposed yet. However, the likely fixes would include:

  1. Expand the IO stats valid combination matrix: Add IOOP_EXTEND as a valid operation for the autovacuum launcher backend type when operating on relation forks (specifically VM/FSM forks of shared catalogs).

  2. Separate the launcher's vacuum path: Potentially refactor so that shared catalog vacuuming is delegated to a worker rather than performed in the launcher, though this would be a larger architectural change and may not be desirable for performance reasons.

  3. Relax the assertion: Make the assertion less strict for edge cases, though this is the least desirable fix as it reduces the diagnostic value of the assertion framework.

Key Technical Context