Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

fix(personhog): disable vacuum truncation on the publish outbox (#118973)

José Sequeirac940696f98f0
diff --git a/rust/persons_migrations/20261016000001_disable_person_publish_outbox_vacuum_truncate.sql b/rust/persons_migrations/20261016000001_disable_person_publish_outbox_vacuum_truncate.sql
new file mode 100644
index 000000000000..2b0d0bd4eadc
--- /dev/null
+++ b/rust/persons_migrations/20261016000001_disable_person_publish_outbox_vacuum_truncate.sql
@@ -0,0 +1,11 @@
+-- The outbox is a queue: identity appends rows and the publisher deletes them
+-- moments later, so every vacuum finds an empty heap tail and tries to
+-- truncate it. Truncation needs an ACCESS EXCLUSIVE lock, which a table under
+-- constant inserts rarely grants, so each autovacuum run polls for the lock
+-- for up to 5 s before it gives up (Timeout:VacuumTruncate):
+-- https://github.com/postgres/postgres/blob/REL_15_STABLE/src/backend/access/heap/vacuumlazy.c#L86-L88
+-- With truncation off, inserts reuse the freed pages through the free space
+-- map and the heap stays at its high-water mark:
+-- https://www.postgresql.org/docs/15/sql-createtable.html#RELOPTION-VACUUM-TRUNCATE
+ALTER TABLE person_publish_outbox SET (vacuum_truncate = off);
+ALTER TABLE person_publish_outbox_tmp SET (vacuum_truncate = off);