Usage of permissionService.deletePermissions started throwing DataIntegrityViolationException in certain cases when calling this method prior to setting permissions:
Detailed exception message also contains following information:
Cause: org.postgresql.util.PSQLException: ERROR: update or delete on table "alf_access_control_list" violates foreign key constraint "fk_alf_node_acl" on table "alf_node"
Detail: Key (id)=(38685) is still referenced from table "alf_node".
Querying the database returns valid related nodes that are content, thumbnails etc. of the folder that is having permissions set.