这是indexloc提供的服务,不要输入任何密码
Skip to content

Event trigger on partitioned tables creates events but does not deliver them #6261

@tirumaraiselvan

Description

@tirumaraiselvan

If you create an event trigger on the partitioned table (main table) then events are generated (for all partitions) but they are not delivered.

This is because the table name value is coming from the Postgres variable TG_TABLE_NAME in the trigger function: https://github.com/hasura/graphql-engine/blob/master/server/src-rsr/trigger.sql.shakespeare and this reports the partition name and not the main table. When the event is subsequently picked for delivery then either the table is not found (if the partition is untracked) or the event trigger definition is not found on the table (since no even trigger is defined on the partition).

Repro:

CREATE TABLE measurement (
    city_id         int not null,
    logdate         date not null,
    peaktemp        int,
    unitsales       int
) PARTITION BY RANGE (logdate);

CREATE TABLE measurement_y2006m02 PARTITION OF measurement
    FOR VALUES FROM ('2006-02-01') TO ('2006-03-01');

CREATE TABLE measurement_y2006m03 PARTITION OF measurement
    FOR VALUES FROM ('2006-03-01') TO ('2006-04-01');

Track measurement and add an event trigger for insert.

Insert some values like (1, '2006-02-10', 30, 100). Note the error in logs:

{"type":"event-trigger","timestamp":"2020-11-26T14:25:06.348+0000","level":"error","detail":{"path":"$","error":"table '"measurement_y2006m03"' not found","code":"unexpected"}}

And if you track the partition measurement_y2006m03 then

{"type":"event-trigger","timestamp":"2020-11-26T14:37:07.825+0000","level":"error","detail":{"path":"$","error":"event trigger 'test_trigger' on table '"measurement_y2006m03"' not found","code":"unexpected"}}

Metadata

Metadata

Assignees

No one assigned

    Labels

    k/bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions