CactuseSecurity / firewall-orchestrator

Network Security data repository for automation, reporting and compliance of firewall rules
https://fwo.cactus.de
Apache License 2.0
33 stars 11 forks source link

Database - check why test management deletion takes ages #2628

Open tpurschke opened 3 weeks ago

tpurschke commented 3 weeks ago

when the database is not empty, the deletion of a test management while upgrading takes a very long time even though the test manager is not really big.

RUNNING HANDLER [test : delete test checkpoint R8x credentials cascading to deletion of mgmt and gw] 

Try to debug this - isolate the part of the cascade that is the bottle-neck.

Test data available here: https://xfer.cactus.de/index.php/f/695887

tpurschke commented 2 weeks ago

fresh install with single import of full config (no historical data): upgrade including deletion of managements takes 9 min. so not reproducible in this way :-(

tpurschke commented 2 weeks ago

the following change might speed things up - needs to be tested

drop trigger IF exists refresh_view_rule_with_owner_delete_trigger ON recertification CASCADE;

CREATE OR REPLACE FUNCTION refresh_view_rule_with_owner_deferred()
RETURNS TRIGGER AS $$
BEGIN
    -- Call the refresh function only once at the end of the transaction
    PERFORM refresh_view_rule_with_owner();
    RETURN NULL;
END;
$$ LANGUAGE plpgsql;

-- create trigger refresh_view_rule_with_owner_delete_trigger
-- after delete on recertification for each statement 
-- execute procedure refresh_view_rule_with_owner();

CREATE CONSTRAINT TRIGGER refresh_view_rule_with_owner_delete_trigger
AFTER DELETE ON recertification
DEFERRABLE INITIALLY DEFERRED
FOR EACH ROW
EXECUTE FUNCTION refresh_view_rule_with_owner_deferred();