Trigger based audit does not work on pg_dist_placement
- Dominant language
- C
- Stars
- 12.8k
- Forks
- 794
- Avg merge
- 2d 14h
- Merged PRs (30d)
- 31
Description
Trigger based audit enabled on Citus metadata table using superuser do not create any audit records.
`create or replace function pg_dist_placement_audit_info() returns trigger
as
$pg_dist_placement_audit$
begin
if (TG_OP = 'DELETE') THEN
insert into pg_dist_placement_audit SELECT 'D', now(), user, OLD.*;
elsif (TG_OP = 'UPDATE') THEN
insert into pg_dist_placement_audit SELECT 'U_OLD', now(), user, OLD.*;
insert into citus.pg_dist_placement_audit SELECT 'U_NEW', now(), user, NEW.*;
elsif (TG_OP = 'INSERT') THEN
insert into pg_dist_placement_audit SELECT 'I', now(), user, NEW.*;
end if;
return null;
end;
$pg_dist_placement_audit$
language plpgsql;
`
`create trigger pg_dist_placement_audit_trigger
after insert or update or delete on pg_dist_placement
for each row
execute procedure pg_dist_placement_audit_info();`
Audit table “pg_dist_placement_audit” is never populated with audit records when there is a DML in the pg_dist_placement table following creating/dropping of a distributed table.
However, this works perfectly fine while manually performing DML operations in “pg_dist_placement” table.
Contributor guide
Research direction
Start by reproducing the trigger setup shown in the issue, then perform DML on pg_dist_placement after creating and dropping a distributed table, comparing it with manual DML. Done means the trigger reliably creates the expected audit records for these metadata-table changes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- postgresql, sql
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100