79655150

Date: 2025-06-05 19:58:28
Score: 0.5
Natty:
Report link

The problem in my case was clearly shown in the logs. I had an unused replication slot that was causing issues. My solution was to drop that slot and explicitly define the schema of my tables in the trigger function, like this:

CREATE OR REPLACE FUNCTION distribute_data()
RETURNS TRIGGER 
AS $FUNCTION$
BEGIN
    INSERT INTO public.pub_insert_a(a) VALUES (NEW.a);
    INSERT INTO public.pub_insert_b(b) VALUES (NEW.b);
    RETURN NEW;
END;
$FUNCTION$ LANGUAGE plpgsql;

CREATE OR REPLACE TRIGGER distribute_data_trigger
AFTER INSERT ON pub_test
FOR EACH ROW 
EXECUTE FUNCTION distribute_data();

And I enabled my trigger as REPLICA
ALTER TABLE pub_test ENABLE REPLICA TRIGGER distribute_data_trigger;

Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: Mateus Rauli