Skip to content

fix(migrations): store audit_log_event.entity_fqn unbounded - #33794

Merged
chirag-madlani merged 3 commits into
mainfrom
chirag-madlani/audit-log-event-widen-fqn
Sep 23, 2026
Merged

chirag-madlani merged 3 commits into
mainfrom
chirag-madlani/audit-log-event-widen-fqn

Conversation

@chirag-madlani

@chirag-madlani chirag-madlani commented Sep 22, 2026 •

Copy link
Copy Markdown
Collaborator

Describe your changes:

entity_fqn holds the raw FQN. For lineage events that FQN is two entity FQNs joined by the relationship marker, so ordinary deeply-nested entities push it past 768 characters — the integration run logged FQNs at 754 on rows that did fit — and the insert then fails with value too long for type character varying(768).

AuditLogRepository catches that and only WARNs, so the audit row is dropped and history goes silently incomplete. One run lost 22 rows this way.

Nothing indexes entity_fqn. Lookups go through entity_fqn_hash (idx_audit_log_event_entity_hash_ts), which FullyQualifiedName.buildHash fills with an MD5 digest per FQN segment (32 hex chars + separator each — roughly 23 segments before it approaches its own bound). That column keeps its length and its index; only the uncapped display value becomes TEXT.

Type of change:

  • Bug fix

Tests:

Verified against live Postgres 17 and MySQL 8.0 containers:

  • Column moves varchar(768) → text cleanly.
  • A second run is a no-op through the information_schema guard.
  • entity_fqn_hash index is intact afterwards.

Notes:

Cherry-picked from #33088 (commit b86ed3e675) to land as a small, independently-mergeable PR. Original commit authored by @harshach. Resolved a trivial conflict against the idx_user_entity_email_lower block that landed on main between original authoring and this cherry-pick — both blocks are appended additions and coexist.

🤖 Generated with Claude Code

RetriggerConfidence Score: 4/5

The column alteration itself appears sound, but the explicit repository requirement to place schema changes in a new migration version remains unsatisfied and must be addressed before merging.

Findings

  1. P2 Existing migration is modified ▶
Summary

This PR widens audit_log_event.entity_fqn from VARCHAR(768) to unbounded text while retaining the hash column used for indexed lookups.

  • Adds guarded, idempotent MySQL and PostgreSQL column alterations.
  • Preserves entity_fqn_hash and its existing index.
  • No new changes to the migration implementation were made since the previous review.

Reviews (3) · Last reviewed commit: "Merge branch 'main' into chirag-madlani/..."

entity_fqn holds the raw FQN, and for lineage events that FQN is two entity
FQNs joined by the relationship marker. Ordinary deeply-nested entities push
it past 768 characters -- the integration run logged FQNs at 754 on the rows
that did fit -- and the insert then fails with "value too long for type
character varying(768)". AuditLogRepository catches that and only WARNs, so
the audit row is dropped and the history goes silently incomplete; the run
lost 22 rows this way.

Nothing indexes entity_fqn. Lookups go through entity_fqn_hash
(idx_audit_log_event_entity_hash_ts), which FullyQualifiedName.buildHash fills
with an MD5 digest per FQN segment -- 32 hex characters plus a separator each,
so roughly 23 segments before it approaches its own bound. That column keeps
its length and its index; only the uncapped display value becomes TEXT.

Verified against live Postgres 17 and MySQL 8.0 containers: the column moves
varchar(768) -> text, a second run is a no-op through the guard, and the
entity_fqn_hash index is intact afterwards.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
(cherry picked from commit b86ed3e)
@github-actions

Copy link
Copy Markdown
Contributor

❌ PR checklist incomplete

This PR cannot be merged until the following are addressed on its linked issue:

  • No GitHub issue is linked. Link an issue in the Development section of the PR (or add Fixes #12345 to the description). For a same-org cross-repo issue, add Fixes open-metadata/<repo>#123 to the description.

The fields live on the linked issue in the Shipping project (open the issue → right sidebar → Projects). After you set them, re-run this check (or push a commit) — issue/project changes do not re-trigger it automatically.

Maintainers can bypass this check by adding the skip-pr-checks label.

@github-actions github-actions Bot added safe to test Add this label to run secure Github workflows on PRs UI UI specific issues labels Sep 22, 2026
Comment on lines +373 to +396
-- audit_log_event.entity_fqn stores the raw FQN. For lineage events that FQN is two
-- entity FQNs joined by the relationship marker, so ordinary deeply-nested entities
-- push it past 768 characters; the insert then fails and AuditLogRepository drops the
-- row with only a WARN, losing audit history silently. Nothing indexes entity_fqn --
-- lookups go through entity_fqn_hash (idx_audit_log_event_entity_hash_ts), an
-- MD5-per-segment digest that stays far inside its own bound -- so the column has no
-- reason to be length-capped.
SET @ddl = (
SELECT IF(
EXISTS (
SELECT 1
FROM information_schema.columns
WHERE table_schema = DATABASE()
AND table_name = 'audit_log_event'
AND column_name = 'entity_fqn'
AND data_type = 'text'
),
'SELECT 1',
'ALTER TABLE audit_log_event MODIFY COLUMN entity_fqn TEXT NULL'
)
);
PREPARE stmt FROM @ddl;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Existing migration is modified

This appends schema-altering SQL to the existing 2.1.0 migration in both the MySQL and PostgreSQL files. The repository requires applied migrations to remain append-only and schema changes to use a new migration version. Depending on an installation's migration history, the edited version can be skipped, leaving entity_fqn at VARCHAR(768) and allowing the audit-row loss this PR intends to fix to continue. This repository requirement must be satisfied before merging.

Context Used: CLAUDE.md (source)

@gitar-bot

gitar-bot Bot commented Sep 23, 2026

Copy link
Copy Markdown
Code Review ✅ Approved

🔴 High risk · The migration widens persistent audit-event storage from bounded VARCHAR to TEXT.

Fixes silent audit log truncation by changing entity_fqn from varchar(768) to text, allowing deeply-nested lineage events (which join multiple FQNs) to be stored without data loss. The entity_fqn_hash index and lookups remain unchanged. Verified against Postgres 17 and MySQL 8.0. No issues found.

Review coverage

📋 Rules No rules evaluated

🧪 Functional validation Not enabled · Set up

🤖 Auto-approval Not enabled · Set up

Options

Display: compact → Counting what did not apply, without listing it.

Comment with these commands to change the behavior for this request:

Compact
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source

This branch was previously deployed

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

Labels

safe to test Add this label to run secure Github workflows on PRs UI UI specific issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants