Skip to content

[18.0][ADD] auditlog_clickhouse_write: Add module#3528

Open
tendil wants to merge 3 commits intoOCA:18.0from
cetmix:18.0-t5246-auditlog_clickhouse-add_module
Open

[18.0][ADD] auditlog_clickhouse_write: Add module#3528
tendil wants to merge 3 commits intoOCA:18.0from
cetmix:18.0-t5246-auditlog_clickhouse-add_module

Conversation

@tendil
Copy link

@tendil tendil commented Feb 19, 2026

Purpose:
Production deployments with extensive audit rules can experience
unbounded growth of audit tables, increasing PostgreSQL bloat and
slowing down audited operations due to synchronous ORM writes. Audit
records stored in PostgreSQL are also mutable for privileged users.

This PR introduces auditlog_clickhouse_write to buffer audit payloads in
PostgreSQL and export them asynchronously to ClickHouse, enabling
scalable audit storage while reducing transactional overhead.

What’s included:

  • ClickHouse connection/configuration model and UI;
  • Local buffer model for queued audit payloads;
  • Asynchronous export via queue_job + cron trigger;
  • Tests covering buffer creation and export job behavior;
  • Documentation.

How to use:

  • Install the module, configure ClickHouse connection, test it;
  • Create tables via UI if needed;
  • Enable the configuration to start buffering and exporting.

Task: 5246

@tendil tendil marked this pull request as draft February 22, 2026 23:04
@Aldeigja Aldeigja force-pushed the 18.0-t5246-auditlog_clickhouse-add_module branch from 65ad212 to c4763c1 Compare February 23, 2026 09:38
@tendil tendil force-pushed the 18.0-t5246-auditlog_clickhouse-add_module branch 3 times, most recently from df7fdac to eed96ad Compare February 23, 2026 14:04
@tendil tendil force-pushed the 18.0-t5246-auditlog_clickhouse-add_module branch 3 times, most recently from 5ae9a83 to 5101588 Compare March 6, 2026 10:50
@tendil tendil marked this pull request as ready for review March 6, 2026 11:17
@tendil tendil force-pushed the 18.0-t5246-auditlog_clickhouse-add_module branch from 5101588 to f2e27d1 Compare March 6, 2026 11:41
@tendil tendil changed the title [18.0][ADD] auditlog_clickhouse: Add module [18.0][ADD] auditlog_clickhouse_write: Add module Mar 6, 2026
@tendil tendil force-pushed the 18.0-t5246-auditlog_clickhouse-add_module branch from f2e27d1 to 350ee69 Compare March 6, 2026 12:03
Copy link
Member

@ivs-cetmix ivs-cetmix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code review LGTM

Copy link

@Aldeigja Aldeigja left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Functional LGTM

@OCA-git-bot
Copy link
Contributor

This PR has the approved label and has been created more than 5 days ago. It should therefore be ready to merge by a maintainer (or a PSC member if the concerned addon has no declared maintainer). 🤖

tendil added 2 commits March 12, 2026 16:54
Audit tables can grow without bounds on production databases, causing
bloat and adding latency to audited operations because logs are written
synchronously in the same transaction. Keeping audit data in PostgreSQL
also leaves an immutability gap for privileged users.

Introduce a dedicated module to buffer audit payloads and export them
asynchronously to ClickHouse, allowing audit storage to scale without
slowing down business transactions and keeping audit data effectively
immutable in a write-only store.

Task: 5246
Split ClickHouse existing-row checks into chunks to avoid oversized
SELECT ... IN (...) queries during large imports.

Previously, retry-safe deduplication could build a very large IN
clause when checking already inserted log or log line ids. This
caused ClickHouse to fail with "Max query size exceeded" and the
queue job stopped processing buffered auditlog rows.

The fix keeps deduplication logic but executes existence checks in
smaller chunks, which preserves idempotent retries and prevents
query size errors on bulk imports.

Task: 5246
@tendil tendil force-pushed the 18.0-t5246-auditlog_clickhouse-add_module branch from 3b20173 to 3696841 Compare March 12, 2026 16:54
Store auditlog HTTP session and request data in ClickHouse together
with audit logs and log lines.

Previously only auditlog_log and auditlog_log_line were exported.
This made ClickHouse-backed logs incomplete for read scenarios that
depend on http_session_id and http_request_id, especially after
recreating the Odoo database.

Also extend buffer processing and tests to handle HTTP-related rows
and keep retry-safe deduplication for the additional tables.

Task: 5246
@tendil tendil force-pushed the 18.0-t5246-auditlog_clickhouse-add_module branch from 3696841 to b7137b6 Compare March 13, 2026 10:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants