Dynamically records not getting to cursor in trigger
Don't use a CURSOR in a Trigger.

Do use INSERT ... ON DUPLICATE KEY UPDATE ... instead of your select+insert/update.

IODKU can handle multiple rows at once, but I don't see why that would happen.  Perhaps Cursor's SELECT belongs there?

A typical pattern is:

INSERT INTO tbl (...)
    SELECT ...
    ON DUPLICATE KEY UPDATE
        a = VALUES(a), ...