Skip to content

Add mini_audit_pro asynchronous audit logging extension#1

Open
tanyang-star wants to merge 1 commit into
masterfrom
codex/develop-postgresql-mini_audit_pro-extension
Open

Add mini_audit_pro asynchronous audit logging extension#1
tanyang-star wants to merge 1 commit into
masterfrom
codex/develop-postgresql-mini_audit_pro-extension

Conversation

@tanyang-star

Copy link
Copy Markdown
Owner

Motivation

  • Provide a lightweight asynchronous auditing extension that captures DML and DDL for selected tables and writes audit events to a persistent mini_audit_log table.
  • Avoid synchronous writes inside hooks by using a shared-memory ring queue and a background worker to batch-flush events via SPI.

Description

  • Add a new contrib extension mini_audit_pro with build support by updating contrib/Makefile and adding contrib/mini_audit_pro/Makefile and .control files.
  • Implement the extension core in src/mini_audit_pro.c, registering ExecutorEnd_hook and ProcessUtility_hook to capture INSERT/UPDATE/DELETE and CREATE/ALTER/DROP TABLE events, enqueueing AuditEvent records into a shared-memory ring buffer protected by a spinlock.
  • Add a background worker mini_audit_worker_main that wakes periodically (or via latch), drains up to a batch of events, and writes them to mini_audit_log using SPI inside a transaction with error handling.
  • Provide SQL install files sql/mini_audit_pro--1.0.sql and wrapper sql/mini_audit_pro.sql, a README.md documenting architecture and configuration GUCs (mini_audit.enable, mini_audit.tables, mini_audit.queue_size, mini_audit.flush_interval_ms, mini_audit.worker_database), and a test.sql smoke script.

Testing

  • No automated CI tests were executed as part of this rollout.
  • A manual smoke test script is included at contrib/mini_audit_pro/test.sql which can be run with psql -f contrib/mini_audit_pro/test.sql after installing the extension to verify basic capture of DML/DDL into mini_audit_log.

Codex Task

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant